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
Name | Type |
---|---|
T | extends TextNode = TextNode |
D | extends CaretDirection = CaretDirection |
Properties
caret
• Readonly
caret: TextPointCaret
<T
, D
>
Defined in
packages/lexical/src/caret/LexicalCaret.ts:251
distance
• Readonly
distance: number
Defined in
packages/lexical/src/caret/LexicalCaret.ts:252
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:256
getTextContent
• getTextContent: () => string
Type declaration
▸ (): string
Returns
string
Defined in
packages/lexical/src/caret/LexicalCaret.ts:260
getTextContentSize
• getTextContentSize: () => number
Type declaration
▸ (): number
Returns
number
Defined in
packages/lexical/src/caret/LexicalCaret.ts:264
type
• Readonly
type: "slice"
Defined in
packages/lexical/src/caret/LexicalCaret.ts:250
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