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.
When false, nothing is recorded, undone or redone.
Whether the Ctrl/Cmd+Z, Ctrl+Y and Ctrl/Cmd+Shift+Z listener is bound (see bindHotKeys).
Be told whenever the stack changes: a step recorded, undone, redone or replaced, the stack reset,
the limit changed, or the manager enabled/disabled. An undo history list or a menu's enabled state
listens here instead of polling stack and sp. A continuous edit (a slider drag, recordUndoCommand) replaces
the last step on each change, so a listener that redraws a list can wait for the next frame. A listener keeps what
it closes over alive: remove it (the returned function) when its UI goes; dispose removes all of them.
a function that removes the listener
Bind 'undo' and 'redo' to the hot keys, on options.hotKeyRoot (default document): Cmd+Z and Cmd+Shift+Z on a
Mac, Ctrl+Z, Ctrl+Shift+Z and Ctrl+Y elsewhere. The keys follow the letter printed on the key (on a QWERTZ
keyboard, Ctrl + the key labelled Z undoes), and its place when it types no Latin letter (Cyrillic, Greek). A key
with Alt (AltGr on Windows types letters) or the other modifier is left alone. Calling it again does nothing. Keys
typed in a text field or an editable element are left to it (shouldHandleKeyEvent). An app that handles
the keys itself calls unbindHotKeys (at any time) and calls undo / redo.
Removes the hot key listener and clears the stack. The change listeners get the reset, then they are removed
too, so a disposed manager keeps no listener (and no UI that it closes over) alive.
Execute function and record it with its opposite "undo" function
either an object with "redo" and "undo" functions
The label of a command: its own label, or for a preset command the label of what the preset
makes of it. For a preset command without its own label this runs the preset on each call, so a history list of
many steps can keep the labels, or give the commands a label.
Get the last command that was done
Gets the last command that was undone
Remember executed command containing "redo" and "undo" functions
either an object with "redo" and "undo" functions
Redo the command which was previously undone
Reset all commands from memory
Change stack size limit initially defined in the constructor options
Whether the hot keys act on this key event. Default: not when it comes from a text field (an input that takes
text, a textarea, a select) or an editable element, which keep their own undo (also inside an open shadow root,
through composedPath), or when it was already handled (defaultPrevented). A focused checkbox, radio button,
range, color input or button does not stop the keys. Override to change it. With nothing to undo or redo the key
is not taken either.
Removes the hot key listener of bindHotKeys; the stack is kept.
Undo previous command if possible
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 -