Delta Format
Last updated
Was this helpful?
Last updated
Was this helpful?
The was originally described by the Quill rich text editor. We adapted the approach to describe changes on sequence-like data (e.g. Y.Text, Y.Array, Y.XmlFragment).
A Delta is a format to describe changes on a sequence-like data structure like Y.Array, Y.XmlFragment, or Y.Text. But it can also be used to describe the current state of a sequence-like data structure, as you can see in the following example:
In many cases, you can even use the delta format to apply changes on a document. In Y.Text the delta format is very handy to express complex operations:
Expresses the intention to delete the first 3 characters.
Expresses the intention to retain one item, and then delete three. E.g.
The insert
delta is always a string in Y.Text. Furthermore, Y.Text also allows assigning formatting attributes to the inserted text.
Expresses the intention to insert "abc"
at index-position 1 and make the insertion bold. Then we skip another character and insert "xyz"
without formatting attributes. E.g.
In Y.Text the retain
delta may also contain formatting attributes that are applied on the retained text.
Expresses the intention to format the first five characters italic.
The insert
delta is always an Array of inserted content in Y.Array & Y.XmlFragment.
The delta format is very powerful to express changes that are performed in a Transaction. As explained in the , events are fired after transactions. With the delta format we can express multiple changes in a single event. E.g.