Rich text / foldkit-richtext
Loading and limits
Use decodeDocument(input, limits?) at a persistence boundary. It rejects excess
fields, duplicate IDs, empty or duplicate marks, invalid structure, unknown nodes,
and unsupported versions — but preserves unknown mark strings verbatim and
round-trips them. findUnknownMarks(document) lists them per text run for a
publishing gate; unknown nodes are still rejected, not preserved. Then enforces limits (default DefaultDocumentLimits: 10,000 blocks,
50,000 text runs, 5,000,000 UTF-16 text units). A violation throws an Error
naming the exceeded bound. Tighten per document with
{ ...DefaultDocumentLimits, maxBlocks: 100 }. The exported Schemas also compose
into an application's Model; when decoding them directly, pass
{ onExcessProperty: 'error' } for the same strict policy.
Because apply skips document-level size limits, validate byte-size and text-length caps on untrusted operation payloads before applying them, and apply byte-size limits before decoding untrusted documents. Retain rejected source content for recovery rather than overwriting it with an empty document. Replicated pairs with foldkit-sync and foldkit-durable in the collaborative pages example.
Transactions validate only newly replaced top-level blocks (re-validating a container whenever anything inside it changes) and cache run indexes, copying only affected arrays while leaving untouched nodes intact.
Next
- Mount an editable browser surface and read-only renderer:
foldkit-richtext-dom - Add styleable toolbars, slash menus, and block handles:
foldkit-mixins-richtext - Convert documents to and from Markdown:
foldkit-richtext-markdown