1
0
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:
Felix Feng
2024-08-21 07:01:23 +08:00
committed by GitHub
parent c3a4e1e3f9
commit e5fed793e7
2 changed files with 16 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-history': minor
---
Add `withMerging`

View File

@@ -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.