Skip to content

UndoRedoMethods

Undo/Redo methods returned from injectGridUndoRedo.

Uses lazy discovery - the grid is found on first method call, not during initialization.

PropertyTypeDescription
undo() => UndoRedoAction | unknownUndo the last edit action.
redo() => UndoRedoAction | unknownRedo the last undone action.
canUndoSignal<boolean>Reactive signal indicating whether undo is available. Updates automatically when edits are made, undone, redone, or history is cleared.
canRedoSignal<boolean>Reactive signal indicating whether redo is available. Updates automatically when edits are made, undone, redone, or history is cleared.
clearHistory() => voidClear all undo/redo history.
getUndoStack() => UndoRedoAction[]Get a copy of the current undo stack.
getRedoStack() => UndoRedoAction[]Get a copy of the current redo stack.
recordEdit(rowIndex: number, field: string, oldValue: unknown, newValue: unknown) => voidManually record an edit action. If a transaction is active, the action is buffered; otherwise it’s pushed to the undo stack.
beginTransaction() => voidBegin a transaction. All edits recorded until endTransaction() are grouped into a single compound action for undo/redo.
endTransaction() => voidEnd the active transaction and push the compound action to the undo stack. If only one edit was recorded, it’s pushed as a plain EditAction. If no edits were recorded, the transaction is discarded.
isReadySignal<boolean>Signal indicating if grid is ready.
// In template:
// <button [disabled]="!undoRedo.canUndo()">Undo</button>
// In computed:
readonly undoAvailable = computed(() => this.undoRedo.canUndo());

// In template:
// <button [disabled]="!undoRedo.canRedo()">Redo</button>
// In computed:
readonly redoAvailable = computed(() => this.undoRedo.canRedo());

AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt