Interface: TextNodeCaretSlice<T, D>
lexical.TextNodeCaretSlice
A TextNodeCaretSlice is a wrapper for a TextNodeCaret that carries a size representing the amount of text selected from the given caret. A negative size means that text before offset is selected, a positive size means that text after offset is selected. The offset+size pair is not affected in any way by the direction of the caret.
The selected string content can be computed as such:
slice.origin.getTextContent().slice(
Math.min(slice.offset, slice.offset + slice.size),
Math.max(slice.offset, slice.offset + slice.size),
)
Type parameters
Name | Type |
---|---|
T | extends TextNode = TextNode |
D | extends CaretDirection = CaretDirection |
Properties
caret
• Readonly
caret: TextNodeCaret
<T
, D
>
Defined in
packages/lexical/src/caret/LexicalCaret.ts:228
size
• Readonly
size: number