UndoStack

UndoStack class.

Constructor

new UndoStack()

Methods

add(cmd)

Add a command to the stack.

Parameters:
NameTypeDescription
cmdobject

The command to add.

addEventListener(type, callback)

Add an event listener to this class.

Parameters:
NameTypeDescription
typestring

The event type.

callbackfunction

The function associated with the provided event type, will be called with the fired event.

getCurrentStackIndex() → {number}

Get the current stack index.

Returns:

The stack index.

Type: 
number

getStackSize() → {number}

Get the stack size.

Returns:

The size of the stack.

Type: 
number

redo()

Redo the last command.

removeEventListener(type, callback)

Remove an event listener from this class.

Parameters:
NameTypeDescription
typestring

The event type.

callbackfunction

The function associated with the provided event type.

undo()

Undo the last command.

Events

redo

Command redo event.

Type:
  • object
Properties
NameTypeDescription
commandstring

The name of the redone command.

undo

Command undo event.

Type:
  • object
Properties
NameTypeDescription
commandstring

The name of the undone command.

undoadd

Command add to undo stack event.

Type:
  • object
Properties
NameTypeDescription
commandstring

The name of the command added to the undo stack.