Trilium Frontend API
    Preparing search index...

    Class TreeCursor

    A tree cursor object focuses on a given node in a syntax tree, and allows you to move to adjacent nodes.

    Implements

    Index

    Constructors

    Properties

    from: number

    The start source offset of this node.

    to: number

    The end source offset.

    type: NodeType

    The node's type.

    Accessors

    • get name(): string

      Shorthand for .type.name.

      Returns string

    • get tree(): Tree

      Get the tree that represents the current node, if any. Will return null when the node is in a tree buffer.

      Returns Tree

    Methods

    • Move the cursor to the first child that ends after pos.

      Parameters

      • pos: number

      Returns boolean

    • Move to the last child that starts before pos.

      Parameters

      • pos: number

      Returns boolean

    • Move the cursor to the child around pos. If side is -1 the child may end at that position, when 1 it may start there. This will also enter overlaid mounted trees unless overlays is set to false.

      Parameters

      • pos: number
      • side: -1 | 0 | 1
      • Optionalmode: IterMode

      Returns boolean

    • Move the cursor to this node's first child. When this returns false, the node has no child, and the cursor has not been moved.

      Returns boolean

    • Iterate over the current node and all its descendants, calling enter when entering a node and leave, if given, when leaving one. When enter returns false, any children of that node are skipped, and leave isn't called for it.

      Parameters

      Returns void

    • Move the cursor to this node's last child.

      Returns boolean

    • Test whether the current node matches a given context—a sequence of direct parent node names. Empty strings in the context array are treated as wildcards.

      Parameters

      • context: readonly string[]

      Returns boolean

    • Move the cursor to the innermost node that covers pos. If side is -1, it will enter nodes that end at pos. If it is 1, it will enter nodes that start at pos.

      Parameters

      • pos: number
      • Optionalside: -1 | 0 | 1

      Returns this

    • Move to the next node in a pre-order traversal, going from a node to its first child or, if the current node is empty or enter is false, its next sibling or the next sibling of the first parent node that has one.

      Parameters

      • Optionalenter: boolean

      Returns boolean

    • Move to this node's next sibling, if any.

      Returns boolean

    • Move to the node's parent node, if this isn't the top node.

      Returns boolean

    • Move to the next node in a last-to-first pre-order traversal. A node is followed by its last child or, if it has none, its previous sibling or the previous sibling of the first parent node that has one.

      Parameters

      • Optionalenter: boolean

      Returns boolean

    • Move to this node's previous sibling, if any.

      Returns boolean