Skip to content

API > @blocksuite/lit > RangeManager

Class: RangeManager ​

CRUD for Range and TextSelection

Constructors ​

constructor ​

new RangeManager(root): RangeManager

Parameters ​

ParameterType
rootBlockSuiteRoot

Returns ​

RangeManager

Defined In ​

packages/lit/src/utils/range-manager.ts:28

Properties ​

_range ​

private _range: null | Range = null

Defined In ​

packages/lit/src/utils/range-manager.ts:34


rangeSynchronizer ​

readonly rangeSynchronizer: RangeSynchronizer

Defined In ​

packages/lit/src/utils/range-manager.ts:26


root ​

root: BlockSuiteRoot

Defined In ​

packages/lit/src/utils/range-manager.ts:28

Accessors ​

value ​

get value(): null | Range

Defined In ​

packages/lit/src/utils/range-manager.ts:30

Methods ​

_calculateVirgo ​

private _calculateVirgo(point): null | [VEditor< {bold: null | true; code: null | true; italic: null | true; link: null | string; strike: null | true; underline: null | true;} >, VRange]

Parameters ​

ParameterType
pointTextRangePoint

Returns ​

null | [VEditor< {bold: null | true; code: null | true; italic: null | true; link: null | string; strike: null | true; underline: null | true;} >, VRange]

Defined In ​

packages/lit/src/utils/range-manager.ts:204


_getBlock ​

private _getBlock(element): BlockElement< BaseBlockModel< object >, BlockService< BaseBlockModel< object > >, string >

Parameters ​

ParameterType
elementHTMLElement

Returns ​

BlockElement< BaseBlockModel< object >, BlockService< BaseBlockModel< object > >, string >

Defined In ​

packages/lit/src/utils/range-manager.ts:338


_getNearestVirgo ​

private _getNearestVirgo(node): undefined | VirgoRootElement

Parameters ​

ParameterType
nodeNode

Returns ​

undefined | VirgoRootElement

Defined In ​

packages/lit/src/utils/range-manager.ts:324


_mergeRanges ​

private _mergeRanges(ranges): null | Range

Parameters ​

ParameterType
rangesRangeSnapshot[]

Returns ​

null | Range

Defined In ​

packages/lit/src/utils/range-manager.ts:262


_nodeToPoint ​

private _nodeToPoint(node): null | {blockId: string; index: number; length: number; path: string[];}

Parameters ​

ParameterType
nodeNode

Returns ​

null | {blockId: string; index: number; length: number; path: string[];}

Defined In ​

packages/lit/src/utils/range-manager.ts:231


_renderRange ​

private _renderRange(): void

Returns ​

void

Defined In ​

packages/lit/src/utils/range-manager.ts:313


_snapshotToRange ​

private _snapshotToRange(snapshot): Range

Parameters ​

ParameterType
snapshotRangeSnapshot

Returns ​

Range

Defined In ​

packages/lit/src/utils/range-manager.ts:255


clearRange ​

clearRange(sync = true): void

Parameters ​

ParameterTypeDefault value
syncbooleantrue

Returns ​

void

Defined In ​

packages/lit/src/utils/range-manager.ts:36


getSelectedBlockElementsByRange ​

getSelectedBlockElementsByRange(range, options = {}): BlockElement< BaseBlockModel< object >, BlockService< BaseBlockModel< object > >, string >[]

Parameters ​

ParameterType
rangeRange
optionsobject
options.match?function
options.mode?"all" | "flat" | "highest"

Returns ​

BlockElement< BaseBlockModel< object >, BlockService< BaseBlockModel< object > >, string >[]

Example ​

ts
aaa
  b[bb
    ccc
ddd
  ee]e

all mode: [aaa, bbb, ccc, ddd, eee]
flat mode: [bbb, ccc, ddd, eee]
highest mode: [bbb, ddd]

match function will be evaluated before filtering using mode
aaa
  b[bb
    ccc
ddd
  ee]e

all mode: [aaa, bbb, ccc, ddd, eee]
flat mode: [bbb, ccc, ddd, eee]
highest mode: [bbb, ddd]

match function will be evaluated before filtering using mode

Defined In ​

packages/lit/src/utils/range-manager.ts:119


pointToRange ​

pointToRange(point): null | Range

Parameters ​

ParameterType
pointTextRangePoint

Returns ​

null | Range

Defined In ​

packages/lit/src/utils/range-manager.ts:194


renderRange ​

renderRange(start, end?): void

Parameters ​

ParameterType
startRange
end?null | Range

Returns ​

void

Defined In ​

packages/lit/src/utils/range-manager.ts:44


syncRangeToTextSelection ​

syncRangeToTextSelection(range): null | TextSelection

Parameters ​

ParameterType
rangenull | Range

Returns ​

null | TextSelection

Defined In ​

packages/lit/src/utils/range-manager.ts:77


syncTextSelectionToRange ​

syncTextSelectionToRange(selection): void

Parameters ​

ParameterType
selectionnull | TextSelection

Returns ​

void

Defined In ​

packages/lit/src/utils/range-manager.ts:54


textSelectionToRange ​

textSelectionToRange(selection): null | Range

Parameters ​

ParameterType
selectionTextSelection

Returns ​

null | Range

Defined In ​

packages/lit/src/utils/range-manager.ts:172