Skip to content

BlockSuite API Documentation / @blocksuite/inline / RangeService

Class: RangeService<TextAttributes>

Contents

Type parameters

TextAttributes extends BaseTextAttributes

Constructors

new RangeService(editor)

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

Parameters

editor: InlineEditor<TextAttributes>

Returns

RangeService<TextAttributes>

Source

packages/inline/src/services/range.ts:22

Properties

_inlineRange

private _inlineRange: null | InlineRange = null

Source

packages/inline/src/services/range.ts:20


editor

readonly editor: InlineEditor<TextAttributes>

Source

packages/inline/src/services/range.ts:22

Accessors

inlineRangeProvider

get inlineRangeProvider(): null | InlineRangeProvider

Returns

null | InlineRangeProvider

Source

packages/inline/src/services/range.ts:24


rootElement

get rootElement(): InlineRootElement<TextAttributes>

Returns

InlineRootElement<TextAttributes>

Source

packages/inline/src/services/range.ts:28

Methods

_applyInlineRange()

private _applyInlineRange(inlineRange): void

Parameters

inlineRange: InlineRange

Returns

void

Source

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


focusEnd()

focusEnd(): void

Returns

void

Source

packages/inline/src/services/range.ts:269


focusIndex()

focusIndex(index): void

Parameters

index: number

Returns

void

Source

packages/inline/src/services/range.ts:290


focusStart()

focusStart(): void

Returns

void

Source

packages/inline/src/services/range.ts:276


getInlineRange()

getInlineRange(): null | InlineRange

Returns

null | InlineRange

Source

packages/inline/src/services/range.ts:88


getInlineRangeFromElement()

getInlineRangeFromElement(element): null | InlineRange

Parameters

element: Element

Returns

null | InlineRange

Source

packages/inline/src/services/range.ts:96


getLine()

getLine(rangeIndex): readonly [VLine, number]

Parameters

rangeIndex: number

Returns

readonly [VLine, number]

Source

packages/inline/src/services/range.ts:134


getNativeSelection()

getNativeSelection(): null | Selection

Returns

null | Selection

Source

packages/inline/src/services/range.ts:79


getTextPoint()

getTextPoint(rangeIndex): TextPoint

Parameters

rangeIndex: number

Returns

TextPoint

Source

packages/inline/src/services/range.ts:110


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

Source

packages/inline/src/services/range.ts:169


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

Source

packages/inline/src/services/range.ts:213


isValidInlineRange()

isValidInlineRange(inlineRange): boolean

Parameters

inlineRange: null | InlineRange

Returns

boolean

Source

packages/inline/src/services/range.ts:156


onInlineRangeUpdated()

onInlineRangeUpdated(__namedParameters): Promise<void>

Parameters

__namedParameters: InlineRangeUpdatedProp

Returns

Promise<void>

Source

packages/inline/src/services/range.ts:32


selectAll()

selectAll(): void

Returns

void

Source

packages/inline/src/services/range.ts:283


setInlineRange()

setInlineRange(inlineRange, sync): void

the inline ranage is synced to the native selection asynchronically if sync is true, the native selection will be synced immediately

Parameters

inlineRange: null | InlineRange

sync: boolean= true

Returns

void

Source

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


syncInlineRange()

syncInlineRange(): void

sync the dom selection from inline ranage for this Editor

Returns

void

Source

packages/inline/src/services/range.ts:300


toDomRange()

toDomRange(inlineRange): null | Range

calculate the dom selection from inline ranage for this Editor

Parameters

inlineRange: InlineRange

Returns

null | Range

Source

packages/inline/src/services/range.ts:310


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

Source

packages/inline/src/services/range.ts:347


Generated using typedoc-plugin-markdown and TypeDoc