Report an issue
Class

History (engine/model)

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

class

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

Filtering

Properties

  • _deltas : Array.<Delta>

    protected

    Deltas added to the history.

  • _historyPoints : Map

    protected

    Helper structure that maps added delta's base version to the index in _deltas at which the delta was added.

  • _undoPairs : Map

    private

    Holds an information which delta undoes which delta.

    Keys of the map are "undoing deltas", that is deltas that undone some other deltas. For each key, the value is a delta that has been undone by the "undoing delta".

  • _undoneDeltas : Set.<Delta>

    private

    Holds all undone deltas.

Methods

  • constructor()

    Creates an empty History instance.

  • addDelta( delta )

    Adds delta to the history.

    Parameters

    delta : Delta

    Delta to add.

  • getDelta( baseVersion ) → Delta | null

    Returns delta from history that bases on given baseVersion.

    Parameters

    baseVersion : Number

    Base version of the delta to get.

    Returns

    Delta | null

    Delta with given base version or null if there is no such delta in history.

  • getDeltas( [ from ], [ to ] ) → Iterable.<Delta>

    Returns deltas added to the history.

    Parameters

    [ from ] : Number

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

    Defaults to 0

    [ to ] : Number

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

    Defaults to Number.POSITIVE_INFINITY

    Returns

    Iterable.<Delta>

    Deltas added to the history from given base versions range.

  • getUndoneDelta( undoingDelta ) → Delta | undefined

    For given undoingDelta, returns the delta which has been undone by it.

    Parameters

    undoingDelta : Delta

    Returns

    Delta | undefined

    Delta that has been undone by given undoingDelta or undefined if given undoingDelta is not undoing any other delta.

  • isUndoingDelta( delta ) → Boolean

    Checks whether given delta is undoing by any other delta.

    Parameters

    delta : Delta

    Delta to check.

    Returns

    Boolean

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

  • isUndoneDelta( delta ) → Boolean

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

    Parameters

    delta : Delta

    Delta to check.

    Returns

    Boolean

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

  • setDeltaAsUndone( undoneDelta, undoingDelta )

    Marks in history that one delta is a delta that is undoing the other delta. By marking deltas this way, history is keeping more context information about deltas which helps in operational transformation.

    Parameters

    undoneDelta : Delta

    Delta which is undone by undoingDelta.

    undoingDelta : Delta

    Delta which undoes undoneDelta.

  • _getIndex( baseVersion )

    private

    Gets an index in _deltas where delta with given baseVersion is added.

    Parameters

    baseVersion : Number

    Base version of delta.