Class: UndoManager

history.UndoManager(historyEventHandler)

new UndoManager(historyEventHandler)

Parameters:
Name Type Description
historyEventHandler module:history.HistoryEventHandler
Source:

Methods

addCommandToHistory(cmd) → {void}

Adds a command object to the undo history stack.

Parameters:
Name Type Description
cmd Command

The command object to add

Source:
Returns:
Type
void

beginUndoableChange(attrName, elems) → {void}

This function tells the canvas to remember the old values of the attrName attribute for each element sent in. The elements and values are stored on a stack, so the next call to finishUndoableChange() will pop the elements and old values off the stack, gets the current values from the DOM and uses all of these to construct the undo-able command.

Parameters:
Name Type Description
attrName string

The name of the attribute being changed

elems Array.<Element>

Array of DOM elements being changed

Source:
Returns:
Type
void

finishUndoableChange() → {BatchCommand}

This function returns a BatchCommand object which summarizes the change since beginUndoableChange was called. The command can then be added to the command history.

Source:
Returns:

Batch command object with resulting changes

Type
BatchCommand

getNextRedoCommandText() → {string}

Source:
Returns:

String associated with the next redo command

Type
string

getNextUndoCommandText() → {string}

Source:
Returns:

String associated with the next undo command

Type
string

getRedoStackSize() → {Integer}

Source:
Returns:

Current size of the redo history stack

Type
Integer

getUndoStackSize() → {Integer}

Source:
Returns:

Current size of the undo history stack

Type
Integer

redo() → {void}

Performs a redo step.

Source:
Returns:
Type
void

resetUndoStack() → {void}

Resets the undo stack, effectively clearing the undo/redo history.

Source:
Returns:
Type
void

undo() → {void}

Performs an undo step.

Source:
Returns:
Type
void