30 lines
732 B
TypeScript
30 lines
732 B
TypeScript
|
|
/**
|
||
|
|
* Base Command interface for undo/redo operations
|
||
|
|
*/
|
||
|
|
export interface Command {
|
||
|
|
/** Execute the command */
|
||
|
|
execute: () => void;
|
||
|
|
/** Undo the command */
|
||
|
|
undo: () => void;
|
||
|
|
/** Optional: merge with another command of same type */
|
||
|
|
merge?: (other: Command) => boolean;
|
||
|
|
/** Command name for display */
|
||
|
|
name: string;
|
||
|
|
/** Timestamp of execution */
|
||
|
|
timestamp: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* History state interface
|
||
|
|
*/
|
||
|
|
export interface HistoryState {
|
||
|
|
/** Stack of executed commands */
|
||
|
|
undoStack: Command[];
|
||
|
|
/** Stack of undone commands */
|
||
|
|
redoStack: Command[];
|
||
|
|
/** Maximum number of commands to store */
|
||
|
|
maxHistorySize: number;
|
||
|
|
/** Is currently executing a command (prevent recursion) */
|
||
|
|
isExecuting: boolean;
|
||
|
|
}
|