BlockSuite API Documentation / @blocksuite/inline / RangeService
Class: RangeService<TextAttributes>
Defined in: packages/framework/inline/src/services/range.ts:16
Type Parameters
TextAttributes
TextAttributes
extends BaseTextAttributes
Constructors
new RangeService()
new RangeService<
TextAttributes
>(editor
):RangeService
<TextAttributes
>
Defined in: packages/framework/inline/src/services/range.ts:393
Parameters
editor
InlineEditor
<TextAttributes
>
Returns
RangeService
<TextAttributes
>
Properties
editor
readonly
editor:InlineEditor
<TextAttributes
>
Defined in: packages/framework/inline/src/services/range.ts:393
Accessors
lastEndRelativePosition
Get Signature
get lastEndRelativePosition():
null
|RelativePosition
Defined in: packages/framework/inline/src/services/range.ts:385
Returns
null
| RelativePosition
lastStartRelativePosition
Get Signature
get lastStartRelativePosition():
null
|RelativePosition
Defined in: packages/framework/inline/src/services/range.ts:389
Returns
null
| RelativePosition
Methods
focusEnd()
focusEnd():
void
Defined in: packages/framework/inline/src/services/range.ts:21
Returns
void
focusIndex()
focusIndex(
index
):void
Defined in: packages/framework/inline/src/services/range.ts:28
Parameters
index
number
Returns
void
focusStart()
focusStart():
void
Defined in: packages/framework/inline/src/services/range.ts:35
Returns
void
getInlineRangeFromElement()
getInlineRangeFromElement(
element
):null
|InlineRange
Defined in: packages/framework/inline/src/services/range.ts:42
Parameters
element
Element
Returns
null
| InlineRange
getLine()
getLine(
rangeIndex
):null
| {line
:VLine
;lineIndex
:number
;rangeIndexRelatedToLine
:number
; }
Defined in: packages/framework/inline/src/services/range.ts:59
Parameters
rangeIndex
number
Returns
null
| { line
: VLine
; lineIndex
: number
; rangeIndexRelatedToLine
: number
; }
getNativeRange()
getNativeRange():
null
|Range
Defined in: packages/framework/inline/src/services/range.ts:90
Returns
null
| Range
getNativeSelection()
getNativeSelection():
null
|Selection
Defined in: packages/framework/inline/src/services/range.ts:96
Returns
null
| Selection
getTextPoint()
getTextPoint(
rangeIndex
):null
|TextPoint
Defined in: packages/framework/inline/src/services/range.ts:104
Parameters
rangeIndex
number
Returns
null
| TextPoint
isFirstLine()
isFirstLine(
inlineRange
):boolean
Defined in: packages/framework/inline/src/services/range.ts:138
There are two cases to have the second line:
- long text auto wrap in span element
- soft break
Parameters
inlineRange
null
| InlineRange
Returns
boolean
isLastLine()
isLastLine(
inlineRange
):boolean
Defined in: packages/framework/inline/src/services/range.ts:183
There are two cases to have the second line:
- long text auto wrap in span element
- soft break
Parameters
inlineRange
null
| InlineRange
Returns
boolean
isValidInlineRange()
isValidInlineRange(
inlineRange
):boolean
Defined in: packages/framework/inline/src/services/range.ts:224
Parameters
inlineRange
null
| InlineRange
Returns
boolean
lockSyncInlineRange()
lockSyncInlineRange():
void
Defined in: packages/framework/inline/src/services/range.ts:279
Returns
void
mount()
mount():
void
Defined in: packages/framework/inline/src/services/range.ts:232
Returns
void
selectAll()
selectAll():
void
Defined in: packages/framework/inline/src/services/range.ts:271
Returns
void
syncInlineRange()
syncInlineRange(
inlineRange
?):void
Defined in: packages/framework/inline/src/services/range.ts:288
sync the dom selection from inline range for this Editor
Parameters
inlineRange?
null
| InlineRange
Returns
void
toDomRange()
toDomRange(
inlineRange
):null
|Range
Defined in: packages/framework/inline/src/services/range.ts:341
calculate the dom selection from inline ranage for this Editor
Parameters
inlineRange
Returns
null
| Range
toInlineRange()
toInlineRange(
range
):null
|InlineRange
Defined in: packages/framework/inline/src/services/range.ts:379
calculate the inline ranage from dom selection for this Editor there are three cases when the inline ranage 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 Editorthe inline ranage of second Editor is
aaaaaa b|bbbb|b cccccc
{index: 1, length: 4}
, the others are null - anchor and focus one in this Editor, one in another Editor2.1 the inline ranage of first Editor is
aaa|aaa aaaaaa bbbbb|b or bbbbb|b cccccc cc|cccc
{index: 3, length: 3}
, the second is{index: 0, length: 5}
, the third is null 2.2 the inline ranage of first Editor is null, the second is{index: 5, length: 1}
, the third is{index: 0, length: 2}
- anchor and focus are in another Editorthe inline range of first Editor is
aa|aaaa bbbbbb cccc|cc
{index: 2, length: 4}
, the second is{index: 0, length: 6}
, the third is{index: 0, length: 4}
Parameters
range
Range
Returns
null
| InlineRange
unlockSyncInlineRange()
unlockSyncInlineRange():
void
Defined in: packages/framework/inline/src/services/range.ts:282
Returns
void