@perkyzz/emvb 0.8.0 → 1.0.0

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.
Files changed (179) hide show
  1. package/README.md +3 -3
  2. package/package.json +4 -4
  3. package/src/admin/agents-api.ts +45 -0
  4. package/src/admin/editor/A11yCopilot.tsx +1 -1
  5. package/src/admin/editor/Editor.tsx +325 -239
  6. package/src/admin/editor/FieldPreview.tsx +164 -0
  7. package/src/admin/editor/Timeline.tsx +2 -1
  8. package/src/admin/editor/TopBar.tsx +36 -3
  9. package/src/admin/editor/canvas/CanvasFrame.tsx +2 -2
  10. package/src/admin/editor/canvas/DeviceBar.tsx +17 -9
  11. package/src/admin/editor/canvas/canvas-scale.ts +2 -2
  12. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  13. package/src/admin/editor/co-design.ts +190 -0
  14. package/src/admin/editor/dnd/new-element.ts +26 -4
  15. package/src/admin/editor/editor-chrome.tsx +3 -3
  16. package/src/admin/editor/editor-commands.ts +8 -3
  17. package/src/admin/editor/editor-css.ts +3 -0
  18. package/src/admin/editor/element-chrome.ts +3 -1
  19. package/src/admin/editor/extension-manifests.ts +20 -0
  20. package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
  21. package/src/admin/editor/extensions-context.tsx +27 -0
  22. package/src/admin/editor/feature-css.ts +17 -0
  23. package/src/admin/editor/host.ts +6 -0
  24. package/src/admin/editor/palette-items.ts +2 -2
  25. package/src/admin/editor/panels/AddPanel.tsx +31 -1
  26. package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
  27. package/src/admin/editor/panels/ClassesSection.tsx +9 -6
  28. package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
  29. package/src/admin/editor/panels/ColorControl.tsx +2 -2
  30. package/src/admin/editor/panels/ElementPanel.tsx +53 -15
  31. package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
  32. package/src/admin/editor/panels/LayersPanel.tsx +10 -6
  33. package/src/admin/editor/panels/LeftPanel.tsx +33 -5
  34. package/src/admin/editor/panels/PageSettings.tsx +4 -0
  35. package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
  36. package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
  37. package/src/admin/editor/panels/settings/BackgroundControls.tsx +76 -20
  38. package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
  39. package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
  40. package/src/admin/editor/panels/settings/EffectsControls.tsx +104 -9
  41. package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
  42. package/src/admin/editor/panels/settings/IconControls.tsx +14 -11
  43. package/src/admin/editor/panels/settings/LengthRow.tsx +27 -16
  44. package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
  45. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +1 -1
  46. package/src/admin/editor/panels/settings/MediaPicker.tsx +5 -5
  47. package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
  48. package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
  49. package/src/admin/editor/panels/settings/StyleRow.tsx +113 -13
  50. package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
  51. package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
  52. package/src/admin/editor/panels/settings/background-mode.ts +14 -11
  53. package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
  54. package/src/admin/editor/panels/settings/box-sides.ts +22 -14
  55. package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
  56. package/src/admin/editor/panels/settings/length-units.ts +55 -2
  57. package/src/admin/editor/panels/settings/query-style.ts +3 -3
  58. package/src/admin/editor/panels/settings/style-sections.ts +51 -10
  59. package/src/admin/editor/panels/style-target.ts +9 -7
  60. package/src/admin/editor/presence.ts +60 -0
  61. package/src/admin/editor/store.ts +6 -2
  62. package/src/admin/editor/useCoDesign.ts +177 -0
  63. package/src/admin/editor/useEditorCommands.ts +4 -4
  64. package/src/admin/editor/useExtensions.ts +45 -0
  65. package/src/admin/editor/useNodeActions.ts +15 -6
  66. package/src/admin/editor/useProposals.ts +81 -0
  67. package/src/admin/index.tsx +5 -1
  68. package/src/admin/languages-api.ts +61 -0
  69. package/src/admin/media-api.ts +27 -0
  70. package/src/admin/pages/AgentSetup.tsx +148 -0
  71. package/src/admin/pages/AgentsPage.tsx +11 -28
  72. package/src/admin/pages/CollectionsPage.tsx +215 -0
  73. package/src/admin/pages/CreateDialog.tsx +15 -0
  74. package/src/admin/pages/ImportButton.tsx +18 -0
  75. package/src/admin/pages/ImportElementorDialog.tsx +669 -0
  76. package/src/admin/pages/ImportPageLinks.tsx +86 -0
  77. package/src/admin/pages/PageList.tsx +15 -1
  78. package/src/admin/pages/ThemePartList.tsx +15 -1
  79. package/src/admin/pages/section-head.tsx +27 -0
  80. package/src/admin/proposals-api.ts +91 -0
  81. package/src/admin/setup/host-collections.ts +100 -0
  82. package/src/admin/ui.ts +39 -2
  83. package/src/admin/widgets/CanvasField.tsx +202 -0
  84. package/src/admin/widgets/convert-body.ts +54 -0
  85. package/src/admin/widgets/field-fetcher.ts +79 -0
  86. package/src/astro/content-port.ts +14 -1
  87. package/src/astro/index.ts +2 -0
  88. package/src/astro/page-count.ts +77 -0
  89. package/src/astro/resolve-theme.ts +58 -3
  90. package/src/astro/resolve.ts +128 -5
  91. package/src/astro/responsive-images.ts +99 -0
  92. package/src/constants.ts +1 -1
  93. package/src/core/a11y/audit.ts +44 -14
  94. package/src/core/arrange.ts +5 -1
  95. package/src/core/bounded-array.ts +31 -0
  96. package/src/core/canvas-collections.ts +20 -0
  97. package/src/core/clipboard.ts +9 -0
  98. package/src/core/contract.ts +285 -0
  99. package/src/core/css/generate.ts +89 -20
  100. package/src/core/css/trace.ts +18 -9
  101. package/src/core/css-keywords.ts +51 -1
  102. package/src/core/design/cascade.ts +12 -9
  103. package/src/core/design/classes.ts +4 -5
  104. package/src/core/design/devices.ts +13 -13
  105. package/src/core/design/states.ts +5 -3
  106. package/src/core/design/transfer.ts +5 -0
  107. package/src/core/design/variables.ts +17 -4
  108. package/src/core/elements/dynamic-elements.ts +19 -4
  109. package/src/core/elements/index.ts +73 -9
  110. package/src/core/extensions/define.ts +13 -0
  111. package/src/core/extensions/index.ts +41 -0
  112. package/src/core/extensions/namespace.ts +82 -0
  113. package/src/core/extensions/normalize.ts +141 -0
  114. package/src/core/extensions/placeholder.ts +41 -0
  115. package/src/core/extensions/registry.ts +94 -0
  116. package/src/core/extensions/render-ext.ts +118 -0
  117. package/src/core/extensions/safe-nodes.ts +93 -0
  118. package/src/core/extensions/schema.ts +112 -0
  119. package/src/core/extensions/types.ts +159 -0
  120. package/src/core/forms/binding.ts +1 -1
  121. package/src/core/history/diff.ts +1 -1
  122. package/src/core/import/elementor/atomic.ts +1595 -0
  123. package/src/core/import/elementor/classes.ts +127 -0
  124. package/src/core/import/elementor/context.ts +429 -0
  125. package/src/core/import/elementor/counter-steps.ts +72 -0
  126. package/src/core/import/elementor/css.ts +445 -0
  127. package/src/core/import/elementor/html.ts +500 -0
  128. package/src/core/import/elementor/index.ts +949 -0
  129. package/src/core/import/elementor/inline-marks.ts +81 -0
  130. package/src/core/import/elementor/snapshots.ts +48 -0
  131. package/src/core/import/elementor/style.ts +409 -0
  132. package/src/core/import/elementor/values.ts +241 -0
  133. package/src/core/import/elementor/widgets.ts +1897 -0
  134. package/src/core/index.ts +84 -0
  135. package/src/core/json-schema.ts +107 -0
  136. package/src/core/limits.ts +19 -0
  137. package/src/core/migrate/index.ts +6 -1
  138. package/src/core/migrate/v18.ts +222 -0
  139. package/src/core/perf/meter.ts +5 -5
  140. package/src/core/portable-text.ts +127 -0
  141. package/src/core/proposals-safety.ts +102 -0
  142. package/src/core/proposals.ts +357 -0
  143. package/src/core/recipes/index.ts +2 -2
  144. package/src/core/render/extras.ts +3 -3
  145. package/src/core/render/index.ts +140 -20
  146. package/src/core/render/loop.ts +1 -1
  147. package/src/core/render/pagination.ts +20 -1
  148. package/src/core/render/section.ts +4 -4
  149. package/src/core/render/vnode.ts +1 -1
  150. package/src/core/sanitize/css.ts +125 -10
  151. package/src/core/sanitize/motion.ts +116 -0
  152. package/src/core/saved-sections.ts +6 -0
  153. package/src/core/schema/descriptors.ts +3 -1
  154. package/src/core/schema/design.ts +2 -1
  155. package/src/core/schema/layout.ts +87 -14
  156. package/src/core/schema/style.ts +251 -114
  157. package/src/core/text-marks.ts +227 -0
  158. package/src/core/theme/dynamic.ts +9 -4
  159. package/src/core/theme/float.ts +1 -0
  160. package/src/core/theme/pagination.ts +9 -0
  161. package/src/core/theme/popup-rules.ts +17 -1
  162. package/src/core/translatable.ts +34 -0
  163. package/src/core/validate.ts +13 -1
  164. package/src/index.ts +35 -1
  165. package/src/mcp/errors.ts +3 -1
  166. package/src/mcp/ports.ts +67 -0
  167. package/src/mcp/prompts.ts +1 -11
  168. package/src/mcp/proposals.ts +281 -0
  169. package/src/mcp/read.ts +10 -9
  170. package/src/mcp/tools.ts +71 -3
  171. package/src/mcp/write.ts +66 -11
  172. package/src/server/agent-settings.ts +21 -2
  173. package/src/server/hooks.ts +81 -0
  174. package/src/server/mcp-routes.ts +15 -0
  175. package/src/server/plugin.ts +53 -5
  176. package/src/server/presence.ts +78 -0
  177. package/src/server/proposals.ts +261 -0
  178. package/src/server/requests.ts +196 -0
  179. package/src/server/tools-served.ts +45 -0
