Skip to main content

TextPointCaretSlice

interface

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.

interface TextPointCaretSlice<T extends TextNode = TextNode, D extends CaretDirection = CaretDirection>

Import

import { TextPointCaretSlice } from '@modular/sdk/editor';

Members7

caret
TextPointCaret<T, D>
distance
number
getSliceIndices
() => [startIndex: number, endIndex: number]
getTextContent
() => string
getTextContentSize
() => number
type
'slice'
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.