Rich text / API

foldkit-richtext-dom

The DOM interpreter for an editable subtree: it renders a semantic Document into an owned subtree, maps positions both ways, and patches only the nodes a ChangeSet names. No Foldkit VDOM reaches inside this subtree, and the semantic document stays authoritative — the DOM is never read as truth beyond mapping a browser selection back to a semantic position.

Functions

adoptTakes over a subtree already in the page when it is exactly what mount would build, such as server markup the browser parsed (§145): the elements stay, and…
mountBuilds the owned subtree and the identity index it is patched through. Decorations are drawn over it and never become content (§64); like the read-only…
patch
positionToRangeThe DOM range for a semantic position, or undefined if it no longer resolves. An offset where two decorated pieces meet lands at the end of the first.
rangeToPositionMaps a browser selection endpoint back to a semantic position: a caret in a run's text, or on an element inside the owned subtree (read as the text boundary…
repairRecovery, not domain state (§31): makes the subtree match the document again after something outside the semantic pipeline touched it — a cancelled IME…
toTextPlain text of the subtree, one line per text block: for assertions and fallback copy.

Interfaces