LanguageValues and typesStandard typesText formats
RichTextBlock
On this page
One block of a RichText: a paragraph, a heading, a quote or a list item.
Use it when you build a RichText in code. To hold a document, use RichText.
Shape
One of these, each with its own fields:
| Variant | Field | Type | Required? |
|---|---|---|---|
RichTextBlock.paragraph |
spans |
List<RichTextSpan> |
Yes |
RichTextBlock.heading |
level |
Int |
Yes |
spans |
List<RichTextSpan> |
Yes | |
RichTextBlock.quote |
spans |
List<RichTextSpan> |
Yes |
RichTextBlock.bullet_item |
level |
Int |
Yes |
spans |
List<RichTextSpan> |
Yes | |
RichTextBlock.numbered_item |
level |
Int |
Yes |
spans |
List<RichTextSpan> |
Yes |
Example
RichTextBlock.heading { level: 2 spans: [ RichTextSpan { text: "Soups" marks: [] link: none } ]}
Good to know
- A heading's level runs from 1 to 6, and a list item's from 1 to 9.
==tells you whether two are the same.<andlist.sort_bydon't take it.
In JSON
An object of its variant's name, as tag, and the variant's fields, in a request, a response or json.write:
{"tag":"paragraph","spans":[{"text":"Fresh ","marks":[]},{"text":"soup","marks":["emphasis"]}]}{"tag":"heading","level":1,"spans":[{"text":"Soups","marks":[]}]}{"tag":"quote","spans":[{"text":"Fresh every day","marks":[]}]}
Details
Text form, storage, how it is shown, and operations
RichTextBlock is in the group Text formats, and has been in Jadpo since 0.1.0.
Text form
It has no single text form, so text.from and text.parse don't take it.
How it is stored
It is stored in one column named for the field, of type jsonb. {"tag":"quote","spans":[{"text":"Fresh every day","marks":[]}]} is stored as '{"tag":"quote","spans":[{"text":"Fresh every day","marks":[]}]}'::jsonb.
How it is shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
{"tag":"paragraph","spans":[{"text":"Fresh ","marks":[]},{"text":"soup","marks":["emphasis"]}]} |
Fresh soup |
{"tag":"heading","level":1,"spans":[{"text":"Soups","marks":[]}]} |
Soups |
{"tag":"quote","spans":[{"text":"Fresh every day","marks":[]}]} |
Fresh every day |
{"tag":"numbered_item","level":2,"spans":[{"text":"Stir","marks":[]}]} |
Stir |
Operations
It also takes text.format, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-rich-text-block.md.Built from Jadpo main at aee2e8f.