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 ​
_isRangeReversed ​
private
_isRangeReversed:boolean
=false
Defined In ​
packages/lit/src/utils/range-manager.ts:35
_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:212
_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:356
_getNearestVirgo ​
private
_getNearestVirgo(node
):undefined
|VirgoRootElement
Parameters ​
Parameter | Type |
---|---|
node | Node |
Returns ​
undefined
| VirgoRootElement
Defined In ​
packages/lit/src/utils/range-manager.ts:342
_mergeRanges ​
private
_mergeRanges(ranges
):null
| {range
:Range
;reversed
:boolean
;}
Parameters ​
Parameter | Type |
---|---|
ranges | RangeSnapshot [] |
Returns ​
null
| {range
: Range
; reversed
: boolean
;}
Defined In ​
packages/lit/src/utils/range-manager.ts:270
_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:239
_renderRange ​
private
_renderRange():void
Returns ​
void
Defined In ​
packages/lit/src/utils/range-manager.ts:323
_snapshotToRange ​
private
_snapshotToRange(snapshot
):Range
Parameters ​
Parameter | Type |
---|---|
snapshot | RangeSnapshot |
Returns ​
Range
Defined In ​
packages/lit/src/utils/range-manager.ts:263
clearRange ​
clearRange(
sync
=true
):void
Parameters ​
Parameter | Type | Default value |
---|---|---|
sync | boolean | true |
Returns ​
void
Defined In ​
packages/lit/src/utils/range-manager.ts:37
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:126
pointToRange ​
pointToRange(
point
):null
|Range
Parameters ​
Parameter | Type |
---|---|
point | TextRangePoint |
Returns ​
null
| Range
Defined In ​
packages/lit/src/utils/range-manager.ts:202
renderRange ​
renderRange(
start
,end
?):void
Parameters ​
Parameter | Type |
---|---|
start | Range |
end ? | null | Range |
Returns ​
void
Defined In ​
packages/lit/src/utils/range-manager.ts:46
syncRangeToTextSelection ​
syncRangeToTextSelection(
range
,isRangeReversed
):null
|TextSelection
Parameters ​
Parameter | Type |
---|---|
range | null | Range |
isRangeReversed | boolean |
Returns ​
null
| TextSelection
Defined In ​
packages/lit/src/utils/range-manager.ts:82
syncTextSelectionToRange ​
syncTextSelectionToRange(
selection
):void
Parameters ​
Parameter | Type |
---|---|
selection | null | TextSelection |
Returns ​
void
Defined In ​
packages/lit/src/utils/range-manager.ts:59
textSelectionToRange ​
textSelectionToRange(
selection
):null
|Range
Parameters ​
Parameter | Type |
---|---|
selection | TextSelection |
Returns ​
null
| Range
Defined In ​
packages/lit/src/utils/range-manager.ts:179