Create a new undo/redo manager.
Maximum number of commands to keep in history (default: 50).
Execute a command and add it to undo history. Calling this method will:
The command to execute.
executeCommand(command: Command): void {
if (!this.isEnabled) return;
command.execute();
this.undoStack.push(command);
this.redoStack = []; // Clear redo stack when new action is performed
// Maintain max history size
if (this.undoStack.length > this.maxHistorySize) {
this.undoStack.shift();
}
}
Undo the last command.
Metadata about the undone command, or null if nothing to undo.
Redo the last undone command.
Metadata about the redone command, or null if nothing to redo.
Temporarily enable or disable command recording. When disabled, executeCommand() becomes a no-op. This is useful during operations like initial data loading where we don't want to record intermediate states.
Whether to enable or disable the manager.
Manages undo/redo history for match operations. Maintains two stacks: undo stack and redo stack. When a command is executed, it's pushed to the undo stack and the redo stack is cleared. Commands can be undone/redone using the public methods.
Source