RichTextBlock
One block of a RichText: a heading's level is 1 to 6, a list item's 1 to 9, how deep it sits.
Text formats; not ordered; since Jadpo 0.1.0.
Make one
Pick one of its variants and give its fields, RichTextBlock.paragraph { spans: ... }.
Variants
| Variant | Fields |
|---|---|
paragraph |
spans: List<RichTextSpan> |
heading |
level: Int, spans: List<RichTextSpan> |
quote |
spans: List<RichTextSpan> |
bullet_item |
level: Int, spans: List<RichTextSpan> |
numbered_item |
level: Int, spans: List<RichTextSpan> |
Text, JSON and storage
It has no single text form, so text.from and text.parse don't take it. JSON sends an object of its variant's name, as tag, and the variant's fields.
| JSON |
|---|
{"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":[]}]} |
{"tag":"numbered_item","level":2,"spans":[{"text":"Stir","marks":[]}]} |
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.
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 has the contract's own operations: text.format, json.read, json.write and ==. It isn't ordered, so < and sorting don't take it. Every standard type meets one contract says how they work.
Markdown for agents: /docs/types/type-rich-text-block.md.Built from Jadpo main at e00e61f.