Interface: CaretRange<D>
lexical.CaretRange
A RangeSelection expressed as a pair of Carets
Type parameters
| Name | Type |
|---|---|
D | extends CaretDirection = CaretDirection |
Hierarchy
-
Iterable<PointCaret<D>>↳
CaretRange
Properties
anchor
• anchor: PointCaret<D>
Defined in
packages/lexical/src/caret/LexicalCaret.ts:114
direction
• Readonly direction: D
Defined in
packages/lexical/src/caret/LexicalCaret.ts:113
focus
• focus: PointCaret<D>
Defined in
packages/lexical/src/caret/LexicalCaret.ts:115
getTextSlices
• getTextSlices: () => TextPointCaretSliceTuple<D>
There are between zero and two non-null TextSliceCarets for a CaretRange. Note that when anchor and focus share an origin node the second element will be null becaues the slice is entirely represented by the first element.
[slice, slice]: anchor and focus are TextPointCaret with distinct origin nodes
[slice, null]: anchor is a TextPointCaret
[null, slice]: focus is a TextPointCaret
[null, null]: Neither anchor nor focus are TextPointCarets
Type declaration
▸ (): TextPointCaretSliceTuple<D>
Returns
Defined in
packages/lexical/src/caret/LexicalCaret.ts:137
isCollapsed
• isCollapsed: () => boolean
Return true if anchor and focus are the same caret
Type declaration
▸ (): boolean
Returns
boolean
Defined in
packages/lexical/src/caret/LexicalCaret.ts:117
iterNodeCarets
• iterNodeCarets: (rootMode: RootMode) => IterableIterator<NodeCaret<D>>
Iterate the carets between anchor and focus in a pre-order fashion, note that this does not include any text slices represented by the anchor and/or focus. Those are accessed separately from getTextSlices.
An ElementNode origin will be yielded as a ChildCaret on enter, and a SiblingCaret on leave.
Type declaration
▸ (rootMode): IterableIterator<NodeCaret<D>>
Parameters
| Name | Type |
|---|---|
rootMode | RootMode |
Returns
IterableIterator<NodeCaret<D>>
Defined in
packages/lexical/src/caret/LexicalCaret.ts:126
type
• Readonly type: "node-caret-range"
Defined in
packages/lexical/src/caret/LexicalCaret.ts:112
Methods
[iterator]
▸ [iterator](): Iterator<PointCaret<D>, any, undefined>
Returns
Iterator<PointCaret<D>, any, undefined>
Inherited from
Iterable.[iterator]