Skip to content

API > @blocksuite/virgo > VirgoRangeService

Class: VirgoRangeService<TextAttributes> ​

Constructors ​

constructor ​

new VirgoRangeService<TextAttributes>(editor): VirgoRangeService< TextAttributes >

Type parameters ​

Parameter
TextAttributes extends {bold: null | true; code: null | true; italic: null | true; link: null | string; strike: null | true; underline: null | true;}

Parameters ​

ParameterType
editorVEditor< TextAttributes >

Returns ​

VirgoRangeService< TextAttributes >

Defined In ​

packages/virgo/src/services/range.ts:18

Properties ​

_vRange ​

private _vRange: null | VRange = null

Defined In ​

packages/virgo/src/services/range.ts:16


editor ​

readonly editor: VEditor< TextAttributes >

Defined In ​

packages/virgo/src/services/range.ts:18

Accessors ​

rootElement ​

get rootElement(): VirgoRootElement< TextAttributes >

Defined In ​

packages/virgo/src/services/range.ts:24


vRangeProvider ​

get vRangeProvider(): null | VRangeProvider

Defined In ​

packages/virgo/src/services/range.ts:20

Methods ​

_applyVRange ​

private _applyVRange(vRange): void

Parameters ​

ParameterType
vRangeVRange

Returns ​

void

Defined In ​

packages/virgo/src/services/range.ts:340


focusEnd ​

focusEnd(): void

Returns ​

void

Defined In ​

packages/virgo/src/services/range.ts:262


focusIndex ​

focusIndex(index): void

Parameters ​

ParameterType
indexnumber

Returns ​

void

Defined In ​

packages/virgo/src/services/range.ts:283


focusStart ​

focusStart(): void

Returns ​

void

Defined In ​

packages/virgo/src/services/range.ts:269


getLine ​

getLine(rangeIndex): readonly [VirgoLine, number]

Parameters ​

ParameterType
rangeIndexnumber

Returns ​

readonly [VirgoLine, number]

Defined In ​

packages/virgo/src/services/range.ts:127


getNativeSelection ​

getNativeSelection(): null | Selection

Returns ​

null | Selection

Defined In ​

packages/virgo/src/services/range.ts:72


getTextPoint ​

getTextPoint(rangeIndex): TextPoint

Parameters ​

ParameterType
rangeIndexnumber

Returns ​

TextPoint

Defined In ​

packages/virgo/src/services/range.ts:103


getVRange ​

getVRange(): null | VRange

Returns ​

null | VRange

Defined In ​

packages/virgo/src/services/range.ts:81


getVRangeFromElement ​

getVRangeFromElement(element): null | VRange

Parameters ​

ParameterType
elementElement

Returns ​

null | VRange

Defined In ​

packages/virgo/src/services/range.ts:89


isFirstLine ​

isFirstLine(vRange): boolean

There are two cases to have the second line:

  1. long text auto wrap in span element
  2. soft break

Parameters ​

ParameterType
vRangenull | VRange

Returns ​

boolean

Defined In ​

packages/virgo/src/services/range.ts:162


isLastLine ​

isLastLine(vRange): boolean

There are two cases to have the second line:

  1. long text auto wrap in span element
  2. soft break

Parameters ​

ParameterType
vRangenull | VRange

Returns ​

boolean

Defined In ​

packages/virgo/src/services/range.ts:206


isVRangeValid ​

isVRangeValid(vRange): boolean

Parameters ​

ParameterType
vRangenull | VRange

Returns ​

boolean

Defined In ​

packages/virgo/src/services/range.ts:149


onVRangeUpdated ​

onVRangeUpdated(__namedParameters): Promise< void >

Parameters ​

ParameterType
__namedParametersVRangeUpdatedProp

Returns ​

Promise< void >

Defined In ​

packages/virgo/src/services/range.ts:28


selectAll ​

selectAll(): void

Returns ​

void

Defined In ​

packages/virgo/src/services/range.ts:276


setVRange ​

setVRange(vRange, sync = true): void

the vRange is synced to the native selection asynchronically if sync is true, the native selection will be synced immediately

Parameters ​

ParameterTypeDefault value
vRangenull | VRangeundefined
syncbooleantrue

Returns ​

void

Defined In ​

packages/virgo/src/services/range.ts:249


syncVRange ​

syncVRange(): void

sync the dom selection from vRange for this Editor

Returns ​

void

Defined In ​

packages/virgo/src/services/range.ts:293


toDomRange ​

toDomRange(vRange): null | Range

calculate the dom selection from vRange for this Editor

Parameters ​

ParameterType
vRangeVRange

Returns ​

null | Range

Defined In ​

packages/virgo/src/services/range.ts:303


toVRange ​

toVRange(range): null | VRange

calculate the vRange from dom selection for this Editor there are three cases when the vRange of this Editor is not null: (In the following, "|" mean anchor and focus, each line is a separate Editor)

  1. anchor and focus are in this Editor aaaaaa b|bbbb|b cccccc the vRange of second Editor is {index: 1, length: 4}, the others are null
  2. anchor and focus one in this Editor, one in another Editor aaa|aaa aaaaaa bbbbb|b or bbbbb|b cccccc cc|cccc 2.1 the vRange of first Editor is {index: 3, length: 3}, the second is {index: 0, length: 5}, the third is null 2.2 the vRange of first Editor is null, the second is {index: 5, length: 1}, the third is
  3. anchor and focus are in another Editor aa|aaaa bbbbbb cccc|cc the vRange of first Editor is {index: 2, length: 4}, the second is {index: 0, length: 6}, the third is

Parameters ​

ParameterType
rangeRange

Returns ​

null | VRange

Defined In ​

packages/virgo/src/services/range.ts:334