Interface: CommandHistory
Provides an undo/redo mechanism to the diagram model and components.
To make it possible to undo/redo the changes, all state modifications are organized in a form of atomic commands. These commands can be combined into a command batch to be presented to user as a single meaningful operation.
Properties
Property | Modifier | Type | Description |
---|---|---|---|
|
| Events for the command history. | |
|
| readonly | Current stack of operation which could be redone (performed again after being undone). Latest undone commands are put at the end of the stack. |
|
| readonly | Current stack of operation which could be undone (reverted). Latest executed (or redone) commands are put at the end of the stack. |
Methods
execute()
execute(
command
):void
Executes the specified command and puts its inverse into undo stack.
Parameters
Parameter | Type |
---|---|
|
Returns
void
Defined in
redo()
redo():
void
Redoes (performs again) the latest undone command.
If redo stack is empty, does nothing.
Returns
void
Defined in
registerToUndo()
registerToUndo(
command
):void
Puts the inverse command directly into undo stack.
Parameters
Parameter | Type |
---|---|
|
Returns
void
Defined in
reset()
reset():
void
Clears undo and redo stacks of commands.
Returns
void
Defined in
startBatch()
startBatch(
title
?):CommandBatch
Starts a new command batch which will be active either stored or discarded.
When a batch is active, all executed or registered to undo commands will be put into the batch instead of the undo stack, so it could be undo as whole later.
Starting a new batch when there is an active command batch already causes the new batch to become nested, which allows to use operations creating command batches as part of a larger operation having its own top-level batch.
Parameters
Parameter | Type |
---|---|
|
|
Returns
Defined in
undo()
undo():
void
Undoes (reverts) the latest executed command and puts it into redo stack.
If undo stack is empty, does nothing.
Returns
void