Appearance
@luminaphoto/lumina-js / Client / HistoryManager
Class: HistoryManager
Linear undo/redo history manager for the Client Editor
Maintains a chronological list of applied operations with a movable cursor. New operations clear the redo tail (standard branching behavior). History depth is bounded by a configurable maximum size.
Constructors
Constructor
ts
new HistoryManager(maxSize?): HistoryManager;Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
maxSize | number | 50 | Maximum number of operations to retain (default: 50) |
Returns
HistoryManager
Methods
addOperation()
ts
addOperation(nodeType, payload): void;Add a new operation to the history after it has been successfully applied
Parameters
| Parameter | Type | Description |
|---|---|---|
nodeType | NodeType | The type of operation that was applied |
payload | Record<string, unknown> | The complete parameters that were passed to the apply method |
Returns
void
canRedo()
ts
canRedo(): boolean;Check if a redo operation is possible
Returns
boolean
True if there are undone operations that can be redone
canUndo()
ts
canUndo(): boolean;Check if an undo operation is possible
Returns
boolean
True if there are operations that can be undone
clear()
ts
clear(): void;Clears all history entries and resets to initial state
Returns
void
getAllEntries()
ts
getAllEntries(): HistoryEntry[];Get all entries in the history, including undone operations
Returns
Copy of the complete history array
getCurrentIndex()
ts
getCurrentIndex(): number;Get the current position in the history
Returns
number
Current index (-1 if no operations applied)
getCurrentState()
ts
getCurrentState(): HistoryEntry[];Get all currently applied operations in chronological order
Returns
Array of history entries up to the current position
getHistoryLength()
ts
getHistoryLength(): number;Get the total number of operations in history (including undone)
Returns
number
Total entry count
getNextRedoOperation()
ts
getNextRedoOperation(): NodeType | null;Get the NodeType of the operation that would be redone next
Returns
NodeType | null
The NodeType of the next redo candidate, or null if nothing to redo
getNextUndoOperation()
ts
getNextUndoOperation(): NodeType | null;Get the NodeType of the operation that would be undone next
Returns
NodeType | null
The NodeType of the next undo candidate, or null if nothing to undo
redo()
ts
redo(): void;Moves the history position forward by one step (redo)
Returns
void
undo()
ts
undo(): void;Moves the history position backward by one step (undo)
Returns
void