Interface: DepthNodeCaret<T, D>
lexical.DepthNodeCaret
A DepthNodeCaret points from an origin ElementNode towards its first or last child.
Type parameters
Name | Type |
---|---|
T | extends ElementNode = ElementNode |
D | extends CaretDirection = CaretDirection |
Hierarchy
-
BaseNodeCaret
<T
,D
>↳
DepthNodeCaret
Properties
direction
• Readonly
direction: D
next if pointing at the next sibling or first child, previous if pointing at the previous sibling or last child
Inherited from
BaseNodeCaret.direction
Defined in
packages/lexical/src/LexicalCaret.ts:35
origin
• Readonly
origin: T
The origin node of this caret, typically this is what you will use in traversals
Inherited from
BaseNodeCaret.origin
Defined in
packages/lexical/src/LexicalCaret.ts:31
type
• Readonly
type: "depth"
Overrides
BaseNodeCaret.type
Defined in
packages/lexical/src/LexicalCaret.ts:133
Methods
[iterator]
▸ [iterator](): Iterator
<BreadthNodeCaret
<LexicalNode
, D
>, any
, undefined
>
Returns
Iterator
<BreadthNodeCaret
<LexicalNode
, D
>, any
, undefined
>
Inherited from
BaseNodeCaret.[iterator]
Defined in
node_modules/typescript/lib/lib.es2015.iterable.d.ts:49
getAdjacentCaret
▸ getAdjacentCaret(): null
| BreadthNodeCaret
<LexicalNode
, D
>
Get a new BreadthNodeCaret from getNodeAtCaret() in the same direction. This is used for traversals, but only goes in the breadth (sibling) direction.
Returns
null
| BreadthNodeCaret
<LexicalNode
, D
>
Inherited from
BaseNodeCaret.getAdjacentCaret
Defined in
packages/lexical/src/LexicalCaret.ts:57
getChildCaret
▸ getChildCaret(): this
Return this, the DepthNode is already a child caret of its origin
Returns
this
Defined in
packages/lexical/src/LexicalCaret.ts:137
getFlipped
▸ 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:
Returns
Example
caret.getFlipped().getFlipped().is(caret) === true;
$getDepthCaret(parent, 'next').getFlipped().is($getBreadthCaret(firstChild, 'previous')) === true;
$getBreadthCaret(lastChild, 'next').getFlipped().is($getDepthCaret(parent, 'previous')) === true;
$getBreadthCaret(firstChild, 'next).getFlipped().is($getBreadthCaret(lastChild, 'previous')) === true;
$getDepthCaret(emptyParent, 'next').getFlipped().is($getDepthCaret(emptyParent, 'previous')) === true;
Inherited from
BaseNodeCaret.getFlipped
Defined in
packages/lexical/src/LexicalCaret.ts:51
getNodeAtCaret
▸ getNodeAtCaret(): null
| LexicalNode
Get the node connected to the origin in the caret's direction, or null if there is no node
Returns
null
| LexicalNode
Inherited from
BaseNodeCaret.getNodeAtCaret
Defined in
packages/lexical/src/LexicalCaret.ts:55
getParentAtCaret
▸ getParentAtCaret(): T
Returns
T
Overrides
BaseNodeCaret.getParentAtCaret
Defined in
packages/lexical/src/LexicalCaret.ts:135
getParentCaret
▸ getParentCaret(mode
): null
| BreadthNodeCaret
<T
, D
>
Parameters
Name | Type |
---|---|
mode | RootMode |
Returns
null
| BreadthNodeCaret
<T
, D
>
Defined in
packages/lexical/src/LexicalCaret.ts:134
insert
▸ insert(node
): this
Insert a node connected to origin in this direction.
For a BreadthNodeCaret
this is origin.insertAfter(node)
for next, or origin.insertBefore(node)
for previous.
For a DepthNodeCaret
this is origin.splice(0, 0, [node])
for next or origin.append(node)
for previous.
Parameters
Name | Type |
---|---|
node | LexicalNode |
Returns
this
Inherited from
BaseNodeCaret.insert
Defined in
packages/lexical/src/LexicalCaret.ts:65
is
▸ is(other
): boolean
Retun true if other is a caret with the same origin (by node key comparion), type, and direction
Parameters
Name | Type |
---|---|
other | null | NodeCaret <CaretDirection > |
Returns
boolean
Inherited from
BaseNodeCaret.is
Defined in
packages/lexical/src/LexicalCaret.ts:37
remove
▸ remove(): this
Remove the getNodeAtCaret() node, if it exists
Returns
this
Inherited from
BaseNodeCaret.remove
Defined in
packages/lexical/src/LexicalCaret.ts:59
replaceOrInsert
▸ replaceOrInsert(node
, includeChildren?
): this
If getNodeAtCaret() is null then replace it with node, otherwise insert node
Parameters
Name | Type |
---|---|
node | LexicalNode |
includeChildren? | boolean |
Returns
this
Inherited from
BaseNodeCaret.replaceOrInsert
Defined in
packages/lexical/src/LexicalCaret.ts:67
splice
▸ splice(deleteCount
, nodes
, nodesDirection?
): this
Splice an iterable (typically an Array) of nodes into this location.
Parameters
Name | Type | Description |
---|---|---|
deleteCount | number | The number of existing nodes to replace or delete |
nodes | Iterable <LexicalNode > | An iterable of nodes that will be inserted in this location, using replace instead of insert for the first deleteCount nodes |
nodesDirection? | CaretDirection | The direction of the nodes iterable, defaults to 'next' |
Returns
this
Inherited from
BaseNodeCaret.splice