Delta Format
Delta is a format for representing rich text content. It’s based on Quill Delta and provides a simple, JSON-serializable way to describe text and formatting.
What is a Delta?
A Delta is a list of operations that describe text content and its formatting:Text Operations
There are three types of text operations:TextInsert
Inserts text with optional attributes:TextRetain
Retains characters, optionally applying attributes:TextDelete
Deletes a specified number of characters:Working with Deltas
Creating Deltas
Common Delta Attributes
Delta Operations
Insert Text
Retain Characters
Delete Characters
Composing Deltas
Combine two deltas sequentially:Computing Differences
Find the difference between two deltas:Slicing Deltas
Extract a portion of a delta:Converting to Plain Text
Inverting Deltas
Create an inverse delta (for undo operations):Delta in Nodes
Nodes store delta content in their attributes:Getting Delta from Node
Text Node Types
Different node types use deltas for text content:Paragraph
Heading
Quote
Code Block
Rich Text Attributes
Text Formatting
Colors and Backgrounds
Links
Code Spans
Combining Attributes
Attribute Slicing
When inserting text, you may want to inherit attributes from surrounding text:Custom Slice Behavior
Configure which attributes should be sliced:Working with Unicode
Delta handles Unicode correctly, including emoji and multi-byte characters:Practical Examples
Building Rich Text
Applying Formatting
Removing Formatting
Delta JSON Structure
Deltas serialize to clean JSON arrays:- Store in databases
- Send over network
- Version control
- Debug and inspect
Transaction Integration
Use transactions to modify deltas in nodes:Best Practices
Use Compose
Build complex deltas by composing simple ones for clarity.
Validate Attributes
Check that attributes exist before accessing them.
Handle Unicode
Use
prevRunePosition and nextRunePosition for correct character positions.JSON Serialization
Deltas are JSON-serializable for easy storage and transmission.
See Also
- Document Structure - Learn about the node hierarchy
- Transactions - Modify deltas safely with transactions
- Custom Blocks - Create custom node types with deltas