ChildCaret
interfaceA ChildCaret points from an origin ElementNode towards its first or last child.
Import
import { ChildCaret } from '@modular/sdk/editor';Members18
- direction
Dnext if pointing at the next sibling or first child, previous if pointing at the previous sibling or last child
- getAdjacentCaret
() => null | SiblingCaret<LexicalNode, D>Get a new SiblingCaret from getNodeAtCaret() in the same direction.
- getChildCaret
() => thisReturn this, the ChildCaret is already a child caret of its origin
- getFlipped
() => NodeCaret<FlipDirection<D>>Get a new NodeCaret with the head and tail of its directional arrow flipped, such that flipping twice is the identity. For example, given a non-empty parent with a firstChild and lastChild, and a second emptyParent node with no children:
- getLatest
() => ChildCaret<T, D>Get a new caret with the latest origin pointer
- getNodeAtCaret
() => null | LexicalNodeGet the node connected to the origin in the caret's direction, or null if there is no node
- getParentAtCaret
() => TGet the ElementNode that is the logical parent (`origin` for `ChildCaret`, `origin.getParent()` for `SiblingCaret`)
- getParentCaret
(mode?: RootMode) => null | SiblingCaret<T, D>- getSiblingCaret
() => SiblingCaret<T, D>Get a new SiblingCaret with this same node
- insert
(node: LexicalNode) => thisInsert a node connected to origin in this direction (before the node that this caret is pointing towards, if any existed). For a `SiblingCaret` this is `origin.insertAfter(node)` for next, or `origin.insertBefore(node)` for previous. For a `ChildCaret` this is `origin.splice(0, 0, [node])` for next or `origin.append(node)` for previous.
- isSameNodeCaret
(other: null | undefined | PointCaret) => other is ChildCaret<T, D>Return true if other is a ChildCaret with the same origin (by node key comparison) and direction.
- isSamePointCaret
(other: null | undefined | PointCaret) => other is ChildCaret<T, D>Return true if other is a ChildCaret with the same origin (by node key comparison) and direction.
- origin
TThe origin node of this caret, typically this is what you will use in traversals
- remove
() => thisRemove the getNodeAtCaret() node that this caret is pointing towards, if it exists
- replaceOrInsert
(node: LexicalNode, includeChildren?: boolean) => thisIf getNodeAtCaret() is not null then replace it with node, otherwise insert node
- splice
(deleteCount: number, nodes: Iterable<LexicalNode>, nodesDirection?: CaretDirection) => thisSplice an iterable (typically an Array) of nodes into this location.
- type
Typesibling for a SiblingCaret (pointing at the next or previous sibling) or child for a ChildCaret (pointing at the first or last child)
- __@iterator@281474976711162()
() => Iterator<T, TReturn, TNext>