Skip to main content

Interface: TextPointCaretSlice<T, D>

lexical.TextPointCaretSlice

A TextPointCaretSlice is a wrapper for a TextPointCaret that carries a signed distance representing the direction and amount of text selected from the given caret. A negative distance means that text before offset is selected, a positive distance means that text after offset is selected. The offset+distance pair is not affected in any way by the direction of the caret.

The selected string content can be computed as such (see also $getTextSliceContent):

slice.origin.getTextContent().slice(
Math.min(slice.offset, slice.offset + slice.distance),
Math.max(slice.offset, slice.offset + slice.distance),
)

Type parameters

NameType
Textends TextNode = TextNode
Dextends CaretDirection = CaretDirection

Properties

caret

Readonly caret: TextPointCaret<T, D>

Defined in

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


distance

Readonly distance: number

Defined in

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