Skip to content

BlockSuite API Documentation / @blocksuite/inline / RangeService

Class: RangeService<TextAttributes>

Type Parameters

TextAttributes extends BaseTextAttributes

Constructors

new RangeService()

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

Parameters

editor: InlineEditor<TextAttributes>

Returns

RangeService<TextAttributes>

Defined in

packages/framework/inline/src/services/range.ts:357

Properties

editor

readonly editor: InlineEditor<TextAttributes>

Defined in

packages/framework/inline/src/services/range.ts:357

Accessors

inlineRangeProvider

get inlineRangeProvider(): null | InlineRangeProvider

Returns

null | InlineRangeProvider

Defined in

packages/framework/inline/src/services/range.ts:337


lastEndRelativePosition

get lastEndRelativePosition(): null | RelativePosition

Returns

null | RelativePosition

Defined in

packages/framework/inline/src/services/range.ts:341


lastStartRelativePosition

get lastStartRelativePosition(): null | RelativePosition

Returns

null | RelativePosition

Defined in

packages/framework/inline/src/services/range.ts:345


rootElement

get rootElement(): InlineRootElement<TextAttributes>

Returns

InlineRootElement<TextAttributes>

Defined in

packages/framework/inline/src/services/range.ts:349


yText

get yText(): YText

Returns

YText

Defined in

packages/framework/inline/src/services/range.ts:353

Methods

focusEnd()

focusEnd(): void

Returns

void

Defined in

packages/framework/inline/src/services/range.ts:49


focusIndex()

focusIndex(index): void

Parameters

index: number

Returns

void

Defined in

packages/framework/inline/src/services/range.ts:56


focusStart()

focusStart(): void

Returns

void

Defined in

packages/framework/inline/src/services/range.ts:63


getInlineRange()

getInlineRange(): null | InlineRange

Returns

null | InlineRange

Defined in

packages/framework/inline/src/services/range.ts:70


getInlineRangeFromElement()

getInlineRangeFromElement(element): null | InlineRange

Parameters

element: Element

Returns

null | InlineRange

Defined in

packages/framework/inline/src/services/range.ts:78


getLine()

getLine(rangeIndex): null | object

Parameters

rangeIndex: number

Returns

null | object

Defined in

packages/framework/inline/src/services/range.ts:360


getNativeRange()

getNativeRange(): null | Range

Returns

null | Range

Defined in

packages/framework/inline/src/services/range.ts:388


getNativeSelection()

getNativeSelection(): null | Selection

Returns

null | Selection

Defined in

packages/framework/inline/src/services/range.ts:394


getTextPoint()

getTextPoint(rangeIndex): null | TextPoint

Parameters

rangeIndex: number

Returns

null | TextPoint

Defined in

packages/framework/inline/src/services/range.ts:402


isFirstLine()

isFirstLine(inlineRange): boolean

There are two cases to have the second line:

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

Parameters

inlineRange: null | InlineRange

Returns

boolean

Defined in

packages/framework/inline/src/services/range.ts:97


isLastLine()

isLastLine(inlineRange): boolean

There are two cases to have the second line:

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

Parameters

inlineRange: null | InlineRange

Returns

boolean

Defined in

packages/framework/inline/src/services/range.ts:139


isValidInlineRange()

isValidInlineRange(inlineRange): boolean

Parameters

inlineRange: null | InlineRange

Returns

boolean

Defined in

packages/framework/inline/src/services/range.ts:177


onInlineRangeUpdated()

onInlineRangeUpdated(__namedParameters): Promise<void>

Parameters

__namedParameters: InlineRangeUpdatedProp

Returns

Promise<void>

Defined in

packages/framework/inline/src/services/range.ts:185


selectAll()

selectAll(): void

Returns

void

Defined in

packages/framework/inline/src/services/range.ts:256


setInlineRange()

setInlineRange(inlineRange, sync): void

the inline range is synced to the native selection asynchronously if sync is true, the native selection will be synced immediately

Parameters

inlineRange: null | InlineRange

sync: boolean = true

Returns

void

Defined in

packages/framework/inline/src/services/range.ts:267


syncInlineRange()

syncInlineRange(): void

sync the dom selection from inline ranage for this Editor

Returns

void

Defined in

packages/framework/inline/src/services/range.ts:284


toDomRange()

toDomRange(inlineRange): null | Range

calculate the dom selection from inline ranage for this Editor

Parameters

inlineRange: InlineRange

Returns

null | Range

Defined in

packages/framework/inline/src/services/range.ts:294


toInlineRange()

toInlineRange(range): null | InlineRange

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)

  1. anchor and focus are in this Editor
    aaaaaa
    b|bbbb|b
    cccccc
    the inline ranage 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 inline ranage of first Editor is {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}
  3. anchor and focus are in another Editor
    aa|aaaa
    bbbbbb
    cccc|cc
    the inline range of first Editor is {index: 2, length: 4}, the second is {index: 0, length: 6}, the third is {index: 0, length: 4}

Parameters

range: Range

Returns

null | InlineRange

Defined in

packages/framework/inline/src/services/range.ts:331