Trilium Frontend API
    Preparing search index...

    Class ModelNodeList

    Provides an interface to operate on a list of module:engine/model/node~ModelNode nodes. NodeList is used internally in classes like module:engine/model/element~ModelElement Element or module:engine/model/documentfragment~ModelDocumentFragment ModelDocumentFragment.

    Implements

    Index

    Constructors

    Accessors

    • get length(): number

      Number of nodes contained inside this node list.

      Returns number

    • get maxOffset(): number

      Sum of module:engine/model/node~ModelNode#offsetSize offset sizes of all nodes contained inside this node list.

      Returns number

    Methods

    • Internal

      Inserts given nodes at given index.

      Parameters

      • index: number

        Index at which nodes should be inserted.

      • nodes: Iterable<ModelNode>

        Nodes to be inserted.

      Returns void

    • Internal

      Removes one or more nodes starting at the given index.

      Parameters

      • indexStart: number

        Index of the first node to remove.

      • OptionalhowMany: number

        Number of nodes to remove.

      Returns ModelNode[]

      Array containing removed nodes.

    • Internal

      Removes children nodes provided as an array. These nodes do not need to be direct siblings.

      This method is faster than removing nodes one by one, as it recalculates offsets only once.

      Parameters

      Returns void

    • Gets the node at the given index. Returns null if incorrect index was passed.

      Parameters

      • index: number

      Returns ModelNode

    • Gets the node at the given offset. Returns null if incorrect offset was passed.

      Parameters

      • offset: number

      Returns ModelNode

    • Returns an index of the given node or null if given node does not have a parent.

      This is an alias to module:engine/model/node~ModelNode#index.

      Parameters

      Returns number

    • Returns the offset at which given node is placed in its parent or null if given node does not have a parent.

      This is an alias to module:engine/model/node~ModelNode#startOffset.

      Parameters

      Returns number

    • Converts index to offset in node list.

      Throws module:utils/ckeditorerror~CKEditorError CKEditorError model-nodelist-index-out-of-bounds if given index is less than 0 or more than #length.

      Parameters

      • index: number

      Returns number

    • Converts offset in node list to index.

      Throws module:utils/ckeditorerror~CKEditorError CKEditorError model-nodelist-offset-out-of-bounds if given offset is less than 0 or more than #maxOffset.

      Parameters

      • offset: number

      Returns number

    • Converts NodeList instance to an array containing nodes that were inserted in the node list. Nodes are also converted to their plain object representation.

      Returns unknown

      NodeList instance converted to Array.