BlockSuite API Documentation / @blocksuite/store / Y / Text
Class: Text 
Type that represents text with formatting information.
This type replaces y-richtext as this implementation is able to handle block formats (format information on a paragraph), embeds (complex elements like pictures and videos), and text formats (bold, italic).
Extends 
Constructors 
new Text(string) 
new Text(
string?):Text
Parameters 
• string?: string
The initial value of the YText.
Returns 
Overrides 
@blocksuite/store.Y.AbstractType.constructor
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:97
Properties 
_dEH 
_dEH:
EventHandler<YEvent<any>[],Transaction>
Deep event handlers
Inherited from 
@blocksuite/store.Y.AbstractType._dEH
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:46
_eH 
_eH:
EventHandler<YTextEvent,Transaction>
Event handlers
Inherited from 
@blocksuite/store.Y.AbstractType._eH
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:41
_hasFormatting 
_hasFormatting:
boolean
Whether this YText contains formatting attributes. This flag is updated when a formatting item is integrated (see ContentFormat.integrate)
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:107
_item 
_item:
null|Item
Inherited from 
@blocksuite/store.Y.AbstractType._item
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:23
_length 
_length:
number
Inherited from 
@blocksuite/store.Y.AbstractType._length
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:36
_map 
_map:
Map<string,Item>
Inherited from 
@blocksuite/store.Y.AbstractType._map
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:27
_pending 
_pending:
null| () =>void[]
Array of pending operations on this type
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:102
_searchMarker 
_searchMarker:
null|ArraySearchMarker[]
Inherited from 
@blocksuite/store.Y.AbstractType._searchMarker
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:50
_start 
_start:
null|Item
Inherited from 
@blocksuite/store.Y.AbstractType._start
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:31
doc 
doc:
null|Doc
Inherited from 
@blocksuite/store.Y.AbstractType.doc
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:35
Accessors 
_first 
get_first():null|Item
The first non-deleted item
Returns 
null | Item
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:81
length 
getlength():number
Number of characters of this text type.
Returns 
number
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:113
parent 
getparent():null|AbstractType<any>
Returns 
null | AbstractType<any>
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:54
Methods 
_callObserver() 
_callObserver(
transaction,_parentSubs):void
Creates YEvent and calls all type observers. Must be implemented by each type.
Parameters 
• transaction: Transaction
• _parentSubs: Set<null | string>
Keys changed on this type. null if list was modified.
Returns 
void
Inherited from 
@blocksuite/store.Y.AbstractType._callObserver
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:89
_copy() 
_copy():
Text
Returns 
Overrides 
@blocksuite/store.Y.AbstractType._copy
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:119
_integrate() 
_integrate(
y,item):void
Integrate this type into the Yjs instance.
- Save this struct in the os
 - This type is sent to other client
 - Observer functions are fired
 
Parameters 
• y: Doc
The Yjs instance
• item: Item
Returns 
void
Overrides 
@blocksuite/store.Y.AbstractType._integrate
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:118
_write() 
_write(
_encoder):void
Parameters 
• _encoder: UpdateEncoderV1 | UpdateEncoderV2
Returns 
void
Inherited from 
@blocksuite/store.Y.AbstractType._write
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:77
applyDelta() 
applyDelta(
delta,opts?):void
Apply a Delta on this shared YText type.
Parameters 
• delta: any
The changes to apply on this element.
• opts?: Object
• opts.sanitize?: boolean
Sanitize input delta. Removes ending newlines if set to true.
Returns 
void
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:141
clone() 
clone():
Text
Returns 
Overrides 
@blocksuite/store.Y.AbstractType.clone
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:123
delete() 
delete(
index,length):void
Deletes text starting from an index.
Parameters 
• index: number
Index at which to start deleting.
• length: number
The number of characters to remove. Defaults to 1.
Returns 
void
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:185
format() 
format(
index,length,attributes):void
Assigns properties to a range of text.
Parameters 
• index: number
The position where to start formatting.
• length: number
The amount of characters to assign properties to.
• attributes: Object
Attribute information to apply on the text.
Returns 
void
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:196
getAttribute() 
getAttribute(
attributeName):any
Returns an attribute value that belongs to the attribute name.
Parameters 
• attributeName: string
The attribute name that identifies the queried value.
Returns 
any
The queried attribute value.
Note 
Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:229
getAttributes() 
getAttributes():
Object
Returns all attribute name/value pairs in a JSON Object.
Returns 
Object
A JSON Object that describes the attributes.
Note 
Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:239
insert() 
insert(
index,text,attributes?):void
Insert text at a given index.
Parameters 
• index: number
The index at which to start inserting.
• text: string
The text to insert at the specified position.
• attributes?: Object
Optionally define some formatting information to apply on the inserted Text.
Returns 
void
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:165
insertEmbed() 
insertEmbed(
index,embed,attributes?):void
Inserts an embed at a index.
Parameters 
• index: number
The index to insert the embed at.
• embed: Object | AbstractType<any>
The Object that represents the embed.
• attributes?: Object
Attribute information to apply on the embed
Returns 
void
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:176
observe() 
observe(
f):void
Observe all events that are created on this type.
Parameters 
• f: (arg0, arg1) => void
Observer function
Returns 
void
Inherited from 
@blocksuite/store.Y.AbstractType.observe
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:95
observeDeep() 
observeDeep(
f):void
Observe all events that are created by this type and its children.
Parameters 
• f: (arg0, arg1) => void
Observer function
Returns 
void
Inherited from 
@blocksuite/store.Y.AbstractType.observeDeep
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:101
removeAttribute() 
removeAttribute(
attributeName):void
Removes an attribute.
Parameters 
• attributeName: string
The attribute name that is to be removed.
Returns 
void
Note 
Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:206
setAttribute() 
setAttribute(
attributeName,attributeValue):void
Sets or updates an attribute.
Parameters 
• attributeName: string
The attribute name that is to be set.
• attributeValue: any
The attribute value that is to be set.
Returns 
void
Note 
Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:217
toDelta() 
toDelta(
snapshot?,prevSnapshot?,computeYChange?):any
Returns the Delta representation of this YText type.
Parameters 
• snapshot?: Snapshot
• prevSnapshot?: Snapshot
• computeYChange?: (arg0, arg1) => any
Returns 
any
The Delta representation of this type.
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:154
toJSON() 
toJSON():
string
Returns the unformatted string representation of this YText type.
Returns 
string
Overrides 
@blocksuite/store.Y.AbstractType.toJSON
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/YText.d.ts:130
unobserve() 
unobserve(
f):void
Unregister an observer function.
Parameters 
• f: (arg0, arg1) => void
Observer function
Returns 
void
Inherited from 
@blocksuite/store.Y.AbstractType.unobserve
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:107
unobserveDeep() 
unobserveDeep(
f):void
Unregister an observer function.
Parameters 
• f: (arg0, arg1) => void
Observer function
Returns 
void
Inherited from 
@blocksuite/store.Y.AbstractType.unobserveDeep
Source 
node_modules/.pnpm/yjs@13.6.11/node_modules/yjs/dist/src/types/AbstractType.d.ts:113
Generated using TypeDoc and typedoc-plugin-markdown.