From e0e5f8d2ea749d4ef1820e4ea6608ee44805cc33 Mon Sep 17 00:00:00 2001 From: Aart Rost Date: Wed, 10 Aug 2022 14:07:40 -0700 Subject: [PATCH] Allow updating captureTimeout on UndoManager instances Used to pause the undoManager by toggling the timeout with `yUndoManager.captureTimeout = Number.MAX_VALUE` --- src/utils/UndoManager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/UndoManager.js b/src/utils/UndoManager.js index c53924a1..99efb94a 100644 --- a/src/utils/UndoManager.js +++ b/src/utils/UndoManager.js @@ -192,6 +192,7 @@ export class UndoManager extends Observable { this.doc = doc this.lastChange = 0 this.ignoreRemoteMapChanges = ignoreRemoteMapChanges + this.captureTimeout = captureTimeout /** * @param {Transaction} transaction */ @@ -223,7 +224,7 @@ export class UndoManager extends Observable { }) const now = time.getUnixTime() let didAdd = false - if (now - this.lastChange < captureTimeout && stack.length > 0 && !undoing && !redoing) { + if (now - this.lastChange < this.captureTimeout && stack.length > 0 && !undoing && !redoing) { // append change to last stack op const lastOp = stack[stack.length - 1] lastOp.deletions = mergeDeleteSets([lastOp.deletions, transaction.deleteSet])