Skip to content

BlockSuite API Documentation / @blocksuite/inline / DeltaService

Class: DeltaService<TextAttributes>

Type Parameters

TextAttributes extends BaseTextAttributes

Constructors

new DeltaService()

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

Parameters

editor

InlineEditor<TextAttributes>

Returns

DeltaService<TextAttributes>

Defined in

packages/framework/inline/src/services/delta.ts:151

Properties

editor

readonly editor: InlineEditor<TextAttributes>

Defined in

packages/framework/inline/src/services/delta.ts:151

Accessors

embedDeltas

Get Signature

get embedDeltas(): DeltaInsert<TextAttributes>[]

Returns

DeltaInsert<TextAttributes>[]

Defined in

packages/framework/inline/src/services/delta.ts:147

Methods

getDeltaByRangeIndex()

getDeltaByRangeIndex(rangeIndex): null | DeltaInsert<TextAttributes>

Here are examples of how this function computes and gets the delta.

We have such a text:

[
  {
     insert: 'aaa',
     attributes: { bold: true },
  },
  {
     insert: 'bbb',
     attributes: { italic: true },
  },
]

getDeltaByRangeIndex(0) returns { insert: 'aaa', attributes: { bold: true } }.

getDeltaByRangeIndex(1) returns { insert: 'aaa', attributes: { bold: true } }.

getDeltaByRangeIndex(3) returns { insert: 'aaa', attributes: { bold: true } }.

getDeltaByRangeIndex(4) returns { insert: 'bbb', attributes: { italic: true } }.

Parameters

rangeIndex

number

Returns

null | DeltaInsert<TextAttributes>

Defined in

packages/framework/inline/src/services/delta.ts:33


getDeltasByInlineRange()

getDeltasByInlineRange(inlineRange): DeltaEntry<TextAttributes>[]

Here are examples of how this function computes and gets the deltas.

We have such a text:

[
  {
     insert: 'aaa',
     attributes: { bold: true },
  },
  {
     insert: 'bbb',
     attributes: { italic: true },
  },
  {
     insert: 'ccc',
     attributes: { underline: true },
  },
]

getDeltasByInlineRange({ index: 0, length: 0 }) returns

[{ insert: 'aaa', attributes: { bold: true }, }, { index: 0, length: 3, }]]

getDeltasByInlineRange({ index: 0, length: 1 }) returns

[{ insert: 'aaa', attributes: { bold: true }, }, { index: 0, length: 3, }]]

getDeltasByInlineRange({ index: 0, length: 4 }) returns

[{ insert: 'aaa', attributes: { bold: true }, }, { index: 0, length: 3, }],
 [{ insert: 'bbb', attributes: { italic: true }, }, { index: 3, length: 3, }]]

getDeltasByInlineRange({ index: 3, length: 1 }) returns

[{ insert: 'aaa', attributes: { bold: true }, }, { index: 0, length: 3, }],
 [{ insert: 'bbb', attributes: { italic: true }, }, { index: 3, length: 3, }]]

getDeltasByInlineRange({ index: 3, length: 3 }) returns

[{ insert: 'aaa', attributes: { bold: true }, }, { index: 0, length: 3, }],
 [{ insert: 'bbb', attributes: { italic: true }, }, { index: 3, length: 3, }]]

getDeltasByInlineRange({ index: 3, length: 4 }) returns

[{ insert: 'aaa', attributes: { bold: true }, }, { index: 0, length: 3, }],
 [{ insert: 'bbb', attributes: { italic: true }, }, { index: 3, length: 3, }],
 [{ insert: 'ccc', attributes: { underline: true }, }, { index: 6, length: 3, }]]

Parameters

inlineRange

InlineRange

Returns

DeltaEntry<TextAttributes>[]

Defined in

packages/framework/inline/src/services/delta.ts:103


mapDeltasInInlineRange()

mapDeltasInInlineRange<Result>(inlineRange, callback): Result[]

Type Parameters

Result

Parameters

inlineRange

InlineRange

callback

(delta, rangeIndex, deltaIndex) => Result

Returns

Result[]

Defined in

packages/framework/inline/src/services/delta.ts:115