UndoManager(typeScope, options)

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.

new UndoManager(typeScope, options)

Parameters:
Name Type Description
typeScope AbstractType.<any> | Array.<AbstractType.<any>>

Accepts either a single type, or an array of types

options UndoManagerOptions

Extends

  • Observable.<('stack-item-added'|'stack-item-popped')>

Classes

UndoManager

Members

redoStack :Array.<StackItem>

undoing :boolean

Whether the client is currently undoing (calling UndoManager.undo)

undoStack :Array.<StackItem>

Methods

redo() → nullable {StackItem}

Redo last undo operation.

Returns:
StackItem -

Returns StackItem if a change was applied

stopCapturing()

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.

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)

undo() → nullable {StackItem}

Undo last changes on type.

Returns:
StackItem -

Returns StackItem if a change was applied