BlockSuite API Documentation / @blocksuite/store / Y / UndoManager
Class: UndoManager ​
Fires 'stack-item-added' event when a stack item was added to either the undo- or the redo-stack. You may store additional stack information via the metadata property on event.stackItem.meta (it is a Map of metadata properties). Fires 'stack-item-popped' event when a stack item was popped from either the undo- or the redo-stack. You may restore the saved stack information from event.stackItem.meta.
Contents ​
Extends ​
Observable<"stack-item-added"|"stack-item-popped"|"stack-cleared"|"stack-item-updated">
Constructors ​
new UndoManager(typeScope, options) ​
new UndoManager(
typeScope,options?):UndoManager
Parameters ​
• typeScope: AbstractType<any> | AbstractType<any>[]
Accepts either a single type, or an array of types
• options?: UndoManagerOptions
Returns ​
Overrides ​
Observable<"stack-item-added" | "stack-item-popped" | "stack-cleared" | "stack-item-updated">.constructor
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:40
Properties ​
_observers ​
_observers:
Map<"stack-item-added"|"stack-item-popped"|"stack-cleared"|"stack-item-updated",any>
Some desc.
Inherited from ​
Observable._observers
Source ​
node_modules/.pnpm/lib0@0.2.88/node_modules/lib0/observable.d.ts:58
afterTransactionHandler ​
afterTransactionHandler: (
transaction) =>void
Parameters ​
• transaction: Transaction
Returns ​
void
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:70
captureTimeout ​
captureTimeout:
number
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:66
captureTransaction ​
captureTransaction: (
arg0) =>boolean
Parameters ​
• arg0: Transaction
Returns ​
boolean
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:48
deleteFilter ​
deleteFilter: (
arg0) =>boolean
Parameters ​
• arg0: Item
Returns ​
boolean
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:46
doc ​
doc:
Doc
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:45
ignoreRemoteMapChanges ​
ignoreRemoteMapChanges:
boolean
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:65
lastChange ​
lastChange:
number
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:64
redoStack ​
redoStack:
StackItem[]
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:56
redoing ​
redoing:
boolean
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:63
scope ​
scope:
AbstractType<any>[]
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:44
trackedOrigins ​
trackedOrigins:
Set<any>
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:47
undoStack ​
undoStack:
StackItem[]
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:52
undoing ​
undoing:
boolean
Whether the client is currently undoing (calling UndoManager.undo)
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:62
Methods ​
addToScope() ​
addToScope(
ytypes):void
Parameters ​
• ytypes: AbstractType<any> | AbstractType<any>[]
Returns ​
void
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:74
addTrackedOrigin() ​
addTrackedOrigin(
origin):void
Parameters ​
• origin: any
Returns ​
void
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:78
canRedo() ​
canRedo():
boolean
Are redo steps available?
Returns ​
boolean
true if redo is possible
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:128
canUndo() ​
canUndo():
boolean
Are undo steps available?
Returns ​
boolean
true if undo is possible
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:122
clear() ​
clear(
clearUndoStack?,clearRedoStack?):void
Parameters ​
• clearUndoStack?: boolean
• clearRedoStack?: boolean
Returns ​
void
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:83
destroy() ​
destroy():
void
Returns ​
void
Inherited from ​
Observable.destroy
Source ​
node_modules/.pnpm/lib0@0.2.88/node_modules/lib0/observable.d.ts:84
emit() ​
emit(
name,args):void
Emit a named event. All registered event listeners that listen to the specified name will receive the event.
Parameters ​
• name: "stack-item-added" | "stack-item-popped" | "stack-cleared" | "stack-item-updated"
The event name.
• args: any[]
The arguments that are applied to the event listener.
Returns ​
void
Inherited from ​
Observable.emit
Todo ​
This should catch exceptions
Source ​
node_modules/.pnpm/lib0@0.2.88/node_modules/lib0/observable.d.ts:83
off() ​
off(
name,f):void
Parameters ​
• name: "stack-item-added" | "stack-item-popped" | "stack-cleared" | "stack-item-updated"
• f: Function
Returns ​
void
Inherited from ​
Observable.off
Source ​
node_modules/.pnpm/lib0@0.2.88/node_modules/lib0/observable.d.ts:73
on() ​
on(
name,f):void
Parameters ​
• name: "stack-item-added" | "stack-item-popped" | "stack-cleared" | "stack-item-updated"
• f: Function
Returns ​
void
Inherited from ​
Observable.on
Source ​
node_modules/.pnpm/lib0@0.2.88/node_modules/lib0/observable.d.ts:63
once() ​
once(
name,f):void
Parameters ​
• name: "stack-item-added" | "stack-item-popped" | "stack-cleared" | "stack-item-updated"
• f: Function
Returns ​
void
Inherited from ​
Observable.once
Source ​
node_modules/.pnpm/lib0@0.2.88/node_modules/lib0/observable.d.ts:68
redo() ​
redo():
null|StackItem
Redo last undo operation.
Returns ​
null | StackItem
Returns StackItem if a change was applied
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:116
removeTrackedOrigin() ​
removeTrackedOrigin(
origin):void
Parameters ​
• origin: any
Returns ​
void
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:82
stopCapturing() ​
stopCapturing():
void
UndoManager merges Undo-StackItem if they are created within time-gap smaller than options.captureTimeout. Call um.stopCapturing() so that the next StackItem won't be merged.
Returns ​
void
Example ​
// without stopCapturing
    ytext.insert(0, 'a')
    ytext.insert(1, 'b')
    um.undo()
    ytext.toString() // => '' (note that 'ab' was removed)
    // with stopCapturing
    ytext.insert(0, 'a')
    um.stopCapturing()
    ytext.insert(0, 'b')
    um.undo()
    ytext.toString() // => 'a' (note that only 'b' was removed)Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:104
undo() ​
undo():
null|StackItem
Undo last changes on type.
Returns ​
null | StackItem
Returns StackItem if a change was applied
Source ​
node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/utils/UndoManager.d.ts:110
Generated using typedoc-plugin-markdown and TypeDoc