UndoManager
is responsible for handling undo and redo operations.
PeerID cannot be changed during the lifetime of the UndoManager.
Note that undo operations are local and cannot revert changes made by other peers. To undo changes made by other peers, consider using the time travel feature.
Each commit made by the current peer is recorded as an undo step in the UndoManager
.
Undo steps can be merged if they occur within a specified merge interval.
mergeInterval
: Optional. The interval in milliseconds within which undo steps can be merged. Default is 1000 ms.maxUndoSteps
: Optional. The maximum number of undo steps to retain. Default is 100.excludeOriginPrefixes
: Optional. An array of string prefixes. Events with origins matching these prefixes will be excluded from undo steps.onPush
: Optional. A callback function that is called when an undo/redo step is pushed.
The function can return a meta data value that will be attached to the given stack item.onPop
: Optional. A callback function that is called when an undo/redo step is popped.
The function will have a meta data value that was attached to the given stack item when
onPush
was called.If a local event's origin matches the given prefix, it will not be recorded in the undo stack.
Can redo the last operation.
Can undo the last operation.
Redo the last undone operation.
The number of max undo steps. If the number of undo steps exceeds this number, the oldest undo step will be removed.
Set the merge interval (in ms).
If the interval is set to 0, the undo steps will not be merged. Otherwise, the undo steps will be merged if the interval between the two steps is less than the given interval.
Set the callback function that is called when an undo/redo step is popped.
The function will have a meta data value that was attached to the given stack item when onPush
was called.
Set the callback function that is called when an undo/redo step is pushed. The function can return a meta data value that will be attached to the given stack item.
Optional
listener: (The callback function.
Undo the last operation.
UndoManager
is responsible for handling undo and redo operations.By default, the maxUndoSteps is set to 100, mergeInterval is set to 1000 ms.
Each commit made by the current peer is recorded as an undo step in the
UndoManager
. Undo steps can be merged if they occur within a specified merge interval.Note that undo operations are local and cannot revert changes made by other peers. To undo changes made by other peers, consider using the time travel feature.
Once the
peerId
is bound to theUndoManager
in the document, it cannot be changed. Otherwise, theUndoManager
may not function correctly.