Skip to content

UndoRedoMethods

Undo/Redo methods returned from useGridUndoRedo.

PropertyTypeDescription
undo() => UndoRedoAction | unknownUndo the last edit action.
redo() => UndoRedoAction | unknownRedo the last undone action.
canUndo() => booleanCheck if there are any actions that can be undone.
canRedo() => booleanCheck if there are any actions that can be redone.
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.
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