API > @blocksuite/lit > RangeManager
Class: RangeManager ​
CRUD for Range and TextSelection
Constructors ​
constructor ​
new RangeManager(
root
):RangeManager
Parameters ​
Parameter | Type |
---|---|
root | BlockSuiteRoot |
Returns ​
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 ​
Parameter | Type |
---|---|
point | TextRangePoint |
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 ​
Parameter | Type |
---|---|
element | HTMLElement |
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 ​
Parameter | Type |
---|---|
node | Node |
Returns ​
undefined
| VirgoRootElement
Defined In ​
packages/lit/src/utils/range-manager.ts:324
_mergeRanges ​
private
_mergeRanges(ranges
):null
|Range
Parameters ​
Parameter | Type |
---|---|
ranges | RangeSnapshot [] |
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 ​
Parameter | Type |
---|---|
node | Node |
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 ​
Parameter | Type |
---|---|
snapshot | RangeSnapshot |
Returns ​
Range
Defined In ​
packages/lit/src/utils/range-manager.ts:255
clearRange ​
clearRange(
sync
=true
):void
Parameters ​
Parameter | Type | Default value |
---|---|---|
sync | boolean | true |
Returns ​
void
Defined In ​
packages/lit/src/utils/range-manager.ts:36
getSelectedBlockElementsByRange ​
getSelectedBlockElementsByRange(
range
,options
={}
):BlockElement
<BaseBlockModel
<object
>,BlockService
<BaseBlockModel
<object
> >,string
>[]
Parameters ​
Parameter | Type |
---|---|
range | Range |
options | object |
options.match ? | function |
options.mode ? | "all" | "flat" | "highest" |
Returns ​
BlockElement
< BaseBlockModel
< object
>, BlockService
< BaseBlockModel
< object
> >, string
>[]
Example ​
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 ​
Parameter | Type |
---|---|
point | TextRangePoint |
Returns ​
null
| Range
Defined In ​
packages/lit/src/utils/range-manager.ts:194
renderRange ​
renderRange(
start
,end
?):void
Parameters ​
Parameter | Type |
---|---|
start | Range |
end ? | null | Range |
Returns ​
void
Defined In ​
packages/lit/src/utils/range-manager.ts:44
syncRangeToTextSelection ​
syncRangeToTextSelection(
range
):null
|TextSelection
Parameters ​
Parameter | Type |
---|---|
range | null | Range |
Returns ​
null
| TextSelection
Defined In ​
packages/lit/src/utils/range-manager.ts:77
syncTextSelectionToRange ​
syncTextSelectionToRange(
selection
):void
Parameters ​
Parameter | Type |
---|---|
selection | null | TextSelection |
Returns ​
void
Defined In ​
packages/lit/src/utils/range-manager.ts:54
textSelectionToRange ​
textSelectionToRange(
selection
):null
|Range
Parameters ​
Parameter | Type |
---|---|
selection | TextSelection |
Returns ​
null
| Range
Defined In ​
packages/lit/src/utils/range-manager.ts:172