Skip to main content

Interface: CaretRange<D>

lexical.CaretRange

A RangeSelection expressed as a pair of Carets

Type parameters

NameType
Dextends CaretDirection = CaretDirection

Hierarchy

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 TextSliceCarets for a CaretRange

0: Neither anchor nor focus are TextPointCarets 1: One of anchor or focus are TextPointCaret, or of the same origin 2: Anchor and focus are both TextPointCaret of different origin

Type declaration

▸ (): TextPointCaretSliceTuple<D>

Returns

TextPointCaretSliceTuple<D>

Defined in

packages/lexical/src/caret/LexicalCaret.ts:134


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
NameType
rootModeRootMode
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]

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:49