Trilium Frontend API
    Preparing search index...

    Class History

    History keeps the track of all the operations applied to the module:engine/model/document~ModelDocument document.

    Index

    Constructors

    Accessors

    • get lastOperation(): Operation

      The last history operation.

      Returns Operation

    • get version(): number

      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.

      Returns number

    • set version(version: number): void

      Parameters

      • version: number

      Returns void

    Methods

    • 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

      Returns void

    • Returns operation from the history that bases on given baseVersion.

      Parameters

      • baseVersion: number

        Base version of the operation to get.

      Returns Operation

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

    • 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

      • OptionalfromBaseVersion: number

        Base version from which operations should be returned (inclusive).

      • OptionaltoBaseVersion: number

        Base version up to which operations should be returned (exclusive).

      Returns Operation[]

      History operations for the given range, in chronological order.

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

      Parameters

      Returns Operation

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

    • Checks whether given operation is undoing any other operation.

      Parameters

      Returns boolean

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

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

      Parameters

      Returns boolean

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

    • Resets the history of operations.

      Returns void

    • 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.

      Returns void