diff --git a/packages/slate/src/interfaces/editor.ts b/packages/slate/src/interfaces/editor.ts index cbc3cd85b..1863e071e 100644 --- a/packages/slate/src/interfaces/editor.ts +++ b/packages/slate/src/interfaces/editor.ts @@ -254,6 +254,7 @@ export interface EditorInterface { ) => RangeRef rangeRefs: (editor: Editor) => Set removeMark: (editor: Editor, key: string) => void + setNormalizing: (editor: Editor, isNormalizing: boolean) => void start: (editor: Editor, at: Location) => Point string: ( editor: Editor, @@ -1549,6 +1550,16 @@ export const Editor: EditorInterface = { editor.removeMark(key) }, + /** + * Manually set if the editor should currently be normalizing. + * + * Note: Using this incorrectly can leave the editor in an invalid state. + * + */ + setNormalizing(editor: Editor, isNormalizing: boolean): void { + NORMALIZING.set(editor, isNormalizing) + }, + /** * Get the start point of a location. */ @@ -1669,11 +1680,11 @@ export const Editor: EditorInterface = { withoutNormalizing(editor: Editor, fn: () => void): void { const value = Editor.isNormalizing(editor) - NORMALIZING.set(editor, false) + Editor.setNormalizing(editor, false) try { fn() } finally { - NORMALIZING.set(editor, value) + Editor.setNormalizing(editor, value) } Editor.normalize(editor) },