Skip to main content

BaseCaret

interface
interface BaseCaret<T extends LexicalNode, D extends CaretDirection, Type>

Import

import { BaseCaret } from '@modular/sdk/editor';

Members12

direction
D

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

getNodeAtCaret
() => null | LexicalNode

Get the node connected to the origin in the caret's direction, or null if there is no node

getParentAtCaret
() => null | ElementNode

Get the ElementNode that is the logical parent (`origin` for `ChildCaret`, `origin.getParent()` for `SiblingCaret`)

getSiblingCaret
() => SiblingCaret<T, D>

Get a new SiblingCaret with this same node

insert
(node: LexicalNode) => this

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

origin
T

The origin node of this caret, typically this is what you will use in traversals

remove
() => this

Remove the getNodeAtCaret() node that this caret is pointing towards, if it exists

replaceOrInsert
(node: LexicalNode, includeChildren?: boolean) => this

If getNodeAtCaret() is not null then replace it with node, otherwise insert node

splice
(deleteCount: number, nodes: Iterable<LexicalNode>, nodesDirection?: CaretDirection) => this

Splice an iterable (typically an Array) of nodes into this location.

type
Type

sibling 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>

Notes

noInheritDoc