Doc v2 document model reference
Doc v2 is the canonical authoring representation, not an additional copy of page content. The serializer produces HTML and the parser creates/reconciles the tree. Consumers must preserve stable identity and whitespace instead of reducing each element to a flat text string.
Before you start
Section titled “Before you start”- Use the current checked schema and pure model/serialization modules. The following abbreviated TypeScript describes shape; it is not a complete persisted fixture.
-
Understand the wrapper:
type DocumentShape = {v: 2title: stringhtmlAttrs: Record<string, string>head: { id: string; kind: string; html: string }[]assetBase: stringglobalCss: stringroot: ElementNode}Use the actual exported schema/type for allowed head kinds and validation. Head entries remain ordered and retain authored source.
-
An element has id, kind
element, tag, attrs, classes, optional css and children.classandstyledo not belong inside attrs. Text and comment are separate node kinds containing text, so mixed content such asHello <strong>world</strong>!keeps its order and spaces. -
Keep DOM usage outside pure model/serialize code. The parse touchpoint injects DOMParser rather than allowing every transform to read browser globals. Route edits through the document store so selection, source buffers and undo behavior stay coherent.
-
Test parse/serialize round trips with mixed text, comments, head entries and scripts. Asset base affects Design/Preview resolution; public HTML preserves authored paths. v1 input follows the explicit migration path rather than being accepted as a second live document format.
Check the result
Section titled “Check the result”- A change preserves meaning, stable IDs where expected and source fidelity under the repository’s architecture and round-trip tests.
Troubleshooting
Section titled “Troubleshooting”Do not trim text nodes or move all scripts into a new implicit location to simplify rendering. If a new node kind or head capability is needed, update the canonical contract and consumers together.
Related guides
Section titled “Related guides”- Understand architecture and extension contracts
- Bindings, loops and conditions reference
- Import HTML and keep recovery exports
Applies to Strukt c02552848c92 · 2026-10-31