@perkyzz/emvb-mcp 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +440 -54
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -6498,7 +6498,7 @@ function duration2(params) {
|
|
|
6498
6498
|
return _isoDuration(ZodISODuration, params);
|
|
6499
6499
|
}
|
|
6500
6500
|
// ../../docs/system/layout-format.md
|
|
6501
|
-
var layout_format_default = "# Layout format (schema 18)\n\nHow EmVB stores a page and its site-wide design, at layout schema 18 and design schema 17, schema contract 1.0 (W-925, D-065: renames, motion under `motion`, unknown keys kept; see [docs/SCHEMA.md](../SCHEMA.md)); Loop forever on an icon animation in W-853, D-059; the image editor's `edit` record on images in W-481; per-element direction, image link and caption, button icons, table of contents, container queries, and focal points in W-341 onward; visitor segments in W-329; Loop fields in W-330; `ch` lengths and negative margins in W-331). The source of truth is the code: `packages/emvb/src/core/schema/` (Zod schemas), `core/limits.ts`, `core/validate.ts` and `core/migrate/`. Update this file in the same change as any of them (ARCHITECTURE.md § Documentation).\n\n## Where it lives\n\n- **Pages** are entries in the hidden `emvb_pages` collection (D-012, D-019). The layout is the `layout` field (EmDash type `json`, shown with the read-only `emvb:layout` widget). The other fields are `title`, `canvas_mode` (`site-layout` or `blank`) and EmDash's own slug, status, revision and SEO fields. EmDash may hand a `json` field back as a string, so readers accept both (`renderStored` in `src/astro/render.ts`).\n- **The design system** (colours, fonts, font sizes, spacings; classes in W-030) is one document in plugin storage, collection `design`, key `system` (D-013). Editors save a draft at key `draft` through `POST /_emdash/api/plugins/emvb/design/save` (W-100, D-040 proposed). `POST .../design/publish` copies that draft onto `system`. The public `GET /_emdash/api/plugins/emvb/design` returns `system` only.\n\n## Page layout\n\n```json\n{\n \"schemaVersion\": 18,\n \"root\": {\n \"id\": \"root0001\",\n \"type\": \"container\",\n \"props\": {},\n \"style\": { \"flexDirection\": \"column\", \"gap\": { \"value\": 16, \"unit\": \"px\" } },\n \"children\": [\n {\n \"id\": \"head0001\",\n \"type\": \"heading\",\n \"props\": { \"text\": \"Welcome\", \"level\": 1 },\n \"style\": { \"color\": { \"var\": \"brand\" } }\n }\n ]\n }\n}\n```\n\n- `schemaVersion` is the literal `18` (D-031, D-032, D-034, D-036, D-038, D-039, D-041, D-042, D-044, W-141, D-045, W-160, W-307, W-329, W-341, W-481, W-885, W-925; older documents are upgraded on read by steps that change nothing, except v11 → v12, which rewrites a gradient's `from` and `to` into `stops`, and v17 → v18 (W-925), which renames `section` to `part-ref`, a node's `label` to `editorLabel` and a Loop's `itemPartId` to `partId`, and moves `transition`, `entrance`, `scrollMotion` and `iconAnimation` under `style.motion`). `root` is always a container.\n- Every node has `id` (4–24 of `A-Z a-z 0-9 _ -`, unique within the page), `type`, `props`, and optional `style`, `states` (W-089, see [State styles](#state-styles-w-089)), `classes` (up to 20 ids of 1–40 of `a-z 0-9 -`, rendered as `emvb-k-<id>`), `bind` (W-307), `variant` (an A/B arm, W-312) and `audience` (who sees it, W-313, W-329).\n- Objects are strict: unknown keys are rejected, not ignored.\n- **Unknown element types** (W-022 / R-033): a node whose `type` is not in the known set is kept on save (`id` rules still apply; `props` is an open record; every shared node field, including `devices` and `hiddenOn`, is allowed and checked as on known nodes; optional `children` are validated recursively). Public pages omit it; the editor shows a selectable placeholder. Damaged known nodes (wrong props) still fail validation with path-specific issues.\n\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `container` | optional `tag` (`div`, `section`, `header`, `footer`, `main`, `article`, `aside`, `nav`), optional `href` and `newTab` (the box is the link; a link inside a link is dropped) | `children: Node[]` (required, may be empty) | that tag (default `div`) with `class=\"emvb-container …\"` |\n| `layout-section` (shown as \"Section\", W-156) | optional `tag` (as `container`, default `section`), `contentWidth` length, `fullWidth` boolean | `children: Node[]` | that tag with `class=\"emvb-layout-section …\"`, wrapping `<div class=\"emvb-layout-section-inner\">` around the children; the inner box is at most `contentWidth` (default 1140 px, none with `fullWidth`) wide and centred |\n| `heading` | `text` (≤ 2000), `level` (1–6), optional `href` (≤ 2000) and `newTab` (W-141), optional `marks` (W-950, see below) | none | `<h1>`–`<h6>`; with a safe `href`, the text is wrapped in `<a class=\"emvb-heading-link\">` (colour and decoration inherited) |\n| `spacer` | `height` length | none | `<div aria-hidden=\"true\">` with height in CSS |\n| `divider` | `{}` | none | `<hr>` |\n| `text` | `text`, optional `tag` (`p` \\| `div`), optional `marks` (W-950) | none | `<p>` or `<div>`; formatted words as below |\n| `label` | `text` | none | `<span>` |\n| `link` | `text`, `href`, optional `newTab` | none | `<a href>` (+ `target`/`rel` when `newTab`) |\n| `button` | `text`, optional `href` and `newTab` | none | `<a href>` when `href` is safe, else `<button type=\"button\">` |\n| `list` | `items` (string[], ≤ 200), optional `ordered`; W-952: optional `marker` (`disc`, `circle`, `square`, `decimal`, `decimal-leading-zero`, `lower-alpha`, `upper-alpha`, `lower-roman`, `upper-roman`, `steps`, `none`; a number style or `steps` makes it numbered) and `start` (1–9999, numbered only) | none | `<ul>` or `<ol>` (with `start`) with `<li>`; the marker is `list-style-type`, `steps` adds `emvb-list--steps` (numbers in circles, CSS sent only when used) |\n| `image` | `src`, `alt`, optional `decorative`, `width`, `height`, `mediaId`, `edit` (editor-only image-editor record, never rendered; see below) | none | `<img loading=\"lazy\">` (decorative → empty `alt` + `role=\"presentation\"`) |\n| `icon` | `iconId` (a bundled Lucide id, or `<set prefix>:<name>` from the icon library, W-236), optional `iconSvg` (the picked icon's SVG, ≤ 32768 chars, W-234 / W-239; `iconId` `upload:<id>` for an uploaded SVG), optional `singleColor` (W-238: `true` paints a picked SVG's own fills, strokes and stops in `currentColor`), `size`, `decorative`, `title`, `href` (≤ 2000) and `newTab` (W-141); a non-empty `href` needs a `title` | none | Inline `<svg>`: `iconSvg` sanitized again at render (allowlist; size, id, role and aria attributes replaced), else the bundled Lucide icon (unknown id and no `iconSvg` → placeholder; never a remote URL); with a safe `href`, the svg is hidden inside `<a class=\"emvb-icon-link\" aria-label=\"title\">` |\n| `video` | `url`, `title`, optional `mediaId` | none | YouTube/Vimeo privacy `<iframe loading=\"lazy\">` or media `<video controls>` (no autoplay) |\n| `form` | `formId` (forms-plugin id; may be empty until bound), optional `nextLabel` and `prevLabel` (≤ 80, W-1065: the step buttons, unset \"Next\" and \"Previous\") | `children: Node[]` (form fields + submit; no nested forms) | Bound: `<form class=\"emvb-form ec-form\" …>`. Unbound: editor placeholder `data-emvb-form-unbound`; omitted on public (no forms runtime). |\n| `form-step` (W-1065) | optional `title` (≤ 200) | `children: Node[]`; only directly inside a `form` | `<fieldset class=\"emvb-form-step ec-form-page\" data-page=\"<n>\" tabindex=\"-1\">` with `<legend>` (untitled: `aria-label=\"Step <n+1>\"`): the forms plugin's multi-page markup. The form adds `<p data-ec-progress aria-live=\"polite\">` before the first step and `<div class=\"emvb-form-step-nav\">` with hidden `data-ec-prev` / `data-ec-next` buttons after the last. The forms script shows one step at a time and checks a step before Next; without it every step shows. Content outside the steps (an intro, Submit) stays outside the pages |\n| `text-input` | `field`, optional `label`, `placeholder`; W-1065: optional `inputType` (`number`, `date`), `min`, `max` (±10¹²), `step` (> 0), `minDate`, `maxDate` (YYYY-MM-DD, a real day) | none | labelled `<input class=\"ec-form-input\">` + `data-error-for`. Type: the bound field's own (`email`, `tel`, `url`, `number`, `date`), else `inputType` when the field is plain text. A number gets `min`/`max` (the field's own limits win) and `step` (unset `any`); a date gets `min`/`max` from `minDate`/`maxDate`. A range with nothing in it is left off |\n| `textarea` | `field`, optional `label`, `placeholder` | none | labelled `<textarea class=\"ec-form-input\">` + `data-error-for` |\n| `select` | `field`, optional `label`, `placeholder` (words the empty first choice; unset is \"Choose…\", W-686) | none | labelled `<select>` (options from the public form definition when available) |\n| `checkbox` | `field`, optional `label` | none | labelled `<input type=\"checkbox\" value=\"true\">` |\n| `radio` | `field`, optional `label`, `placeholder` | none | `<fieldset>` of radios (options from definition when available) |\n| `submit` | optional `label` | none | `<button type=\"submit\" class=\"ec-form-submit\">` |\n| `post-title` | optional `level` (1–6) | none | Dynamic heading from `ThemeDynamicData.post` |\n| `post-excerpt` | optional `maxWords` (whole number, 1–10000, W-177) | none | Dynamic excerpt paragraph; with `maxWords`, cut to that many words with \"…\" |\n| `post-content` | (none) | none | Dynamic body (Portable Text → safe blocks) |\n| `post-image` | optional `decorative` | none | Dynamic featured image when URL present |\n| `post-link` | optional `text`, `newTab` | none | Dynamic permalink; blank text → title |\n| `post-date` | optional `format`: `medium` (default), `short`, `long`, `full` or `numeric` (W-177) | none | `<time datetime>` with the published date in UTC; `numeric` is YYYY-MM-DD |\n| `post-author` | (none) | none | The author's name |\n| `pagination` | optional `prevText`, `nextText`, `showCount` and `countText` (`{page}` and `{total}`; unset text is \"Page {page} of {total}\"), `titleText` (the paged archive title, `{title}` and `{page}`, W-529), `archiveTitle` (replaces \"Posts\" as the posts archive title, ≤ 60, W-532), and screen reader names `navLabel` (\"Pagination\"), `pageLabel` (\"Page {page}\"), `prevLabel` and `nextLabel` (\"Previous page\" / \"Next page\", used when the text is only an arrow), each ≤ 60 (W-689) | none | `nav` of Previous, page numbers and Next. Nothing on a single page, with no archive data, or inside a Loop item |\n| `loop` | optional `partId` (the item part; `itemPartId` before schema 18); `perPage` (1–50, unset = 20) on an archive; a collection Loop also takes `collection`, `limit`, `order`, `display`, `columns`, `permalink`, `imageField`, `excerptField` and `filter` (see [Schema 13](#schema-13-the-w-307-feature-batch) and [Schema 14](#schema-14)) | `children: Node[]` (inline item template when no part id) | Repeats the item template for each post or collection entry |\n| `grid` | `columns` (1–12); optional `columnsTablet` and `columnsMobile` (1–12, W-139); optional `columnTracks`, `columnTracksTablet`, `columnTracksMobile` (1–12 tracks: `1fr`, `2fr`, `3fr`, `auto`, `min-content`, `max-content`, or a length) | `children: Node[]` | `display: grid` with that many equal columns, or the custom tracks when that device sets them; the device values go in the tablet and mobile media queries, and an unset one follows the next wider device |\n| `part-ref` (shown as \"Theme section\"; `section` before schema 18) | optional `partId` | `children: Node[]` (inline contents when no part id) | When `partId` is set, the published Section theme part's children replace the local ones |\n\nAn image's optional `edit` (W-481, D-061) is written by the image editor and never rendered. `src`, `mediaId`, `width` and `height` point at the edited file; `edit` points back at the original: `v` (`1`), `engine` (`\"photocn\"`), `engineVersion` (such as `\"0.1.2\"`), `recipe` (photocn's `RecipeV1`, strict: sliders −1 to 1, blur and curve points 0 to 1, at most 32 points per curve channel, straighten ±45°, a filter name of up to 32 letters, digits, spaces, `_` or `-`, a blend image only as a site path or `https:` URL, at most 16 KB as JSON), optional `originalMediaId`, `originalSrc` (up to 2000 characters), `output` (`format` `webp`, `jpeg` or `png`, optional `quality` 0.1 to 1, optional `maxSide` 16 to 10000 px, `stripGps` boolean) and `editedAt` (an ISO 8601 timestamp).\n\nEvery node may also carry an optional `editorLabel` (`label` before schema 18; 1–80 characters, trimmed; an editor-only name shown in Layers and on the canvas, never rendered, W-157), optional `htmlId` (CSS `id`, unique on the page, theme parts included: a header and a page are rendered apart, so EmVB can't rename an id you chose without breaking links to it (W-1077); since 1.1.2 an id that names a browser global such as `location` or `document` is kept in the layout but not rendered, S-12), `classes` (style-class ids from the design system, S4), `devices` and `hiddenOn` (W-096, below).\n\n**Forms (S5):** form fields are only valid inside a `form` (or under one). Pages with a form set `needsFormsRuntime`; the host route loads `EmVBFormsRuntime` so `initForms` handles AJAX submit. Pages without a form stay zero EmVB JS (R-031).\n\n### Style properties (W-017, extended in W-088)\n\n**Text marks (W-950).** `marks` on a Heading or Text is up to 100 ranges `{ \"start\", \"end\", \"bold\"?: true, \"italic\"?: true, \"color\"?: colour, \"href\"?, \"newTab\"?: true }` over its `text` (characters `start` to `end`, end not included, 0–2000). They render as `<strong>`, `<em>`, `<span class=\"emvb-mark-c<n>\">` (the colour as `--emvb-mark-<n>` on the element, up to 8 per element; `.emvb-mark-c<n>{color:var(--emvb-mark-<n>)}` is sent only when a page uses one) and `<a class=\"emvb-mark-link\">` (checked like any link; left out inside a linked heading). Ranges past the text are clipped when drawn, so editing the text never invalidates a page; the editor moves them with the words.\n\nLengths are `{ \"value\": 0–10000, \"unit\": \"px\" | \"rem\" | \"em\" | \"%\" | \"vw\" | \"vh\" | \"ch\" }` (`vw` and `vh` since W-088, `ch` since W-331). Colours are hex or `{ \"var\": \"<id>\" }`. A **size** is a length, a variable reference or `\"auto\"`. An **offset** is a size whose value may also be negative (−10000 to 10000). A **fluid size** (W-955) is `{ \"fluid\": { \"min\": 0–10000, \"max\": 0–10000 } }` in px: written as `clamp()` growing from `min` on 360 px wide screens to `max` on 1280 px ones (the formula the design's fluid sizes use); `fontSize`, `gap`, the width and height keys, padding and margins (and the offsets) take one.\n\n| Key | Value | CSS |\n| --- | --- | --- |\n| `flexDirection` | `row`, `column`, `row-reverse`, `column-reverse` | `flex-direction` |\n| `flexWrap` | `nowrap`, `wrap`, `wrap-reverse` | `flex-wrap` |\n| `justifyContent` | `flex-start`, `flex-end`, `center`, `space-between`, `space-around`, `space-evenly` | `justify-content` |\n| `alignItems` | `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-items` |\n| `gap` | length | `gap` |\n| `gridColumnSpan` / `gridRowSpan` (W-099) | whole number 1–12 | `grid-column` / `grid-row` as `span N` |\n| `gridColumnStart` / `gridRowStart` | whole number 1–13 | `grid-column` / `grid-row` as the line number, or `start / span N` when a span is set too |\n| `width` / `height` | size | `width` / `height` |\n| `minWidth` / `maxWidth` / `minHeight` / `maxHeight` | length | matching size properties (`maxHeight` since W-088) |\n| `flexGrow`, `flexShrink` (W-954) | number 0–100 | `flex-grow`, `flex-shrink`: a Flexbox or Container child's share of free space, and of the shortfall |\n| `flexBasis` (W-954) | length or `auto` | `flex-basis`: the child's starting size along the row or column |\n| `alignSelf` (W-954) | `auto`, `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-self`: the child's own cross-axis alignment (`auto` follows the parent's Align) |\n| `order` (W-954) | whole number −99 to 99 | `order`: the child's place among its siblings (lower first) |\n| `overflow` | `visible`, `hidden`, `clip`, `scroll`, `auto` | `overflow` |\n| `overflowX`, `overflowY` (W-957) | same as `overflow` | `overflow-x`, `overflow-y`, after `overflow` so one axis wins |\n| `aspectRatio` | `\"auto\"` or `\"w/h\"` with whole numbers 1–9999, such as `\"16/9\"` | `aspect-ratio` (`16 / 9`) |\n| `objectFit` | `fill`, `contain`, `cover`, `none`, `scale-down` | `object-fit` (the editor offers it on Image and Video) |\n| `objectPosition` (W-957) | `center`, `top`, `bottom`, `left`, `right`, `top left`, `top right`, `bottom left`, `bottom right` | `object-position` (Image and Video) |\n| `paddingTop` / `Right` / `Bottom` / `Left` | length | `padding-*` |\n| `marginTop` / `Right` / `Bottom` / `Left` | offset (negative since W-331) | `margin-*` |\n| `position` | `static`, `relative`, `absolute`, `fixed`, `sticky` | `position` |\n| `top` / `right` / `bottom` / `left` | offset | matching inset properties |\n| `zIndex` | whole number −9999 to 9999 | `z-index` |\n| `fontFamily` | a font stack (1–200, checked as safe) or a font variable | `font-family` |\n| `fontSize` | length | `font-size` |\n| `lineHeight` | length, or a unitless number 0–100 | `line-height` |\n| `letterSpacing` | length whose value may be negative (−10000 to 10000) | `letter-spacing` |\n| `fontWeight` | `100`–`900` in steps of 100, `normal`, `bold` | `font-weight` |\n| `textAlign` | `left`, `center`, `right`, `justify` | `text-align` |\n| `textTransform` | `none`, `uppercase`, `lowercase`, `capitalize` | `text-transform` |\n| `textDecoration` | `none`, `underline`, `overline`, `line-through` | `text-decoration` (W-113; a button sets `none` in its base CSS) |\n| `markerColor`, `markerSize` (W-952, Lists) | colour; length | `--emvb-marker-color`, `--emvb-marker-size`, read by the marker and step rules (sent only when a page sets them) |\n| `fontStyle` (W-957) | `normal`, `italic` | `font-style` |\n| `whiteSpace` (W-957) | `normal`, `nowrap`, `pre-line`, `pre-wrap` | `white-space` (a Text element defaults to `pre-line`) |\n| `overflowWrap` (W-957) | `normal`, `break-word`, `anywhere` | `overflow-wrap` |\n| `color` / `backgroundColor` / `borderColor` | colour | matching colour properties |\n| `backgroundImage` (W-094) | http(s) URL or a site path, no spaces, quotes or parentheses | `background-image` as `url(\"…\")`. With no size, position or repeat: `cover`, `center`, `no-repeat` |\n| `backgroundVideo` | the same URL rule as `backgroundImage` | a muted, looping `<video>` behind the content |\n| `backgroundSize` | `auto`, `cover`, `contain` | `background-size` (the image layer) |\n| `backgroundPosition` | `center`, an edge (`top`, `bottom`, `left`, `right`) or a corner (`top left` and the other three) | `background-position` |\n| `backgroundRepeat` | `no-repeat`, `repeat`, `repeat-x`, `repeat-y` | `background-repeat` |\n| `gradient` | `{ type, angle?, position?, stops }`: `type` `linear`, `radial` or `conic`; `angle` whole degrees 0–360 (the linear direction, default 180, or the conic start, default 0); `position` (the radial centre, default `center`) takes the `backgroundPosition` values; `stops` are 2–10 `{ color, at }`, `color` a colour and `at` a whole % 0–100 | `linear-gradient`, `radial-gradient` (a circle) or `conic-gradient`, stops in `at` order, behind the image |\n| `overlay` | `{ color, opacity: 0–1 }`, or since W-949 `{ gradient, opacity?: 0–1 }` with the same `gradient` shape | a colour or gradient layer above the image (a scrim). Hex becomes 8-digit hex; a colour variable becomes `color-mix`; a gradient overlay's `opacity` (unset = 1) fades every stop |\n| `borderWidth` / `borderRadius` | length | matching border properties: every side or corner |\n| `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` (W-138) | length | `border-top-width`, `border-inline-end-width`, `border-bottom-width`, `border-inline-start-width`, after `border-width`, so a side beats it |\n| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` (W-138) | length or a spacing variable | `border-start-start-radius`, `border-start-end-radius`, `border-end-end-radius`, `border-end-start-radius`, after `border-radius` |\n| `borderStyle` | `none`, `solid`, `dashed`, `dotted` | `border-style` |\n| `opacity` | number 0–1 (the editor shows 0–100 %) | `opacity` |\n| `boxShadow` | `{ x, y, blur, spread, color?, inset? }`: px numbers, `x`, `y` and `spread` −1000 to 1000, `blur` 0 to 1000; `color` is a colour; `inset` is a boolean | `box-shadow` as `[inset] Xpx Ypx Bpx Spx [colour]`; no colour means the text colour |\n| `filter` | `{ blur?, brightness?, contrast?, saturate?, grayscale?, hueRotate? }`, at least one set: `blur` 0–100 px, `brightness` / `contrast` / `saturate` 0–300 %, `grayscale` 0–100 %, `hueRotate` 0–360° | `filter`, functions always in that order, such as `blur(2px) grayscale(100%)` |\n| `backdropFilter` (W-957) | the same object as `filter` | `backdrop-filter`, applied to what is behind the element (frosted glass) |\n| `transform` (W-953) | `{ x?, y?, scale?, rotate? }`, at least one: `x` and `y` whole px −2000 to 2000, `scale` whole % 10–400, `rotate` whole degrees −360 to 360 | `translate`, `scale` and `rotate` (CSS's own properties, so an entrance never cancels it; a scroll motion or loop on the same property wins while it runs). In a hover state it is a lift; animate it with a `transform` transition |\n| `cursor` | `default`, `pointer`, `text`, `move`, `grab`, `not-allowed`, `help`, `crosshair`, `zoom-in` | `cursor` |\n| `motion.transition` (W-089, Normal only) | `{ duration, delay?, easing, property }`: `duration` and `delay` whole ms 0–2000; `easing` `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`; `property` `all`, `colors`, `opacity`, `shadow`, `filter`, `transform` (W-953). No other keys | `transition`, one entry per CSS property: `colors` is `color`, `background-color` and `border-color`; `shadow` is `box-shadow`; `transform` is `translate`, `scale` and `rotate`. For example `opacity 200ms ease-out 50ms` |\n| `motion.entrance` (W-101, Normal only) | `{ type, duration, delay?, trigger? }`: `type` is `fade`, `fade-up`, `fade-down`, `slide-up`, `slide-down` or `scale`; `duration` and `delay` whole ms 0–2000; `trigger` is `load` (default) or `view` (as it scrolls in; browsers without scroll-driven animations play it on load) | `animation` named `emvb-<type>`, once, `ease-out`, `both`. Reduced motion sets `animation: none` |\n| `motion.sticky` (W-1070, Normal only; 1.4) | `{ distance?, background?, shadow?, padding?, hide? }` (at least one effect) or `{ type: \"none\" }`. `distance` 10–2000 px (unset 120); `background` a colour; `shadow` true; `padding` a length (top and bottom); `hide` true | Page-scroll animations (`animation-timeline: scroll(root)`, range `0px <distance>px`) to the scrolled look, sent only where scroll-driven animations exist; off for reduced motion. `hide` (on any device) adds `data-emvb-sticky-hide` and the `sticky` runtime, which slides the element away while scrolling down (up, or down when it is held by `bottom` with no `top`) and back on scrolling up, never while focus is inside. Each device's `hide` is written as `--emvb-sticky-hide: 1` or `0` (Desktop `0` unless set; unset on a narrower device keeps the wider one's; `{ type: \"none\" }` is `0`), which the runtime reads at the current width. The slide is a Web Animation, so the element's own `transition` is untouched |\n| `motion.loop` (W-938, Normal only; 1.0) | `{ effects, duration, easing?, alternate?, loop? }` or `{ type: \"none\" }`. `effects` as `motion.scroll`; `duration` 200–20000 ms; `easing` a transition easing (default `ease-in-out`); `alternate` false plays one way; `loop: true` never stops | A time-based CSS animation; stops after about 5 s unless `loop`; off for reduced motion. The accessibility check flags Loop forever and runs over 5 s |\n| `motion.scroll` (W-319, Normal only; `scrollMotion` before schema 18) | `{ effects, range }` or `{ type: \"none\" }`. Each effect is `{ type, from, to }`: `type` is `fade`, `move-x`, `move-y`, `scale`, `rotate` or `blur` (one of each). `range` is `enter`, `cross`, `exit` or `page`. `none` stops motion a wider device set | CSS scroll-driven animations. Reduced motion, and browsers without them, show the element still |\n| `iconRotate` (W-237, icons) | whole degrees −360 to 360 | `--emvb-icon-rotate`, read by the icon's `svg` as `rotate` |\n| `iconFlip` (W-237, icons) | `none`, `horizontal`, `vertical`, `both` | `--emvb-icon-flip` (`1 1`, `-1 1`, `1 -1`, `-1 -1`), read by the `svg` as `scale` |\n| `iconScale` (W-237) | number 0.1–4 | `scale` on the element (the icon and its background shape) |\n| `iconStrokeWidth` (W-237, outline icons) | number 0.25–6 | `--emvb-icon-stroke`; applies when the stored SVG's root has a stroke width of 1, 1.5, 2, 2.5 or 3 (render moves it into an `emvb-icon-sw<w>` class) |\n| `iconShadow` (W-237, icons) | `{ x, y, blur, color? }`: px, `x` and `y` −100 to 100, `blur` 0–100 | `--emvb-icon-shadow` as `drop-shadow(Xpx Ypx Bpx [colour])`, read by the `svg` as `filter` (follows the outline) |\n| `motion.icon` (W-237, Normal only; `iconAnimation` before schema 18) | `{ type, duration }`: `type` `spin` or `pulse`; `duration` whole ms 200–10000; optional `loop: true` (W-853, D-059) keeps it running forever. Or `{ type: \"none\" }` (W-248), which stops an animation a device inherits from a wider one | `--emvb-icon-animation` (`emvb-icon-spin <ms> linear <runs>`, `emvb-icon-pulse <ms> ease-in-out <runs> alternate` or `none`; W-848: `<runs>` is as many whole runs as fit in 5 s, at least one, even for a pulse; with `loop: true` it is `infinite`); the icon base CSS turns it off under `prefers-reduced-motion: reduce` |\n\n**W-088 additions are additive.** Every new key and unit is optional and every earlier value keeps its meaning, so stored pages and classes are valid unchanged. The version moved to 2 (D-031) with a v1 → v2 step that changes nothing, so an older EmVB shows \"saved by a newer EmVB\" rather than an invalid-layout error. The keys are the same on `node.style` and on `design.classes[].style`. The generator builds each value from typed numbers and keywords only and runs the same `isSafeCssValue` gate as every other property; anything else is dropped with a `rejected-style` warning. A shadow colour bound to a colour variable counts as a use of that variable, and deleting the variable clears it from the page layout and from class styles.\n\n### State styles (W-089)\n\n`node.states` and `design.classes[].states` are `{ \"hover\"?, \"focus\"?, \"active\"? }`. Each state is a style object with the same keys, limits and variable references as `style`, except `motion` (transition, entrance, scroll and icon motion), which belongs to Normal only. Any other state name is refused. Adding `states` moved the version to 3 (D-032) with a v2 → v3 step that changes nothing.\n\n```json\n{\n \"id\": \"btn00001\",\n \"type\": \"button\",\n \"props\": { \"text\": \"Go\" },\n \"style\": { \"backgroundColor\": \"#1d4ed8\", \"motion\": { \"transition\": { \"duration\": 200, \"easing\": \"ease-out\", \"property\": \"colors\" } } },\n \"states\": { \"hover\": { \"backgroundColor\": \"#1e3a8a\" }, \"focus\": { \"borderColor\": \"#f59e0b\" } }\n}\n```\n\n- **Selectors.** `hover` is `:hover`, `focus` is `:focus-visible` (keyboard focus, so a mouse click leaves no focus style); a linked Heading or Icon also matches when its inner link has keyboard focus (`:has(> :is(.emvb-heading-link,.emvb-icon-link):focus-visible)`, W-242) and `active` is `:active`.\n- **Cascade.** Each selector's base rule is followed by its `:hover`, `:focus-visible` and `:active` rules, classes first and then the local rule. So a state rule beats every Normal rule (a class's Hover colour shows over a local Normal colour), within one state the local rule beats the class, and Active beats Focus, which beats Hover.\n- **Safety.** State values go through the same mappers and `isSafeCssValue` gate as `style`. A rejected value is dropped with a `rejected-style` warning naming `<state>.<key>` (such as `hover.color`); a `motion` inside a state is refused by validation and dropped by the renderer and reported the same way, and so is an unknown state name. An unknown variable in a state is reported like one in `style`. An element whose only styles are states still gets `emvb-e-<id>`.\n- **Reduced motion.** When any rule has a `transition`, the CSS ends with one `@media (prefers-reduced-motion: reduce){…{transition:none}}` block that lists exactly those selectors. Nothing else changes under reduced motion.\n- **Editor preview.** The canvas CSS repeats every state rule for `[data-emvb-state=\"hover\"|\"focus\"|\"active\"]`, and the editor sets that attribute on the selected element while a state is chosen in the Style tab. Public CSS has neither the attribute nor those selectors.\n\n### Per-device styles (W-096)\n\n`node.devices` and `design.classes[].devices` are `{ \"laptop\"?, \"tablet\"?, \"mobile\"? }` (`laptop` since W-956). Each is a style object with the same keys as `style`. Only keys that differ from the wider devices are stored. `node.hiddenOn` and `design.classes[].hiddenOn` are arrays of `\"desktop\"`, `\"laptop\"`, `\"tablet\"` and `\"mobile\"` (at most one of each). Desktop itself stays in `style`.\n\n- **Queries.** Laptop is `@media (max-width: 1366.98px)`, then tablet `@media (max-width: 1024.98px)`, then mobile `@media (max-width: 767.98px)`. A narrower screen matches every wider query, so the narrowest device wins on a shared key, and a laptop-only key still applies on tablets and phones. The tablet and mobile bounds match `deviceForWidth` (under 768 mobile, under 1025 tablet), which popup targeting and visitor rules use (a laptop is desktop there).\n- **Hide.** Each device has its own query, so `display: none` does not leak: desktop `(min-width: 1367px)`, laptop `(min-width: 1025px) and (max-width: 1366.98px)`, tablet `(min-width: 768px) and (max-width: 1024.98px)`, mobile `(max-width: 767.98px)`. An element hidden on both Desktop and Laptop gets the one rule `(min-width: 1025px)`. Before W-956, `\"desktop\"` meant every screen from 1025 px; schema 17 pages are upgraded to `[\"desktop\", \"laptop\", …]` on read, so they render byte for byte as before.\n- **Grids.** Column counts have no laptop value: laptops use the desktop columns. The `.98` keeps fractional widths from zoom or display scaling (1024.5, say) inside one device, so nothing slips between two hide queries (W-506).\n- **Wide screen (W-959, 1.1).** An own `style.wide` record holds the values for 2400 px and up, in `@media (min-width: 2400px)`, built on Desktop's (the narrower devices never overlap it). `style.wide.hidden` overrides the Desktop hide there: `true` adds `(min-width: 2400px)` for an element not hidden on Desktop; `false` on an element hidden on Desktop stops its Desktop rule at `2399.98px`. Without `hidden`, Wide screen follows Desktop and the CSS is what it was. The renderer reads it as one more device (`renderableNode` moves it to `devices.wide` and `wideHidden`). Grid column counts have no Wide screen value.\n- **States.** Hover, focus and active stay all-viewport. Device overrides edit Normal only.\n- **Version.** Adding these fields moved the version to 5 (D-036) with a v4 → v5 step that changes nothing.\n\n## Design system document\n\n```json\n{\n \"schemaVersion\": 17,\n \"variables\": {\n \"colors\": [{ \"id\": \"brand\", \"name\": \"Brand\", \"value\": \"#0055ff\" }],\n \"fonts\": [{ \"id\": \"body\", \"name\": \"Body\", \"value\": \"Noto Sans, sans-serif\" }],\n \"fontSizes\": [{ \"id\": \"lg\", \"name\": \"Large\", \"value\": { \"value\": 24, \"unit\": \"px\" } }],\n \"spacings\": [{ \"id\": \"md\", \"name\": \"Medium\", \"value\": { \"value\": 16, \"unit\": \"px\" } }]\n },\n \"classes\": [{ \"id\": \"card\", \"name\": \"Card\", \"style\": { \"paddingTop\": { \"value\": 16, \"unit\": \"px\" } } }]\n}\n```\n\n- Colour ids are 1–40 of `a-z 0-9 -`, names 1–60 characters, values hex as above. At most 200 colours.\n- A colour may set `dark` (a hex, 1.4, W-1067): its value when the visitor's system prefers dark and no Theme toggle chose light, and whenever one chose dark. The page CSS repeats those variables (with `color-scheme: dark`) under `@media (prefers-color-scheme: dark)` for `.emvb-root` outside `[data-emvb-theme=\"light\"]`, and for `.emvb-root` inside `[data-emvb-theme=\"dark\"]`. Colours without `dark` are the same in both.\n- A font may set `family`, `faces` and `source` (1.4, W-1072): its own WOFF2 files, written as `@font-face` rules on pages whose CSS uses the variable. [SCHEMA.md](../SCHEMA.md) has the limits and checks, [Custom fonts](../guides/custom-fonts.md) the editor side.\n- The document is at most 256 KiB (`MAX_DESIGN_BYTES`).\n- A font size or spacing variable may set `fluid: { min, max }` (px, 0–1000). It is emitted as `clamp()` between `fluidRange` (unset is 360 to 1280 px; `minWidth` must be less than `maxWidth`). `value` stays the fixed fallback (W-316).\n- `direction` is `ltr`, `rtl` or `auto` (unset is left to right). It is `dir` on every EmVB root, and hosts get it back for `<html dir>` (W-230).\n- `defaults` is a starting style per tag (`h1`–`h6`, `p`, `a`, `button`), emitted under `:where(.emvb-root)` so a class still wins.\n\n## Limits and validation\n\n`validateLayout()` runs on every save (the plugin's `beforeSave` hook) and on every read (editor and public render), in this order:\n\n1. **Size:** the JSON is at most 512 KiB (`MAX_LAYOUT_BYTES`) in UTF-8 bytes.\n2. **Version:** `upgradeLayout()` runs the migration chain up to the current version. A document from a newer EmVB is refused with \"Update EmVB to edit it\", never downgraded.\n3. **Structure:** at most 2000 nodes (`MAX_NODES`) and 24 levels (`MAX_DEPTH`), checked iteratively before parsing.\n4. **Schema:** the Zod schema above.\n5. **Ids:** every node id is unique.\n\nIssues carry a path such as `root.children[0].props.level`, which the editor uses to select the element at fault. A layout that fails on read renders nothing on the public page and logs only the page id (R-033).\n\n## Rendered output\n\n- The root gets `emvb-root`, each node `emvb-<type>` and, when its style, a state, a device override or a hide flag yields a rule, `emvb-e-<id>`. Invalid style values are dropped with a render warning. A reference to an unknown variable is kept and also reported as a warning. Unknown element types render nothing publicly and a placeholder with `data-emvb-id` in the editor (warning `unknown-type`). An unknown node still keeps `dir`, `container` and `query` (W-352), so a later version that understands the type still has them.\n- The CSS is, in order: `@font-face` rules for the custom font variables the CSS uses (W-1072, see [Custom fonts](../guides/custom-fonts.md)), variables on `.emvb-root` (`--emvb-c-*` colours, `--emvb-f-*` fonts, `--emvb-fs-*` font sizes, `--emvb-s-*` spacings) and the colours' dark values (W-1067), base CSS for the element types in use, then class rules (W-030), then one `.emvb-e-<id>{…}` rule per styled node (R-021). Each class and local rule is followed by its state rules, then the tablet media query, the mobile media query and the hide queries (see [Per-device styles](#per-device-styles-w-096)). A reduced-motion block closes the CSS when a transition is set (see [State styles](#state-styles-w-089)).\n- **Style classes** (`design.classes[]`): `{ id, name, style, states?, devices?, hiddenOn? }`. Elements list ids in `node.classes`; HTML gets `emvb-k-<id>` in that order. When two classes set the same property, the one later in `design.classes` wins, because its rule comes later in the stylesheet. Local `.emvb-e-<id>` rules come after every class, so local styles win. `classStylesInListOrder` feeds `resolveCascade` in that list order.\n- Length/font style props may use `{ \"var\": \"<id>\", \"from\": \"spacing\"|\"fontSize\"|\"font\" }` (colours keep `{ \"var\": \"<id>\" }`). Offsets (`top`, `right`, `bottom`, `left`) take spacing variables; the shadow colour takes a colour variable.\n- Text and attributes are escaped by the serializer. Public output has no scripts and no editor `data-emvb-*` attributes (such as `data-emvb-id`). The only `data-emvb-*` attributes it carries are these public hooks (`PUBLIC_DATA_ATTRIBUTES` in `core/public-attributes.ts`, kept in step with this list by a test): `data-emvb-theme-part` on a theme part's wrapper ([theme-parts.md](theme-parts.md#public-render)); `data-emvb-loop-item` (the post id) on each Loop item; `data-emvb-popup`, `data-emvb-popup-config` and `data-emvb-popup-dismiss` on popup chrome; `data-emvb-float`, `data-emvb-float-dismiss` and `data-emvb-float-edge` on float chrome; `data-emvb-menu-empty` on an empty Menu; the widget hooks their opt-in runtimes read: `data-emvb-alert-dismiss` (Alert), `data-emvb-lightbox` (Gallery), `data-emvb-arrows`, `data-emvb-dots`, `data-emvb-autoplay` and `data-emvb-loop` (Carousel), `data-emvb-counter` (Counter), `data-emvb-countdown` (Countdown), `data-emvb-map` (Map), `data-emvb-rotate` (Animated headline), `data-emvb-share-list` and `data-emvb-share` (Share buttons); `data-emvb-theme-toggle` on a Theme toggle (W-1067); `data-emvb-sticky-hide` on an element that hides while scrolling down (W-1070); and `data-emvb-ext` (the element type) on an extension element's wrapper. The runtimes may add their own state attributes after load (`data-emvb-menu-dismissed`, `data-emvb-ready`, `data-emvb-shown`, and `data-emvb-theme` on `<html>`).\n\n## Changing the format\n\n- Add a migration `LAYOUT_MIGRATIONS[n]` (pure, version n to n + 1) and bump `LAYOUT_SCHEMA_VERSION` in the same change.\n- Add fixtures and tests for the old and new shapes, and update this file.\n- `test/docs/layout-format.test.ts` checks this file's title, the \"literal `N`\" sentence and the JSON examples against the code, so a schema bump must update them.\n\n## S8 additive elements (W-072–W-074)\n\n- **`div-block`**: block container (`display:block`); children like Container. Optional `href` and `newTab`, like Container.\n- **`flexbox`**: flex container defaulting to row + wrap + gap (Container stays column). Optional `href` and `newTab`.\n- **`svg`**: `props.markup` (sanitized allowlist; no scripts/handlers/`use`/`foreignObject`); optional `title`, `decorative`, `size`. A valid non-square `viewBox` keeps its ratio: the longer side is `size` (48 when unset) and the other side scales. A square, missing, or unreadable `viewBox` stays a square of `size`.\n- **`tabs` / `tab-panel`**: Tabs hold only tab-panels. Public markup is CSS-only (radio + `:has()`); the optional tabs script only takes the hidden radios out of the tab order.\n- **`accordion` / `accordion-item`**: items are `<details>`. An item needs `summary` (1–200) and may start `open`. No script.\n- **`menu` / `menu-item`**: a `nav` (named by `label`, default \"Menu\") of links. `direction` is `row` or `column`. An item with children is a dropdown; `wide` stretches that panel across the menu. A menu with a dropdown can load the optional menu script so Escape closes it. An empty menu is a plain box, not a `nav`.\n - **Mega menu (W-1069, 1.4, additive):** `panelPartId` (string, at most 128) names a Section theme part whose layout fills the item's panel in place of its children; `panelWidth` (a length) is that panel's width, or its widest when `wide` (unset: its content's width, at most the screen less 2rem). The panel is the same `<details>` disclosure as any dropdown (class `emvb-menu-panel--mega`, item `emvb-menu-item--mega`), so it opens by click, tap, Enter or Space and on hover with a fine pointer, with no script; the menu script, loaded as for any dropdown, adds Escape and closing on a click outside. The part renders under the synced-section guards: a part already being rendered (a panel that shows itself, directly or through other parts) and parts past the depth limit (8) or the render's element budget count as missing. A missing, unpublished or empty part leaves the item's own children, so an item without children is a plain link. On phones (below 768px) the panel stacks inline under its item instead of floating. Its rules (`menu-mega` base CSS) are sent only with a page that renders a mega panel, so other menus' markup and CSS are unchanged.\n- **`grid`** also takes optional `href` and `newTab`.\n\n\n## Schema 13: the W-307 feature batch\n\nSchema 13 only adds optional fields, so a v12 document upgrades unchanged.\n\n### Collection Loops (W-308)\n\nA `loop` with `props.collection` (a collection slug) lists that collection's published entries\ninstead of the archive's posts. `limit` (1–50, default 6), `order` (`newest`, `oldest`, `title`),\n`display` (`list`, `grid`, `cards`) and `columns` (1–6) are optional. Hosts fill\n`dynamic.collections[loopId]` (see `collectCollectionLoops`). A `loop-empty` child is left out of\nthe item design and rendered when there are no entries; it is only valid inside a `loop`.\n\n### Data bindings (W-307)\n\nAny node may carry `bind`: prop name → `{ source, key }`. `source` is `post` (a post field such as\n`title`, or any plain field of the entry by name, for example `role`), `site` (a site setting:\n`title`, `tagline`, `url`, `social.github`…) or `param` (a URL parameter). Which props can be bound\nis fixed per element (`BINDABLE_FIELDS`: text, links, image source and alt). The typed prop stays as\nthe fallback when the source has no value. Bound values are plain text, capped at 500 characters,\nand go through the element's own escaping and link and image URL checks.\n\nA link or image bound to `param` only takes same-site URLs: relative ones, or absolute ones on the\npage's origin (hosts pass it as `dynamic.origin`). Anything else shows the typed value, unless the\nbinding sets `outside: true` (\"Allow outside sites\" in the editor). Anyone can craft a URL\nparameter, so that option lets them point the page's links and images at any site.\n\n### A/B tests and visitors (W-312, W-313, W-329)\n\nAny node may set `variant`: `{ test, arm, split? }`. `test` is a name of lowercase letters, digits and `-` (up to 32). `arm` is `a` or `b`. `split` (on the B element, 1–99, unset = 50) is the share of visitors who see B. The host picks one arm per visitor and keeps it in a cookie.\n\n`audience` shows or hides the element. Every field that is set must match, and `hide: true` flips that to \"everyone except\":\n\n- `countries`: two-letter codes, 1–50\n- `devices`: `mobile`, `tablet`, `desktop`\n- `visitor`: `new` or `returning`\n- `hours`: `{ from, to }` (0–23 and 0–24; wraps past midnight when `to` < `from`) and `days` (0 = Sunday), in `timeZone` (an IANA name; unset = UTC)\n- `segments` (W-329): 1–20 names the host passes (`member`, `pro`), lowercase letters, digits, `-` and `_`\n\nA rule the host cannot check does not match. Pages with a variant or an audience are sent `Cache-Control: private, no-store`.\n\n## Schema 14\n\nSchema 14 only adds optional fields, so a v13 document upgrades unchanged.\n\n- **Visitor segments (W-329).** `audience.segments`, above. Hosts pass them as `resolveEmVBPage(Astro, { visitor: { segments } })` and the same option on `resolveThemeParts`. `country`, `device` and `returning` on that object replace what EmVB detects.\n- **Loop fields (W-330).** On a collection Loop, `permalink` is a site path containing `{slug}` or `{id}` (unset is `/<collection>/{slug}`). `imageField` and `excerptField` name the entry fields Post Image and Post Excerpt read (unset is `featured_image` and `excerpt`). `filter` is up to five `field=value` pairs separated by `;`. A taxonomy name filters by term, and the same field twice matches either value.\n- **`ch` and negative margins (W-331).** Lengths may use `ch`. Margins may be negative (−10000 to 10000). Padding stays 0 or more.\n\n## Internal proposal records (W-928)\n\nProposals are review data in the plugin-storage collection `emvb_proposals`, not page\nrevisions. A row holds `{ proposal, createdAt }`, keyed by a server-generated 16-hex id.\nThe version-1 proposal is `{ version: 1, target: { collection, id }, baseRevision,\nbaseDesignRevision, ops }`. The plugin adapter currently reads the target entry's\n`layout` field (native visual pages and theme parts); arbitrary host canvas-field\nselection is not part of this transport. `baseRevision` is EmDash's current `_rev`.\n`baseDesignRevision` is the effective draft style revision, or the published style\nrevision when no draft exists, or null on an empty site. It is checked only when\nclass/variable ops are present, so page-only proposals survive unrelated style edits.\n\nOperations run in list order against frozen schema 18 ids and names:\n\n- `insert`: `{ kind, parentId, index, node }` — a complete stored node/subtree.\n- `move`: `{ kind, id, parentId, index }` — uses editor drop rules; index addresses\n the destination children **before** removal, as in `moveNode`.\n- `update`: `{ kind, id, set }` — editable node fields only. `props` shallow-merges;\n other fields replace their whole value, and null clears an optional node field.\n `id`, `type` and `children` cannot be patched. Use `editorLabel`, `props.partId`\n and `style.motion`, not their old aliases.\n- `delete`: `{ kind, id }` — never the root.\n- `class`: `{ kind, id, value }` — full class upsert, or null to remove an existing id.\n- `variable`: `{ kind, group, id, value }` — full variable upsert/removal;\n group is `colors`, `fonts`, `fontSizes` or `spacings`. Payload ids must match the\n operation id. Names must already be clean and unique in their list; no truncation.\n\n`applyProposal(base, proposal, selectedIndexes?)` returns a new `{ layout, design }`\nonly: it cannot save, publish, acquire an edit lock, or change review/undo state.\nSelected indexes refer to the original list; selection order cannot reorder ops.\nEach selected intermediate result passes stored-layout/design validation, nesting\nrules and the existing URL/SVG/CSS/font allowlists. Unknown layout keys still use\nthe frozen contract's keep-and-ignore rules. A dependency on an omitted operation,\na missing id, a bad node, a duplicate id, an invalid index or any other refusal\naborts the entire preview. Nothing is partially returned or persisted. W-930 must\nfeed accepted results through normal undo and draft saves, including the existing\nsite-wide guards for shared-style deletion; this store never writes site styles.\n\nCreation checks **all** ops and re-reads the base before storage. `STALE_BASE` reports\nexpected/current revisions and asks the caller to read the current document and\nsubmit a rebased proposal; there is no merge/retry/override. Preparation rechecks the\nlive revisions, so keeping or reading an old proposal does not make it applicable.\nGet/list are review reads, not an applicability guarantee; malformed rows are refused\nby get and omitted by list. Per-isolate serialization matches saved sections; there\nis no distributed content transaction (the final draft save still needs its own CAS).\n\nBudgets: 100 ops, 512 KiB JSON, 64 JSON nesting levels, and 100 stored proposals per\nsite; resulting layouts/designs retain all existing byte/node/depth limits. Cycles,\nnon-JSON values and prototype-manipulation keys are refused before parsing.\n\nPlugin-local editor transport mirrors saved sections: `proposals` (target-filtered\nlist), `proposals/get`, `proposals/create`, `proposals/withdraw`. Every route requires\n`content:edit_any` and EmDash's private-request/CSRF guard. These are not public/MCP\nAPIs; W-929 adds MCP tools and W-930 adds review UI later. Withdrawal only removes\nreview data; it cannot affect a page. No per-op review states or agent publish path\nare implemented here.\n\n## 1.2 widgets (W-1018–W-1025)\n\nAdded in 1.2, additive: new element types only, so an older 1.x keeps them on save and leaves them out of\nthe page (see Unknown element types above). Each renders without script.\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `rating` (shown as \"Star rating\", W-1023) | `value` (0–10, any decimal; shown to one decimal), optional `max` (whole number 1–10, unset 5; a `value` above it shows as `max`, so lowering it never makes a page invalid), `label` (≤ 120; `{value}` and `{max}` are filled in; unset \"Rated {value} out of {max}\"), `size` (8–128 px per star, unset 20) | none | `<div role=\"img\" aria-label=\"Rated 4.5 out of 5\">` with one `aria-hidden` star SVG per point, filled in the element's text colour; a part-filled star is the filled star cut by its `viewBox` over a 25 % star. Right to left, stars fill from the right |\n| `alert` (W-1025) | `variant` (`info`, `success`, `warning`, `danger`), optional `title` (≤ 200), `text` (≤ 2000; line breaks kept), optional `hideIcon`, `dismissible`, `dismissLabel` (≤ 80, unset \"Dismiss\") | none | `<div role=\"note\" class=\"emvb-alert emvb-alert-<variant>\">` in the variant's colours (text on background at least 7:1, overridable by the element's styles), its `aria-hidden` icon unless `hideIcon`, then the title and text paragraphs. `dismissible` adds `<button type=\"button\" data-emvb-alert-dismiss aria-label=\"Dismiss\">`, hidden by CSS until the opt-in alerts runtime marks it ready; that script hides the Alert on press and moves focus to the next focusable element. The page then lists `\"alerts\"` in `runtimes` |\n| `icon-box` (W-1020) | `iconId` and optional `iconSvg` (as on `icon`), `iconSize` (8–512 px, unset 48), `title` (≤ 200), optional `titleLevel` (2–6, unset 3), `text` (≤ 2000, line breaks kept), optional `position` (`top`, `left`, `right`; unset `top`), `href`, `newTab` | none | `<div class=\"emvb-icon-box emvb-media-box emvb-media-box-<position>\">` with the icon `aria-hidden` in `.emvb-media-box-media`, then `<hN class=\"emvb-media-box-title\">` and `<p class=\"emvb-media-box-text\">`. With a safe `href` the title is wrapped in `<a class=\"emvb-media-box-link\">`, whose `::after` covers the box, so the whole box is clickable through one named link. An empty title or text is left out |\n| `image-box` (W-1021) | the picture keys of `image`: `src`, `alt` (required unless `decorative`), optional `mediaId`, `width`, `height`, `focalX`, `focalY` (kept for the media library; a box doesn't crop); optional `imageSize` (`small` 25 %, `medium` 40 %, `large` 60 %, `full`; the picture's share of the width when beside the words, unset `medium`); and the title, text, position and link keys of `icon-box` | none | as `icon-box`, class `emvb-image-box` (plus `emvb-image-box-<size>` unless medium), with `<img loading=\"lazy\" decoding=\"async\">` and its `width`/`height` in `.emvb-media-box-media`; no media part without a safe `src` |\n| `testimonial` (W-1022) | `quote` (≤ 2000, line breaks kept), `name` (≤ 200), optional `role` (≤ 200), optional photo keys `src`, `alt` (written by the media library, not rendered), `mediaId`, `width`, `height`, `focalX`, `focalY`; optional `rating` (0–10) and `ratingMax` (1–10, unset 5) | none | `<figure class=\"emvb-testimonial\">`: the rating as in `rating` (`role=\"img\"`, \"Rated 5 out of 5\") when `rating` is set, `<blockquote class=\"emvb-testimonial-quote\"><p>`, then `<figcaption>` with the photo (48 px, round, `alt=\"\"`: the name is beside it) and the name and role |\n| `social-icons` (W-1024) | optional `label` (≤ 80, unset \"Social media\"), `shape` (`plain`, `circle`, `rounded`, `square`; unset `plain`), `brandColors` | `children`: Social links only, at most 20 | `<ul class=\"emvb-social-icons emvb-social-<shape>\" aria-label=\"Social media\">`; icons are one em, so the element's font size sizes them (1.5em by default). Badges draw the icon in white on the text colour, or on each network's colour with `brandColors` |\n| `social-link` (W-1024) | `network` (one of `facebook`, `instagram`, `x`, `linkedin`, `youtube`, `tiktok`, `bluesky`, `mastodon`, `threads`, `github`, `pinterest`, `whatsapp`, `discord`, `twitch`, `reddit`, `dribbble`, `behance`, `telegram`, `spotify`, `email`, `rss`, `website`), `href` (≤ 2000), optional `label` (≤ 80, the link's name; unset the network's name), `newTab` | none; only inside `social-icons` | `<li class=\"emvb-social-link emvb-social-<network>\"><a href aria-label=\"Instagram\">` around the preset's `aria-hidden` SVG (Font Awesome Free, CC BY 4.0, generated into `core/icons/social.generated.ts`). Without a safe `href` the icon shows dimmed in a `<span aria-hidden>` with no link |\n| `gallery` (W-1019) | optional `layout` (`grid` squares or `masonry`; unset `grid`), `columns` (1–6, unset 3; at most 2 up to 1024 px wide and 1 up to 767 px), `lightbox`, `label` (≤ 80) | `children`: Gallery images only, at most 60 | `<ul class=\"emvb-gallery emvb-gallery-<layout> emvb-gallery-cols-<n>\">`, named by `label`. `lightbox` adds `data-emvb-lightbox` and lists `\"lightbox\"` in `runtimes`: that script turns each picture into a \"View larger: <alt>\" button opening one native modal `<dialog>` with Previous/Next (and arrow keys), a spoken \"2 of 5\", Close and Escape; focus returns to the picture |\n| `gallery-image` (W-1019) | the picture keys of `image` (`src`, `alt` required unless `decorative`, `mediaId`, `width`, `height`, `focalX`, `focalY`) and optional `caption` (≤ 500) | none; only inside `gallery` | `<li class=\"emvb-gallery-image\"><figure>` with a lazy `<img>` and its `<figcaption>`; no picture without a safe `src` |\n| `carousel` (W-1018) | optional `label` (≤ 80, unset \"Carousel\"), `perView` (1–4, unset 1; at most 2 up to 1024 px, 1 up to 767 px), `arrows`, `dots`, `autoplay`, `interval` (3–30 seconds, unset 6), `loop` | `children`: Slides only, at most 20 | `<section aria-roledescription=\"carousel\" aria-label=\"Carousel\">` with a focusable `<div class=\"emvb-carousel-track\" tabindex=\"0\">` that scrolls and snaps to each slide with no script (`aria-live` polite, off while autoplaying). `arrows`, `dots` or `autoplay` add `data-emvb-*` options and list `\"carousel\"` in `runtimes`: that script adds Previous/Next (disabled at the ends unless `loop`), one \"Go to slide n\" button per view position (`aria-current`), and for autoplay a Pause/Play button before the slides; autoplay pauses while hovered or focused and starts paused under `prefers-reduced-motion` |\n| `carousel-slide` (W-1018) | optional `label` (≤ 80) | `children: Node[]`; only inside `carousel` | `<div role=\"group\" aria-roledescription=\"slide\" aria-label=\"2 of 5\">` (or its `label`) |\n\n**Widget runtimes (W-1025).** `renderPage` returns `runtimes`, the opt-in widget scripts the rendered\nelements asked for (sorted; empty for most pages). `renderStored` and `resolveThemeParts` set it only\nwhen it is not empty. `EmVBPage` mounts them itself; a site layout mounts its theme parts' with\n`<EmVBWidgetRuntimes names={theme.runtimes} />` from `@perkyzz/emvb/astro/widgets`. The HTML/CSS\nexport writes each one next to the pages that use it (`assets/emvb-alerts.js`, `assets/emvb-lightbox.js`, `assets/emvb-carousel.js`). The names are `alerts`, `lightbox` and `carousel` (1.2); `counter`, `countdown`, `map`, `headline` and `share` (1.3); `sticky` (Hide while scrolling down) and `theme` (Theme toggle) (1.4); and `ext:<package>` for an extension's own runtime ([EXTENSIONS.md](../EXTENSIONS.md), 1.4).\n\n## 1.3 marketing widgets (W-1038–W-1048)\n\nNew element types only (layout schema stays 18): a page that uses them can't be opened by EmVB\n1.2, which keeps them on save without showing them. Each renders without script; the opt-in\nscripts are listed in `runtimes`.\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `counter` (W-1038) | `value` (−10¹² to 10¹²), optional `start` (same range, unset 0), `decimals` (0–3, unset 0), `separator` (`,` `.` space or `'`; unset none; with `.` the decimal mark is `,`), `prefix` and `suffix` (≤ 20), `title` (≤ 200), `countUp`, `duration` (300–5000 ms, unset 2000) | none | `<div class=\"emvb-counter\">` with `<p class=\"emvb-counter-number\">` (prefix, `<span class=\"emvb-counter-value\">` holding the final number, suffix) and the title paragraph. `countUp` adds `data-emvb-counter`, `data-from`, `data-to`, `data-decimals`, `data-separator` and `data-duration` to the value and lists `\"counter\"` in `runtimes`; that script counts from `start` when the number scrolls into view, with a hidden copy of the final number for screen readers while it counts, and does nothing under reduced motion |\n| `progress` (shown as \"Progress bar\", W-1039) | `value` (0–10⁶), optional `max` (above 0, ≤ 10⁶, unset 100; a `value` above it shows as full), `label` (≤ 120), `showValue`, `kind` (`meter` or `progressbar`, unset `meter`), `thickness` (2–48 px, unset 8), `grow` | none | `<div class=\"emvb-progress\">` with an optional head (the label and, with `showValue`, an `aria-hidden` percentage), then `<div role=\"meter\" aria-label=\"…\" aria-valuemin=\"0\" aria-valuemax aria-valuenow aria-valuetext=\"75%\">` holding an `aria-hidden` SVG: a 20 % track and a fill `rect` as wide as the share, in the element's text colour, no inline styles. `grow` adds the `emvb-progress-grow` class, whose fill grows in with a CSS scroll-driven animation, only where supported and not under reduced motion. Right to left, it fills from the right |\n| `countdown` (W-1040) | `target` (`YYYY-MM-DDTHH:MM[:SS]` with `Z` or a `±HH:MM` offset, a real date), optional `title` (≤ 200), `label` (≤ 40, unset \"Ends\"), `ticking`, `hideSeconds`, `expired` (`text`, `hide` or `link`, unset `text`), `expiredText` (≤ 200, unset \"This offer has ended.\"), `expiredHref` (a link, sanitised like any) | none | `<div class=\"emvb-countdown\">` with the title and `<p>Ends <time datetime=\"…\">1 Dec 2026, 09:00 UTC−5</time></p>`, the date written in the target's own offset. `ticking` adds `data-emvb-countdown`, `data-target` and `data-expired`, a clock (`aria-hidden` days, hours, minutes and seconds, without seconds under `hideSeconds`) with a `Pause` button (`aria-pressed`), and the ended paragraph (a link with `link`, none with `hide`); CSS hides the clock until the opt-in countdown runtime marks it ready and the ended text until it is shown. The runtime ticks every second (no live region), stops on Pause, and at the target shows the ended text and hides the clock, or hides the Countdown. The page then lists `\"countdown\"` in `runtimes` |\n| `map` (W-1041) | `address` (1–300, line breaks kept), optional `provider` (`osm` or `google`, unset `osm`), `lat` (−90 to 90) and `lng` (−180 to 180), `zoom` (1–19, unset 15), `linkText` (≤ 80, unset \"Open in OpenStreetMap\" or \"Open in Google Maps\"), `embed`, `height` (150–800 px, unset 360) | none | `<div class=\"emvb-map\">` with the address paragraph and `<a class=\"emvb-map-link\" rel=\"noopener\">` to the place (a search for the address, or a marker at `lat`/`lng`). `embed` (with `lat`/`lng` for OpenStreetMap) adds `data-emvb-map` and a `.emvb-map-frame` holding `data-src`, `data-title` (\"Map of\" the address's first line) and `data-height`, a \"Show the map\" button and a note naming the service; CSS hides it until the opt-in map runtime marks the Map ready. Pressed, the runtime replaces it with a titled, lazy `<iframe>` (only `https://www.openstreetmap.org/export/embed.html?…` or `https://www.google.com/maps?…`) and moves focus to it, so the page requests nothing from the map service before that. Hosts with a Content Security Policy add `frame-src https://www.openstreetmap.org https://www.google.com`. The page then lists `\"map\"` in `runtimes` |\n| `price-table` (shown as \"Price table\", W-1042) | `title` (≤ 120), optional `titleLevel` (2–6, unset 3), `description` (≤ 500), `price` (≤ 20, text such as `29.99` or `Free`), optional `currency` (≤ 5), `period` (≤ 40), `regularPrice` (≤ 20), `features` and `excluded` (≤ 30 lines of ≤ 200 each), `buttonText` (≤ 80), `buttonHref` (a link, sanitised), `newTab`, `featured`, `ribbon` (≤ 30, unset \"Featured\") | none | `<div class=\"emvb-price-table\">` (plus `emvb-price-table-featured` and a ribbon paragraph when `featured`), the title heading, the description, `<p class=\"emvb-price-table-price\">` with the regular price in `<s>` when on sale (with \"Regular price:\" and \"Sale price:\" for screen readers only), the amount with its currency and the period; a list of included features with a check mark and excluded ones with a cross, struck through and introduced as \"Not included:\" for screen readers; then the button link (left out without text or a safe link; `newTab` adds `target=\"_blank\" rel=\"noopener noreferrer\"`). No script |\n| `price-list` (shown as \"Price list\", W-1043) | optional `label` (≤ 80) | `children: Node[]`, Price list items only, at most 50 | `<ul class=\"emvb-price-list\" aria-label=\"…\">` (no name without `label`) |\n| `price-list-item` (W-1043) | `title` (≤ 120), `price` (≤ 20, text), optional `description` (≤ 500), `src` with an Image's picture keys and `alt` (≤ 500; unset or empty: decorative), `href` (a link, sanitised), `newTab` | none; only inside `price-list` | `<li class=\"emvb-price-list-item\">` with the picture first (`loading=\"lazy\"`), then `<p class=\"emvb-price-list-head\">` holding the title (a link with `href`), an `aria-hidden` dotted leader and the price, and the description paragraph. No script |\n| `cta` (shown as \"Call to action\", W-1044) | `title` (≤ 200), optional `titleLevel` (2–6, unset 3), `text`, `src` with an Image's picture keys and `alt` (unset or empty: decorative), `layout` (`behind`, `top`, `left`, `right`; unset `behind`), `buttonText` (≤ 80), `href` (a link, sanitised), `newTab`, `ribbon` (≤ 30) | none | `<div class=\"emvb-cta emvb-cta-<layout>\">` (`top` without a picture) with the ribbon, the picture in `.emvb-cta-media` (behind: covering the box under a 55 % black overlay, the words in white), then the title heading, text and button. With a safe `href` the title holds the one link, `emvb-cta-linked` stretches it over the whole box, and the button is an `aria-hidden` span; without one there is no link or button. No script |\n| `flip-box` (shown as \"Flip box\", W-1045) | `frontTitle` (≤ 200), optional `frontText`, `backTitle` (≤ 200), `backText`, `titleLevel` (2–6, unset 3), `buttonText` (≤ 80), `href` (a link, sanitised), `newTab`, `direction` (`right`, `left`, `up`, `down`; unset `right`), `toggleLabel` (≤ 40, unset \"Turn over\") | none | `<div class=\"emvb-flip-box emvb-flip-<direction>\">` holding `.emvb-flip-inner` with two faces stacked in one grid cell (the box is as tall as the taller face), each with its title and text, the back with the button link; then `<label class=\"emvb-flip-toggle\"><input type=\"checkbox\" class=\"emvb-flip-check\">Turn over</label>`. CSS turns the inner on hover (only under `(hover:hover)`), when the checkbox is ticked, and when keyboard focus is inside the back face; both faces stay in the accessibility tree. Reduced motion drops the transition. No script |\n| `headline` (shown as \"Animated headline\", W-1046) | optional `level` (1–6, unset 2), `before` and `after` (≤ 200), `highlight` (1–120), `mark` (`underline`, `circle`, `strike`, `none`; unset `underline`), `rotate` (≤ 10 words of ≤ 120), `rotating`, `interval` (1.5–10 s, unset 2.5), `turns` (1–5, unset 2) | none | `<hN class=\"emvb-headline emvb-headline-<mark>\">before <span class=\"emvb-headline-mark\">highlight</span> after</hN>`, counted as a heading by the accessibility check. The mark is drawn once by CSS (a growing gradient, or an `aria-hidden` SVG circle), already drawn under reduced motion. `rotating` with other words adds `data-emvb-rotate` (the words as JSON), `data-interval` and `data-turns` and lists `\"headline\"` in `runtimes`; the runtime hides the changing word from screen readers (they read the sentence with the first word), adds a Pause button after the heading, and stops on the first word after its rounds or on Pause; nothing rotates under reduced motion |\n| `share-buttons` (shown as \"Share buttons\", W-1047) | optional `label` (≤ 80, unset \"Share this page\"), `shape` (as Social icons), `brandColors`, `nativeShare` | `children: Node[]`, Share links only, at most 12 | `<ul class=\"emvb-share-buttons emvb-share-<shape>\" aria-label=\"Share this page\">`. `nativeShare` adds a last item with `<button type=\"button\" class=\"emvb-share-native\" data-emvb-share>Share…</button>`, hidden by CSS until the opt-in share runtime finds the browser's `navigator.share` and marks the list ready; pressed, it opens the share sheet for the page. The page then lists `\"share\"` in `runtimes` |\n| `share-link` (W-1047) | `network` (`facebook`, `x`, `linkedin`, `whatsapp`, `telegram`, `reddit`, `bluesky`, `threads`, `email`), optional `label` (≤ 80) | none; only inside `share-buttons` | `<li class=\"emvb-share-<network>\"><a href=\"…\" aria-label=\"Share on Facebook\" target=\"_blank\" rel=\"noopener noreferrer\">` with the network's `aria-hidden` icon; the address is the service's own share link with the page URL encoded in it (email: `mailto:?body=…`, same tab). The page URL comes from the host as `dynamic.pageUrl` (`resolveEmVBPage` and `resolveThemeParts` fill it with the request's origin and path when a layout has Share buttons); without it a public page renders no share links, and the editor uses `https://example.com/`. No tracking script |\n| `hotspots` (W-1048) | `src` and `alt` with an Image's picture keys and `decorative`, optional `label` (≤ 80, unset \"Points on the picture\") | `children: Node[]`, Hotspots only, at most 20 | `<div class=\"emvb-hotspots\">` with the picture (`loading=\"lazy\"`; the accessibility check wants its alt text as for an Image) and `<ol class=\"emvb-hotspots-list\" aria-label=\"…\">` of markers numbered by a CSS counter |\n| `hotspot` (W-1048) | `title` (1–120), optional `text` (≤ 1000), `x` and `y` (0–100 %), optional `xTablet`, `yTablet`, `xMobile`, `yMobile` (unset: the wider device's) | none; only inside `hotspots` | `<li>` placed by its own CSS rule (`left`/`top` in percent, tablet and phone values in their media queries), holding `<button type=\"button\" popovertarget=\"emvb-hotspot-<id>\" aria-label=\"title\">` and `<div id=\"emvb-hotspot-<id>\" popover=\"auto\">` with the title and note. The native Popover API opens and closes it (Escape, click outside) with no script; where `position-area` is supported the note sits by its marker, elsewhere in the middle of the screen. `popover`, `popovertarget` and `popovertargetaction` joined the markup attribute allowlist |\n\n## 1.4 additions (W-1067–W-1086)\n\nAdditive, as in 1.2 and 1.3: layout schema 18 and design schema 17 stay, a page that uses a new\nelement type can't be shown by EmVB 1.3, which keeps it on save, and every new key is optional.\nTwo new element types:\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `search-form` (W-1073) | optional `action` (≤ 500; a site path or web address, unset or refused `/search`), `label` (≤ 80, unset \"Search\"), `placeholder` (≤ 120), `buttonText` (≤ 40, unset \"Search\") | none | `<form role=\"search\" aria-label=\"…\" method=\"get\" action=\"…\">` with `<input type=\"search\" name=\"q\" aria-label=\"…\">` and `<button type=\"submit\">`. No script: the browser sends `?q=` to the search page, as EmDash's own Search widget does. Never inside a `form` (the save refuses it, as a form in a form) |\n| `theme-toggle` (W-1067) | optional `label` (≤ 40, unset \"Dark mode\") | none | `<button type=\"button\" aria-pressed=\"false\" data-emvb-theme-toggle>`, shown only once the opt-in `theme` runtime marks it ready. The runtime keeps a choice in `localStorage` (`emvb-theme`) and sets `<html data-emvb-theme=\"light\\|dark\">`, which the page CSS reads before the system setting; `aria-pressed` says whether dark is on |\n\nNew optional keys on existing records:\n\n- `menu-item` `panelPartId` and `panelWidth`: a mega menu panel (see `menu` / `menu-item` above).\n- `motion.sticky` in a style record: scroll effects for a sticky or fixed element (see the style\n table above).\n- A colour variable's `dark` and a font variable's `family`, `faces` and `source` (see Design\n system document above).\n- A popup's triggers: `panel` (off-canvas panel), and `advanced.urlParams`, `advanced.from` and\n `advanced.until` (see [theme-parts.md](theme-parts.md)).\n\nExtensions may also put allowlisted classes on their output and ship their own stylesheet and\nruntime ([EXTENSIONS.md](../EXTENSIONS.md)); none of that is stored in a layout.\n";
|
|
6501
|
+
var layout_format_default = "# Layout format (schema 18)\n\nHow EmVB stores a page and its site-wide design, at layout schema 18 and design schema 17, schema contract 1.0 (W-925, D-065: renames, motion under `motion`, unknown keys kept; see [docs/SCHEMA.md](../SCHEMA.md)); Loop forever on an icon animation in W-853, D-059; the image editor's `edit` record on images in W-481; per-element direction, image link and caption, button icons, table of contents, container queries, and focal points in W-341 onward; visitor segments in W-329; Loop fields in W-330; `ch` lengths and negative margins in W-331). The source of truth is the code: `packages/emvb/src/core/schema/` (Zod schemas), `core/limits.ts`, `core/validate.ts` and `core/migrate/`. Update this file in the same change as any of them (ARCHITECTURE.md § Documentation).\n\n## Where it lives\n\n- **Pages** are entries in the hidden `emvb_pages` collection (D-012, D-019). The layout is the `layout` field (EmDash type `json`, shown with the read-only `emvb:layout` widget). The other fields are `title`, `canvas_mode` (`site-layout` or `blank`) and EmDash's own slug, status, revision and SEO fields. EmDash may hand a `json` field back as a string, so readers accept both (`renderStored` in `src/astro/render.ts`).\n- **The design system** (colours, fonts, font sizes, spacings; classes in W-030) is one document in plugin storage, collection `design`, key `system` (D-013). Editors save a draft at key `draft` through `POST /_emdash/api/plugins/emvb/design/save` (W-100, D-040 proposed). `POST .../design/publish` copies that draft onto `system`. The public `GET /_emdash/api/plugins/emvb/design` returns `system` only.\n\n## Page layout\n\n```json\n{\n \"schemaVersion\": 18,\n \"root\": {\n \"id\": \"root0001\",\n \"type\": \"container\",\n \"props\": {},\n \"style\": { \"flexDirection\": \"column\", \"gap\": { \"value\": 16, \"unit\": \"px\" } },\n \"children\": [\n {\n \"id\": \"head0001\",\n \"type\": \"heading\",\n \"props\": { \"text\": \"Welcome\", \"level\": 1 },\n \"style\": { \"color\": { \"var\": \"brand\" } }\n }\n ]\n }\n}\n```\n\n- `schemaVersion` is the literal `18` (D-031, D-032, D-034, D-036, D-038, D-039, D-041, D-042, D-044, W-141, D-045, W-160, W-307, W-329, W-341, W-481, W-885, W-925; older documents are upgraded on read by steps that change nothing, except v11 → v12, which rewrites a gradient's `from` and `to` into `stops`, and v17 → v18 (W-925), which renames `section` to `part-ref`, a node's `label` to `editorLabel` and a Loop's `itemPartId` to `partId`, and moves `transition`, `entrance`, `scrollMotion` and `iconAnimation` under `style.motion`). `root` is always a container.\n- Every node has `id` (4–24 of `A-Z a-z 0-9 _ -`, unique within the page), `type`, `props`, and optional `style`, `states` (W-089, see [State styles](#state-styles-w-089)), `classes` (up to 20 ids of 1–40 of `a-z 0-9 -`, rendered as `emvb-k-<id>`), `bind` (W-307), `variant` (an A/B arm, W-312) and `audience` (who sees it, W-313, W-329).\n- Objects are strict: unknown keys are rejected, not ignored.\n- **Unknown element types** (W-022 / R-033): a node whose `type` is not in the known set is kept on save (`id` rules still apply; `props` is an open record; every shared node field, including `devices` and `hiddenOn`, is allowed and checked as on known nodes; optional `children` are validated recursively). Public pages omit it; the editor shows a selectable placeholder. Damaged known nodes (wrong props) still fail validation with path-specific issues.\n\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `container` | optional `tag` (`div`, `section`, `header`, `footer`, `main`, `article`, `aside`, `nav`), optional `href` and `newTab` (the box is the link; a link inside a link is dropped) | `children: Node[]` (required, may be empty) | that tag (default `div`) with `class=\"emvb-container …\"` |\n| `layout-section` (shown as \"Section\", W-156) | optional `tag` (as `container`, default `section`), `contentWidth` length, `fullWidth` boolean | `children: Node[]` | that tag with `class=\"emvb-layout-section …\"`, wrapping `<div class=\"emvb-layout-section-inner\">` around the children; the inner box is at most `contentWidth` (default 1140 px, none with `fullWidth`) wide and centred |\n| `heading` | `text` (≤ 2000), `level` (1–6), optional `href` (≤ 2000) and `newTab` (W-141), optional `marks` (W-950, see below) | none | `<h1>`–`<h6>`; with a safe `href`, the text is wrapped in `<a class=\"emvb-heading-link\">` (colour and decoration inherited) |\n| `spacer` | `height` length | none | `<div aria-hidden=\"true\">` with height in CSS |\n| `divider` | `{}` | none | `<hr>` |\n| `text` | `text`, optional `tag` (`p` \\| `div`), optional `marks` (W-950) | none | `<p>` or `<div>`; formatted words as below |\n| `label` | `text` | none | `<span>` |\n| `link` | `text`, `href`, optional `newTab` | none | `<a href>` (+ `target`/`rel` when `newTab`) |\n| `button` | `text`, optional `href` and `newTab` | none | `<a href>` when `href` is safe, else `<button type=\"button\">` |\n| `list` | `items` (string[], ≤ 200), optional `ordered`; W-952: optional `marker` (`disc`, `circle`, `square`, `decimal`, `decimal-leading-zero`, `lower-alpha`, `upper-alpha`, `lower-roman`, `upper-roman`, `steps`, `none`; a number style or `steps` makes it numbered) and `start` (1–9999, numbered only) | none | `<ul>` or `<ol>` (with `start`) with `<li>`; the marker is `list-style-type`, `steps` adds `emvb-list--steps` (numbers in circles, CSS sent only when used) |\n| `image` | `src`, `alt`, optional `decorative`, `width`, `height`, `mediaId`, `edit` (editor-only image-editor record, never rendered; see below) | none | `<img loading=\"lazy\">` (decorative → empty `alt` + `role=\"presentation\"`) |\n| `icon` | `iconId` (a bundled Lucide id, or `<set prefix>:<name>` from the icon library, W-236), optional `iconSvg` (the picked icon's SVG, ≤ 32768 chars, W-234 / W-239; `iconId` `upload:<id>` for an uploaded SVG), optional `singleColor` (W-238: `true` paints a picked SVG's own fills, strokes and stops in `currentColor`), `size`, `decorative`, `title`, `href` (≤ 2000) and `newTab` (W-141); a non-empty `href` needs a `title` | none | Inline `<svg>`: `iconSvg` sanitized again at render (allowlist; size, id, role and aria attributes replaced), else the bundled Lucide icon (unknown id and no `iconSvg` → placeholder; never a remote URL); with a safe `href`, the svg is hidden inside `<a class=\"emvb-icon-link\" aria-label=\"title\">` |\n| `video` | `url`, `title`, optional `mediaId` | none | YouTube/Vimeo privacy `<iframe loading=\"lazy\">` or media `<video controls>` (no autoplay) |\n| `form` | `formId` (forms-plugin id; may be empty until bound), optional `nextLabel` and `prevLabel` (≤ 80, W-1065: the step buttons, unset \"Next\" and \"Previous\") | `children: Node[]` (form fields + submit; no nested forms) | Bound: `<form class=\"emvb-form ec-form\" …>`. Unbound: editor placeholder `data-emvb-form-unbound`; omitted on public (no forms runtime). |\n| `form-step` (W-1065) | optional `title` (≤ 200) | `children: Node[]`; only directly inside a `form` | `<fieldset class=\"emvb-form-step ec-form-page\" data-page=\"<n>\" tabindex=\"-1\">` with `<legend>` (untitled: `aria-label=\"Step <n+1>\"`): the forms plugin's multi-page markup. The form adds `<p data-ec-progress aria-live=\"polite\">` before the first step and `<div class=\"emvb-form-step-nav\">` with hidden `data-ec-prev` / `data-ec-next` buttons after the last. The forms script shows one step at a time and checks a step before Next; without it every step shows. Content outside the steps (an intro, Submit) stays outside the pages |\n| `text-input` | `field`, optional `label`, `placeholder`; W-1065: optional `inputType` (`number`, `date`), `min`, `max` (±10¹²), `step` (> 0), `minDate`, `maxDate` (YYYY-MM-DD, a real day) | none | labelled `<input class=\"ec-form-input\">` + `data-error-for`. Type: the bound field's own (`email`, `tel`, `url`, `number`, `date`), else `inputType` when the field is plain text. A number gets `min`/`max` (the field's own limits win) and `step` (unset `any`); a date gets `min`/`max` from `minDate`/`maxDate`. A range with nothing in it is left off |\n| `textarea` | `field`, optional `label`, `placeholder` | none | labelled `<textarea class=\"ec-form-input\">` + `data-error-for` |\n| `select` | `field`, optional `label`, `placeholder` (words the empty first choice; unset is \"Choose…\", W-686) | none | labelled `<select>` (options from the public form definition when available) |\n| `checkbox` | `field`, optional `label` | none | labelled `<input type=\"checkbox\" value=\"true\">` |\n| `radio` | `field`, optional `label`, `placeholder` | none | `<fieldset>` of radios (options from definition when available) |\n| `submit` | optional `label` | none | `<button type=\"submit\" class=\"ec-form-submit\">` |\n| `post-title` | optional `level` (1–6) | none | Dynamic heading from `ThemeDynamicData.post` |\n| `post-excerpt` | optional `maxWords` (whole number, 1–10000, W-177) | none | Dynamic excerpt paragraph; with `maxWords`, cut to that many words with \"…\" |\n| `post-content` | (none) | none | Dynamic body (Portable Text → safe blocks) |\n| `post-image` | optional `decorative` | none | Dynamic featured image when URL present |\n| `post-link` | optional `text`, `newTab` | none | Dynamic permalink; blank text → title |\n| `post-date` | optional `format`: `medium` (default), `short`, `long`, `full` or `numeric` (W-177) | none | `<time datetime>` with the published date in UTC; `numeric` is YYYY-MM-DD |\n| `post-author` | (none) | none | The author's name |\n| `pagination` | optional `prevText`, `nextText`, `showCount` and `countText` (`{page}` and `{total}`; unset text is \"Page {page} of {total}\"), `titleText` (the paged archive title, `{title}` and `{page}`, W-529), `archiveTitle` (replaces \"Posts\" as the posts archive title, ≤ 60, W-532), and screen reader names `navLabel` (\"Pagination\"), `pageLabel` (\"Page {page}\"), `prevLabel` and `nextLabel` (\"Previous page\" / \"Next page\", used when the text is only an arrow), each ≤ 60 (W-689) | none | `nav` of Previous, page numbers and Next. Nothing on a single page, with no archive data, or inside a Loop item |\n| `loop` | optional `partId` (the item part; `itemPartId` before schema 18); `perPage` (1–50, unset = 20) on an archive; a collection Loop also takes `collection`, `limit`, `order`, `display`, `columns`, `permalink`, `imageField`, `excerptField` and `filter` (see [Schema 13](#schema-13-the-w-307-feature-batch) and [Schema 14](#schema-14)) | `children: Node[]` (inline item template when no part id) | Repeats the item template for each post or collection entry |\n| `grid` | `columns` (1–12); optional `columnsTablet` and `columnsMobile` (1–12, W-139); optional `columnTracks`, `columnTracksTablet`, `columnTracksMobile` (1–12 tracks: `1fr`, `2fr`, `3fr`, `auto`, `min-content`, `max-content`, or a length) | `children: Node[]` | `display: grid` with that many equal columns, or the custom tracks when that device sets them; the device values go in the tablet and mobile media queries, and an unset one follows the next wider device |\n| `part-ref` (shown as \"Theme section\"; `section` before schema 18) | optional `partId` | `children: Node[]` (inline contents when no part id) | When `partId` is set, the published Section theme part's children replace the local ones |\n\nAn image's optional `edit` (W-481, D-061) is written by the image editor and never rendered. `src`, `mediaId`, `width` and `height` point at the edited file; `edit` points back at the original: `v` (`1`), `engine` (`\"photocn\"`), `engineVersion` (such as `\"0.1.2\"`), `recipe` (photocn's `RecipeV1`, strict: sliders −1 to 1, blur and curve points 0 to 1, at most 32 points per curve channel, straighten ±45°, a filter name of up to 32 letters, digits, spaces, `_` or `-`, a blend image only as a site path or `https:` URL, at most 16 KB as JSON), optional `originalMediaId`, `originalSrc` (up to 2000 characters), `output` (`format` `webp`, `jpeg` or `png`, optional `quality` 0.1 to 1, optional `maxSide` 16 to 10000 px, `stripGps` boolean) and `editedAt` (an ISO 8601 timestamp).\n\nEvery node may also carry an optional `editorLabel` (`label` before schema 18; 1–80 characters, trimmed; an editor-only name shown in Layers and on the canvas, never rendered, W-157), optional `htmlId` (CSS `id`, unique on the page, theme parts included: a header and a page are rendered apart, so EmVB can't rename an id you chose without breaking links to it (W-1077); since 1.1.2 an id that names a browser global such as `location` or `document` is kept in the layout but not rendered, S-12), `classes` (style-class ids from the design system, S4), `devices` and `hiddenOn` (W-096, below).\n\n**Forms (S5):** form fields are only valid inside a `form` (or under one). Pages with a form set `needsFormsRuntime`; the host route loads `EmVBFormsRuntime` so `initForms` handles AJAX submit. Pages without a form stay zero EmVB JS (R-031).\n\n### Style properties (W-017, extended in W-088)\n\n**Text marks (W-950).** `marks` on a Heading or Text is up to 100 ranges `{ \"start\", \"end\", \"bold\"?: true, \"italic\"?: true, \"color\"?: colour, \"href\"?, \"newTab\"?: true }` over its `text` (characters `start` to `end`, end not included, 0–2000). They render as `<strong>`, `<em>`, `<span class=\"emvb-mark-c<n>\">` (the colour as `--emvb-mark-<n>` on the element, up to 8 per element; `.emvb-mark-c<n>{color:var(--emvb-mark-<n>)}` is sent only when a page uses one) and `<a class=\"emvb-mark-link\">` (checked like any link; left out inside a linked heading). Ranges past the text are clipped when drawn, so editing the text never invalidates a page; the editor moves them with the words.\n\nLengths are `{ \"value\": 0–10000, \"unit\": \"px\" | \"rem\" | \"em\" | \"%\" | \"vw\" | \"vh\" | \"ch\" }` (`vw` and `vh` since W-088, `ch` since W-331). Colours are hex or `{ \"var\": \"<id>\" }`. A **size** is a length, a variable reference or `\"auto\"`. An **offset** is a size whose value may also be negative (−10000 to 10000). A **fluid size** (W-955) is `{ \"fluid\": { \"min\": 0–10000, \"max\": 0–10000 } }` in px: written as `clamp()` growing from `min` on 360 px wide screens to `max` on 1280 px ones (the formula the design's fluid sizes use); `fontSize`, `gap`, the width and height keys, padding and margins (and the offsets) take one.\n\n| Key | Value | CSS |\n| --- | --- | --- |\n| `flexDirection` | `row`, `column`, `row-reverse`, `column-reverse` | `flex-direction` |\n| `flexWrap` | `nowrap`, `wrap`, `wrap-reverse` | `flex-wrap` |\n| `justifyContent` | `flex-start`, `flex-end`, `center`, `space-between`, `space-around`, `space-evenly` | `justify-content` |\n| `alignItems` | `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-items` |\n| `gap` | length | `gap` |\n| `gridColumnSpan` / `gridRowSpan` (W-099) | whole number 1–12 | `grid-column` / `grid-row` as `span N` |\n| `gridColumnStart` / `gridRowStart` | whole number 1–13 | `grid-column` / `grid-row` as the line number, or `start / span N` when a span is set too |\n| `width` / `height` | size | `width` / `height` |\n| `minWidth` / `maxWidth` / `minHeight` / `maxHeight` | length | matching size properties (`maxHeight` since W-088) |\n| `flexGrow`, `flexShrink` (W-954) | number 0–100 | `flex-grow`, `flex-shrink`: a Flexbox or Container child's share of free space, and of the shortfall |\n| `flexBasis` (W-954) | length or `auto` | `flex-basis`: the child's starting size along the row or column |\n| `alignSelf` (W-954) | `auto`, `stretch`, `flex-start`, `flex-end`, `center`, `baseline` | `align-self`: the child's own cross-axis alignment (`auto` follows the parent's Align) |\n| `order` (W-954) | whole number −99 to 99 | `order`: the child's place among its siblings (lower first) |\n| `overflow` | `visible`, `hidden`, `clip`, `scroll`, `auto` | `overflow` |\n| `overflowX`, `overflowY` (W-957) | same as `overflow` | `overflow-x`, `overflow-y`, after `overflow` so one axis wins |\n| `aspectRatio` | `\"auto\"` or `\"w/h\"` with whole numbers 1–9999, such as `\"16/9\"` | `aspect-ratio` (`16 / 9`) |\n| `objectFit` | `fill`, `contain`, `cover`, `none`, `scale-down` | `object-fit` (the editor offers it on Image and Video) |\n| `objectPosition` (W-957) | `center`, `top`, `bottom`, `left`, `right`, `top left`, `top right`, `bottom left`, `bottom right` | `object-position` (Image and Video) |\n| `paddingTop` / `Right` / `Bottom` / `Left` | length | `padding-*` |\n| `marginTop` / `Right` / `Bottom` / `Left` | offset (negative since W-331) | `margin-*` |\n| `position` | `static`, `relative`, `absolute`, `fixed`, `sticky` | `position` |\n| `top` / `right` / `bottom` / `left` | offset | matching inset properties |\n| `zIndex` | whole number −9999 to 9999 | `z-index` |\n| `fontFamily` | a font stack (1–200, checked as safe) or a font variable | `font-family` |\n| `fontSize` | length | `font-size` |\n| `lineHeight` | length, or a unitless number 0–100 | `line-height` |\n| `letterSpacing` | length whose value may be negative (−10000 to 10000) | `letter-spacing` |\n| `fontWeight` | `100`–`900` in steps of 100, `normal`, `bold` | `font-weight` |\n| `textAlign` | `left`, `center`, `right`, `justify` | `text-align` |\n| `textTransform` | `none`, `uppercase`, `lowercase`, `capitalize` | `text-transform` |\n| `textDecoration` | `none`, `underline`, `overline`, `line-through` | `text-decoration` (W-113; a button sets `none` in its base CSS) |\n| `markerColor`, `markerSize` (W-952, Lists) | colour; length | `--emvb-marker-color`, `--emvb-marker-size`, read by the marker and step rules (sent only when a page sets them) |\n| `fontStyle` (W-957) | `normal`, `italic` | `font-style` |\n| `whiteSpace` (W-957) | `normal`, `nowrap`, `pre-line`, `pre-wrap` | `white-space` (a Text element defaults to `pre-line`) |\n| `overflowWrap` (W-957) | `normal`, `break-word`, `anywhere` | `overflow-wrap` |\n| `color` / `backgroundColor` / `borderColor` | colour | matching colour properties |\n| `backgroundImage` (W-094) | http(s) URL or a site path, no spaces, quotes or parentheses | `background-image` as `url(\"…\")`. With no size, position or repeat: `cover`, `center`, `no-repeat` |\n| `backgroundVideo` | the same URL rule as `backgroundImage` | a muted, looping `<video>` behind the content |\n| `backgroundSize` | `auto`, `cover`, `contain` | `background-size` (the image layer) |\n| `backgroundPosition` | `center`, an edge (`top`, `bottom`, `left`, `right`) or a corner (`top left` and the other three) | `background-position` |\n| `backgroundRepeat` | `no-repeat`, `repeat`, `repeat-x`, `repeat-y` | `background-repeat` |\n| `gradient` | `{ type, angle?, position?, stops }`: `type` `linear`, `radial` or `conic`; `angle` whole degrees 0–360 (the linear direction, default 180, or the conic start, default 0); `position` (the radial centre, default `center`) takes the `backgroundPosition` values; `stops` are 2–10 `{ color, at }`, `color` a colour and `at` a whole % 0–100 | `linear-gradient`, `radial-gradient` (a circle) or `conic-gradient`, stops in `at` order, behind the image |\n| `overlay` | `{ color, opacity: 0–1 }`, or since W-949 `{ gradient, opacity?: 0–1 }` with the same `gradient` shape | a colour or gradient layer above the image (a scrim). Hex becomes 8-digit hex; a colour variable becomes `color-mix`; a gradient overlay's `opacity` (unset = 1) fades every stop |\n| `borderWidth` / `borderRadius` | length | matching border properties: every side or corner |\n| `borderTopWidth`, `borderRightWidth`, `borderBottomWidth`, `borderLeftWidth` (W-138) | length | `border-top-width`, `border-inline-end-width`, `border-bottom-width`, `border-inline-start-width`, after `border-width`, so a side beats it |\n| `borderTopLeftRadius`, `borderTopRightRadius`, `borderBottomRightRadius`, `borderBottomLeftRadius` (W-138) | length or a spacing variable | `border-start-start-radius`, `border-start-end-radius`, `border-end-end-radius`, `border-end-start-radius`, after `border-radius` |\n| `borderStyle` | `none`, `solid`, `dashed`, `dotted` | `border-style` |\n| `opacity` | number 0–1 (the editor shows 0–100 %) | `opacity` |\n| `boxShadow` | `{ x, y, blur, spread, color?, inset? }`: px numbers, `x`, `y` and `spread` −1000 to 1000, `blur` 0 to 1000; `color` is a colour; `inset` is a boolean | `box-shadow` as `[inset] Xpx Ypx Bpx Spx [colour]`; no colour means the text colour |\n| `filter` | `{ blur?, brightness?, contrast?, saturate?, grayscale?, hueRotate? }`, at least one set: `blur` 0–100 px, `brightness` / `contrast` / `saturate` 0–300 %, `grayscale` 0–100 %, `hueRotate` 0–360° | `filter`, functions always in that order, such as `blur(2px) grayscale(100%)` |\n| `backdropFilter` (W-957) | the same object as `filter` | `backdrop-filter`, applied to what is behind the element (frosted glass) |\n| `transform` (W-953) | `{ x?, y?, scale?, rotate? }`, at least one: `x` and `y` whole px −2000 to 2000, `scale` whole % 10–400, `rotate` whole degrees −360 to 360 | `translate`, `scale` and `rotate` (CSS's own properties, so an entrance never cancels it; a scroll motion or loop on the same property wins while it runs). In a hover state it is a lift; animate it with a `transform` transition |\n| `cursor` | `default`, `pointer`, `text`, `move`, `grab`, `not-allowed`, `help`, `crosshair`, `zoom-in` | `cursor` |\n| `motion.transition` (W-089, Normal only) | `{ duration, delay?, easing, property }`: `duration` and `delay` whole ms 0–2000; `easing` `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`; `property` `all`, `colors`, `opacity`, `shadow`, `filter`, `transform` (W-953). No other keys | `transition`, one entry per CSS property: `colors` is `color`, `background-color` and `border-color`; `shadow` is `box-shadow`; `transform` is `translate`, `scale` and `rotate`. For example `opacity 200ms ease-out 50ms` |\n| `motion.entrance` (W-101, Normal only) | `{ type, duration, delay?, trigger? }`: `type` is `fade`, `fade-up`, `fade-down`, `slide-up`, `slide-down` or `scale`; `duration` and `delay` whole ms 0–2000; `trigger` is `load` (default) or `view` (as it scrolls in; browsers without scroll-driven animations play it on load) | `animation` named `emvb-<type>`, once, `ease-out`, `both`. Reduced motion sets `animation: none` |\n| `motion.sticky` (W-1070, Normal only; 1.4) | `{ distance?, background?, shadow?, padding?, hide? }` (at least one effect) or `{ type: \"none\" }`. `distance` 10–2000 px (unset 120); `background` a colour; `shadow` true; `padding` a length (top and bottom); `hide` true | Page-scroll animations (`animation-timeline: scroll(root)`, range `0px <distance>px`) to the scrolled look, sent only where scroll-driven animations exist; off for reduced motion. `hide` (on any device) adds `data-emvb-sticky-hide` and the `sticky` runtime, which slides the element away while scrolling down (up, or down when it is held by `bottom` with no `top`) and back on scrolling up, never while focus is inside. Each device's `hide` is written as `--emvb-sticky-hide: 1` or `0` (Desktop `0` unless set; unset on a narrower device keeps the wider one's; `{ type: \"none\" }` is `0`), which the runtime reads at the current width. The slide is a Web Animation, so the element's own `transition` is untouched |\n| `motion.loop` (W-938, Normal only; 1.0) | `{ effects, duration, easing?, alternate?, loop? }` or `{ type: \"none\" }`. `effects` as `motion.scroll`; `duration` 200–20000 ms; `easing` a transition easing (default `ease-in-out`); `alternate` false plays one way; `loop: true` never stops | A time-based CSS animation; stops after about 5 s unless `loop`; off for reduced motion. The accessibility check flags Loop forever and runs over 5 s |\n| `motion.scroll` (W-319, Normal only; `scrollMotion` before schema 18) | `{ effects, range }` or `{ type: \"none\" }`. Each effect is `{ type, from, to }`: `type` is `fade`, `move-x`, `move-y`, `scale`, `rotate` or `blur` (one of each). `range` is `enter`, `cross`, `exit` or `page`. `none` stops motion a wider device set | CSS scroll-driven animations. Reduced motion, and browsers without them, show the element still |\n| `iconRotate` (W-237, icons) | whole degrees −360 to 360 | `--emvb-icon-rotate`, read by the icon's `svg` as `rotate` |\n| `iconFlip` (W-237, icons) | `none`, `horizontal`, `vertical`, `both` | `--emvb-icon-flip` (`1 1`, `-1 1`, `1 -1`, `-1 -1`), read by the `svg` as `scale` |\n| `iconScale` (W-237) | number 0.1–4 | `scale` on the element (the icon and its background shape) |\n| `iconStrokeWidth` (W-237, outline icons) | number 0.25–6 | `--emvb-icon-stroke`; applies when the stored SVG's root has a stroke width of 1, 1.5, 2, 2.5 or 3 (render moves it into an `emvb-icon-sw<w>` class) |\n| `iconShadow` (W-237, icons) | `{ x, y, blur, color? }`: px, `x` and `y` −100 to 100, `blur` 0–100 | `--emvb-icon-shadow` as `drop-shadow(Xpx Ypx Bpx [colour])`, read by the `svg` as `filter` (follows the outline) |\n| `motion.icon` (W-237, Normal only; `iconAnimation` before schema 18) | `{ type, duration }`: `type` `spin` or `pulse`; `duration` whole ms 200–10000; optional `loop: true` (W-853, D-059) keeps it running forever. Or `{ type: \"none\" }` (W-248), which stops an animation a device inherits from a wider one | `--emvb-icon-animation` (`emvb-icon-spin <ms> linear <runs>`, `emvb-icon-pulse <ms> ease-in-out <runs> alternate` or `none`; W-848: `<runs>` is as many whole runs as fit in 5 s, at least one, even for a pulse; with `loop: true` it is `infinite`); the icon base CSS turns it off under `prefers-reduced-motion: reduce` |\n\n**W-088 additions are additive.** Every new key and unit is optional and every earlier value keeps its meaning, so stored pages and classes are valid unchanged. The version moved to 2 (D-031) with a v1 → v2 step that changes nothing, so an older EmVB shows \"saved by a newer EmVB\" rather than an invalid-layout error. The keys are the same on `node.style` and on `design.classes[].style`. The generator builds each value from typed numbers and keywords only and runs the same `isSafeCssValue` gate as every other property; anything else is dropped with a `rejected-style` warning. A shadow colour bound to a colour variable counts as a use of that variable, and deleting the variable clears it from the page layout and from class styles.\n\n### State styles (W-089)\n\n`node.states` and `design.classes[].states` are `{ \"hover\"?, \"focus\"?, \"active\"? }`. Each state is a style object with the same keys, limits and variable references as `style`, except `motion` (transition, entrance, scroll and icon motion), which belongs to Normal only. Any other state name is refused. Adding `states` moved the version to 3 (D-032) with a v2 → v3 step that changes nothing.\n\n```json\n{\n \"id\": \"btn00001\",\n \"type\": \"button\",\n \"props\": { \"text\": \"Go\" },\n \"style\": { \"backgroundColor\": \"#1d4ed8\", \"motion\": { \"transition\": { \"duration\": 200, \"easing\": \"ease-out\", \"property\": \"colors\" } } },\n \"states\": { \"hover\": { \"backgroundColor\": \"#1e3a8a\" }, \"focus\": { \"borderColor\": \"#f59e0b\" } }\n}\n```\n\n- **Selectors.** `hover` is `:hover`, `focus` is `:focus-visible` (keyboard focus, so a mouse click leaves no focus style); a linked Heading or Icon also matches when its inner link has keyboard focus (`:has(> :is(.emvb-heading-link,.emvb-icon-link):focus-visible)`, W-242) and `active` is `:active`.\n- **Cascade.** Each selector's base rule is followed by its `:hover`, `:focus-visible` and `:active` rules, classes first and then the local rule. So a state rule beats every Normal rule (a class's Hover colour shows over a local Normal colour), within one state the local rule beats the class, and Active beats Focus, which beats Hover.\n- **Safety.** State values go through the same mappers and `isSafeCssValue` gate as `style`. A rejected value is dropped with a `rejected-style` warning naming `<state>.<key>` (such as `hover.color`); a `motion` inside a state is refused by validation and dropped by the renderer and reported the same way, and so is an unknown state name. An unknown variable in a state is reported like one in `style`. An element whose only styles are states still gets `emvb-e-<id>`.\n- **Reduced motion.** When any rule has a `transition`, the CSS ends with one `@media (prefers-reduced-motion: reduce){…{transition:none}}` block that lists exactly those selectors. Nothing else changes under reduced motion.\n- **Editor preview.** The canvas CSS repeats every state rule for `[data-emvb-state=\"hover\"|\"focus\"|\"active\"]`, and the editor sets that attribute on the selected element while a state is chosen in the Style tab. Public CSS has neither the attribute nor those selectors.\n\n### Per-device styles (W-096)\n\n`node.devices` and `design.classes[].devices` are `{ \"laptop\"?, \"tablet\"?, \"mobile\"? }` (`laptop` since W-956). Each is a style object with the same keys as `style`. Only keys that differ from the wider devices are stored. `node.hiddenOn` and `design.classes[].hiddenOn` are arrays of `\"desktop\"`, `\"laptop\"`, `\"tablet\"` and `\"mobile\"` (at most one of each). Desktop itself stays in `style`.\n\n- **Queries.** Laptop is `@media (max-width: 1366.98px)`, then tablet `@media (max-width: 1024.98px)`, then mobile `@media (max-width: 767.98px)`. A narrower screen matches every wider query, so the narrowest device wins on a shared key, and a laptop-only key still applies on tablets and phones. The tablet and mobile bounds match `deviceForWidth` (under 768 mobile, under 1025 tablet), which popup targeting and visitor rules use (a laptop is desktop there).\n- **Hide.** Each device has its own query, so `display: none` does not leak: desktop `(min-width: 1367px)`, laptop `(min-width: 1025px) and (max-width: 1366.98px)`, tablet `(min-width: 768px) and (max-width: 1024.98px)`, mobile `(max-width: 767.98px)`. An element hidden on both Desktop and Laptop gets the one rule `(min-width: 1025px)`. Before W-956, `\"desktop\"` meant every screen from 1025 px; schema 17 pages are upgraded to `[\"desktop\", \"laptop\", …]` on read, so they render byte for byte as before.\n- **Grids.** Column counts have no laptop value: laptops use the desktop columns. The `.98` keeps fractional widths from zoom or display scaling (1024.5, say) inside one device, so nothing slips between two hide queries (W-506).\n- **Wide screen (W-959, 1.1).** An own `style.wide` record holds the values for 2400 px and up, in `@media (min-width: 2400px)`, built on Desktop's (the narrower devices never overlap it). `style.wide.hidden` overrides the Desktop hide there: `true` adds `(min-width: 2400px)` for an element not hidden on Desktop; `false` on an element hidden on Desktop stops its Desktop rule at `2399.98px`. Without `hidden`, Wide screen follows Desktop and the CSS is what it was. The renderer reads it as one more device (`renderableNode` moves it to `devices.wide` and `wideHidden`). Grid column counts have no Wide screen value.\n- **States.** Hover, focus and active stay all-viewport. Device overrides edit Normal only.\n- **Version.** Adding these fields moved the version to 5 (D-036) with a v4 → v5 step that changes nothing.\n\n## Design system document\n\n```json\n{\n \"schemaVersion\": 17,\n \"variables\": {\n \"colors\": [{ \"id\": \"brand\", \"name\": \"Brand\", \"value\": \"#0055ff\" }],\n \"fonts\": [{ \"id\": \"body\", \"name\": \"Body\", \"value\": \"Noto Sans, sans-serif\" }],\n \"fontSizes\": [{ \"id\": \"lg\", \"name\": \"Large\", \"value\": { \"value\": 24, \"unit\": \"px\" } }],\n \"spacings\": [{ \"id\": \"md\", \"name\": \"Medium\", \"value\": { \"value\": 16, \"unit\": \"px\" } }]\n },\n \"classes\": [{ \"id\": \"card\", \"name\": \"Card\", \"style\": { \"paddingTop\": { \"value\": 16, \"unit\": \"px\" } } }]\n}\n```\n\n- Colour ids are 1–40 of `a-z 0-9 -`, names 1–60 characters, values hex as above. At most 200 colours.\n- A colour may set `dark` (a hex, 1.4, W-1067): its value when the visitor's system prefers dark and no Theme toggle chose light, and whenever one chose dark. The page CSS repeats those variables (with `color-scheme: dark`) under `@media (prefers-color-scheme: dark)` for `.emvb-root` outside `[data-emvb-theme=\"light\"]`, and for `.emvb-root` inside `[data-emvb-theme=\"dark\"]`. Colours without `dark` are the same in both.\n- A font may set `family`, `faces` and `source` (1.4, W-1072): its own WOFF2 files, written as `@font-face` rules on pages whose CSS uses the variable. [SCHEMA.md](../SCHEMA.md) has the limits and checks, [Custom fonts](../guides/custom-fonts.md) the editor side.\n- The document is at most 256 KiB (`MAX_DESIGN_BYTES`).\n- A font size or spacing variable may set `fluid: { min, max }` (px, 0–1000). It is emitted as `clamp()` between `fluidRange` (unset is 360 to 1280 px; `minWidth` must be less than `maxWidth`). `value` stays the fixed fallback (W-316).\n- `direction` is `ltr`, `rtl` or `auto` (unset is left to right). It is `dir` on every EmVB root, and hosts get it back for `<html dir>` (W-230).\n- `defaults` is a starting style per tag (`h1`–`h6`, `p`, `a`, `button`), emitted under `:where(.emvb-root)` so a class still wins. The `button` default also reaches Button elements that have a URL and so render as `<a>` (`:where(.emvb-root) a:where(.emvb-button)`, the same tag weight, after the `a` default so it wins over it there); Link elements get only the `a` default (1.4.1, W-1090).\n\n## Limits and validation\n\n`validateLayout()` runs on every save (the plugin's `beforeSave` hook) and on every read (editor and public render), in this order:\n\n1. **Size:** the JSON is at most 512 KiB (`MAX_LAYOUT_BYTES`) in UTF-8 bytes.\n2. **Version:** `upgradeLayout()` runs the migration chain up to the current version. A document from a newer EmVB is refused with \"Update EmVB to edit it\", never downgraded.\n3. **Structure:** at most 2000 nodes (`MAX_NODES`) and 24 levels (`MAX_DEPTH`), checked iteratively before parsing.\n4. **Schema:** the Zod schema above.\n5. **Ids:** every node id is unique.\n\nIssues carry a path such as `root.children[0].props.level`, which the editor uses to select the element at fault. A layout that fails on read renders nothing on the public page and logs only the page id (R-033).\n\n## Rendered output\n\n- The root gets `emvb-root`, each node `emvb-<type>` and, when its style, a state, a device override or a hide flag yields a rule, `emvb-e-<id>`. Invalid style values are dropped with a render warning. A reference to an unknown variable is kept and also reported as a warning. Unknown element types render nothing publicly and a placeholder with `data-emvb-id` in the editor (warning `unknown-type`). An unknown node still keeps `dir`, `container` and `query` (W-352), so a later version that understands the type still has them.\n- The CSS is, in order: `@font-face` rules for the custom font variables the CSS uses (W-1072, see [Custom fonts](../guides/custom-fonts.md)), variables on `.emvb-root` (`--emvb-c-*` colours, `--emvb-f-*` fonts, `--emvb-fs-*` font sizes, `--emvb-s-*` spacings) and the colours' dark values (W-1067), base CSS for the element types in use, then class rules (W-030), then one `.emvb-e-<id>{…}` rule per styled node (R-021). Each class and local rule is followed by its state rules, then the tablet media query, the mobile media query and the hide queries (see [Per-device styles](#per-device-styles-w-096)). A reduced-motion block closes the CSS when a transition is set (see [State styles](#state-styles-w-089)).\n- **Style classes** (`design.classes[]`): `{ id, name, style, states?, devices?, hiddenOn? }`. Elements list ids in `node.classes`; HTML gets `emvb-k-<id>` in that order. When two classes set the same property, the one later in `design.classes` wins, because its rule comes later in the stylesheet. Local `.emvb-e-<id>` rules come after every class, so local styles win. `classStylesInListOrder` feeds `resolveCascade` in that list order.\n- Length/font style props may use `{ \"var\": \"<id>\", \"from\": \"spacing\"|\"fontSize\"|\"font\" }` (colours keep `{ \"var\": \"<id>\" }`). Offsets (`top`, `right`, `bottom`, `left`) take spacing variables; the shadow colour takes a colour variable.\n- Text and attributes are escaped by the serializer. Public output has no scripts and no editor `data-emvb-*` attributes (such as `data-emvb-id`). The only `data-emvb-*` attributes it carries are these public hooks (`PUBLIC_DATA_ATTRIBUTES` in `core/public-attributes.ts`, kept in step with this list by a test): `data-emvb-theme-part` on a theme part's wrapper ([theme-parts.md](theme-parts.md#public-render)); `data-emvb-loop-item` (the post id) on each Loop item; `data-emvb-popup`, `data-emvb-popup-config` and `data-emvb-popup-dismiss` on popup chrome; `data-emvb-float`, `data-emvb-float-dismiss` and `data-emvb-float-edge` on float chrome; `data-emvb-menu-empty` on an empty Menu; the widget hooks their opt-in runtimes read: `data-emvb-alert-dismiss` (Alert), `data-emvb-lightbox` (Gallery), `data-emvb-arrows`, `data-emvb-dots`, `data-emvb-autoplay` and `data-emvb-loop` (Carousel), `data-emvb-counter` (Counter), `data-emvb-countdown` (Countdown), `data-emvb-map` (Map), `data-emvb-rotate` (Animated headline), `data-emvb-share-list` and `data-emvb-share` (Share buttons); `data-emvb-theme-toggle` on a Theme toggle (W-1067); `data-emvb-sticky-hide` on an element that hides while scrolling down (W-1070), or on a sticky header or footer part's wrapper (W-1097); and `data-emvb-ext` (the element type) on an extension element's wrapper. The runtimes may add their own state attributes after load (`data-emvb-menu-dismissed`, `data-emvb-ready`, `data-emvb-shown`, and `data-emvb-theme` on `<html>`).\n\n## Changing the format\n\n- Add a migration `LAYOUT_MIGRATIONS[n]` (pure, version n to n + 1) and bump `LAYOUT_SCHEMA_VERSION` in the same change.\n- Add fixtures and tests for the old and new shapes, and update this file.\n- `test/docs/layout-format.test.ts` checks this file's title, the \"literal `N`\" sentence and the JSON examples against the code, so a schema bump must update them.\n\n## S8 additive elements (W-072–W-074)\n\n- **`div-block`**: block container (`display:block`); children like Container. Optional `href` and `newTab`, like Container.\n- **`flexbox`**: flex container defaulting to row + wrap + gap (Container stays column). Optional `href` and `newTab`.\n- **`svg`**: `props.markup` (sanitized allowlist; no scripts/handlers/`use`/`foreignObject`); optional `title`, `decorative`, `size`. A valid non-square `viewBox` keeps its ratio: the longer side is `size` (48 when unset) and the other side scales. A square, missing, or unreadable `viewBox` stays a square of `size`.\n- **`tabs` / `tab-panel`**: Tabs hold only tab-panels. Public markup is CSS-only (radio + `:has()`); the optional tabs script only takes the hidden radios out of the tab order.\n- **`accordion` / `accordion-item`**: items are `<details>`. An item needs `summary` (1–200) and may start `open`. No script.\n- **`menu` / `menu-item`**: a `nav` (named by `label`, default \"Menu\") of links. `direction` is `row` or `column`. An item with children is a dropdown; `wide` stretches that panel across the menu. A menu with a dropdown can load the optional menu script so Escape closes it. An empty menu is a plain box, not a `nav`.\n - **Mega menu (W-1069, 1.4, additive):** `panelPartId` (string, at most 128) names a Section theme part whose layout fills the item's panel in place of its children; `panelWidth` (a length) is that panel's width, or its widest when `wide` (unset: its content's width, at most the screen less 2rem). The panel is the same `<details>` disclosure as any dropdown (class `emvb-menu-panel--mega`, item `emvb-menu-item--mega`), so it opens by click, tap, Enter or Space and on hover with a fine pointer, with no script; the menu script, loaded as for any dropdown, adds Escape and closing on a click outside. The part renders under the synced-section guards: a part already being rendered (a panel that shows itself, directly or through other parts) and parts past the depth limit (8) or the render's element budget count as missing. A missing, unpublished or empty part leaves the item's own children, so an item without children is a plain link. On phones (below 768px) the panel stacks inline under its item instead of floating. Its rules (`menu-mega` base CSS) are sent only with a page that renders a mega panel, so other menus' markup and CSS are unchanged.\n- **`grid`** also takes optional `href` and `newTab`.\n\n\n## Schema 13: the W-307 feature batch\n\nSchema 13 only adds optional fields, so a v12 document upgrades unchanged.\n\n### Collection Loops (W-308)\n\nA `loop` with `props.collection` (a collection slug) lists that collection's published entries\ninstead of the archive's posts. `limit` (1–50, default 6), `order` (`newest`, `oldest`, `title`),\n`display` (`list`, `grid`, `cards`) and `columns` (1–6) are optional. Hosts fill\n`dynamic.collections[loopId]` (see `collectCollectionLoops`). A `loop-empty` child is left out of\nthe item design and rendered when there are no entries; it is only valid inside a `loop`.\n\n### Data bindings (W-307)\n\nAny node may carry `bind`: prop name → `{ source, key }`. `source` is `post` (a post field such as\n`title`, or any plain field of the entry by name, for example `role`), `site` (a site setting:\n`title`, `tagline`, `url`, `social.github`…) or `param` (a URL parameter). Which props can be bound\nis fixed per element (`BINDABLE_FIELDS`: text, links, image source and alt). The typed prop stays as\nthe fallback when the source has no value. Bound values are plain text, capped at 500 characters,\nand go through the element's own escaping and link and image URL checks.\n\nA link or image bound to `param` only takes same-site URLs: relative ones, or absolute ones on the\npage's origin (hosts pass it as `dynamic.origin`). Anything else shows the typed value, unless the\nbinding sets `outside: true` (\"Allow outside sites\" in the editor). Anyone can craft a URL\nparameter, so that option lets them point the page's links and images at any site.\n\n### A/B tests and visitors (W-312, W-313, W-329)\n\nAny node may set `variant`: `{ test, arm, split? }`. `test` is a name of lowercase letters, digits and `-` (up to 32). `arm` is `a` or `b`. `split` (on the B element, 1–99, unset = 50) is the share of visitors who see B. The host picks one arm per visitor and keeps it in a cookie.\n\n`audience` shows or hides the element. Every field that is set must match, and `hide: true` flips that to \"everyone except\":\n\n- `countries`: two-letter codes, 1–50\n- `devices`: `mobile`, `tablet`, `desktop`\n- `visitor`: `new` or `returning`, from the first-party `emvb_seen` cookie (one year, HttpOnly). Only a page with this rule reads or sets it. `emvb({ visitorCookie: \"consent\" | \"never\" })` holds it back (W-1092), and then everyone counts as `new`\n- `hours`: `{ from, to }` (0–23 and 0–24; wraps past midnight when `to` < `from`) and `days` (0 = Sunday), in `timeZone` (an IANA name; unset = UTC)\n- `segments` (W-329): 1–20 names the host passes (`member`, `pro`), lowercase letters, digits, `-` and `_`\n\nA rule the host cannot check does not match. Pages with a variant or an audience are sent `Cache-Control: private, no-store`.\n\n## Schema 14\n\nSchema 14 only adds optional fields, so a v13 document upgrades unchanged.\n\n- **Visitor segments (W-329).** `audience.segments`, above. Hosts pass them as `resolveEmVBPage(Astro, { visitor: { segments } })` and the same option on `resolveThemeParts`. `country`, `device` and `returning` on that object replace what EmVB detects.\n- **Loop fields (W-330).** On a collection Loop, `permalink` is a site path containing `{slug}` or `{id}` (unset is `/<collection>/{slug}`). `imageField` and `excerptField` name the entry fields Post Image and Post Excerpt read (unset is `featured_image` and `excerpt`; since 1.4.1, an entry with no `featured_image` image shows its first image field, W-1090). The editor offers the collection's image fields as a list. An image field's value is read from its `src` or `url`, or, for an upload picked in EmDash's admin (which stores no `src`), from `meta.storageKey` as `/_emdash/api/media/file/<key>`, as EmDash's own image component does. `filter` is up to five `field=value` pairs separated by `;`. A taxonomy name filters by term, and the same field twice matches either value.\n- **`ch` and negative margins (W-331).** Lengths may use `ch`. Margins may be negative (−10000 to 10000). Padding stays 0 or more.\n\n## Internal proposal records (W-928)\n\nProposals are review data in the plugin-storage collection `emvb_proposals`, not page\nrevisions. A row holds `{ proposal, createdAt }`, keyed by a server-generated 16-hex id.\nThe version-1 proposal is `{ version: 1, target: { collection, id }, baseRevision,\nbaseDesignRevision, ops }`. The plugin adapter currently reads the target entry's\n`layout` field (native visual pages and theme parts); arbitrary host canvas-field\nselection is not part of this transport. `baseRevision` is EmDash's current `_rev`.\n`baseDesignRevision` is the effective draft style revision, or the published style\nrevision when no draft exists, or null on an empty site. It is checked only when\nclass/variable ops are present, so page-only proposals survive unrelated style edits.\n\nOperations run in list order against frozen schema 18 ids and names:\n\n- `insert`: `{ kind, parentId, index, node }` — a complete stored node/subtree.\n- `move`: `{ kind, id, parentId, index }` — uses editor drop rules; index addresses\n the destination children **before** removal, as in `moveNode`.\n- `update`: `{ kind, id, set }` — editable node fields only. `props` shallow-merges;\n other fields replace their whole value, and null clears an optional node field.\n `id`, `type` and `children` cannot be patched. Use `editorLabel`, `props.partId`\n and `style.motion`, not their old aliases.\n- `delete`: `{ kind, id }` — never the root.\n- `class`: `{ kind, id, value }` — full class upsert, or null to remove an existing id.\n- `variable`: `{ kind, group, id, value }` — full variable upsert/removal;\n group is `colors`, `fonts`, `fontSizes` or `spacings`. Payload ids must match the\n operation id. Names must already be clean and unique in their list; no truncation.\n\n`applyProposal(base, proposal, selectedIndexes?)` returns a new `{ layout, design }`\nonly: it cannot save, publish, acquire an edit lock, or change review/undo state.\nSelected indexes refer to the original list; selection order cannot reorder ops.\nEach selected intermediate result passes stored-layout/design validation, nesting\nrules and the existing URL/SVG/CSS/font allowlists. Unknown layout keys still use\nthe frozen contract's keep-and-ignore rules. A dependency on an omitted operation,\na missing id, a bad node, a duplicate id, an invalid index or any other refusal\naborts the entire preview. Nothing is partially returned or persisted. W-930 must\nfeed accepted results through normal undo and draft saves, including the existing\nsite-wide guards for shared-style deletion; this store never writes site styles.\n\nCreation checks **all** ops and re-reads the base before storage. `STALE_BASE` reports\nexpected/current revisions and asks the caller to read the current document and\nsubmit a rebased proposal; there is no merge/retry/override. Preparation rechecks the\nlive revisions, so keeping or reading an old proposal does not make it applicable.\nGet/list are review reads, not an applicability guarantee; malformed rows are refused\nby get and omitted by list. Per-isolate serialization matches saved sections; there\nis no distributed content transaction (the final draft save still needs its own CAS).\n\nBudgets: 100 ops, 512 KiB JSON, 64 JSON nesting levels, and 100 stored proposals per\nsite; resulting layouts/designs retain all existing byte/node/depth limits. Cycles,\nnon-JSON values and prototype-manipulation keys are refused before parsing.\n\nPlugin-local editor transport mirrors saved sections: `proposals` (target-filtered\nlist), `proposals/get`, `proposals/create`, `proposals/withdraw`. Every route requires\n`content:edit_any` and EmDash's private-request/CSRF guard. These are not public/MCP\nAPIs; W-929 adds MCP tools and W-930 adds review UI later. Withdrawal only removes\nreview data; it cannot affect a page. No per-op review states or agent publish path\nare implemented here.\n\n## 1.2 widgets (W-1018–W-1025)\n\nAdded in 1.2, additive: new element types only, so an older 1.x keeps them on save and leaves them out of\nthe page (see Unknown element types above). Each renders without script.\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `rating` (shown as \"Star rating\", W-1023) | `value` (0–10, any decimal; shown to one decimal), optional `max` (whole number 1–10, unset 5; a `value` above it shows as `max`, so lowering it never makes a page invalid), `label` (≤ 120; `{value}` and `{max}` are filled in; unset \"Rated {value} out of {max}\"), `size` (8–128 px per star, unset 20) | none | `<div role=\"img\" aria-label=\"Rated 4.5 out of 5\">` with one `aria-hidden` star SVG per point, filled in the element's text colour; a part-filled star is the filled star cut by its `viewBox` over a 25 % star. Right to left, stars fill from the right |\n| `alert` (W-1025) | `variant` (`info`, `success`, `warning`, `danger`), optional `title` (≤ 200), `text` (≤ 2000; line breaks kept), optional `hideIcon`, `dismissible`, `dismissLabel` (≤ 80, unset \"Dismiss\") | none | `<div role=\"note\" class=\"emvb-alert emvb-alert-<variant>\">` in the variant's colours (text on background at least 7:1, overridable by the element's styles), its `aria-hidden` icon unless `hideIcon`, then the title and text paragraphs. `dismissible` adds `<button type=\"button\" data-emvb-alert-dismiss aria-label=\"Dismiss\">`, hidden by CSS until the opt-in alerts runtime marks it ready; that script hides the Alert on press and moves focus to the next focusable element. The page then lists `\"alerts\"` in `runtimes` |\n| `icon-box` (W-1020) | `iconId` and optional `iconSvg` (as on `icon`), `iconSize` (8–512 px, unset 48), `title` (≤ 200), optional `titleLevel` (2–6, unset 3), `text` (≤ 2000, line breaks kept), optional `position` (`top`, `left`, `right`; unset `top`), `href`, `newTab` | none | `<div class=\"emvb-icon-box emvb-media-box emvb-media-box-<position>\">` with the icon `aria-hidden` in `.emvb-media-box-media`, then `<hN class=\"emvb-media-box-title\">` and `<p class=\"emvb-media-box-text\">`. With a safe `href` the title is wrapped in `<a class=\"emvb-media-box-link\">`, whose `::after` covers the box, so the whole box is clickable through one named link. An empty title or text is left out |\n| `image-box` (W-1021) | the picture keys of `image`: `src`, `alt` (required unless `decorative`), optional `mediaId`, `width`, `height`, `focalX`, `focalY` (kept for the media library; a box doesn't crop); optional `imageSize` (`small` 25 %, `medium` 40 %, `large` 60 %, `full`; the picture's share of the width when beside the words, unset `medium`); and the title, text, position and link keys of `icon-box` | none | as `icon-box`, class `emvb-image-box` (plus `emvb-image-box-<size>` unless medium), with `<img loading=\"lazy\" decoding=\"async\">` and its `width`/`height` in `.emvb-media-box-media`; no media part without a safe `src` |\n| `testimonial` (W-1022) | `quote` (≤ 2000, line breaks kept), `name` (≤ 200), optional `role` (≤ 200), optional photo keys `src`, `alt` (written by the media library, not rendered), `mediaId`, `width`, `height`, `focalX`, `focalY`; optional `rating` (0–10) and `ratingMax` (1–10, unset 5) | none | `<figure class=\"emvb-testimonial\">`: the rating as in `rating` (`role=\"img\"`, \"Rated 5 out of 5\") when `rating` is set, `<blockquote class=\"emvb-testimonial-quote\"><p>`, then `<figcaption>` with the photo (48 px, round, `alt=\"\"`: the name is beside it) and the name and role |\n| `social-icons` (W-1024) | optional `label` (≤ 80, unset \"Social media\"), `shape` (`plain`, `circle`, `rounded`, `square`; unset `plain`), `brandColors` | `children`: Social links only, at most 20 | `<ul class=\"emvb-social-icons emvb-social-<shape>\" aria-label=\"Social media\">`; icons are one em, so the element's font size sizes them (1.5em by default). Badges draw the icon in white on the text colour, or on each network's colour with `brandColors` |\n| `social-link` (W-1024) | `network` (one of `facebook`, `instagram`, `x`, `linkedin`, `youtube`, `tiktok`, `bluesky`, `mastodon`, `threads`, `github`, `pinterest`, `whatsapp`, `discord`, `twitch`, `reddit`, `dribbble`, `behance`, `telegram`, `spotify`, `email`, `rss`, `website`), `href` (≤ 2000), optional `label` (≤ 80, the link's name; unset the network's name), `newTab` | none; only inside `social-icons` | `<li class=\"emvb-social-link emvb-social-<network>\"><a href aria-label=\"Instagram\">` around the preset's `aria-hidden` SVG (Font Awesome Free, CC BY 4.0, generated into `core/icons/social.generated.ts`). Without a safe `href` the icon shows dimmed in a `<span aria-hidden>` with no link |\n| `gallery` (W-1019) | optional `layout` (`grid` squares or `masonry`; unset `grid`), `columns` (1–6, unset 3; at most 2 up to 1024 px wide and 1 up to 767 px), `lightbox`, `label` (≤ 80) | `children`: Gallery images only, at most 60 | `<ul class=\"emvb-gallery emvb-gallery-<layout> emvb-gallery-cols-<n>\">`, named by `label`. `lightbox` adds `data-emvb-lightbox` and lists `\"lightbox\"` in `runtimes`: that script turns each picture into a \"View larger: <alt>\" button opening one native modal `<dialog>` with Previous/Next (and arrow keys), a spoken \"2 of 5\", Close and Escape; focus returns to the picture |\n| `gallery-image` (W-1019) | the picture keys of `image` (`src`, `alt` required unless `decorative`, `mediaId`, `width`, `height`, `focalX`, `focalY`) and optional `caption` (≤ 500) | none; only inside `gallery` | `<li class=\"emvb-gallery-image\"><figure>` with a lazy `<img>` and its `<figcaption>`; no picture without a safe `src` |\n| `carousel` (W-1018) | optional `label` (≤ 80, unset \"Carousel\"), `perView` (1–4, unset 1; at most 2 up to 1024 px, 1 up to 767 px), `arrows`, `dots`, `autoplay`, `interval` (3–30 seconds, unset 6), `loop` | `children`: Slides only, at most 20 | `<section aria-roledescription=\"carousel\" aria-label=\"Carousel\">` with a focusable `<div class=\"emvb-carousel-track\" tabindex=\"0\">` that scrolls and snaps to each slide with no script (`aria-live` polite, off while autoplaying). `arrows`, `dots` or `autoplay` add `data-emvb-*` options and list `\"carousel\"` in `runtimes`: that script adds Previous/Next (disabled at the ends unless `loop`), one \"Go to slide n\" button per view position (`aria-current`), and for autoplay a Pause/Play button before the slides; autoplay pauses while hovered or focused and starts paused under `prefers-reduced-motion` |\n| `carousel-slide` (W-1018) | optional `label` (≤ 80) | `children: Node[]`; only inside `carousel` | `<div role=\"group\" aria-roledescription=\"slide\" aria-label=\"2 of 5\">` (or its `label`) |\n\n**Widget runtimes (W-1025).** `renderPage` returns `runtimes`, the opt-in widget scripts the rendered\nelements asked for (sorted; empty for most pages). `renderStored` and `resolveThemeParts` set it only\nwhen it is not empty. `EmVBPage` mounts them itself; a site layout mounts its theme parts' with\n`<EmVBWidgetRuntimes names={theme.runtimes} />` from `@perkyzz/emvb/astro/widgets`. The HTML/CSS\nexport writes each one next to the pages that use it (`assets/emvb-alerts.js`, `assets/emvb-lightbox.js`, `assets/emvb-carousel.js`). The names are `alerts`, `lightbox` and `carousel` (1.2); `counter`, `countdown`, `map`, `headline` and `share` (1.3); `sticky` (Hide while scrolling down) and `theme` (Theme toggle) (1.4); and `ext:<package>` for an extension's own runtime ([EXTENSIONS.md](../EXTENSIONS.md), 1.4).\n\n## 1.3 marketing widgets (W-1038–W-1048)\n\nNew element types only (layout schema stays 18): a page that uses them can't be opened by EmVB\n1.2, which keeps them on save without showing them. Each renders without script; the opt-in\nscripts are listed in `runtimes`.\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `counter` (W-1038) | `value` (−10¹² to 10¹²), optional `start` (same range, unset 0), `decimals` (0–3, unset 0), `separator` (`,` `.` space or `'`; unset none; with `.` the decimal mark is `,`), `prefix` and `suffix` (≤ 20), `title` (≤ 200), `countUp`, `duration` (300–5000 ms, unset 2000) | none | `<div class=\"emvb-counter\">` with `<p class=\"emvb-counter-number\">` (prefix, `<span class=\"emvb-counter-value\">` holding the final number, suffix) and the title paragraph. `countUp` adds `data-emvb-counter`, `data-from`, `data-to`, `data-decimals`, `data-separator` and `data-duration` to the value and lists `\"counter\"` in `runtimes`; that script counts from `start` when the number scrolls into view, with a hidden copy of the final number for screen readers while it counts, and does nothing under reduced motion |\n| `progress` (shown as \"Progress bar\", W-1039) | `value` (0–10⁶), optional `max` (above 0, ≤ 10⁶, unset 100; a `value` above it shows as full), `label` (≤ 120), `showValue`, `kind` (`meter` or `progressbar`, unset `meter`), `thickness` (2–48 px, unset 8), `grow` | none | `<div class=\"emvb-progress\">` with an optional head (the label and, with `showValue`, an `aria-hidden` percentage), then `<div role=\"meter\" aria-label=\"…\" aria-valuemin=\"0\" aria-valuemax aria-valuenow aria-valuetext=\"75%\">` holding an `aria-hidden` SVG: a 20 % track and a fill `rect` as wide as the share, in the element's text colour, no inline styles. `grow` adds the `emvb-progress-grow` class, whose fill grows in with a CSS scroll-driven animation, only where supported and not under reduced motion. Right to left, it fills from the right |\n| `countdown` (W-1040) | `target` (`YYYY-MM-DDTHH:MM[:SS]` with `Z` or a `±HH:MM` offset, a real date), optional `title` (≤ 200), `label` (≤ 40, unset \"Ends\"), `ticking`, `hideSeconds`, `expired` (`text`, `hide` or `link`, unset `text`), `expiredText` (≤ 200, unset \"This offer has ended.\"), `expiredHref` (a link, sanitised like any) | none | `<div class=\"emvb-countdown\">` with the title and `<p>Ends <time datetime=\"…\">1 Dec 2026, 09:00 UTC−5</time></p>`, the date written in the target's own offset. `ticking` adds `data-emvb-countdown`, `data-target` and `data-expired`, a clock (`aria-hidden` days, hours, minutes and seconds, without seconds under `hideSeconds`) with a `Pause` button (`aria-pressed`), and the ended paragraph (a link with `link`, none with `hide`); CSS hides the clock until the opt-in countdown runtime marks it ready and the ended text until it is shown. The runtime ticks every second (no live region), stops on Pause, and at the target shows the ended text and hides the clock, or hides the Countdown. The page then lists `\"countdown\"` in `runtimes` |\n| `map` (W-1041) | `address` (1–300, line breaks kept), optional `provider` (`osm` or `google`, unset `osm`), `lat` (−90 to 90) and `lng` (−180 to 180), `zoom` (1–19, unset 15), `linkText` (≤ 80, unset \"Open in OpenStreetMap\" or \"Open in Google Maps\"), `embed`, `height` (150–800 px, unset 360) | none | `<div class=\"emvb-map\">` with the address paragraph and `<a class=\"emvb-map-link\" rel=\"noopener\">` to the place (a search for the address, or a marker at `lat`/`lng`). `embed` (with `lat`/`lng` for OpenStreetMap) adds `data-emvb-map` and a `.emvb-map-frame` holding `data-src`, `data-title` (\"Map of\" the address's first line) and `data-height`, a \"Show the map\" button and a note naming the service; CSS hides it until the opt-in map runtime marks the Map ready. Pressed, the runtime replaces it with a titled, lazy `<iframe>` (only `https://www.openstreetmap.org/export/embed.html?…` or `https://www.google.com/maps?…`) and moves focus to it, so the page requests nothing from the map service before that. Hosts with a Content Security Policy add `frame-src https://www.openstreetmap.org https://www.google.com`. The page then lists `\"map\"` in `runtimes` |\n| `price-table` (shown as \"Price table\", W-1042) | `title` (≤ 120), optional `titleLevel` (2–6, unset 3), `description` (≤ 500), `price` (≤ 20, text such as `29.99` or `Free`), optional `currency` (≤ 5), `period` (≤ 40), `regularPrice` (≤ 20), `features` and `excluded` (≤ 30 lines of ≤ 200 each), `buttonText` (≤ 80), `buttonHref` (a link, sanitised), `newTab`, `featured`, `ribbon` (≤ 30, unset \"Featured\") | none | `<div class=\"emvb-price-table\">` (plus `emvb-price-table-featured` and a ribbon paragraph when `featured`), the title heading, the description, `<p class=\"emvb-price-table-price\">` with the regular price in `<s>` when on sale (with \"Regular price:\" and \"Sale price:\" for screen readers only), the amount with its currency and the period; a list of included features with a check mark and excluded ones with a cross, struck through and introduced as \"Not included:\" for screen readers; then the button link (left out without text or a safe link; `newTab` adds `target=\"_blank\" rel=\"noopener noreferrer\"`). No script |\n| `price-list` (shown as \"Price list\", W-1043) | optional `label` (≤ 80) | `children: Node[]`, Price list items only, at most 50 | `<ul class=\"emvb-price-list\" aria-label=\"…\">` (no name without `label`) |\n| `price-list-item` (W-1043) | `title` (≤ 120), `price` (≤ 20, text), optional `description` (≤ 500), `src` with an Image's picture keys and `alt` (≤ 500; unset or empty: decorative), `href` (a link, sanitised), `newTab` | none; only inside `price-list` | `<li class=\"emvb-price-list-item\">` with the picture first (`loading=\"lazy\"`), then `<p class=\"emvb-price-list-head\">` holding the title (a link with `href`), an `aria-hidden` dotted leader and the price, and the description paragraph. No script |\n| `cta` (shown as \"Call to action\", W-1044) | `title` (≤ 200), optional `titleLevel` (2–6, unset 3), `text`, `src` with an Image's picture keys and `alt` (unset or empty: decorative), `layout` (`behind`, `top`, `left`, `right`; unset `behind`), `buttonText` (≤ 80), `href` (a link, sanitised), `newTab`, `ribbon` (≤ 30) | none | `<div class=\"emvb-cta emvb-cta-<layout>\">` (`top` without a picture) with the ribbon, the picture in `.emvb-cta-media` (behind: covering the box under a 55 % black overlay, the words in white), then the title heading, text and button. With a safe `href` the title holds the one link, `emvb-cta-linked` stretches it over the whole box, and the button is an `aria-hidden` span; without one there is no link or button. No script |\n| `flip-box` (shown as \"Flip box\", W-1045) | `frontTitle` (≤ 200), optional `frontText`, `backTitle` (≤ 200), `backText`, `titleLevel` (2–6, unset 3), `buttonText` (≤ 80), `href` (a link, sanitised), `newTab`, `direction` (`right`, `left`, `up`, `down`; unset `right`), `toggleLabel` (≤ 40, unset \"Turn over\") | none | `<div class=\"emvb-flip-box emvb-flip-<direction>\">` holding `.emvb-flip-inner` with two faces stacked in one grid cell (the box is as tall as the taller face), each with its title and text, the back with the button link; then `<label class=\"emvb-flip-toggle\"><input type=\"checkbox\" class=\"emvb-flip-check\">Turn over</label>`. CSS turns the inner on hover (only under `(hover:hover)`), when the checkbox is ticked, and when keyboard focus is inside the back face; both faces stay in the accessibility tree. Reduced motion drops the transition. No script |\n| `headline` (shown as \"Animated headline\", W-1046) | optional `level` (1–6, unset 2), `before` and `after` (≤ 200), `highlight` (1–120), `mark` (`underline`, `circle`, `strike`, `none`; unset `underline`), `rotate` (≤ 10 words of ≤ 120), `rotating`, `interval` (1.5–10 s, unset 2.5), `turns` (1–5, unset 2) | none | `<hN class=\"emvb-headline emvb-headline-<mark>\">before <span class=\"emvb-headline-mark\">highlight</span> after</hN>`, counted as a heading by the accessibility check. The mark is drawn once by CSS (a growing gradient, or an `aria-hidden` SVG circle), already drawn under reduced motion. `rotating` with other words adds `data-emvb-rotate` (the words as JSON), `data-interval` and `data-turns` and lists `\"headline\"` in `runtimes`; the runtime hides the changing word from screen readers (they read the sentence with the first word), adds a Pause button after the heading, and stops on the first word after its rounds or on Pause; nothing rotates under reduced motion |\n| `share-buttons` (shown as \"Share buttons\", W-1047) | optional `label` (≤ 80, unset \"Share this page\"), `shape` (as Social icons), `brandColors`, `nativeShare` | `children: Node[]`, Share links only, at most 12 | `<ul class=\"emvb-share-buttons emvb-share-<shape>\" aria-label=\"Share this page\">`. `nativeShare` adds a last item with `<button type=\"button\" class=\"emvb-share-native\" data-emvb-share>Share…</button>`, hidden by CSS until the opt-in share runtime finds the browser's `navigator.share` and marks the list ready; pressed, it opens the share sheet for the page. The page then lists `\"share\"` in `runtimes` |\n| `share-link` (W-1047) | `network` (`facebook`, `x`, `linkedin`, `whatsapp`, `telegram`, `reddit`, `bluesky`, `threads`, `email`), optional `label` (≤ 80) | none; only inside `share-buttons` | `<li class=\"emvb-share-<network>\"><a href=\"…\" aria-label=\"Share on Facebook\" target=\"_blank\" rel=\"noopener noreferrer\">` with the network's `aria-hidden` icon; the address is the service's own share link with the page URL encoded in it (email: `mailto:?body=…`, same tab). The page URL comes from the host as `dynamic.pageUrl` (`resolveEmVBPage` and `resolveThemeParts` fill it with the request's origin and path when a layout has Share buttons); without it a public page renders no share links, and the editor uses `https://example.com/`. No tracking script |\n| `hotspots` (W-1048) | `src` and `alt` with an Image's picture keys and `decorative`, optional `label` (≤ 80, unset \"Points on the picture\") | `children: Node[]`, Hotspots only, at most 20 | `<div class=\"emvb-hotspots\">` with the picture (`loading=\"lazy\"`; the accessibility check wants its alt text as for an Image) and `<ol class=\"emvb-hotspots-list\" aria-label=\"…\">` of markers numbered by a CSS counter |\n| `hotspot` (W-1048) | `title` (1–120), optional `text` (≤ 1000), `x` and `y` (0–100 %), optional `xTablet`, `yTablet`, `xMobile`, `yMobile` (unset: the wider device's) | none; only inside `hotspots` | `<li>` placed by its own CSS rule (`left`/`top` in percent, tablet and phone values in their media queries), holding `<button type=\"button\" popovertarget=\"emvb-hotspot-<id>\" aria-label=\"title\">` and `<div id=\"emvb-hotspot-<id>\" popover=\"auto\">` with the title and note. The native Popover API opens and closes it (Escape, click outside) with no script; where `position-area` is supported the note sits by its marker, elsewhere in the middle of the screen. `popover`, `popovertarget` and `popovertargetaction` joined the markup attribute allowlist |\n\n## 1.4 additions (W-1067–W-1086)\n\nAdditive, as in 1.2 and 1.3: layout schema 18 and design schema 17 stay, a page that uses a new\nelement type can't be shown by EmVB 1.3, which keeps it on save, and every new key is optional.\nTwo new element types:\n\n| Type | `props` | Children | Renders as |\n| --- | --- | --- | --- |\n| `search-form` (W-1073) | optional `action` (≤ 500; a site path or web address, unset or refused `/search`), `label` (≤ 80, unset \"Search\"), `placeholder` (≤ 120), `buttonText` (≤ 40, unset \"Search\") | none | `<form role=\"search\" aria-label=\"…\" method=\"get\" action=\"…\">` with `<input type=\"search\" name=\"q\" aria-label=\"…\">` and `<button type=\"submit\">`. No script: the browser sends `?q=` to the search page, as EmDash's own Search widget does. Never inside a `form` (the save refuses it, as a form in a form) |\n| `theme-toggle` (W-1067) | optional `label` (≤ 40, unset \"Dark mode\") | none | `<button type=\"button\" aria-pressed=\"false\" data-emvb-theme-toggle>`, shown only once the opt-in `theme` runtime marks it ready. The runtime keeps a choice in `localStorage` (`emvb-theme`) and sets `<html data-emvb-theme=\"light\\|dark\">`, which the page CSS reads before the system setting; `aria-pressed` says whether dark is on |\n\nNew optional keys on existing records:\n\n- `menu-item` `panelPartId` and `panelWidth`: a mega menu panel (see `menu` / `menu-item` above).\n- `motion.sticky` in a style record: scroll effects for a sticky or fixed element (see the style\n table above).\n- A colour variable's `dark` and a font variable's `family`, `faces` and `source` (see Design\n system document above).\n- A popup's triggers: `panel` (off-canvas panel), and `advanced.urlParams`, `advanced.from` and\n `advanced.until` (see [theme-parts.md](theme-parts.md)).\n\nExtensions may also put allowlisted classes on their output and ship their own stylesheet and\nruntime ([EXTENSIONS.md](../EXTENSIONS.md)); none of that is stored in a layout.\n";
|
|
6502
6502
|
|
|
6503
6503
|
// skill/emvb-page-builder/SKILL.md
|
|
6504
6504
|
var SKILL_default = `---
|
|
@@ -12602,7 +12602,7 @@ var loop = {
|
|
|
12602
12602
|
kind: "text",
|
|
12603
12603
|
label: "Image field",
|
|
12604
12604
|
optional: true,
|
|
12605
|
-
message: "The field Post image shows, such as photo. Leave it empty for the featured image."
|
|
12605
|
+
message: "The field Post image shows, such as photo. Leave it empty for the featured image, or else the collection's first image field."
|
|
12606
12606
|
},
|
|
12607
12607
|
{
|
|
12608
12608
|
key: "excerptField",
|
|
@@ -15404,6 +15404,19 @@ function pruneEmptyLists(nodes) {
|
|
|
15404
15404
|
return keep;
|
|
15405
15405
|
}
|
|
15406
15406
|
|
|
15407
|
+
// ../emvb/src/core/sanitize/escape.ts
|
|
15408
|
+
var TEXT_ENTITIES = { "&": "&", "<": "<", ">": ">" };
|
|
15409
|
+
var ATTR_ENTITIES = { ...TEXT_ENTITIES, '"': """, "'": "'" };
|
|
15410
|
+
function escapeText(value) {
|
|
15411
|
+
return value.replace(/[&<>]/g, (ch) => TEXT_ENTITIES[ch] ?? ch);
|
|
15412
|
+
}
|
|
15413
|
+
function escapeAttr(value) {
|
|
15414
|
+
return value.replace(/[&<>"']/g, (ch) => ATTR_ENTITIES[ch] ?? ch);
|
|
15415
|
+
}
|
|
15416
|
+
|
|
15417
|
+
// ../emvb/src/core/theme/part-wrapper.ts
|
|
15418
|
+
var COPIED = new Set(["top", "bottom", "z-index", "--emvb-sticky-hide"]);
|
|
15419
|
+
|
|
15407
15420
|
// ../emvb/src/core/design/devices.ts
|
|
15408
15421
|
function hiddenOnEveryDevice(owner) {
|
|
15409
15422
|
if (!DEVICES.every((device) => owner.hiddenOn?.includes(device)))
|
|
@@ -15598,16 +15611,6 @@ var sizes = new WeakMap;
|
|
|
15598
15611
|
var THEME_STORAGE_KEY = "emvb-theme";
|
|
15599
15612
|
var THEME_BOOT_SCRIPT = `<script>try{var t=localStorage.getItem("${THEME_STORAGE_KEY}");if(t==="light"||t==="dark")document.documentElement.setAttribute("data-emvb-theme",t)}catch(e){}</script>`;
|
|
15600
15613
|
|
|
15601
|
-
// ../emvb/src/core/sanitize/escape.ts
|
|
15602
|
-
var TEXT_ENTITIES = { "&": "&", "<": "<", ">": ">" };
|
|
15603
|
-
var ATTR_ENTITIES = { ...TEXT_ENTITIES, '"': """, "'": "'" };
|
|
15604
|
-
function escapeText(value) {
|
|
15605
|
-
return value.replace(/[&<>]/g, (ch) => TEXT_ENTITIES[ch] ?? ch);
|
|
15606
|
-
}
|
|
15607
|
-
function escapeAttr(value) {
|
|
15608
|
-
return value.replace(/[&<>"']/g, (ch) => ATTR_ENTITIES[ch] ?? ch);
|
|
15609
|
-
}
|
|
15610
|
-
|
|
15611
15614
|
// ../emvb/src/core/render/vnode.ts
|
|
15612
15615
|
var TAGS = new Set([
|
|
15613
15616
|
"div",
|
|
@@ -15723,12 +15726,127 @@ var MAX_EXTENSION_CSS_BYTES = 256 * 1024;
|
|
|
15723
15726
|
var MAX_EXTENSION_RUNTIME_BYTES = 64 * 1024;
|
|
15724
15727
|
// ../emvb/src/core/extensions/namespace.ts
|
|
15725
15728
|
var KNOWN = new Set(KNOWN_ELEMENT_TYPES);
|
|
15729
|
+
function isExtensionType(type) {
|
|
15730
|
+
return type.startsWith("ext:");
|
|
15731
|
+
}
|
|
15726
15732
|
// ../emvb/src/core/extensions/schema.ts
|
|
15733
|
+
var EXT_MAX_STRING = MAX_TEXT_LENGTH;
|
|
15734
|
+
var EXT_MAX_ARRAY = 32;
|
|
15735
|
+
var EXT_MAX_OBJECT_KEYS = 32;
|
|
15736
|
+
var EXT_MAX_DEPTH = 4;
|
|
15737
|
+
var EXT_MAX_NUMBER = 1e9;
|
|
15727
15738
|
var FIELD_KINDS = new Set(["text", "textarea", "number", "int", "select", "boolean", "href"]);
|
|
15739
|
+
function compileAt(schema, depth) {
|
|
15740
|
+
if (depth > EXT_MAX_DEPTH) {
|
|
15741
|
+
return never();
|
|
15742
|
+
}
|
|
15743
|
+
switch (schema.type) {
|
|
15744
|
+
case "string": {
|
|
15745
|
+
const max = Math.min(schema.maxLength ?? EXT_MAX_STRING, EXT_MAX_STRING);
|
|
15746
|
+
const min = Math.max(0, schema.minLength ?? 0);
|
|
15747
|
+
let s = string2().max(max);
|
|
15748
|
+
if (min > 0)
|
|
15749
|
+
s = s.min(min);
|
|
15750
|
+
return schema.default !== undefined ? s.default(schema.default) : s;
|
|
15751
|
+
}
|
|
15752
|
+
case "number": {
|
|
15753
|
+
const min = schema.min ?? -EXT_MAX_NUMBER;
|
|
15754
|
+
const max = Math.min(schema.max ?? EXT_MAX_NUMBER, EXT_MAX_NUMBER);
|
|
15755
|
+
let n = number2().min(min).max(max);
|
|
15756
|
+
if (schema.integer)
|
|
15757
|
+
n = n.int();
|
|
15758
|
+
return schema.default !== undefined ? n.default(schema.default) : n;
|
|
15759
|
+
}
|
|
15760
|
+
case "boolean": {
|
|
15761
|
+
const b = boolean2();
|
|
15762
|
+
return schema.default !== undefined ? b.default(schema.default) : b;
|
|
15763
|
+
}
|
|
15764
|
+
case "enum": {
|
|
15765
|
+
const values = schema.values.filter((v) => typeof v === "string" && v.length <= 64).slice(0, 32);
|
|
15766
|
+
if (values.length === 0)
|
|
15767
|
+
return never();
|
|
15768
|
+
const e = _enum(values);
|
|
15769
|
+
return schema.default !== undefined && values.includes(schema.default) ? e.default(schema.default) : e;
|
|
15770
|
+
}
|
|
15771
|
+
case "array": {
|
|
15772
|
+
const maxItems = Math.min(schema.maxItems ?? EXT_MAX_ARRAY, EXT_MAX_ARRAY);
|
|
15773
|
+
const a = boundedArray(compileAt(schema.items, depth + 1), maxItems);
|
|
15774
|
+
return schema.default !== undefined ? a.default([...schema.default]) : a;
|
|
15775
|
+
}
|
|
15776
|
+
case "object": {
|
|
15777
|
+
const keys = Object.keys(schema.properties).slice(0, EXT_MAX_OBJECT_KEYS);
|
|
15778
|
+
const shape = {};
|
|
15779
|
+
const required = new Set(schema.required ?? []);
|
|
15780
|
+
for (const key of keys) {
|
|
15781
|
+
if (!/^[a-zA-Z][a-zA-Z0-9_]{0,31}$/.test(key))
|
|
15782
|
+
continue;
|
|
15783
|
+
const prop = schema.properties[key];
|
|
15784
|
+
if (!prop)
|
|
15785
|
+
continue;
|
|
15786
|
+
const compiled = compileAt(prop, depth + 1);
|
|
15787
|
+
shape[key] = required.has(key) ? compiled : compiled.optional();
|
|
15788
|
+
}
|
|
15789
|
+
return object(shape).strict();
|
|
15790
|
+
}
|
|
15791
|
+
default:
|
|
15792
|
+
return never();
|
|
15793
|
+
}
|
|
15794
|
+
}
|
|
15795
|
+
function compileExtensionProps(schema) {
|
|
15796
|
+
return compileAt(schema, 0);
|
|
15797
|
+
}
|
|
15798
|
+
function schemaDefaults(schema) {
|
|
15799
|
+
if (schema.type !== "object")
|
|
15800
|
+
return {};
|
|
15801
|
+
const out = {};
|
|
15802
|
+
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
15803
|
+
if ("default" in prop && prop.default !== undefined)
|
|
15804
|
+
out[key] = prop.default;
|
|
15805
|
+
}
|
|
15806
|
+
return out;
|
|
15807
|
+
}
|
|
15808
|
+
function validateExtensionProps(schema, input) {
|
|
15809
|
+
const compiled = compileExtensionProps(schema);
|
|
15810
|
+
const result = compiled.safeParse(input ?? {});
|
|
15811
|
+
if (result.success) {
|
|
15812
|
+
const props = result.data && typeof result.data === "object" && !Array.isArray(result.data) ? result.data : {};
|
|
15813
|
+
return { ok: true, props };
|
|
15814
|
+
}
|
|
15815
|
+
return { ok: false, props: schemaDefaults(schema) };
|
|
15816
|
+
}
|
|
15728
15817
|
// ../emvb/src/core/extensions/placeholder.ts
|
|
15729
15818
|
var EXTENSION_PLACEHOLDER_CSS = ".emvb-ext-missing{margin:0;padding:12px 16px;border:1px dashed currentColor;opacity:0.7;font:inherit}" + ".emvb-ext{min-width:0}";
|
|
15730
15819
|
// ../emvb/src/core/extensions/registry.ts
|
|
15731
15820
|
var KEY = Symbol.for("emvb.extensions.v1");
|
|
15821
|
+
function store() {
|
|
15822
|
+
const g = globalThis;
|
|
15823
|
+
if (!g[KEY])
|
|
15824
|
+
g[KEY] = { byId: new Map, manifests: [] };
|
|
15825
|
+
return g[KEY];
|
|
15826
|
+
}
|
|
15827
|
+
function extensionAssets(id) {
|
|
15828
|
+
return store().assets?.get(id);
|
|
15829
|
+
}
|
|
15830
|
+
function listedExtensionManifests() {
|
|
15831
|
+
return store().manifests.map((m) => {
|
|
15832
|
+
const assets = extensionAssets(m.id);
|
|
15833
|
+
return assets ? Object.assign({}, m, { assets }) : m;
|
|
15834
|
+
});
|
|
15835
|
+
}
|
|
15836
|
+
function liveElement(type) {
|
|
15837
|
+
const manifests = store().manifests;
|
|
15838
|
+
for (const manifest of manifests) {
|
|
15839
|
+
const elManifest = manifest.elements.find((e) => e.type === type);
|
|
15840
|
+
if (!elManifest)
|
|
15841
|
+
continue;
|
|
15842
|
+
const extension = store().byId.get(manifest.id);
|
|
15843
|
+
const element = extension?.elements?.find((e) => e.name === elManifest.name);
|
|
15844
|
+
if (!extension || !element)
|
|
15845
|
+
continue;
|
|
15846
|
+
return { extension, element, manifest: elManifest };
|
|
15847
|
+
}
|
|
15848
|
+
return;
|
|
15849
|
+
}
|
|
15732
15850
|
// ../emvb/src/core/extensions/safe-nodes.ts
|
|
15733
15851
|
var EXT_CLASSES = new WeakMap;
|
|
15734
15852
|
var KNOWN2 = new Set(KNOWN_ELEMENT_TYPES);
|
|
@@ -15763,7 +15881,6 @@ var POST_BIND_KEYS = [
|
|
|
15763
15881
|
{ key: "featuredImageAlt", label: "Featured image alt" }
|
|
15764
15882
|
];
|
|
15765
15883
|
var POST_KEYS = new Set(POST_BIND_KEYS.map((k) => k.key));
|
|
15766
|
-
|
|
15767
15884
|
// ../emvb/src/core/render/extras.ts
|
|
15768
15885
|
var BOX = new Set(["container", "div-block", "flexbox", "grid"]);
|
|
15769
15886
|
var FORMS_RUNTIME_ATTRS = new Set([
|
|
@@ -20262,13 +20379,61 @@ function typedField(type, raw) {
|
|
|
20262
20379
|
return {};
|
|
20263
20380
|
}
|
|
20264
20381
|
var MAX_FORM_STEPS = 20;
|
|
20382
|
+
var PLUGIN_FIELD_TYPES = {
|
|
20383
|
+
text: "text",
|
|
20384
|
+
email: "email",
|
|
20385
|
+
url: "url",
|
|
20386
|
+
tel: "tel",
|
|
20387
|
+
number: "number",
|
|
20388
|
+
date: "date",
|
|
20389
|
+
time: "text",
|
|
20390
|
+
password: "text",
|
|
20391
|
+
textarea: "textarea",
|
|
20392
|
+
select: "select",
|
|
20393
|
+
radio: "radio",
|
|
20394
|
+
checkbox: "checkbox",
|
|
20395
|
+
acceptance: "checkbox"
|
|
20396
|
+
};
|
|
20397
|
+
function formFieldName(candidates, taken, fallback) {
|
|
20398
|
+
let base = "";
|
|
20399
|
+
for (const { text, lower } of candidates) {
|
|
20400
|
+
const clean = (text ?? "").normalize("NFKD").replaceAll(/[\u0300-\u036f]/g, "").trim().replaceAll(/[^a-zA-Z0-9_-]+/g, "_").replace(/^[^a-zA-Z]+/, "").replace(/[_-]+$/, "").slice(0, 72);
|
|
20401
|
+
if (clean && FIELD_NAME_PATTERN.test(clean)) {
|
|
20402
|
+
base = lower ? clean.toLowerCase() : clean;
|
|
20403
|
+
break;
|
|
20404
|
+
}
|
|
20405
|
+
}
|
|
20406
|
+
base ||= fallback;
|
|
20407
|
+
let name = base;
|
|
20408
|
+
for (let n = 2;taken.has(name); n++)
|
|
20409
|
+
name = `${base}_${n}`;
|
|
20410
|
+
return name;
|
|
20411
|
+
}
|
|
20412
|
+
function formOptions(value) {
|
|
20413
|
+
const options = [];
|
|
20414
|
+
const seen = new Set;
|
|
20415
|
+
for (const line of (str(value) ?? "").split(/\r?\n/).slice(0, 100)) {
|
|
20416
|
+
const [rawLabel = "", rawValue] = line.split("|");
|
|
20417
|
+
const label = plain(rawLabel).text.trim().slice(0, 200);
|
|
20418
|
+
const option = (rawValue === undefined ? label : plain(rawValue).text.trim()).slice(0, 200);
|
|
20419
|
+
if (!label || !option || seen.has(option))
|
|
20420
|
+
continue;
|
|
20421
|
+
seen.add(option);
|
|
20422
|
+
options.push({ label, value: option });
|
|
20423
|
+
}
|
|
20424
|
+
return options;
|
|
20425
|
+
}
|
|
20426
|
+
var isOn = (value) => value === true || value === "true" || value === "yes";
|
|
20265
20427
|
var form2 = (s, ctx, el) => {
|
|
20266
20428
|
const fields = Array.isArray(s["form_fields"]) ? s["form_fields"].slice(0, 100) : [];
|
|
20267
20429
|
const loose = [];
|
|
20268
20430
|
const steps = [];
|
|
20431
|
+
const loosePlan = [];
|
|
20432
|
+
const stepPlans = [];
|
|
20269
20433
|
const names = new Set;
|
|
20270
20434
|
let nextLabel = "";
|
|
20271
20435
|
let prevLabel = "";
|
|
20436
|
+
let checkboxLists = 0;
|
|
20272
20437
|
fields.forEach((raw, i) => {
|
|
20273
20438
|
if (!isRecord3(raw))
|
|
20274
20439
|
return;
|
|
@@ -20277,6 +20442,7 @@ var form2 = (s, ctx, el) => {
|
|
|
20277
20442
|
if (steps.length >= MAX_FORM_STEPS)
|
|
20278
20443
|
return;
|
|
20279
20444
|
steps.push({ title: plain(raw["field_label"]).text.slice(0, 200), children: [] });
|
|
20445
|
+
stepPlans.push([]);
|
|
20280
20446
|
nextLabel ||= plain(raw["next_button"]).text.slice(0, 80);
|
|
20281
20447
|
prevLabel ||= plain(raw["previous_button"]).text.slice(0, 80);
|
|
20282
20448
|
return;
|
|
@@ -20286,11 +20452,9 @@ var form2 = (s, ctx, el) => {
|
|
|
20286
20452
|
ctx.note("skipped", el, `Form field type "${type}" was left out.`);
|
|
20287
20453
|
return;
|
|
20288
20454
|
}
|
|
20289
|
-
let name = str(raw["custom_id"]) ?? "";
|
|
20290
|
-
if (!FIELD_NAME_PATTERN.test(name) || name.length > 80 || names.has(name))
|
|
20291
|
-
name = `field_${i + 1}`;
|
|
20292
|
-
names.add(name);
|
|
20293
20455
|
const label = plain(raw["field_label"]).text.slice(0, 200) || (type === "acceptance" ? plain(raw["acceptance_text"]).text.slice(0, 200) : "");
|
|
20456
|
+
const name = formFieldName([{ text: str(raw["custom_id"]) }, { text: label, lower: true }, { text: type }], names, `field_${i + 1}`);
|
|
20457
|
+
names.add(name);
|
|
20294
20458
|
const placeholder = plain(raw["placeholder"]).text.slice(0, 200);
|
|
20295
20459
|
const field = node2(ctx, nodeType, {
|
|
20296
20460
|
field: name,
|
|
@@ -20298,21 +20462,43 @@ var form2 = (s, ctx, el) => {
|
|
|
20298
20462
|
...placeholder && nodeType !== "checkbox" ? { placeholder } : {},
|
|
20299
20463
|
...typedField(type, raw)
|
|
20300
20464
|
});
|
|
20465
|
+
const options = nodeType === "select" || nodeType === "radio" ? formOptions(raw["field_options"]) : [];
|
|
20466
|
+
if (type === "checkbox" && formOptions(raw["field_options"]).length > 1)
|
|
20467
|
+
checkboxLists += 1;
|
|
20468
|
+
const typed = typedField(type, raw);
|
|
20469
|
+
const planned = {
|
|
20470
|
+
name,
|
|
20471
|
+
label: label || name,
|
|
20472
|
+
type: PLUGIN_FIELD_TYPES[type] ?? "text",
|
|
20473
|
+
required: isOn(raw["required"]) || type === "acceptance",
|
|
20474
|
+
...placeholder && nodeType !== "checkbox" ? { placeholder } : {},
|
|
20475
|
+
...options.length > 0 ? { options } : {},
|
|
20476
|
+
...typed.min !== undefined ? { min: typed.min } : {},
|
|
20477
|
+
...typed.max !== undefined ? { max: typed.max } : {}
|
|
20478
|
+
};
|
|
20301
20479
|
const step = steps[steps.length - 1];
|
|
20302
|
-
if (step)
|
|
20480
|
+
if (step) {
|
|
20303
20481
|
step.children.push(field);
|
|
20304
|
-
|
|
20482
|
+
stepPlans[stepPlans.length - 1]?.push(planned);
|
|
20483
|
+
} else {
|
|
20305
20484
|
loose.push(field);
|
|
20485
|
+
loosePlan.push(planned);
|
|
20486
|
+
}
|
|
20306
20487
|
});
|
|
20307
|
-
if (steps.length > 0 && loose.length > 0)
|
|
20488
|
+
if (steps.length > 0 && loose.length > 0) {
|
|
20308
20489
|
steps.unshift({ title: "", children: loose.splice(0) });
|
|
20490
|
+
stepPlans.unshift(loosePlan.splice(0));
|
|
20491
|
+
}
|
|
20309
20492
|
const children = [
|
|
20310
20493
|
...loose,
|
|
20311
20494
|
...steps.map((step) => node2(ctx, "form-step", step.title ? { title: step.title } : {}, { children: step.children }))
|
|
20312
20495
|
];
|
|
20313
20496
|
const label = plain(s["button_text"]).text.slice(0, 80) || "Send";
|
|
20314
20497
|
children.push(node2(ctx, "submit", { label }));
|
|
20315
|
-
ctx.note("approximated", el, "
|
|
20498
|
+
ctx.note("approximated", el, "Each form needs connecting to an EmDash form before it shows on your site; the import can create it in EmDash Forms. Email actions weren't imported.");
|
|
20499
|
+
if (checkboxLists > 0) {
|
|
20500
|
+
ctx.note("approximated", el, "A checkbox list became one checkbox; its options weren't kept.");
|
|
20501
|
+
}
|
|
20316
20502
|
if (steps.length > 0) {
|
|
20317
20503
|
ctx.note("approximated", el, `Form steps became EmVB form steps; one Next and one Previous label serve every step, and the step indicator is EmDash's "Step 1 of 3".`);
|
|
20318
20504
|
}
|
|
@@ -20320,9 +20506,19 @@ var form2 = (s, ctx, el) => {
|
|
|
20320
20506
|
...steps.length > 0 && nextLabel ? { nextLabel } : {},
|
|
20321
20507
|
...steps.length > 0 && prevLabel ? { prevLabel } : {}
|
|
20322
20508
|
};
|
|
20323
|
-
|
|
20324
|
-
|
|
20325
|
-
|
|
20509
|
+
const built = node2(ctx, "form", { formId: "", ...labels }, { style: { gap: { value: 10, unit: "px" } }, children });
|
|
20510
|
+
const successMessage = plain(s["success_message"]).text.trim().slice(0, 500);
|
|
20511
|
+
const plan = {
|
|
20512
|
+
nodeId: built.id,
|
|
20513
|
+
name: plain(s["form_name"]).text.trim().slice(0, 200) || "Imported form",
|
|
20514
|
+
pages: steps.length > 0 ? steps.map((step, i) => step.title ? { title: step.title, fields: stepPlans[i] ?? [] } : { fields: stepPlans[i] ?? [] }) : [{ fields: loosePlan }],
|
|
20515
|
+
submitLabel: label,
|
|
20516
|
+
...successMessage ? { successMessage } : {},
|
|
20517
|
+
...labels
|
|
20518
|
+
};
|
|
20519
|
+
if (ctx.forms.length < 50)
|
|
20520
|
+
ctx.forms.push(plan);
|
|
20521
|
+
return [built];
|
|
20326
20522
|
};
|
|
20327
20523
|
function menuItems(ctx, links, depth = 0) {
|
|
20328
20524
|
return links.slice(0, 50).map((entry) => node2(ctx, "menu-item", {
|
|
@@ -21191,6 +21387,94 @@ class McpToolError extends Error {
|
|
|
21191
21387
|
}
|
|
21192
21388
|
}
|
|
21193
21389
|
|
|
21390
|
+
// ../emvb/src/mcp/extensions.ts
|
|
21391
|
+
function registeredExtensionElements() {
|
|
21392
|
+
return listedExtensionManifests().flatMap((manifest) => manifest.elements.filter((element) => liveElement(element.type) !== undefined).map((element) => Object.assign({ extensionId: manifest.id }, element)));
|
|
21393
|
+
}
|
|
21394
|
+
var withDefault = (out, value) => value === undefined ? out : Object.assign(out, { default: value });
|
|
21395
|
+
function extensionJsonSchema(schema) {
|
|
21396
|
+
switch (schema.type) {
|
|
21397
|
+
case "string":
|
|
21398
|
+
return withDefault({
|
|
21399
|
+
type: "string",
|
|
21400
|
+
maxLength: Math.min(schema.maxLength ?? MAX_TEXT_LENGTH, MAX_TEXT_LENGTH),
|
|
21401
|
+
...schema.minLength ? { minLength: schema.minLength } : {}
|
|
21402
|
+
}, schema.default);
|
|
21403
|
+
case "number":
|
|
21404
|
+
return withDefault({
|
|
21405
|
+
type: schema.integer ? "integer" : "number",
|
|
21406
|
+
...schema.min !== undefined ? { minimum: schema.min } : {},
|
|
21407
|
+
...schema.max !== undefined ? { maximum: schema.max } : {}
|
|
21408
|
+
}, schema.default);
|
|
21409
|
+
case "boolean":
|
|
21410
|
+
return withDefault({ type: "boolean" }, schema.default);
|
|
21411
|
+
case "enum":
|
|
21412
|
+
return withDefault({ type: "string", enum: [...schema.values] }, schema.default);
|
|
21413
|
+
case "array":
|
|
21414
|
+
return withDefault({
|
|
21415
|
+
type: "array",
|
|
21416
|
+
items: extensionJsonSchema(schema.items),
|
|
21417
|
+
maxItems: Math.min(schema.maxItems ?? 32, 32)
|
|
21418
|
+
}, schema.default);
|
|
21419
|
+
case "object":
|
|
21420
|
+
return {
|
|
21421
|
+
type: "object",
|
|
21422
|
+
properties: Object.fromEntries(Object.entries(schema.properties).map(([key, prop]) => [key, extensionJsonSchema(prop)])),
|
|
21423
|
+
...schema.required?.length ? { required: [...schema.required] } : {},
|
|
21424
|
+
additionalProperties: false
|
|
21425
|
+
};
|
|
21426
|
+
default:
|
|
21427
|
+
return {};
|
|
21428
|
+
}
|
|
21429
|
+
}
|
|
21430
|
+
function expected(schema) {
|
|
21431
|
+
switch (schema.type) {
|
|
21432
|
+
case "string":
|
|
21433
|
+
return `text of at most ${Math.min(schema.maxLength ?? MAX_TEXT_LENGTH, MAX_TEXT_LENGTH)} characters${schema.minLength ? ` and at least ${schema.minLength}` : ""}`;
|
|
21434
|
+
case "number":
|
|
21435
|
+
return `${schema.integer ? "a whole number" : "a number"}${schema.min !== undefined ? ` from ${schema.min}` : ""}${schema.max !== undefined ? ` up to ${schema.max}` : ""}`;
|
|
21436
|
+
case "boolean":
|
|
21437
|
+
return "true or false";
|
|
21438
|
+
case "enum":
|
|
21439
|
+
return `one of ${schema.values.join(", ")}`;
|
|
21440
|
+
case "array":
|
|
21441
|
+
return `a list of at most ${Math.min(schema.maxItems ?? 32, 32)} items`;
|
|
21442
|
+
default:
|
|
21443
|
+
return "an object";
|
|
21444
|
+
}
|
|
21445
|
+
}
|
|
21446
|
+
function propIssues(schema, props) {
|
|
21447
|
+
if (schema.type !== "object")
|
|
21448
|
+
return ["its props don't match its schema"];
|
|
21449
|
+
const issues = [];
|
|
21450
|
+
for (const [key, value] of Object.entries(props)) {
|
|
21451
|
+
const prop = schema.properties[key];
|
|
21452
|
+
if (!prop) {
|
|
21453
|
+
issues.push(`${key} isn't one of its props (${Object.keys(schema.properties).join(", ")})`);
|
|
21454
|
+
} else if (!validateExtensionProps({ type: "object", properties: { [key]: prop } }, { [key]: value }).ok) {
|
|
21455
|
+
issues.push(`${key} must be ${expected(prop)}`);
|
|
21456
|
+
}
|
|
21457
|
+
}
|
|
21458
|
+
for (const key of schema.required ?? []) {
|
|
21459
|
+
const prop = schema.properties[key];
|
|
21460
|
+
if (props[key] === undefined && !(prop && ("default" in prop) && prop.default !== undefined))
|
|
21461
|
+
issues.push(`${key} is required`);
|
|
21462
|
+
}
|
|
21463
|
+
return issues;
|
|
21464
|
+
}
|
|
21465
|
+
function checkedExtensionProps(type, props) {
|
|
21466
|
+
const live = liveElement(type);
|
|
21467
|
+
if (!live) {
|
|
21468
|
+
throw new McpToolError("REFUSED", `Unknown element type ${type}: no extension on this site provides it. Call list_element_types.`);
|
|
21469
|
+
}
|
|
21470
|
+
const given = props && typeof props === "object" && !Array.isArray(props) ? props : {};
|
|
21471
|
+
const result = validateExtensionProps(live.element.schema, given);
|
|
21472
|
+
if (result.ok)
|
|
21473
|
+
return result.props;
|
|
21474
|
+
const issues = propIssues(live.element.schema, given);
|
|
21475
|
+
throw new McpToolError("INVALID_INPUT", `Invalid props for ${type}: ${(issues.length ? issues : ["they don't match its schema"]).join("; ")}. Call list_element_types with this type for its props.`, { issues });
|
|
21476
|
+
}
|
|
21477
|
+
|
|
21194
21478
|
// ../emvb/src/mcp/read.ts
|
|
21195
21479
|
async function loadPage(ports, pageId) {
|
|
21196
21480
|
const page = await ports.getPage(pageId);
|
|
@@ -21290,8 +21574,7 @@ var SCHEMAS = new Map(KNOWN_NODE_SCHEMAS.map((schema) => [
|
|
|
21290
21574
|
schema.shape.props
|
|
21291
21575
|
]));
|
|
21292
21576
|
var sample = (type) => Object.assign({}, defaultElement(type, "sample"), { id: "sample" });
|
|
21293
|
-
function allowedParents(
|
|
21294
|
-
const child = sample(type);
|
|
21577
|
+
function allowedParents(child) {
|
|
21295
21578
|
return ELEMENT_DESCRIPTORS.map((d) => d.type).filter((parentType) => {
|
|
21296
21579
|
const parent = sample(parentType);
|
|
21297
21580
|
if (!isParentNode(parent))
|
|
@@ -21311,7 +21594,9 @@ var ListElementTypesOutput = object({
|
|
|
21311
21594
|
allowedParents: array(string2()),
|
|
21312
21595
|
props: unknown(),
|
|
21313
21596
|
example: unknown(),
|
|
21314
|
-
notes: string2().optional()
|
|
21597
|
+
notes: string2().optional(),
|
|
21598
|
+
fields: unknown().optional(),
|
|
21599
|
+
extension: string2().optional()
|
|
21315
21600
|
}))
|
|
21316
21601
|
});
|
|
21317
21602
|
var ELEMENT_NOTES = {
|
|
@@ -21325,28 +21610,53 @@ var ELEMENT_NOTES = {
|
|
|
21325
21610
|
accordion: "Holds only accordion-item children; summary is the visible question, the children are the answer. Set open: true on at most one item.",
|
|
21326
21611
|
"layout-section": "Use one per page band. props.contentWidth caps the inner width (for example 1200 px) while the background spans the screen."
|
|
21327
21612
|
};
|
|
21613
|
+
function extensionEntries(type) {
|
|
21614
|
+
return registeredExtensionElements().filter((element) => type === undefined || element.type === type).map((element) => {
|
|
21615
|
+
const example = {
|
|
21616
|
+
id: "sample",
|
|
21617
|
+
type: element.type,
|
|
21618
|
+
props: validateExtensionProps(element.schema, {}).props
|
|
21619
|
+
};
|
|
21620
|
+
return {
|
|
21621
|
+
type: element.type,
|
|
21622
|
+
name: element.label,
|
|
21623
|
+
group: element.group,
|
|
21624
|
+
container: false,
|
|
21625
|
+
allowedParents: allowedParents(example),
|
|
21626
|
+
props: extensionJsonSchema(element.schema),
|
|
21627
|
+
example: { type: element.type, props: example.props },
|
|
21628
|
+
fields: element.fields,
|
|
21629
|
+
extension: element.extensionId,
|
|
21630
|
+
notes: `An extension element from ${element.extensionId}. Its props are checked by the extension's schema; it holds no children.`
|
|
21631
|
+
};
|
|
21632
|
+
});
|
|
21633
|
+
}
|
|
21328
21634
|
function listElementTypes(input) {
|
|
21329
21635
|
const descriptors = input.type ? ELEMENT_DESCRIPTORS.filter((d) => d.type === input.type) : ELEMENT_DESCRIPTORS;
|
|
21330
|
-
|
|
21636
|
+
const extensions = extensionEntries(input.type);
|
|
21637
|
+
if (input.type && descriptors.length === 0 && extensions.length === 0) {
|
|
21331
21638
|
throw new McpToolError("NOT_FOUND", `Unknown element type ${input.type}.`);
|
|
21332
21639
|
}
|
|
21333
21640
|
return {
|
|
21334
|
-
elements:
|
|
21335
|
-
|
|
21336
|
-
|
|
21337
|
-
|
|
21338
|
-
|
|
21339
|
-
|
|
21340
|
-
|
|
21341
|
-
|
|
21342
|
-
|
|
21343
|
-
|
|
21344
|
-
|
|
21345
|
-
|
|
21346
|
-
|
|
21347
|
-
|
|
21348
|
-
|
|
21349
|
-
|
|
21641
|
+
elements: [
|
|
21642
|
+
...descriptors.map((d) => {
|
|
21643
|
+
const props = SCHEMAS.get(d.type);
|
|
21644
|
+
const example = sample(d.type);
|
|
21645
|
+
const entry = {
|
|
21646
|
+
type: d.type,
|
|
21647
|
+
name: d.name,
|
|
21648
|
+
group: d.group,
|
|
21649
|
+
container: isParentNode(example),
|
|
21650
|
+
allowedParents: allowedParents(example),
|
|
21651
|
+
props: props ? toJSONSchema(props, { unrepresentable: "any" }) : {},
|
|
21652
|
+
example: { type: example.type, props: example.props ?? {} }
|
|
21653
|
+
};
|
|
21654
|
+
if (ELEMENT_NOTES[d.type])
|
|
21655
|
+
entry["notes"] = ELEMENT_NOTES[d.type];
|
|
21656
|
+
return entry;
|
|
21657
|
+
}),
|
|
21658
|
+
...extensions
|
|
21659
|
+
]
|
|
21350
21660
|
};
|
|
21351
21661
|
}
|
|
21352
21662
|
var GetSiteStylesInput = strictObject({});
|
|
@@ -21575,6 +21885,39 @@ async function listVersions(ports, input) {
|
|
|
21575
21885
|
};
|
|
21576
21886
|
}
|
|
21577
21887
|
|
|
21888
|
+
// ../emvb/src/mcp/agent-defaults.ts
|
|
21889
|
+
var AGENT_SAMPLE_PROPS = {
|
|
21890
|
+
alert: ["title"],
|
|
21891
|
+
testimonial: ["role"],
|
|
21892
|
+
counter: ["suffix", "title"],
|
|
21893
|
+
progress: ["label"],
|
|
21894
|
+
countdown: ["title"],
|
|
21895
|
+
map: ["lat", "lng"],
|
|
21896
|
+
"price-table": [
|
|
21897
|
+
"description",
|
|
21898
|
+
"currency",
|
|
21899
|
+
"period",
|
|
21900
|
+
"features",
|
|
21901
|
+
"excluded",
|
|
21902
|
+
"buttonText",
|
|
21903
|
+
"buttonHref",
|
|
21904
|
+
"featured"
|
|
21905
|
+
],
|
|
21906
|
+
cta: ["text", "buttonText", "href"],
|
|
21907
|
+
"flip-box": ["frontText", "backTitle", "backText", "buttonText", "href"],
|
|
21908
|
+
headline: ["before", "after", "rotate"]
|
|
21909
|
+
};
|
|
21910
|
+
function agentDefaultElement(type, id) {
|
|
21911
|
+
const base = defaultElement(type, id);
|
|
21912
|
+
const sample = AGENT_SAMPLE_PROPS[type];
|
|
21913
|
+
if (!sample || !base.props)
|
|
21914
|
+
return base;
|
|
21915
|
+
const props = { ...base.props };
|
|
21916
|
+
for (const key of sample)
|
|
21917
|
+
delete props[key];
|
|
21918
|
+
return { ...base, props };
|
|
21919
|
+
}
|
|
21920
|
+
|
|
21578
21921
|
// ../emvb/src/mcp/queue.ts
|
|
21579
21922
|
var tails = new Map;
|
|
21580
21923
|
function queued(key, work) {
|
|
@@ -21720,7 +22063,7 @@ async function mutatePage(ports, tool, pageId, expectedRev, apply) {
|
|
|
21720
22063
|
if (!current.ok) {
|
|
21721
22064
|
throw new McpToolError("INVALID_LAYOUT", "The stored layout can't be read. Repair it in the editor.");
|
|
21722
22065
|
}
|
|
21723
|
-
const next = apply(current.layout);
|
|
22066
|
+
const next = apply(current.layout, page);
|
|
21724
22067
|
refuseUnsafeImageSources(current.layout, next.layout);
|
|
21725
22068
|
refuseUnsafeLinks(current.layout, next.layout);
|
|
21726
22069
|
refuseUnsafeSvg(current.layout, next.layout);
|
|
@@ -21848,13 +22191,23 @@ var BoundedElementSpec = preprocess((value, ctx) => {
|
|
|
21848
22191
|
}
|
|
21849
22192
|
return upgradeLegacyNode(value);
|
|
21850
22193
|
}, ElementSpec);
|
|
22194
|
+
function buildExtensionNode(spec) {
|
|
22195
|
+
const { type, props, children, ...rest } = spec;
|
|
22196
|
+
delete rest.id;
|
|
22197
|
+
const checked = checkedExtensionProps(type, props ?? {});
|
|
22198
|
+
if (children?.length)
|
|
22199
|
+
refused(`${type} is an extension element and holds no children.`);
|
|
22200
|
+
return { ...rest, id: "new", type, props: checked };
|
|
22201
|
+
}
|
|
21851
22202
|
function buildNode(spec) {
|
|
22203
|
+
if (isExtensionType(spec.type))
|
|
22204
|
+
return buildExtensionNode(spec);
|
|
21852
22205
|
if (!KNOWN_TYPES.has(spec.type)) {
|
|
21853
22206
|
refused(`Unknown element type ${spec.type}. Call list_element_types.`);
|
|
21854
22207
|
}
|
|
21855
22208
|
const { type, props, children, ...rest } = spec;
|
|
21856
22209
|
delete rest.id;
|
|
21857
|
-
const base =
|
|
22210
|
+
const base = agentDefaultElement(type, "new");
|
|
21858
22211
|
const node = { ...base, ...rest, props: { ...base.props, ...props } };
|
|
21859
22212
|
if (children)
|
|
21860
22213
|
node.children = children.map(buildNode);
|
|
@@ -21864,7 +22217,8 @@ var arranged = (result) => result.ok ? result.layout : refused(result.reason);
|
|
|
21864
22217
|
var CreatePageInput = strictObject({
|
|
21865
22218
|
title: string2().trim().min(1).max(200),
|
|
21866
22219
|
recipes: array(_enum(SECTION_RECIPES.map((r) => r.id))).max(12).optional(),
|
|
21867
|
-
template: _enum(PAGE_TEMPLATES.map((t) => t.id)).optional()
|
|
22220
|
+
template: _enum(PAGE_TEMPLATES.map((t) => t.id)).optional(),
|
|
22221
|
+
titleHeading: boolean2().optional()
|
|
21868
22222
|
});
|
|
21869
22223
|
var CreatePageOutput = object({ pageId: string2(), slug: string2(), rev: string2() });
|
|
21870
22224
|
var firstHeading = (node) => node.type === "heading" ? node : ("children" in node && Array.isArray(node.children) ? node.children : []).map(firstHeading).find(Boolean);
|
|
@@ -21908,6 +22262,9 @@ async function createPage(ports, input) {
|
|
|
21908
22262
|
if (recipes[0] === "hero")
|
|
21909
22263
|
layout = { ...layout, root: { ...layout.root, children: [] } };
|
|
21910
22264
|
}
|
|
22265
|
+
if (input.titleHeading === false && !input.template) {
|
|
22266
|
+
layout = { ...layout, root: { ...layout.root, children: [] } };
|
|
22267
|
+
}
|
|
21911
22268
|
for (const id of recipes) {
|
|
21912
22269
|
const node = recipeNode(id, design, layout);
|
|
21913
22270
|
if (node)
|
|
@@ -21939,18 +22296,39 @@ var AddElementInput = strictObject({
|
|
|
21939
22296
|
element: BoundedElementSpec,
|
|
21940
22297
|
expectedRev: Rev.optional()
|
|
21941
22298
|
});
|
|
22299
|
+
var isH1 = (node) => (node.type === "heading" || node.type === "headline") && propsOf(node)["level"] === 1;
|
|
22300
|
+
var h1Ids = (node) => [
|
|
22301
|
+
...isH1(node) ? [node.id] : [],
|
|
22302
|
+
...nodeChildren(node).flatMap(h1Ids)
|
|
22303
|
+
];
|
|
22304
|
+
function untouchedTitleHeading(layout, title) {
|
|
22305
|
+
return nodeChildren(layout.root).find((node) => {
|
|
22306
|
+
if (node.type !== "heading" || Object.keys(node).some((k) => !["id", "type", "props"].includes(k)))
|
|
22307
|
+
return false;
|
|
22308
|
+
const props = propsOf(node);
|
|
22309
|
+
return Object.keys(props).length === 2 && props["level"] === 1 && props["text"] === title.trim();
|
|
22310
|
+
});
|
|
22311
|
+
}
|
|
21942
22312
|
async function addElement(ports, input) {
|
|
21943
22313
|
const element = resolveDesignRefs(input.element, (await ports.getDesign()).design);
|
|
21944
|
-
return mutatePage(ports, "add_element", input.pageId, input.expectedRev, (layout) => {
|
|
22314
|
+
return mutatePage(ports, "add_element", input.pageId, input.expectedRev, (layout, page) => {
|
|
21945
22315
|
if (!findNode(layout, input.parentId)) {
|
|
21946
22316
|
refused(`No element with id ${input.parentId} on this page to add into. Call get_layout for the ids.`);
|
|
21947
22317
|
}
|
|
21948
22318
|
const node = withFreshIds(layout, buildNode(element));
|
|
21949
|
-
|
|
22319
|
+
let next = arranged(addNode(layout, node, {
|
|
21950
22320
|
parentId: input.parentId,
|
|
21951
22321
|
index: input.index ?? Number.MAX_SAFE_INTEGER
|
|
21952
22322
|
}));
|
|
21953
|
-
|
|
22323
|
+
const changed = [node.id];
|
|
22324
|
+
let summary = `Added ${node.type} ${node.id}`;
|
|
22325
|
+
const title = h1Ids(node).length > 0 ? untouchedTitleHeading(layout, page.title) : undefined;
|
|
22326
|
+
if (title && h1Ids(layout.root).length === 1 && input.parentId !== title.id) {
|
|
22327
|
+
next = removeNode(next, title.id).layout;
|
|
22328
|
+
changed.push(title.id);
|
|
22329
|
+
summary += `; removed the page's title heading ${title.id} (the new element has the page's H1)`;
|
|
22330
|
+
}
|
|
22331
|
+
return { layout: next, changed, summary };
|
|
21954
22332
|
});
|
|
21955
22333
|
}
|
|
21956
22334
|
var MoveElementInput = strictObject({
|
|
@@ -22077,6 +22455,14 @@ async function updateElement(ports, input) {
|
|
|
22077
22455
|
} else if (isRecord5(copy[top]))
|
|
22078
22456
|
delete copy[top][sub];
|
|
22079
22457
|
}
|
|
22458
|
+
if (isExtensionType(node.type)) {
|
|
22459
|
+
if (!liveElement(node.type)) {
|
|
22460
|
+
refused(`${node.type} can't be changed: no extension on this site provides it. Remove it or install the extension.`);
|
|
22461
|
+
}
|
|
22462
|
+
const touchesProps = "props" in set || (input.unset ?? []).some((path) => path === "props" || path.startsWith("props."));
|
|
22463
|
+
if (touchesProps)
|
|
22464
|
+
copy["props"] = checkedExtensionProps(node.type, copy["props"]);
|
|
22465
|
+
}
|
|
22080
22466
|
return copy;
|
|
22081
22467
|
});
|
|
22082
22468
|
return { layout: next, changed: [input.nodeId], summary: `Updated ${input.nodeId}` };
|
|
@@ -22899,7 +23285,7 @@ var READ_TOOLS = [
|
|
|
22899
23285
|
tool({
|
|
22900
23286
|
name: "list_element_types",
|
|
22901
23287
|
title: "List element types",
|
|
22902
|
-
description: "Lists every EmVB element type with its props JSON Schema, whether it holds children, which parents accept it and a default example. Never invent element types.",
|
|
23288
|
+
description: "Lists every EmVB element type with its props JSON Schema, whether it holds children, which parents accept it and a default example, plus the extension elements registered on this site (ext:<package>/<name>, with their fields). Never invent element types.",
|
|
22903
23289
|
input: ListElementTypesInput,
|
|
22904
23290
|
output: ListElementTypesOutput,
|
|
22905
23291
|
readOnly: true,
|
|
@@ -22981,7 +23367,7 @@ var WRITE_TOOLS = [
|
|
|
22981
23367
|
tool({
|
|
22982
23368
|
name: "create_page",
|
|
22983
23369
|
title: "Create a page",
|
|
22984
|
-
description: "Creates a new unpublished EmVB page with a starter layout, optionally followed by section recipes (hero, features, …), or from a starter page template (template: see list_templates). Returns the page id and rev.",
|
|
23370
|
+
description: "Creates a new unpublished EmVB page with a starter layout, optionally followed by section recipes (hero, features, …), or from a starter page template (template: see list_templates). Without a template or a hero recipe the page starts with an H1 of its title: titleHeading false leaves it out, and an element with an H1 added later replaces it while it is unchanged. Returns the page id and rev.",
|
|
22985
23371
|
input: CreatePageInput,
|
|
22986
23372
|
output: CreatePageOutput,
|
|
22987
23373
|
readOnly: false,
|
|
@@ -22991,7 +23377,7 @@ var WRITE_TOOLS = [
|
|
|
22991
23377
|
tool({
|
|
22992
23378
|
name: "add_element",
|
|
22993
23379
|
title: "Add an element",
|
|
22994
|
-
description: "Adds an element (with optional children) into parentId at index (default: last). Unset props take the type's defaults; ids are generated. Refused with the editor's reason when the parent can't hold it.",
|
|
23380
|
+
description: "Adds an element (with optional children) into parentId at index (default: last). Unset required props take the type's defaults; optional props you leave out stay unset (no sample text, links or prices); ids are generated. Refused with the editor's reason when the parent can't hold it.",
|
|
22995
23381
|
input: AddElementInput,
|
|
22996
23382
|
output: WriteOutput,
|
|
22997
23383
|
readOnly: false,
|
|
@@ -23428,7 +23814,7 @@ function httpRemote(endpoint, token, version) {
|
|
|
23428
23814
|
}
|
|
23429
23815
|
|
|
23430
23816
|
// src/bridge.ts
|
|
23431
|
-
var BRIDGE_VERSION = "1.4.
|
|
23817
|
+
var BRIDGE_VERSION = "1.4.2";
|
|
23432
23818
|
var failure2 = (message) => ({
|
|
23433
23819
|
content: [{ type: "text", text: message }],
|
|
23434
23820
|
isError: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perkyzz/emvb-mcp",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Local (stdio) MCP server for EmVB pages: lets AI agents build EmDash pages through your site's EmDash MCP endpoint.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"emdash",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@modelcontextprotocol/server": "2.4.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@perkyzz/emvb": "1.4.
|
|
44
|
+
"@perkyzz/emvb": "1.4.2",
|
|
45
45
|
"zod": "~4.5.4"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|