Rich text / foldkit-richtext-dom

Render a read-only document

foldkit-richtext-dom/view renders a Document or slice blocks as static Foldkit Html via inertHtml, without mounting any editable runtime:

ts
import * as RichText from 'foldkit-richtext'
import { renderBlocks, renderDocument } from 'foldkit-richtext-dom/view'

const doc = RichText.decodeDocument({
  version: 1,
  children: [{ type: 'Paragraph', id: 'p', children: [{ type: 'Text', id: 't', text: 'Read only', marks: [] }] }],
})

const html = renderDocument(doc)
renderBlocks(doc.children)
renderDocument(doc, RichText.standardRendering)
renderDocument(doc, RichText.standardRendering, [])

Pass the same Rendering registry used by the editor and HTML serializer so custom marks and blocks render identically. Decorations map via RichText.decorationsIn to <span data-decoration="...">, with safe lowercase string fields in decoration.data emitted as data-decoration-<key> attributes.