Skip to main content

CaretRange

interface

A RangeSelection expressed as a pair of Carets

interface CaretRange<D extends CaretDirection = CaretDirection>

Import

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

Members8

anchor
PointCaret<D>
direction
D
focus
PointCaret<D>
getTextSlices
() => TextPointCaretSliceTuple<D>

There are between zero and two non-null TextSliceCarets for a CaretRange. Note that when anchor and focus share an origin node the second element will be null because the slice is entirely represented by the first element. `[slice, slice]`: anchor and focus are TextPointCaret with distinct origin nodes `[slice, null]`: anchor is a TextPointCaret `[null, slice]`: focus is a TextPointCaret `[null, null]`: Neither anchor nor focus are TextPointCarets

isCollapsed
() => boolean

Return true if anchor and focus are the same caret

iterNodeCarets
(rootMode?: RootMode) => IterableIterator<NodeCaret<D>>

Iterate the carets between anchor and focus in a pre-order fashion, note that this does not include any text slices represented by the anchor and/or focus. Those are accessed separately from getTextSlices. An ElementNode origin will be yielded as a ChildCaret on enter, and a SiblingCaret on leave.

type
'node-caret-range'
__@iterator@281474976711162()
() => Iterator<T, TReturn, TNext>