BlockSuite API Documentation / @blocksuite/virgo / VirgoDeltaService
Class: VirgoDeltaService<TextAttributes> ​
Contents ​
Type parameters ​
• TextAttributes extends BaseTextAttributes
Constructors ​
new VirgoDeltaService(editor) ​
new VirgoDeltaService<
TextAttributes
>(editor
):VirgoDeltaService
<TextAttributes
>
Parameters ​
• editor: VEditor
<TextAttributes
>
Returns ​
VirgoDeltaService
<TextAttributes
>
Source ​
packages/virgo/src/services/delta.ts:12
Properties ​
editor ​
readonly
editor:VEditor
<TextAttributes
>
Source ​
packages/virgo/src/services/delta.ts:12
Accessors ​
deltas ​
get
deltas():DeltaInsert
<TextAttributes
>[]
Returns ​
DeltaInsert
<TextAttributes
>[]
Source ​
packages/virgo/src/services/delta.ts:14
normalizedDeltas ​
get
normalizedDeltas():DeltaInsert
<TextAttributes
>[]
Returns ​
DeltaInsert
<TextAttributes
>[]
Source ​
packages/virgo/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/virgo/src/services/delta.ts:119
getDeltasByVRange() ​
getDeltasByVRange(
vRange
):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 },
},
]
getDeltasByVRange({ index: 0, length: 0 })
returns
[{ insert: 'aaa', attributes: { bold: true }, }, { index: 0, length: 3, }]]
getDeltasByVRange({ index: 0, length: 1 })
returns
[{ insert: 'aaa', attributes: { bold: true }, }, { index: 0, length: 3, }]]
getDeltasByVRange({ index: 0, length: 4 })
returns
[{ insert: 'aaa', attributes: { bold: true }, }, { index: 0, length: 3, }],
[{ insert: 'bbb', attributes: { italic: true }, }, { index: 3, length: 3, }]]
getDeltasByVRange({ index: 3, length: 1 })
returns
[{ insert: 'aaa', attributes: { bold: true }, }, { index: 0, length: 3, }],
[{ insert: 'bbb', attributes: { italic: true }, }, { index: 3, length: 3, }]]
getDeltasByVRange({ index: 3, length: 3 })
returns
[{ insert: 'aaa', attributes: { bold: true }, }, { index: 0, length: 3, }],
[{ insert: 'bbb', attributes: { italic: true }, }, { index: 3, length: 3, }]]
getDeltasByVRange({ 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 ​
• vRange: VRange
Returns ​
DeltaEntry
<TextAttributes
>[]
Source ​
packages/virgo/src/services/delta.ts:189
isNormalizedDeltaSelected() ​
isNormalizedDeltaSelected(
normalizedDeltaIndex
,vRange
):boolean
Parameters ​
• normalizedDeltaIndex: number
• vRange: VRange
Returns ​
boolean
Source ​
packages/virgo/src/services/delta.ts:70
mapDeltasInVRange() ​
mapDeltasInVRange<
Result
>(vRange
,callback
,normalize
):Result
[]
Type parameters ​
• Result
Parameters ​
• vRange: VRange
• callback: (delta
, rangeIndex
, deltaIndex
) => Result
• normalize: boolean
= false
Returns ​
Result
[]
Source ​
packages/virgo/src/services/delta.ts:37
render() ​
render(
syncVRange
):Promise
<void
>
Parameters ​
• syncVRange: boolean
= true
Returns ​
Promise
<void
>
Source ​
packages/virgo/src/services/delta.ts:200
Generated using typedoc-plugin-markdown and TypeDoc