Skip to content

Fix changing text formatting style does not work correctly when selecting multiple#39

Merged
hoangdat merged 3 commits intomasterfrom
bugfix/fix-format-style-incorrect
Jul 16, 2025
Merged

Fix changing text formatting style does not work correctly when selecting multiple#39
hoangdat merged 3 commits intomasterfrom
bugfix/fix-format-style-incorrect

Conversation

@dab246
Copy link
Member

@dab246 dab246 commented Jun 26, 2025

Issue

Changing text formatting style does not work correctly when selecting multiple

Root cause

Because document.onselectionchange is only fired when the selection changes, not when the content or formatting of the selection changes. When document.execCommand('italic') applies the formatting but does not change the selection, so onselectionchange is not called again.

Solution

Use MutationObserver to listen for DOM changes.

@hoangdat hoangdat merged commit 235dc4e into master Jul 16, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants