History (engine/model)
@ckeditor/ckeditor5-engine/src/model/history
History
keeps the track of all the operations applied to the document.
Filtering
Properties
-
lastOperation : Operation | undefined
module:engine/model/history~History#lastOperation
readonly
The last history operation.
-
version : Number
module:engine/model/history~History#version
The version of the last operation in the history.
The history version is incremented automatically when a new operation is added to the history. Setting the version manually should be done only in rare circumstances when a gap is planned between history versions. When doing so, a gap will be created and the history will accept adding an operation with base version equal to the new history version.
-
_baseVersionToOperationIndex : Map.<Number, Number>
module:engine/model/history~History#_baseVersionToOperationIndex
private
A map that allows retrieving the operations fast based on the given base version.
-
_gaps : Map.<number, number>
module:engine/model/history~History#_gaps
private
The gap pairs kept in the <from,to> format.
Anytime the
history.version
is set to a version larger thanhistory.version + 1
, a new <lastHistoryVersion, newHistoryVersion> entry is added to the map. -
_operations : Array.<Operation>
module:engine/model/history~History#_operations
private readonly
Operations added to the history.
-
_undoPairs : Map
module:engine/model/history~History#_undoPairs
private
-
_undoneOperations : Set.<Operation>
module:engine/model/history~History#_undoneOperations
private
Holds all undone operations.
-
_version : Number
module:engine/model/history~History#_version
private
The history version.
Methods
-
constructor()
module:engine/model/history~History#constructor
Creates an empty History instance.
-
addOperation( operation )
module:engine/model/history~History#addOperation
Adds an operation to the history and increments the history version.
The operation's base version should be equal to the history version. Otherwise an error is thrown.
Parameters
operation : Operation
Operation to add.
-
getOperation( baseVersion ) → Operation | undefined
module:engine/model/history~History#getOperation
Returns operation from the history that bases on given
baseVersion
.Parameters
baseVersion : Number
Base version of the operation to get.
Returns
Operation | undefined
Operation with given base version or
undefined
if there is no such operation in history.
-
getOperations( [ fromBaseVersion ], [ toBaseVersion ] ) → Array.<Operation>
module:engine/model/history~History#getOperations
Returns operations from the given range of operation base versions that were added to the history.
Note that there may be gaps in operations base versions.
Parameters
[ fromBaseVersion ] : Number
Base version from which operations should be returned (inclusive).
[ toBaseVersion ] : Number
Base version up to which operations should be returned (exclusive).
Returns
Array.<Operation>
History operations for the given range, in chronological order.
-
getUndoneOperation( undoingOperation ) → Operation | undefined
module:engine/model/history~History#getUndoneOperation
For given
undoingOperation
, returns the operation which has been undone by it. -
isUndoingOperation( operation ) → Boolean
module:engine/model/history~History#isUndoingOperation
Checks whether given
operation
is undoing any other operation.Parameters
operation : Operation
Operation to check.
Returns
Boolean
true
if givenoperation
is undoing any other operation,false
otherwise.
-
isUndoneOperation( operation ) → Boolean
module:engine/model/history~History#isUndoneOperation
Checks whether given
operation
has been undone by any other operation.Parameters
operation : Operation
Operation to check.
Returns
Boolean
true
if givenoperation
has been undone any other operation,false
otherwise.
-
reset()
module:engine/model/history~History#reset
Resets the history of operations.
-
setOperationAsUndone( undoneOperation, undoingOperation )
module:engine/model/history~History#setOperationAsUndone
Marks in history that one operation is an operation that is undoing the other operation. By marking operation this way, history is keeping more context information about operations, which helps in operational transformation.
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.