Skip to content

BlockSuite API Documentation / @blocksuite/inline / DeltaService

Class: DeltaService<TextAttributes> ​

Contents ​

Type parameters ​

• TextAttributes extends BaseTextAttributes

Constructors ​

new DeltaService(editor) ​

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

Parameters ​

• editor: InlineEditor<TextAttributes>

Returns ​

DeltaService<TextAttributes>

Source ​

packages/inline/src/services/delta.ts:12

Properties ​

editor ​

readonly editor: InlineEditor<TextAttributes>

Source ​

packages/inline/src/services/delta.ts:12

Accessors ​

deltas ​

get deltas(): DeltaInsert<TextAttributes>[]

Returns ​

DeltaInsert<TextAttributes>[]

Source ​

packages/inline/src/services/delta.ts:14


normalizedDeltas ​

get normalizedDeltas(): DeltaInsert<TextAttributes>[]

Returns ​

DeltaInsert<TextAttributes>[]

Source ​

packages/inline/src/services/delta.ts:18

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>

Source ​

packages/inline/src/services/delta.ts:119


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>[]

Source ​

packages/inline/src/services/delta.ts:189


isNormalizedDeltaSelected() ​

isNormalizedDeltaSelected(normalizedDeltaIndex, inlineRange): boolean

Parameters ​

• normalizedDeltaIndex: number

• inlineRange: InlineRange

Returns ​

boolean

Source ​

packages/inline/src/services/delta.ts:70


mapDeltasInInlineRange() ​

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

Type parameters ​

• Result

Parameters ​

• inlineRange: InlineRange

• callback: (delta, rangeIndex, deltaIndex) => Result

• normalize: boolean= false

Returns ​

Result[]

Source ​

packages/inline/src/services/delta.ts:37


render() ​

render(syncInlineRange): Promise<void>

Parameters ​

• syncInlineRange: boolean= true

Returns ​

Promise<void>

Source ​

packages/inline/src/services/delta.ts:202


Generated using typedoc-plugin-markdown and TypeDoc