mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-30 10:29:48 +02:00
Expose interface to setNormalizing (#3859)
This commit is contained in:
@@ -254,6 +254,7 @@ export interface EditorInterface {
|
||||
) => RangeRef
|
||||
rangeRefs: (editor: Editor) => Set<RangeRef>
|
||||
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)
|
||||
},
|
||||
|
Reference in New Issue
Block a user