API > @blocksuite/store > Text
Class: Text ​
Constructors ​
constructor ​
new Text(
input
?):Text
Parameters ​
Parameter | Type |
---|---|
input ? | string | Text |
Returns ​
Defined In ​
packages/store/src/yjs/text-adapter.ts:19
Properties ​
_yText ​
private
readonly
_yText:Text
Defined In ​
packages/store/src/yjs/text-adapter.ts:17
Accessors ​
length ​
get
length():number
Defined In ​
packages/store/src/yjs/text-adapter.ts:35
yText ​
get
yText():Text
Defined In ​
packages/store/src/yjs/text-adapter.ts:39
Methods ​
_transact ​
private
_transact(callback
):void
Parameters ​
Parameter | Type |
---|---|
callback | function |
Returns ​
void
Defined In ​
packages/store/src/yjs/text-adapter.ts:43
applyDelta ​
applyDelta(
delta
):void
Parameters ​
Parameter | Type |
---|---|
delta | DeltaOperation [] |
Returns ​
void
Defined In ​
packages/store/src/yjs/text-adapter.ts:241
clear ​
clear():
void
Returns ​
void
Defined In ​
packages/store/src/yjs/text-adapter.ts:232
clone ​
clone():
Text
Returns ​
Defined In ​
packages/store/src/yjs/text-adapter.ts:55
delete ​
delete(
index
,length
):void
Parameters ​
Parameter | Type |
---|---|
index | number |
length | number |
Returns ​
void
Defined In ​
packages/store/src/yjs/text-adapter.ts:190
format ​
format(
index
,length
,format
):void
Parameters ​
Parameter | Type |
---|---|
index | number |
length | number |
format | any |
Returns ​
void
Defined In ​
packages/store/src/yjs/text-adapter.ts:171
insert ​
insert(
content
,index
,attributes
?):void
Parameters ​
Parameter | Type |
---|---|
content | string |
index | number |
attributes ? | Record < string , unknown > |
Returns ​
void
Defined In ​
packages/store/src/yjs/text-adapter.ts:121
insertList ​
insertList(
insertTexts
,index
):void
Parameters ​
Parameter | Type |
---|---|
insertTexts | DeltaOperation [] |
index | number |
Returns ​
void
Deprecated ​
Use insert or applyDelta instead.
Defined In ​
packages/store/src/yjs/text-adapter.ts:143
join ​
join(
other
):void
Parameters ​
Parameter | Type |
---|---|
other | Text |
Returns ​
void
Defined In ​
packages/store/src/yjs/text-adapter.ts:159
replace ​
replace(
index
,length
,content
,attributes
?):void
Parameters ​
Parameter | Type |
---|---|
index | number |
length | number |
content | string |
attributes ? | object |
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/store/src/yjs/text-adapter.ts:209
sliceToDelta ​
sliceToDelta(
begin
,end
?):DeltaOperation
[]
Parameters ​
Parameter | Type |
---|---|
begin | number |
end ? | number |
Returns ​
Defined In ​
packages/store/src/yjs/text-adapter.ts:251
split ​
split(
index
,length
=0
):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 ​
Parameter | Type | Default value |
---|---|---|
index | number | undefined |
length | number | 0 |
Returns ​
Defined In ​
packages/store/src/yjs/text-adapter.ts:74
toDelta ​
toDelta():
DeltaOperation
[]
Returns ​
Defined In ​
packages/store/src/yjs/text-adapter.ts:247
toString ​
toString():
string
Returns ​
string
Defined In ​
packages/store/src/yjs/text-adapter.ts:301
fromDelta ​
static
fromDelta(delta
):Text
Parameters ​
Parameter | Type |
---|---|
delta | DeltaOperation [] |
Returns ​
Defined In ​
packages/store/src/yjs/text-adapter.ts:29