1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-29 18:09:49 +02:00

Fix addMark/removeMark caused unexpected onChange. (#4227)

* Fix addMark/removeMark caused unexpected onChange.

* Create three-parrots-remember.md

Co-authored-by: Ian Storm Taylor <ian@ianstormtaylor.com>
This commit is contained in:
Ulion
2021-05-06 08:30:17 +08:00
committed by GitHub
parent 623960a7d1
commit e6413d4625
2 changed files with 11 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
'slate': patch
---
Fixed a bug that would allow multiple changes to be scheduled at the same time.

View File

@@ -106,9 +106,11 @@ export const createEditor = (): Editor => {
} }
editor.marks = marks editor.marks = marks
if (!FLUSHING.get(editor)) {
editor.onChange() editor.onChange()
} }
} }
}
}, },
deleteBackward: (unit: 'character' | 'word' | 'line' | 'block') => { deleteBackward: (unit: 'character' | 'word' | 'line' | 'block') => {
@@ -296,9 +298,11 @@ export const createEditor = (): Editor => {
const marks = { ...(Editor.marks(editor) || {}) } const marks = { ...(Editor.marks(editor) || {}) }
delete marks[key] delete marks[key]
editor.marks = marks editor.marks = marks
if (!FLUSHING.get(editor)) {
editor.onChange() editor.onChange()
} }
} }
}
}, },
} }