BlockSuite API Documentation / @blocksuite/store / Text
Class: Text
Constructors
new Text()
new Text(
input
?,onChange
?):Text
Parameters
• input?: string
| YText
| DeltaInsert
[]
• onChange?: OnTextChange
Returns
Defined in
packages/framework/store/src/reactive/text.ts:40
Accessors
deltas$
get
deltas$():Signal
<DeltaOperation
[]>
Returns
Signal
<DeltaOperation
[]>
Defined in
packages/framework/store/src/reactive/text.ts:28
length
get
length():number
Returns
number
Defined in
packages/framework/store/src/reactive/text.ts:32
yText
get
yText():YText
Returns
YText
Defined in
packages/framework/store/src/reactive/text.ts:36
Methods
applyDelta()
applyDelta(
delta
):void
Parameters
• delta: DeltaOperation
[]
Returns
void
Defined in
packages/framework/store/src/reactive/text.ts:99
bind()
bind(
onChange
?):void
Parameters
• onChange?: OnTextChange
Returns
void
Defined in
packages/framework/store/src/reactive/text.ts:105
clear()
clear():
void
Returns
void
Defined in
packages/framework/store/src/reactive/text.ts:109
clone()
clone():
Text
Returns
Defined in
packages/framework/store/src/reactive/text.ts:118
delete()
delete(
index
,length
):void
Parameters
• index: number
• length: number
Returns
void
Defined in
packages/framework/store/src/reactive/text.ts:122
format()
format(
index
,length
,format
):void
Parameters
• index: number
• length: number
• format: any
Returns
void
Defined in
packages/framework/store/src/reactive/text.ts:143
insert()
insert(
content
,index
,attributes
?):void
Parameters
• content: string
• index: number
• attributes?: Record
<string
, unknown
>
Returns
void
Defined in
packages/framework/store/src/reactive/text.ts:163
join()
join(
other
):void
Parameters
• other: Text
Returns
void
Defined in
packages/framework/store/src/reactive/text.ts:183
replace()
replace(
index
,length
,content
,attributes
?):void
Parameters
• index: number
• length: number
• content: string
• attributes?
• attributes.bold?: null
| true
• attributes.code?: null
| true
• attributes.italic?: null
| true
• attributes.link?: null
| string
• attributes.strike?: null
| true
• attributes.underline?: null
| true
Returns
void
Defined in
packages/framework/store/src/reactive/text.ts:195
sliceToDelta()
sliceToDelta(
begin
,end
?):DeltaOperation
[]
Parameters
• begin: number
• end?: number
Returns
Defined in
packages/framework/store/src/reactive/text.ts:219
split()
split(
index
,length
):Text
NOTE: The string included in [index, index + length) will be deleted.
Here are three cases for point position(index + length): [{insert: 'abc', ...}, {insert: 'def', ...}, {insert: 'ghi', ...}]
- abc|de|fghi left: [{insert: 'abc', ...}] right: [{insert: 'f', ...}, {insert: 'ghi', ...}]
- abc|def|ghi left: [{insert: 'abc', ...}] right: [{insert: 'ghi', ...}]
- abc|defg|hi left: [{insert: 'abc', ...}] right: [{insert: 'hi', ...}]
Parameters
• index: number
• length: number
= 0
Returns
Defined in
packages/framework/store/src/reactive/text.ts:288
toDelta()
toDelta():
DeltaOperation
[]
Returns
Defined in
packages/framework/store/src/reactive/text.ts:338
toString()
toString():
string
Returns
string
Defined in
packages/framework/store/src/reactive/text.ts:342
fromDelta()
static
fromDelta(delta
,onChange
?):Text
Parameters
• delta: DeltaOperation
[]
• onChange?: OnTextChange
Returns
Deprecated
This method will lose the change observer unless you pass the onChange callback.
Defined in
packages/framework/store/src/reactive/text.ts:80