Trilium Frontend API
    Preparing search index...

    Class MergeOperation

    Operation to merge two module:engine/model/element~ModelElement elements.

    The merged element is the parent of ~MergeOperation#sourcePosition and it is merged into the parent of ~MergeOperation#targetPosition. All nodes from the merged element are moved to ~MergeOperation#targetPosition.

    The merged element is moved to the graveyard at ~MergeOperation#graveyardPosition.

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a merge operation.

      Parameters

      • sourcePosition: ModelPosition

        Position inside the merged element. All nodes from that element after that position will be moved to #targetPosition.

      • howMany: number

        Summary offset size of nodes which will be moved from the merged element to the new parent.

      • targetPosition: ModelPosition

        Position which the nodes from the merged elements will be moved to.

      • graveyardPosition: ModelPosition

        Position in graveyard to which the merged element will be moved.

      • baseVersion: number

        Document module:engine/model/document~ModelDocument#version on which operation can be applied or null if the operation operates on detached (non-document) tree.

      Returns MergeOperation

    Properties

    baseVersion: number

    module:engine/model/document~ModelDocument#version on which operation can be applied. If you try to module:engine/model/model~Model#applyOperation apply operation with different base version than the module:engine/model/document~ModelDocument#version document version the module:utils/ckeditorerror~CKEditorError model-document-applyOperation-wrong-version error is thrown.

    batch: Batch

    module:engine/model/batch~Batch Batch to which the operation is added or null if the operation is not added to any batch yet.

    Note, that a #isDocumentOperation non-document operation has this property always set to null, and is never added to any batch.

    graveyardPosition: ModelPosition

    Position in graveyard to which the merged element will be moved.

    howMany: number

    Summary offset size of nodes which will be moved from the merged element to the new parent.

    isDocumentOperation: boolean

    Defines whether operation is executed on attached or detached module:engine/model/item~ModelItem items.

    sourcePosition: ModelPosition

    Position inside the merged element. All nodes from that element after that position will be moved to #targetPosition.

    targetPosition: ModelPosition

    Position which the nodes from the merged elements will be moved to.

    Accessors

    • get affectedSelectable(): ModelSelectable

      A selectable that will be affected by the operation after it is executed.

      The exact returned parameter differs between operation types.

      Returns ModelSelectable

    • get deletionPosition(): ModelPosition

      Position before the merged element (which will be deleted).

      Returns ModelPosition

    • get movedRange(): ModelRange

      Artificial range that contains all the nodes from the merged element that will be moved to ~MergeOperation#sourcePosition. The range starts at ~MergeOperation#sourcePosition and ends in the same parent, at POSITIVE_INFINITY offset.

      Returns ModelRange

    • get type(): "merge"

      Operation type.

      Returns "merge"

    • get className(): string

      Name of the operation class used for serialization.

      Returns string

    Methods

    • Internal

      Executes the operation - modifications described by the operation properties will be applied to the model tree.

      Returns void

    • Internal

      Checks whether the operation's parameters are correct and the operation can be correctly executed. Throws an error if operation is not valid.

      Returns void

    • Creates and returns an operation that has the same parameters as this operation.

      Returns MergeOperation

    • See module:engine/model/operation/operation~Operation#getReversed Operation#getReversed().

      Returns Operation

    • Custom toJSON method to solve child-parent circular dependencies.

      Returns unknown

      Clone of this object with the operation property replaced with string.

    • Creates MergeOperation object from deserialized object, i.e. from parsed JSON string.

      Parameters

      • json: any

        Deserialized JSON object.

      • document: ModelDocument

        Document on which this operation will be applied.

      Returns MergeOperation