CKEDITOR.plugins.undo.UndoManager
Main logic for the Redo/Undo feature.
Filtering
Properties
-
The maximum number of snapshots in the stack. Configurable via CKEDITOR.config.undoStackSize.
-
Contains the previously processed key group, based on keyGroups.
-1means an unknown group.Defaults to
-1 -
-
An array storing the number of key presses, count in a row. Use keyGroups members as index.
Note: The keystroke count will be reset after reaching the limit of characters per snapshot.
Defaults to
[0, 0] -
Static properties
-
Key groups identifier mapping. Used for accessing members in strokesRecorded.
FUNCTIONAL– identifier for the Backspace / Delete key.PRINTABLE– identifier for printable keys.
Example usage:
undoManager.strokesRecorded[ undoManager.keyGroups.FUNCTIONAL ];Defaults to
{PRINTABLE: 0, FUNCTIONAL: 1} -
since 4.4.5 readonly static
navigationKeyCodes : ObjectCKEDITOR.plugins.undo.UndoManager#navigationKeyCodesCodes for navigation keys like Arrows, Page Up/Down, etc. Used by the isNavigationKey method.
Defaults to
{37: 1, 38: 1, 39: 1, 40: 1, 36: 1, 35: 1, 33: 1, 34: 1}
Methods
-
constructor( editor ) → UndoManagerCKEDITOR.plugins.undo.UndoManager#constructor -
Registers a filtering rule.
Parameters
rule : FunctionCallback function that returns filtered data.
-
getNextImage( isUndo ) → ImageCKEDITOR.plugins.undo.UndoManager#getNextImageGets the closest available image.
Parameters
isUndo : BooleanIf
true, it will return the previous image.
Returns
ImageNext image or
null.
-
Whether the new
keyCodebelongs to a different group than the previous one (previousKeyGroup).Parameters
keyCode : Number
Returns
Boolean
-
Locks the snapshot stack to prevent any save/update operations and when necessary, updates the tip of the snapshot stack with the DOM changes introduced during the locked period, after the unlock method is called.
It is mainly used to ensure any DOM operations that should not be recorded (e.g. auto paragraphing) are not added to the stack.
Note: For every
lockcall you must call unlock once to unlock the undo manager.Parameters
[ dontUpdate ] : BooleanWhen set to
true, the last snapshot will not be updated with current content and selection. By default, if undo manager was up to date when the lock started, the last snapshot will be updated to the current state when unlocking. This means that all changes done during the lock will be merged into the previous snapshot or the next one. Use this option to gain more control over this behavior. For example, it is possible to group changes done during the lock into a separate snapshot.[ forceUpdate ] : BooleanWhen set to
true, the last snapshot will always be updated with the current content and selection regardless of the current state of the undo manager. When not set, the last snapshot will be updated only if the undo manager was up to date when locking. Additionally, this option makes it possible to lock the snapshot when the editor is not in thewysiwygmode, because when it is passed, the snapshots will not need to be compared.
-
redo()CKEDITOR.plugins.undo.UndoManager#redoPerforms a redo operation on current index.
-
redoable() → BooleanCKEDITOR.plugins.undo.UndoManager#redoableChecks the current redo state.
Returns
BooleanWhether the document has a previous state to retrieve.
-
refreshState()CKEDITOR.plugins.undo.UndoManager#refreshStateRefreshes the state of the undo manager as well as the state of the
undoandredocommands. -
reset()CKEDITOR.plugins.undo.UndoManager#resetResets the undo stack.
-
resetType()CKEDITOR.plugins.undo.UndoManager#resetType -
restoreImage( image )CKEDITOR.plugins.undo.UndoManager#restoreImage -
save( onContentOnly, image, [ autoFireChange ] )CKEDITOR.plugins.undo.UndoManager#saveSaves a snapshot of the document image for later retrieval.
Parameters
onContentOnly : BooleanIf set to
true, the snapshot will be saved only if the content has changed.image : ImageAn optional image to save. If skipped, current editor will be used.
[ autoFireChange ] : BooleanIf set to
false, will not trigger the CKEDITOR.editor.change event to editor.Defaults to
true
-
type( keyCode, [ strokesPerSnapshotExceeded ] )CKEDITOR.plugins.undo.UndoManager#typeHandles keystroke support for the undo manager. It is called on the
keyupevent for keystrokes that can change the editor content.Parameters
keyCode : NumberThe key code.
[ strokesPerSnapshotExceeded ] : BooleanWhen set to
true, the method will behave as if the strokes limit was exceeded regardless of the strokesRecorded value.
-
undo()CKEDITOR.plugins.undo.UndoManager#undoPerforms an undo operation on current index.
-
undoable() → BooleanCKEDITOR.plugins.undo.UndoManager#undoableChecks the current undo state.
Returns
BooleanWhether the document has a future state to restore.
-
Unlocks the snapshot stack and checks to amend the last snapshot.
See lock for more details.
-
update( [ newImage ] )CKEDITOR.plugins.undo.UndoManager#updateUpdates the last snapshot of the undo stack with the current editor content.
Parameters
[ newImage ] : ImageThe image which will replace the current one. If it is not set, it defaults to the image taken from the editor.
-
since 4.4.4
updateSelection( newSnapshot ) → BooleanCKEDITOR.plugins.undo.UndoManager#updateSelectionAmends the last snapshot and changes its selection (only in case when content is equal between these two).
Parameters
newSnapshot : ImageNew snapshot with new selection.
Returns
BooleanReturns
trueif selection was amended.
Static methods
-
Returns the group to which the passed
keyCodebelongs.Parameters
keyCode : Number
Returns
Number
-
since 4.4.5 static
getOppositeKeyGroup( keyGroup ) → NumberCKEDITOR.plugins.undo.UndoManager#getOppositeKeyGroup -
since 4.4.5 static
ieFunctionalKeysBug( keyCode ) → BooleanCKEDITOR.plugins.undo.UndoManager#ieFunctionalKeysBugWhether we need to use a workaround for functional (Backspace, Delete) keys not firing the
keypressevent in Internet Explorer in this environment and for the specifiedkeyCode.Parameters
keyCode : Number
Returns
Boolean
-
since 4.4.5 static
isNavigationKey( keyCode ) → BooleanCKEDITOR.plugins.undo.UndoManager#isNavigationKeyChecks whether a key is one of navigation keys (Arrows, Page Up/Down, etc.). See also the navigationKeyCodes property.
Parameters
keyCode : Number
Returns
Boolean