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 ​
Parameter | Type |
---|---|
editor | VEditor < 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 ​
Parameter | Type |
---|---|
vRange | VRange |
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 ​
Parameter | Type |
---|---|
index | number |
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 ​
Parameter | Type |
---|---|
rangeIndex | number |
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 ​
Parameter | Type |
---|---|
rangeIndex | number |
Returns ​
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 ​
Parameter | Type |
---|---|
element | Element |
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:
- long text auto wrap in span element
- soft break
Parameters ​
Parameter | Type |
---|---|
vRange | null | 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:
- long text auto wrap in span element
- soft break
Parameters ​
Parameter | Type |
---|---|
vRange | null | VRange |
Returns ​
boolean
Defined In ​
packages/virgo/src/services/range.ts:206
isVRangeValid ​
isVRangeValid(
vRange
):boolean
Parameters ​
Parameter | Type |
---|---|
vRange | null | VRange |
Returns ​
boolean
Defined In ​
packages/virgo/src/services/range.ts:149
onVRangeUpdated ​
onVRangeUpdated(
__namedParameters
):Promise
<void
>
Parameters ​
Parameter | Type |
---|---|
__namedParameters | VRangeUpdatedProp |
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 ​
Parameter | Type | Default value |
---|---|---|
vRange | null | VRange | undefined |
sync | boolean | true |
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 ​
Parameter | Type |
---|---|
vRange | VRange |
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)
- 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
- 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
- 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 ​
Parameter | Type |
---|---|
range | Range |
Returns ​
null
| VRange
Defined In ​
packages/virgo/src/services/range.ts:334