mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-22 06:53:25 +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()
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
* the new operations into previous save point in the history.
|
||||
|
Reference in New Issue
Block a user