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.

Type parameters

NameType
Textends TextNode = TextNode
Dextends CaretDirection = CaretDirection

Properties

caret

Readonly caret: TextPointCaret<T, D>

Defined in

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


distance

Readonly distance: number

Defined in

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


getSliceIndices

getSliceIndices: () => [startIndex: number, endIndex: number]

Type declaration

▸ (): [startIndex: number, endIndex: number]

Returns

[startIndex: number, endIndex: number]

Defined in

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


getTextContent

getTextContent: () => string

Type declaration

▸ (): string

Returns

string

Defined in

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


getTextContentSize

getTextContentSize: () => number

Type declaration

▸ (): number

Returns

number

Defined in

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


type

Readonly type: "slice"

Defined in

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

Methods

removeTextSlice

removeTextSlice(): TextPointCaret<T, D>

Remove the slice of text from the contained caret, returning a new TextPointCaret without the wrapper (since the size would be zero).

Note that this is a lower-level utility that does not have any specific behavior for 'segmented' or 'token' modes and it will not remove an empty TextNode.

Returns

TextPointCaret<T, D>

The inner TextPointCaret with the same offset and direction and the latest TextNode origin after mutation

Defined in

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