HistoryCommand
Documentation / @elitechart/core / HistoryCommand
Defined in: history/history-stack.ts:28
A reversible command.
redo is the forward action (first invoked when push is called
with execute: true). undo reverses it. Both MUST be pure with
respect to the command instance — calling redo(); undo();
repeatedly must leave the world in the same state as not calling
either.
Example
Properties
kind?
Defined in: history/history-stack.ts:32
Command kind for coalescing + filtering (optional).
label
Defined in: history/history-stack.ts:30
Short, user-readable label used for UI hints (e.g. menu items).
Methods
canMerge()?
Defined in: history/history-stack.ts:40
Optional merge test. If canMerge(prev) returns true, the stack
coalesces this command into prev via mergeWith and does
NOT push a new entry. Useful for rapid drag steps.
Parameters
prev
HistoryCommand
Returns
boolean
mergeWith()?
Defined in: history/history-stack.ts:45
Optional merge. Extend prev with state from this command; return
the merged command (or mutate prev in place and return it).
Parameters
prev
HistoryCommand
Returns
HistoryCommand
redo()
Defined in: history/history-stack.ts:33
Returns
void
undo()
Defined in: history/history-stack.ts:34
Returns
void