rich_text_input() provides a lazy-loaded, structured rich-text editor powered by ProseMirror. Pages that do not render a rich_text_input never download its editing bundle.
rich_text_input()
rich_text_input
It connects directly to form() (including onFormState dirty tracking, baseline_key, and named actions), preserves focus across lazy load, and lets host apps declare immutable protected block types (such as diagrams, tables, embeds, or site directives) while keeping storage conversion in the host app.
form()
onFormState
baseline_key
actions
<ComponentPreview title="Interactive Rich Text Field">
{
"type": "form_action",
"action": "save_doc",
"submit_label": "Save draft",
"children": [
"type": "rich_text_input",
"name": "doc",
"label": "Page content",
"value": {
"type": "doc",
"content": [
{"type": "heading", "attrs": {"level": 2}, "content": [{"type": "text", "text": "Getting started"}]},
{"type": "paragraph", "content": [{"type": "text", "text": "Edit headings, paragraphs, links, lists, and code blocks with full undo and redo."}]},
{"type": "preserved", "attrs": {"id": "0", "label": "Mermaid diagram", "hint": "View in themed preview"}}
]
}
</ComponentPreview>
When submitted, your handler (or <BlockTree onAction={...} />) receives both the sibling inputs and the parsed structured JSON document in one payload:
<BlockTree onAction={...} />
Inside a React plugin using <BlockTree>:
<BlockTree>
rich_text_input edits a storage-agnostic ProseMirror JSON document ({"type": "doc", "content": [...]}):
{"type": "doc", "content": [...]}
| Category | Node / Mark | Attributes |
|---|---|---|
| Blocks | paragraph, blockquote, horizontal_rule, bullet_list, list_item | — |
paragraph
blockquote
horizontal_rule
bullet_list
list_item
| Headings | heading | level (1–6) |
heading
level
1
6
| Ordered lists | ordered_list | order (default 1) |
ordered_list
order
| Code blocks | code_block | language (default "") |
code_block
language
""
| Protected blocks | preserved + any host-defined preserved_types | id, label, hint, data |
preserved
preserved_types
id
label
hint
data
| Inline | text, hard_break, image | image: src, alt, title |
text
hard_break
image
src
alt
title
| Marks | strong, em, code, link | link: href, title |
strong
em
code
link
href
The generic "preserved" block type is always registered, and you can declare additional custom atom types via preserved_types. When preserve_order=True (the default), any edit, backspace, select-all, or paste transaction that would delete, reorder, or duplicate a protected block is automatically rejected so host-managed content (diagrams, tables, embeds, directives) stays intact.
"preserved"
preserve_order=True
Cmd/Ctrl+B
Cmd/Ctrl+I
Cmd/Ctrl+
(Inline code),
(Undo),
/
(Redo),
(split list item),
http:
https:
mailto:
tel:
javascript:
vbscript:
data:
~78 kB
/chat
| Parameter | Type | Default | Description |
|---|---|---|---|
| label | str | "" | Accessible field label |
str
| name | str \| None | None | Key submitted in enclosing form() payloads and onFormState |
name
str \| None
None
| value | dict \| None | empty doc | Initial structured JSON document ({"type": "doc", "content": [...]}) |
value
dict \| None
| placeholder | str | "" | Optional placeholder hint |
placeholder
| disabled | bool | False | Disable editing and toolbar buttons |
disabled
bool
False
| read_only | bool | False | Render as non-editable rich content |
read_only
| preserved_types | list[dict \| str] \| None | None | Extra host-defined protected atom block specs ({type, label, hint}) |
list[dict \| str] \| None
{type, label, hint}
| preserve_order | bool | True | Prevent deleting, reordering, or duplicating protected blocks |
preserve_order
True
| toolbar | list[str] \| None | all | Optional subset of style, bold, italic, code, bullet_list, ordered_list, blockquote, link, image, undo, redo |
toolbar
list[str] \| None
style
bold
italic
undo
redo
| min_height | int \| None | None | Optional minimum editor surface height in pixels |
min_height
int \| None
| auto_submit | bool | False | Submit enclosing form on document changes |
auto_submit