Skip to content

Local search · English

    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.

    • Use the current checked schema and pure model/serialization modules. The following abbreviated TypeScript describes shape; it is not a complete persisted fixture.
    1. Understand the wrapper:

      type DocumentShape = {
      v: 2
      title: string
      htmlAttrs: Record<string, string>
      head: { id: string; kind: string; html: string }[]
      assetBase: string
      globalCss: string
      root: ElementNode
      }

      Use the actual exported schema/type for allowed head kinds and validation. Head entries remain ordered and retain authored source.

    2. An element has id, kind element, tag, attrs, classes, optional css and children. class and style do not belong inside attrs. Text and comment are separate node kinds containing text, so mixed content such as Hello <strong>world</strong>! keeps its order and spaces.

    3. 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.

    4. 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.

    • A change preserves meaning, stable IDs where expected and source fidelity under the repository’s architecture and round-trip tests.

    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.

    Applies to Strukt c02552848c92 · 2026-10-31