use-undo-manager
Version:
A React hook that enables undo/redo history management with debounced state commits.
20 lines (19 loc) • 519 B
TypeScript
export interface UseUndoManagerOptions<T> {
commitDelay?: number;
historyLimit?: number;
onCommit?: (state: T) => void;
}
export declare function useUndoManager<T>(initialState: T, options?: UseUndoManagerOptions<T>): {
state: T;
committed: T;
set: (newState: T) => void;
undo: () => void;
redo: () => void;
flush: () => void;
pause: () => void;
resume: () => void;
reset: (newState?: T) => void;
mergeLast: () => void;
canUndo: boolean;
canRedo: boolean;
};