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
>
Source
packages/framework/inline/src/services/delta.ts:16
Properties
editor
readonly
editor:InlineEditor
<TextAttributes
>
Source
packages/framework/inline/src/services/delta.ts:16
Accessors
deltas
get
deltas():DeltaInsert
<TextAttributes
>[]
Returns
DeltaInsert
<TextAttributes
>[]
Source
packages/framework/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/framework/inline/src/services/delta.ts:106
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/framework/inline/src/services/delta.ts:176
isNormalizedDeltaSelected()
isNormalizedDeltaSelected(
normalizedDeltaIndex
,inlineRange
):boolean
Parameters
• normalizedDeltaIndex: number
• inlineRange: InlineRange
Returns
boolean
Source
packages/framework/inline/src/services/delta.ts:57
mapDeltasInInlineRange()
mapDeltasInInlineRange<
Result
>(inlineRange
,callback
,normalize
):Result
[]
Type parameters
• Result
Parameters
• inlineRange: InlineRange
• callback
• normalize: boolean
= false
Returns
Result
[]
Source
packages/framework/inline/src/services/delta.ts:22
render()
render(
syncInlineRange
):Promise
<void
>
Parameters
• syncInlineRange: boolean
= true
Returns
Promise
<void
>
Source
packages/framework/inline/src/services/delta.ts:189