@@ -36,7 +36,7 @@ import {
36
36
  type Arranged,
37
37
  inheritedStyle,
38
38
  type LayoutNode,
39
- type PopupDevice,
39
+ type Device,
40
40
  type ResponsiveDevice,
41
41
  classStylesInListOrder,
42
42
  iconHasAdjustableStroke,
@@ -44,7 +44,8 @@ import {
44
44
  resolveCascade,
45
45
  SAMPLE_POST,
46
46
  STYLE_STATES,
47
- type StyleProps,
47
+ type FlatStyleProps,
48
+ flattenMotion,
48
49
  type StyleStates,
49
50
  boxLinkHeldBack,
50
51
  } from "../../../core/index.ts";
@@ -65,6 +66,7 @@ import {
65
66
  HtmlIdField,
66
67
  } from "./settings/AdvancedFields.tsx";
67
68
  import { ClassChipInput } from "./settings/ClassChipInput.tsx";
69
+ import { useExtensionElement } from "../extensions-context.tsx";
68
70
  import { StateDot, StateSwitcher, type StyleStateChoice } from "./settings/StateSwitcher.tsx";
69
71
  import {
70
72
  DEFAULT_UI,
@@ -131,7 +133,7 @@ const writeSections = (type: string, open: Set<StyleSectionId>) => {
131
133
  }
132
134
  };
133
135
 
134
- const countSet = (type: string, style: StyleProps | undefined, section: StyleSectionId) =>
136
+ const countSet = (type: string, style: FlatStyleProps | undefined, section: StyleSectionId) =>
135
137
  keysFor(type, section, style).filter((key) => style?.[key] !== undefined).length;
136
138
 
137
139
  /** Whether any state sets a key of this section (the section header's dot in Normal). */
@@ -159,7 +161,7 @@ const JUMP_HELP: Record<Exclude<StyleStateChoice, "normal">, string> = {
159
161
  const positionInEffect = (
160
162
  node: LayoutNode,
161
163
  design: DesignSystem,
162
- cls: { style?: StyleProps } | undefined,
164
+ cls: { style?: FlatStyleProps } | undefined,
163
165
  ) =>
164
166
  cls
165
167
  ? cls.style?.position
@@ -218,7 +220,7 @@ type Props = {
218
220
  /** The chosen style state, for the canvas preview (W-089). */
219
221
  onStyleState?: (nodeId: string, state: StyleStateChoice) => void;
220
222
  /** Tablet and mobile edit overrides. Desktop edits `style` (W-096). */
221
- device?: PopupDevice;
223
+ device?: Device;
222
224
  /** Add, move and delete for Accordion items and Tabs panels (W-130). */
223
225
  items?: ItemActions;
224
226
  /** The theme part being edited, if any, for the H1 warning (W-208). */
@@ -321,10 +323,12 @@ function pairFields<F extends { key: string }>(fields: readonly F[]): F[][] {
321
323
 
322
324
  /** UX-071: fields that only apply to some values of another field on the same element. */
323
325
  const SHOWN_WHEN: Readonly<
324
- Record<string, (props: Record<string, unknown>, device: PopupDevice) => boolean>
326
+ Record<string, (props: Record<string, unknown>, device: Device) => boolean>
325
327
  > = {
326
328
  "loop.columns": (props) => props["display"] === "grid" || props["display"] === "cards",
327
329
  "pagination.countText": (props) => props["showCount"] === true,
330
+ "pagination.lastText": (props) => props["showLast"] === true,
331
+ "pagination.lastLabel": (props) => props["showLast"] === true,
328
332
  // Post Link always links to its post, so its new-tab switch always applies.
329
333
  "post-link.newTab": () => true,
330
334
  // UX-075: each device's tracks show on that device, as Columns does (W-139).
@@ -333,7 +337,7 @@ const SHOWN_WHEN: Readonly<
333
337
  "grid.columnTracksMobile": (_props, device) => device === "mobile",
334
338
  };
335
339
 
336
- function fieldShown(key: string, node: LayoutNode, device: PopupDevice = "desktop"): boolean {
340
+ function fieldShown(key: string, node: LayoutNode, device: Device = "desktop"): boolean {
337
341
  const props = node.props as Record<string, unknown>;
338
342
  // A stored value always shows, so it can be seen and reset.
339
343
  if (props[key] !== undefined) return true;
@@ -347,7 +351,19 @@ function fieldShown(key: string, node: LayoutNode, device: PopupDevice = "deskto
347
351
 
348
352
  /** Right panel with an element selected (IA / W-021): descriptor Content + Style sections. */
349
353
  export function ElementPanel(props: Props) {
350
- const descriptor = ELEMENT_DESCRIPTORS.find((d) => d.type === props.node.type);
354
+ const builtIn = ELEMENT_DESCRIPTORS.find((d) => d.type === props.node.type);
355
+ const extension = useExtensionElement(props.node.type);
356
+ const descriptor: ElementDescriptor | undefined = builtIn
357
+ ? builtIn
358
+ : extension
359
+ ? {
360
+ type: extension.type,
361
+ name: extension.label,
362
+ group: extension.group,
363
+ defaultTab: "content",
364
+ fields: [...extension.fields],
365
+ }
366
+ : undefined;
351
367
  if (!descriptor) {
352
368
  return (
353
369
  <div
@@ -355,9 +371,21 @@ export function ElementPanel(props: Props) {
355
371
  data-emvb-panel="element"
356
372
  data-emvb-element={props.node.type}
357
373
  >
358
- <h2 className="emvb-panel-title">Unknown element</h2>
374
+ <h2 className="emvb-panel-title">
375
+ {props.node.type.startsWith("ext:") ? "Missing extension" : "Unknown element"}
376
+ </h2>
359
377
  <p className="emvb-helper">
360
- Unknown element &quot;{props.node.type}&quot;. It can be moved or deleted, but not edited.
378
+ {props.node.type.startsWith("ext:") ? (
379
+ <>
380
+ This block needs the extension for &quot;{props.node.type}&quot;. It can be moved or
381
+ deleted; install the extension to edit it.
382
+ </>
383
+ ) : (
384
+ <>
385
+ Unknown element &quot;{props.node.type}&quot;. It can be moved or deleted, but not
386
+ edited.
387
+ </>
388
+ )}
361
389
  </p>
362
390
  {props.rejection && <Alert>{props.rejection}</Alert>}
363
391
  </div>
@@ -411,10 +439,16 @@ function KnownElementPanel({
411
439
  React.useEffect(() => {
412
440
  onStyleState?.(node.id, tab === "style" ? styleState : "normal");
413
441
  }, [node.id, styleState, tab, onStyleState]);
414
- const normal = cls ? cls.style : node.style;
442
+ // W-925: the rows read the flat motion keys; applyStylePatch nests them again.
443
+ const normal = flattenMotion(cls ? cls.style : node.style);
415
444
  const states = cls ? cls.states : node.states;
416
445
  const responsive: ResponsiveDevice | null = device === "desktop" ? null : device;
417
- const ownerDevices = cls ? cls.devices : node.devices;
446
+ const storedDevices = cls ? cls.devices : node.devices;
447
+ const ownerDevices = storedDevices && {
448
+ laptop: flattenMotion(storedDevices.laptop),
449
+ tablet: flattenMotion(storedDevices.tablet),
450
+ mobile: flattenMotion(storedDevices.mobile),
451
+ };
418
452
  const style = responsive
419
453
  ? ownerDevices?.[responsive]
420
454
  : styleState === "normal"
@@ -423,6 +457,8 @@ function KnownElementPanel({
423
457
  const ownInherited = responsive
424
458
  ? {
425
459
  ...normal,
460
+ // W-956: each device inherits the wider ones: Laptop, then Tablet.
461
+ ...(responsive !== "laptop" ? ownerDevices?.laptop : undefined),
426
462
  ...(responsive === "mobile" ? ownerDevices?.tablet : undefined),
427
463
  }
428
464
  : styleState === "normal"
@@ -461,7 +497,7 @@ function KnownElementPanel({
461
497
  !singleColorOffered &&
462
498
  node.props.singleColor !== true &&
463
499
  ownColors;
464
- const patchStyle = (patch: Partial<StyleProps>) => {
500
+ const patchStyle = (patch: Partial<FlatStyleProps>) => {
465
501
  const written = applyStylePatch({
466
502
  node,
467
503
  design,
@@ -579,7 +615,8 @@ function KnownElementPanel({
579
615
  duplicateName={
580
616
  field.key === "field" && layout ? duplicateFieldName(layout, node.id) : false
581
617
  }
582
- device={device}
618
+ // Field values have no laptop setting: Laptop edits the desktop value.
619
+ device={device === "laptop" ? "desktop" : device}
583
620
  />
584
621
  </React.Fragment>
585
622
  ));
@@ -688,7 +725,8 @@ function KnownElementPanel({
688
725
  if (cls || styleState !== "normal") return null;
689
726
  return section(
690
727
  id,
691
- (node.htmlId ? 1 : 0) + (node.attributes?.length ?? 0),
728
+ // W-914: a per-element direction counts as a set Advanced value too.
729
+ (node.htmlId ? 1 : 0) + (node.dir ? 1 : 0) + (node.attributes?.length ?? 0),
692
730
  <>
693
731
  <HtmlIdField node={node} layout={layout} onChange={onChange} />
694
732
  <DirectionField node={node} onChange={onChange} />
@@ -0,0 +1,152 @@
1
+ import { Badge, Button, Checkbox } from "@cloudflare/kumo";
2
+ import { TranslateIcon } from "@phosphor-icons/react";
3
+ import * as React from "react";
4
+ import type { Layout } from "../../../core/schema/layout.ts";
5
+ import { translatableStrings } from "../../../core/translatable.ts";
6
+ import type { Fetcher } from "../../api.ts";
7
+ import { ApiError } from "../../api.ts";
8
+ import {
9
+ createTranslation,
10
+ listTranslations,
11
+ siteLocales,
12
+ type Translation,
13
+ } from "../../languages-api.ts";
14
+ import { createRequest } from "../../proposals-api.ts";
15
+ import { editorUrl } from "../exit.ts";
16
+
17
+ const nameOf = (locale: string) => {
18
+ try {
19
+ return new Intl.DisplayNames(undefined, { type: "language" }).of(locale) ?? locale;
20
+ } catch {
21
+ return locale;
22
+ }
23
+ };
24
+
25
+ /**
26
+ * W-936 Translate this page (D-068): each language is its own entry. A missing one is created as
27
+ * a draft copy of this layout (EmDash's `translationOf`) and opened; optionally the person's agent
28
+ * is asked to translate it, and its proposal is reviewed in the new page's Agent tab.
29
+ */
30
+ export function LanguagesSection({
31
+ fetcher,
32
+ collection,
33
+ entryId,
34
+ title,
35
+ slug,
36
+ layout,
37
+ navigate = (url) => window.location.assign(url),
38
+ }: {
39
+ fetcher: Fetcher;
40
+ collection: string;
41
+ entryId: string;
42
+ title: string;
43
+ slug: string;
44
+ layout: Layout | null;
45
+ navigate?: (url: string) => void;
46
+ }) {
47
+ const [site, setSite] = React.useState<{ defaultLocale: string; locales: string[] } | null>(null);
48
+ const [translations, setTranslations] = React.useState<Translation[]>([]);
49
+ const [askAgent, setAskAgent] = React.useState(true);
50
+ const [busy, setBusy] = React.useState<string | null>(null);
51
+ const [error, setError] = React.useState<string | null>(null);
52
+ React.useEffect(() => {
53
+ let cancelled = false;
54
+ siteLocales(fetcher)
55
+ .then(async (locales) => {
56
+ if (cancelled || !locales) return;
57
+ setSite(locales);
58
+ const list = await listTranslations(fetcher, collection, entryId);
59
+ if (!cancelled) setTranslations(list);
60
+ })
61
+ .catch(() => undefined);
62
+ return () => {
63
+ cancelled = true;
64
+ };
65
+ }, [fetcher, collection, entryId]);
66
+ if (!site) return null;
67
+ const current = translations.find((t) => t.id === entryId)?.locale ?? site.defaultLocale;
68
+ const texts = layout ? translatableStrings(layout).length : 0;
69
+
70
+ const translate = async (locale: string) => {
71
+ if (!layout || busy) return;
72
+ setBusy(locale);
73
+ setError(null);
74
+ try {
75
+ const id = await createTranslation(fetcher, {
76
+ collection,
77
+ sourceId: entryId,
78
+ locale,
79
+ title,
80
+ slug,
81
+ layout,
82
+ });
83
+ if (askAgent) {
84
+ await createRequest(
85
+ fetcher,
86
+ collection,
87
+ id,
88
+ `Translate this page from ${nameOf(current)} (${current}) into ${nameOf(locale)} (${locale}). Change only the words (${texts} texts: headings, text, buttons, alt text, labels); keep the layout, links, images and styles.`,
89
+ ).catch(() => undefined);
90
+ }
91
+ navigate(editorUrl(id, collection));
92
+ } catch (e) {
93
+ setError(e instanceof ApiError ? e.message : "Couldn't create the translation. Try again.");
94
+ setBusy(null);
95
+ }
96
+ };
97
+
98
+ return (
99
+ <section className="emvb-field-group" aria-label="Languages" data-emvb-languages="">
100
+ <span className="emvb-field-label">Languages</span>
101
+ <ul className="emvb-codesign-ops">
102
+ {site.locales.map((locale) => {
103
+ const found = translations.find((t) => t.locale === locale);
104
+ return (
105
+ <li key={locale} className="emvb-codesign-op" data-emvb-language={locale}>
106
+ <span className="emvb-codesign-op-text">
107
+ {nameOf(locale)} <span className="emvb-helper">({locale})</span>
108
+ </span>
109
+ <span className="emvb-codesign-op-actions">
110
+ {locale === current ? (
111
+ <Badge variant="blue">This page</Badge>
112
+ ) : found ? (
113
+ <Button
114
+ size="sm"
115
+ variant="ghost"
116
+ data-emvb-language-open=""
117
+ onClick={() => navigate(editorUrl(found.id, collection))}
118
+ >
119
+ Open
120
+ </Button>
121
+ ) : (
122
+ <Button
123
+ size="sm"
124
+ variant="secondary"
125
+ icon={<TranslateIcon aria-hidden="true" />}
126
+ aria-busy={busy === locale || undefined}
127
+ disabled={!layout || (busy !== null && busy !== locale)}
128
+ data-emvb-language-translate=""
129
+ onClick={() => void translate(locale)}
130
+ >
131
+ Translate
132
+ </Button>
133
+ )}
134
+ </span>
135
+ </li>
136
+ );
137
+ })}
138
+ </ul>
139
+ {site.locales.some((l) => l !== current && !translations.some((t) => t.locale === l)) && (
140
+ <Checkbox
141
+ label="Ask my agent to translate the new page"
142
+ checked={askAgent}
143
+ onCheckedChange={(checked: boolean) => setAskAgent(checked)}
144
+ />
145
+ )}
146
+ <p className="emvb-helper" role={error ? "alert" : undefined}>
147
+ {error ??
148
+ `Translate copies this page's layout into a draft in that language (${texts} texts to translate), then opens it.`}
149
+ </p>
150
+ </section>
151
+ );
152
+ }
@@ -365,10 +365,10 @@ const LayerRow = React.memo(function LayerRow({
365
365
  const preview = layerPreview(node);
366
366
  const typeName = ELEMENT_NAMES[node.type] ?? node.type;
367
367
  // A label names the row in place of the type (W-157); the type stays in the tooltip.
368
- const name = node.label ?? typeName;
368
+ const name = node.editorLabel ?? typeName;
369
369
  // Names and previews truncate, so the tooltip carries them in full (DESIGN.md, W-168).
370
- const tooltip = node.label
371
- ? `${node.label} (${typeName})`
370
+ const tooltip = node.editorLabel
371
+ ? `${node.editorLabel} (${typeName})`
372
372
  : preview
373
373
  ? `${typeName}: ${preview}`
374
374
  : typeName;
@@ -439,7 +439,7 @@ const LayerRow = React.memo(function LayerRow({
439
439
  setRenaming(false);
440
440
  if (text === null || !actions.onRename) return;
441
441
  const next = clipText(text.trim(), 80).trim() || undefined;
442
- if (next !== node.label) actions.onRename(node.id, next);
442
+ if (next !== node.editorLabel) actions.onRename(node.id, next);
443
443
  };
444
444
  return (
445
445
  <li role="treeitem" aria-expanded={hasChildren ? !collapsed : undefined}>
@@ -477,7 +477,11 @@ const LayerRow = React.memo(function LayerRow({
477
477
  <span className="emvb-layer-caret" />
478
478
  )}
479
479
  {renaming ? (
480
- <RenameInput initial={node.label ?? ""} placeholder={typeName} onDone={finishRename} />
480
+ <RenameInput
481
+ initial={node.editorLabel ?? ""}
482
+ placeholder={typeName}
483
+ onDone={finishRename}
484
+ />
481
485
  ) : (
482
486
  <button
483
487
  ref={selectButton}
@@ -485,7 +489,7 @@ const LayerRow = React.memo(function LayerRow({
485
489
  className="emvb-layer-select"
486
490
  aria-current={selected ? "true" : undefined}
487
491
  title={tooltip}
488
- data-emvb-layer-label={node.label ? "" : undefined}
492
+ data-emvb-layer-label={node.editorLabel ? "" : undefined}
489
493
  onDoubleClick={startRename}
490
494
  onKeyDown={(event) => {
491
495
  if (event.key === "F2") {
@@ -3,12 +3,15 @@ import * as React from "react";
3
3
  import type { ElementType, Layout } from "../../../core/index.ts";
4
4
  import { AddPanel } from "./AddPanel.tsx";
5
5
  import { LayersPanel } from "./LayersPanel.tsx";
6
+ import { CoDesignPanel } from "./CoDesignPanel.tsx";
7
+ import type { CoDesign } from "../useCoDesign.ts";
8
+ import { ExtensionPanels } from "../extensions/ExtensionPanels.tsx";
6
9
  import type { ClipboardActions } from "../useClipboardActions.ts";
7
10
  import type { SavedSectionActions } from "../useSavedSections.ts";
8
11
 
9
12
  const SESSION_KEY = "emvb-left-tab";
10
13
 
11
- /** Add | Layers left panel (W-018). Remembers the last tab for the session. */
14
+ /** Add | Layers | Agent left panel (W-018, W-930). Remembers the last tab for the session. */
12
15
  export function LeftPanel({
13
16
  layout,
14
17
  selectedId,
@@ -24,11 +27,12 @@ export function LeftPanel({
24
27
  onRename,
25
28
  onSaveSection,
26
29
  formsAvailable = true,
30
+ coDesign,
27
31
  }: {
28
32
  layout: Layout | null;
29
33
  selectedId: string | null;
30
34
  onSelect: (id: string) => void;
31
- onAdd: (type: ElementType) => void;
35
+ onAdd: (type: ElementType | string) => void;
32
36
  /** Adds a section recipe (W-320). */
33
37
  onRecipe?: (id: string) => void;
34
38
  /** My sections (W-876). */
@@ -43,10 +47,13 @@ export function LeftPanel({
43
47
  /** Save as section in the row menu (W-876). */
44
48
  onSaveSection?: (id: string) => void;
45
49
  formsAvailable?: boolean;
50
+ /** W-930: agent proposals to review; the Agent tab shows only with it. */
51
+ coDesign?: CoDesign;
46
52
  }) {
47
53
  const [tab, setTab] = React.useState(() => {
48
54
  try {
49
- return sessionStorage.getItem(SESSION_KEY) === "layers" ? "layers" : "add";
55
+ const last = sessionStorage.getItem(SESSION_KEY);
56
+ return last === "layers" || (last === "agent" && coDesign) ? last : "add";
50
57
  } catch {
51
58
  return "add";
52
59
  }
@@ -67,12 +74,33 @@ export function LeftPanel({
67
74
  tabs={[
68
75
  { value: "add", label: "Add" },
69
76
  { value: "layers", label: "Layers" },
77
+ ...(coDesign
78
+ ? [
79
+ {
80
+ value: "agent",
81
+ label:
82
+ coDesign.proposals.items.length > 0
83
+ ? `Agent (${coDesign.proposals.items.length})`
84
+ : "Agent",
85
+ },
86
+ ]
87
+ : []),
70
88
  ]}
71
89
  value={tab}
72
90
  onValueChange={changeTab}
73
91
  />
74
- {tab === "add" ? (
75
- <AddPanel onAdd={onAdd} onRecipe={onRecipe} saved={saved} formsAvailable={formsAvailable} />
92
+ {tab === "agent" && coDesign ? (
93
+ <CoDesignPanel co={coDesign} layout={layout} />
94
+ ) : tab === "add" ? (
95
+ <>
96
+ <AddPanel
97
+ onAdd={onAdd}
98
+ onRecipe={onRecipe}
99
+ saved={saved}
100
+ formsAvailable={formsAvailable}
101
+ />
102
+ <ExtensionPanels />
103
+ </>
76
104
  ) : (
77
105
  <LayersPanel
78
106
  layout={layout}
@@ -40,6 +40,7 @@ export function PageSettings({
40
40
  onChange,
41
41
  kind = "page",
42
42
  fetcher,
43
+ languages,
43
44
  }: {
44
45
  page: PageDraft;
45
46
  slugError: string | null;
@@ -47,6 +48,8 @@ export function PageSettings({
47
48
  kind?: "page" | "theme-part";
48
49
  /** For the Social image picker (W-287); without it the field isn't offered. */
49
50
  fetcher?: Fetcher;
51
+ /** W-936: the Languages section, when the site has more than one. */
52
+ languages?: React.ReactNode;
50
53
  }) {
51
54
  // Hooks run before the theme-part branch, so switching `kind` keeps the hook order (W-092).
52
55
  const descriptionId = React.useId();
@@ -234,6 +237,7 @@ export function PageSettings({
234
237
  />
235
238
  </Collapsible.Panel>
236
239
  </Collapsible.Root>
240
+ {languages}
237
241
  </div>
238
242
  );
239
243
  }
@@ -1,12 +1,14 @@
1
1
  import type * as React from "react";
2
2
  import type { Deletion } from "../restore-deleted.ts";
3
- import type { DesignSystem, LayoutNode, PopupDevice } from "../../../core/index.ts";
3
+ import type { DesignSystem, LayoutNode, Device } from "../../../core/index.ts";
4
4
  import type { Fetcher } from "../../api.ts";
5
5
  import type { EditorAction, EditorState } from "../store.ts";
6
6
  import { ElementPanel } from "./ElementPanel.tsx";
7
7
  import type { ItemActions } from "./settings/ItemList.tsx";
8
8
  import type { StyleStateChoice } from "./settings/StateSwitcher.tsx";
9
9
  import { PageSettings } from "./PageSettings.tsx";
10
+ import { LanguagesSection } from "./LanguagesSection.tsx";
11
+ import { PAGES_COLLECTION } from "../../../constants.ts";
10
12
  import { SiteStylesDrawer } from "./SiteStylesDrawer.tsx";
11
13
 
12
14
  /** The right panel: Site styles when open, else the selected element's settings, else page settings. */
@@ -26,6 +28,7 @@ export function SettingsPanel({
26
28
  slugError,
27
29
  onSlugEdit,
28
30
  kind,
31
+ translatable = false,
29
32
  onStyleState,
30
33
  device = "desktop",
31
34
  items,
@@ -46,10 +49,12 @@ export function SettingsPanel({
46
49
  slugError: string | null;
47
50
  onSlugEdit: () => void;
48
51
  kind: "page" | "theme-part";
52
+ /** W-936: an EmVB page (not field mode) offers its other languages. */
53
+ translatable?: boolean;
49
54
  /** The Style tab's chosen state, for the canvas preview (W-089). */
50
55
  onStyleState?: (nodeId: string, state: StyleStateChoice) => void;
51
56
  /** Which device's styles the Style tab edits (W-096). */
52
- device?: PopupDevice;
57
+ device?: Device;
53
58
  /** Accordion and Tabs item actions (W-130). */
54
59
  items?: ItemActions;
55
60
  }) {
@@ -115,6 +120,20 @@ export function SettingsPanel({
115
120
  slugError={slugError}
116
121
  kind={kind}
117
122
  fetcher={fetcher}
123
+ {...(translatable && kind === "page"
124
+ ? {
125
+ languages: (
126
+ <LanguagesSection
127
+ fetcher={fetcher}
128
+ collection={PAGES_COLLECTION}
129
+ entryId={state.id}
130
+ title={state.page.title}
131
+ slug={state.page.slug}
132
+ layout={state.page.layout}
133
+ />
134
+ ),
135
+ }
136
+ : {})}
118
137
  onChange={(patch) => {
119
138
  if (patch.slug !== undefined) onSlugEdit();
120
139
  dispatch({ type: "set-page", patch });
@@ -20,7 +20,9 @@ import {
20
20
  type DefaultStyleTag,
21
21
  type DesignSystem,
22
22
  type Layout,
23
- type StyleProps,
23
+ type FlatStyleProps,
24
+ flattenMotion,
25
+ patchNestedStyle,
24
26
  type VariableKind,
25
27
  } from "../../../core/index.ts";
26
28
  import { BUTTON, SOLID_DESTRUCTIVE } from "../../ui.ts";
@@ -566,12 +568,10 @@ function DefaultsSection({
566
568
  onSave: (design: DesignSystem) => Promise<boolean | void>;
567
569
  }) {
568
570
  const [tag, setTag] = React.useState<DefaultStyleTag>("p");
569
- const style = design.defaults?.[tag];
570
- const patch = (partial: Partial<StyleProps>) => {
571
- const next: StyleProps = { ...style, ...partial };
572
- for (const key of Object.keys(partial) as (keyof StyleProps)[]) {
573
- if (partial[key] === undefined) delete next[key];
574
- }
571
+ const stored = design.defaults?.[tag];
572
+ const style = flattenMotion(stored);
573
+ const patch = (partial: Partial<FlatStyleProps>) => {
574
+ const next = patchNestedStyle(stored, partial);
575
575
  const defaults = {
576
576
  ...design.defaults,
577
577
  [tag]: Object.keys(next).length > 0 ? next : undefined,