1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 18:39:51 +02:00

Expose interface to setNormalizing (#3859)

This commit is contained in:
Jason Tamulonis
2021-06-07 12:39:05 -07:00
committed by GitHub
parent 61171a2382
commit e042ebd4a2

View File

@@ -254,6 +254,7 @@ export interface EditorInterface {
) => RangeRef ) => RangeRef
rangeRefs: (editor: Editor) => Set<RangeRef> rangeRefs: (editor: Editor) => Set<RangeRef>
removeMark: (editor: Editor, key: string) => void removeMark: (editor: Editor, key: string) => void
setNormalizing: (editor: Editor, isNormalizing: boolean) => void
start: (editor: Editor, at: Location) => Point start: (editor: Editor, at: Location) => Point
string: ( string: (
editor: Editor, editor: Editor,
@@ -1549,6 +1550,16 @@ export const Editor: EditorInterface = {
editor.removeMark(key) 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. * Get the start point of a location.
*/ */
@@ -1669,11 +1680,11 @@ export const Editor: EditorInterface = {
withoutNormalizing(editor: Editor, fn: () => void): void { withoutNormalizing(editor: Editor, fn: () => void): void {
const value = Editor.isNormalizing(editor) const value = Editor.isNormalizing(editor)
NORMALIZING.set(editor, false) Editor.setNormalizing(editor, false)
try { try {
fn() fn()
} finally { } finally {
NORMALIZING.set(editor, value) Editor.setNormalizing(editor, value)
} }
Editor.normalize(editor) Editor.normalize(editor)
}, },