Skip to content

BlockSuite API Documentation / @blocksuite/store / Text

Class: Text

Constructors

new Text()

new Text(input?, onChange?): Text

Parameters

input?

string | YText | DeltaInsert[]

onChange?

OnTextChange

Returns

Text

Defined in

packages/framework/store/src/reactive/text.ts:41

Accessors

deltas$

Get Signature

get deltas$(): Signal<DeltaOperation[]>

Returns

Signal<DeltaOperation[]>

Defined in

packages/framework/store/src/reactive/text.ts:29


length

Get Signature

get length(): number

Returns

number

Defined in

packages/framework/store/src/reactive/text.ts:33


yText

Get Signature

get yText(): YText

Returns

YText

Defined in

packages/framework/store/src/reactive/text.ts:37

Methods

applyDelta()

applyDelta(delta): void

Parameters

delta

DeltaOperation[]

Returns

void

Defined in

packages/framework/store/src/reactive/text.ts:92


bind()

bind(onChange?): void

Parameters

onChange?

OnTextChange

Returns

void

Defined in

packages/framework/store/src/reactive/text.ts:98


clear()

clear(): void

Returns

void

Defined in

packages/framework/store/src/reactive/text.ts:102


clone()

clone(): Text

Returns

Text

Defined in

packages/framework/store/src/reactive/text.ts:111


delete()

delete(index, length): void

Parameters

index

number

length

number

Returns

void

Defined in

packages/framework/store/src/reactive/text.ts:115


format()

format(index, length, format): void

Parameters

index

number

length

number

format

any

Returns

void

Defined in

packages/framework/store/src/reactive/text.ts:136


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:156


join()

join(other): void

Parameters

other

Text

Returns

void

Defined in

packages/framework/store/src/reactive/text.ts:176


replace()

replace(index, length, content, attributes?): void

Parameters

index

number

length

number

content

string

attributes?
bold

null | true

code

null | true

italic

null | true

null | string

strike

null | true

underline

null | true

Returns

void

Defined in

packages/framework/store/src/reactive/text.ts:188


sliceToDelta()

sliceToDelta(begin, end?): DeltaOperation[]

Parameters

begin

number

end?

number

Returns

DeltaOperation[]

Defined in

packages/framework/store/src/reactive/text.ts:212


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', ...}]

  1. abc|de|fghi left: [{insert: 'abc', ...}] right: [{insert: 'f', ...}, {insert: 'ghi', ...}]
  2. abc|def|ghi left: [{insert: 'abc', ...}] right: [{insert: 'ghi', ...}]
  3. abc|defg|hi left: [{insert: 'abc', ...}] right: [{insert: 'hi', ...}]

Parameters

index

number

length

number = 0

Returns

Text

Defined in

packages/framework/store/src/reactive/text.ts:281


toDelta()

toDelta(): DeltaOperation[]

Returns

DeltaOperation[]

Defined in

packages/framework/store/src/reactive/text.ts:331


toString()

toString(): string

Returns

string

Defined in

packages/framework/store/src/reactive/text.ts:335