/** * JSUndoManagerOptions interface that defines the options for the JSUndoManager class. * * @category Undo */ export interface JSUndoManagerOptions { /** * Maximum commands stack size. */ limit: number; /** * Whether to emit execution status in console. */ debug: boolean; /** * Whether to bind "undo" and "redo" commands to "Ctrl+Z", "Ctrl+Y" & "Ctrl+Shift+Z" hot keys in the DOM */ bindHotKeys: boolean; /** * Root element for hot keys binding. */ hotKeyRoot?: HTMLElement; } /** * Simple command interface for JSUndoManager with explicit actions * * This is used for commands that are executed immediately and have no type field. * * @category Undo */ export type JSUndoManagerCommand1 = { redo: Function; undo: Function; }; /** * Command interface for JSUndoManager with a type field. * * This is used for commands that can be preset or predefined, allowing for easier management of commands. * * @category Undo */ export type JSUndoManagerCommand2 = { type: string; }; /** * Combined command type for JSUndoManager that can be either a simple command or a preset command. * * @category Undo */ export type JSUndoManagerCommand = JSUndoManagerCommand1 | JSUndoManagerCommand2; /** * Simple JavaScript undo/redo command manager supporting transactions with no dependencies. * * Fork Of JavaScript Undo Manager 1.0.0, by Alexey Grinko, licensed under MIT License. * * Changes - * 1. Added presets commands * 2. Port to TypeScript * 3. Remove transactions, see {@link SetValueUndoCommand} for a replacement * @class JSUndoManager * @category Undo */ export declare class JSUndoManager { limit: number; options: JSUndoManagerOptions; enabled: boolean; stack: JSUndoManagerCommand[]; sp: number; /** * Presets for commands, allows to define command types and their handlers. * A preset maps from a JSUndoManagerCommand2 to a JSUndoManagerCommand1. * * To add a preset, simply set it on this object, or using `Object.assign`. * * @type {RecordJSUndoManagerCommand1>} */ presets: Record JSUndoManagerCommand1>; constructor(options: JSUndoManagerOptions); /** * Bind 'undo' and 'redo' actions to 'Ctrl/Cmd+Z', 'Ctrl+Y' & 'Ctrl/Cmd+Shift+Z' hot keys. * It is a basic implementation for quick testing and should be replaced with custom event handlers * for more flexible processing. * @returns {JSUndoManager} */ bindHotKeys(): this; /** * Removes the event listeners and clears the stack */ dispose(): this; private _keyDown; /** * Remember executed command containing "redo" and "undo" functions * @param {Object|Function} command - either an object with "redo" and "undo" functions * @returns {JSUndoManager} */ record(command: JSUndoManagerCommand): this; replaceLast(command: JSUndoManagerCommand): this | undefined; /** * Execute function and record it with its opposite "undo" function * @param {Object|Function} command - either an object with "redo" and "undo" functions * @param {Function} [undo] - "undo" function, used if the first argument is also a function * @returns {JSUndoManager} */ execute(command: JSUndoManagerCommand): this | undefined; _rc(command: JSUndoManagerCommand1 | JSUndoManagerCommand2): JSUndoManagerCommand1; _record(command: JSUndoManagerCommand): void; _rebase(): void; _keepLimit(): void; /** * Undo previous command if possible * @returns {JSUndoManager} */ undo(): this; /** * Check whether undoing previous command is possible * @returns {boolean} */ canUndo(): boolean; /** * Get the last command that was done */ peek(): JSUndoManagerCommand | null; /** * Redo the command which was previously undone * @returns {JSUndoManager} */ redo(): this; /** * Check whether redoing command is possible * @returns {boolean} */ canRedo(): boolean; /** * Gets the last command that was undone */ peekForward(): JSUndoManagerCommand | null; /** * Change stack size limit initially defined in the constructor options * @param {number} limit */ setLimit(limit: number): this; /** * Reset all commands from memory */ reset(): this; /** * Check whether the commands stack is empty * @returns {boolean} */ isEmpty(): boolean; /** * Check whether the commands stack size reaches its limit * @returns {boolean} */ isFull(): boolean; /** * Get number of commands in memory stack * @returns {Number} */ getSize(): number; log(msg: string, ...args: any[]): void; } //# sourceMappingURL=JSUndoManager.d.ts.map