YText.YText(stringopt)

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).

new YText(stringopt)

Parameters:
Name Type Attributes Description
string String <optional>

The initial value of the YText.

Extends

Methods

applyDelta(delta)

Apply a Delta on this shared YText type.

Parameters:
Name Type Description
delta any

The changes to apply on this element.

delete(index, length)

Deletes text starting from an index.

Parameters:
Name Type Description
index number

Index at which to start deleting.

length number

The number of characters to remove. Defaults to 1.

format(index, length, attributes)

Assigns properties to a range of text.

Parameters:
Name Type Description
index number

The position where to start formatting.

length number

The amount of characters to assign properties to.

attributes TextAttributes

Attribute information to apply on the text.

insert(index, text, attributes)

Insert text at a given index.

Parameters:
Name Type Description
index number

The index at which to start inserting.

text String

The text to insert at the specified position.

attributes TextAttributes

Optionally define some formatting information to apply on the inserted Text.

insertEmbed(index, embed, attributes)

Inserts an embed at a index.

Parameters:
Name Type Description
index number

The index to insert the embed at.

embed Object

The Object that represents the embed.

attributes TextAttributes

Attribute information to apply on the embed

toDelta(snapshotopt, prevSnapshotopt) → {any}

Returns the Delta representation of this YText type.

Parameters:
Name Type Attributes Description
snapshot Snapshot <optional>
prevSnapshot Snapshot <optional>
Returns:
any -

The Delta representation of this type.

toString()

Returns the unformatted string representation of this YText type.