Class

History (engine/model)

@ckeditor/ckeditor5-engine/src/model/history

class

History keeps the track of all the operations applied to the document.

Filtering

Properties

  • _operations : Array.<Operation>

    protected

    Operations added to the history.

  • _undoPairs : Map

    private

    Holds an information which operation undoes which operation.

    Keys of the map are "undoing operations", that is operations that undone some other operations. For each key, the value is an operation that has been undone by the "undoing operation".

  • _undoneOperations : Set.<Operation>

    private

    Holds all undone operations.

Methods

  • constructor()

    Creates an empty History instance.

  • addOperation( operation )

    Adds an operation to the history.

    Parameters

    operation : Operation

    Operation to add.

  • getOperation( baseVersion ) → Operation | null

    Returns operation from the history that bases on given baseVersion.

    Parameters

    baseVersion : Number

    Base version of the operation to get.

    Returns

    Operation | null

    Operation with given base version or null if there is no such operation in history.

  • getOperations( [ from ], [ to ] ) → Iterable.<Operation>

    Returns operations added to the history.

    Parameters

    [ from ] : Number

    Base version from which operations should be returned (inclusive). Defaults to 0, which means that operations from the first one will be returned.

    Defaults to 0

    [ to ] : Number

    Base version up to which operations should be returned (exclusive). Defaults to Number.POSITIVE_INFINITY which means that operations up to the last one will be returned.

    Defaults to Number.POSITIVE_INFINITY

    Returns

    Iterable.<Operation>

    Operations added to the history.

  • getUndoneOperation( undoingOperation ) → Operation | undefined

    For given undoingOperation, returns the operation which has been undone by it.

    Parameters

    undoingOperation : Operation

    Returns

    Operation | undefined

    Operation that has been undone by given undoingOperation or undefined if given undoingOperation is not undoing any other operation.

  • isUndoingOperation( operation ) → Boolean

    Checks whether given operation is undoing any other operation.

    Parameters

    operation : Operation

    Operation to check.

    Returns

    Boolean

    true if given operation is undoing any other operation, false otherwise.

  • isUndoneOperation( operation ) → Boolean

    Checks whether given operation has been undone by any other operation.

    Parameters

    operation : Operation

    Operation to check.

    Returns

    Boolean

    true if given operation has been undone any other operation, false otherwise.

  • setOperationAsUndone( undoneOperation, undoingOperation )

    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.

    Parameters

    undoneOperation : Operation

    Operation which is undone by undoingOperation.

    undoingOperation : Operation

    Operation which undoes undoneOperation.