mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-23 07:22:55 +02:00
Add withMerging (#5696)
This commit is contained in:
5
.changeset/honest-rice-doubt.md
Normal file
5
.changeset/honest-rice-doubt.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-history': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add `withMerging`
|
@@ -62,6 +62,17 @@ export const HistoryEditor = {
|
|||||||
editor.undo()
|
editor.undo()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply a series of changes inside a synchronous `fn`, These operations will
|
||||||
|
* be merged into the previous history.
|
||||||
|
*/
|
||||||
|
withMerging(editor: HistoryEditor, fn: () => void): void {
|
||||||
|
const prev = HistoryEditor.isMerging(editor)
|
||||||
|
MERGING.set(editor, true)
|
||||||
|
fn()
|
||||||
|
MERGING.set(editor, prev)
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a series of changes inside a synchronous `fn`, without merging any of
|
* Apply a series of changes inside a synchronous `fn`, without merging any of
|
||||||
* the new operations into previous save point in the history.
|
* the new operations into previous save point in the history.
|
||||||
|
Reference in New Issue
Block a user