@perkyzz/emvb 0.9.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 (160) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  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 +297 -248
  6. package/src/admin/editor/Timeline.tsx +2 -1
  7. package/src/admin/editor/TopBar.tsx +4 -2
  8. package/src/admin/editor/canvas/CanvasFrame.tsx +2 -2
  9. package/src/admin/editor/canvas/DeviceBar.tsx +17 -9
  10. package/src/admin/editor/canvas/canvas-scale.ts +2 -2
  11. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  12. package/src/admin/editor/co-design.ts +190 -0
  13. package/src/admin/editor/dnd/new-element.ts +26 -4
  14. package/src/admin/editor/editor-chrome.tsx +3 -3
  15. package/src/admin/editor/editor-commands.ts +8 -3
  16. package/src/admin/editor/element-chrome.ts +3 -1
  17. package/src/admin/editor/extension-manifests.ts +20 -0
  18. package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
  19. package/src/admin/editor/extensions-context.tsx +27 -0
  20. package/src/admin/editor/feature-css.ts +17 -0
  21. package/src/admin/editor/palette-items.ts +2 -2
  22. package/src/admin/editor/panels/AddPanel.tsx +31 -1
  23. package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
  24. package/src/admin/editor/panels/ClassesSection.tsx +9 -6
  25. package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
  26. package/src/admin/editor/panels/ColorControl.tsx +2 -2
  27. package/src/admin/editor/panels/ElementPanel.tsx +49 -14
  28. package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
  29. package/src/admin/editor/panels/LayersPanel.tsx +10 -6
  30. package/src/admin/editor/panels/LeftPanel.tsx +33 -5
  31. package/src/admin/editor/panels/PageSettings.tsx +4 -0
  32. package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
  33. package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
  34. package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
  35. package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
  36. package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
  37. package/src/admin/editor/panels/settings/EffectsControls.tsx +104 -9
  38. package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
  39. package/src/admin/editor/panels/settings/IconControls.tsx +14 -11
  40. package/src/admin/editor/panels/settings/LengthRow.tsx +27 -16
  41. package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
  42. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +1 -1
  43. package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
  44. package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
  45. package/src/admin/editor/panels/settings/StyleRow.tsx +113 -13
  46. package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
  47. package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
  48. package/src/admin/editor/panels/settings/background-mode.ts +14 -11
  49. package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
  50. package/src/admin/editor/panels/settings/box-sides.ts +22 -14
  51. package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
  52. package/src/admin/editor/panels/settings/length-units.ts +53 -1
  53. package/src/admin/editor/panels/settings/query-style.ts +3 -3
  54. package/src/admin/editor/panels/settings/style-sections.ts +51 -10
  55. package/src/admin/editor/panels/style-target.ts +9 -7
  56. package/src/admin/editor/presence.ts +60 -0
  57. package/src/admin/editor/store.ts +6 -2
  58. package/src/admin/editor/useCoDesign.ts +177 -0
  59. package/src/admin/editor/useEditorCommands.ts +4 -4
  60. package/src/admin/editor/useExtensions.ts +45 -0
  61. package/src/admin/editor/useNodeActions.ts +15 -6
  62. package/src/admin/editor/useProposals.ts +81 -0
  63. package/src/admin/languages-api.ts +61 -0
  64. package/src/admin/pages/AgentSetup.tsx +148 -0
  65. package/src/admin/pages/AgentsPage.tsx +9 -26
  66. package/src/admin/pages/CreateDialog.tsx +15 -0
  67. package/src/admin/pages/ImportButton.tsx +18 -0
  68. package/src/admin/pages/ImportElementorDialog.tsx +669 -0
  69. package/src/admin/pages/ImportPageLinks.tsx +86 -0
  70. package/src/admin/pages/PageList.tsx +15 -1
  71. package/src/admin/pages/ThemePartList.tsx +15 -1
  72. package/src/admin/pages/section-head.tsx +27 -0
  73. package/src/admin/proposals-api.ts +91 -0
  74. package/src/admin/ui.ts +39 -2
  75. package/src/astro/content-port.ts +14 -1
  76. package/src/astro/resolve-theme.ts +14 -1
  77. package/src/astro/resolve.ts +89 -2
  78. package/src/constants.ts +1 -1
  79. package/src/core/a11y/audit.ts +44 -14
  80. package/src/core/arrange.ts +5 -1
  81. package/src/core/bounded-array.ts +31 -0
  82. package/src/core/clipboard.ts +9 -0
  83. package/src/core/contract.ts +285 -0
  84. package/src/core/css/generate.ts +89 -20
  85. package/src/core/css/trace.ts +18 -9
  86. package/src/core/css-keywords.ts +51 -1
  87. package/src/core/design/cascade.ts +12 -9
  88. package/src/core/design/classes.ts +4 -5
  89. package/src/core/design/devices.ts +13 -13
  90. package/src/core/design/states.ts +5 -3
  91. package/src/core/design/transfer.ts +5 -0
  92. package/src/core/design/variables.ts +17 -4
  93. package/src/core/elements/dynamic-elements.ts +3 -3
  94. package/src/core/elements/index.ts +73 -9
  95. package/src/core/extensions/define.ts +13 -0
  96. package/src/core/extensions/index.ts +41 -0
  97. package/src/core/extensions/namespace.ts +82 -0
  98. package/src/core/extensions/normalize.ts +141 -0
  99. package/src/core/extensions/placeholder.ts +41 -0
  100. package/src/core/extensions/registry.ts +94 -0
  101. package/src/core/extensions/render-ext.ts +118 -0
  102. package/src/core/extensions/safe-nodes.ts +93 -0
  103. package/src/core/extensions/schema.ts +112 -0
  104. package/src/core/extensions/types.ts +159 -0
  105. package/src/core/forms/binding.ts +1 -1
  106. package/src/core/history/diff.ts +1 -1
  107. package/src/core/import/elementor/atomic.ts +1595 -0
  108. package/src/core/import/elementor/classes.ts +127 -0
  109. package/src/core/import/elementor/context.ts +429 -0
  110. package/src/core/import/elementor/counter-steps.ts +72 -0
  111. package/src/core/import/elementor/css.ts +445 -0
  112. package/src/core/import/elementor/html.ts +500 -0
  113. package/src/core/import/elementor/index.ts +949 -0
  114. package/src/core/import/elementor/inline-marks.ts +81 -0
  115. package/src/core/import/elementor/snapshots.ts +48 -0
  116. package/src/core/import/elementor/style.ts +409 -0
  117. package/src/core/import/elementor/values.ts +241 -0
  118. package/src/core/import/elementor/widgets.ts +1897 -0
  119. package/src/core/index.ts +82 -0
  120. package/src/core/json-schema.ts +107 -0
  121. package/src/core/limits.ts +19 -0
  122. package/src/core/migrate/index.ts +6 -1
  123. package/src/core/migrate/v18.ts +222 -0
  124. package/src/core/perf/meter.ts +5 -5
  125. package/src/core/proposals-safety.ts +102 -0
  126. package/src/core/proposals.ts +357 -0
  127. package/src/core/recipes/index.ts +2 -2
  128. package/src/core/render/extras.ts +3 -3
  129. package/src/core/render/index.ts +140 -20
  130. package/src/core/render/loop.ts +1 -1
  131. package/src/core/render/section.ts +4 -4
  132. package/src/core/render/vnode.ts +1 -1
  133. package/src/core/sanitize/css.ts +125 -10
  134. package/src/core/sanitize/motion.ts +116 -0
  135. package/src/core/saved-sections.ts +6 -0
  136. package/src/core/schema/descriptors.ts +3 -1
  137. package/src/core/schema/design.ts +2 -1
  138. package/src/core/schema/layout.ts +82 -14
  139. package/src/core/schema/style.ts +251 -114
  140. package/src/core/text-marks.ts +227 -0
  141. package/src/core/theme/dynamic.ts +9 -4
  142. package/src/core/theme/float.ts +1 -0
  143. package/src/core/theme/popup-rules.ts +17 -1
  144. package/src/core/translatable.ts +34 -0
  145. package/src/core/validate.ts +13 -1
  146. package/src/index.ts +24 -0
  147. package/src/mcp/errors.ts +3 -1
  148. package/src/mcp/ports.ts +67 -0
  149. package/src/mcp/prompts.ts +1 -11
  150. package/src/mcp/proposals.ts +281 -0
  151. package/src/mcp/read.ts +10 -9
  152. package/src/mcp/tools.ts +71 -3
  153. package/src/mcp/write.ts +66 -11
  154. package/src/server/agent-settings.ts +5 -1
  155. package/src/server/mcp-routes.ts +15 -0
  156. package/src/server/plugin.ts +35 -2
  157. package/src/server/presence.ts +78 -0
  158. package/src/server/proposals.ts +261 -0
  159. package/src/server/requests.ts +196 -0
  160. package/src/server/tools-served.ts +45 -0
@@ -375,7 +375,8 @@ export function TimelineDialog({
375
375
  title={v.agent.summary}
376
376
  >
377
377
  <RobotIcon aria-hidden="true" size={12} />
378
- Agent
378
+ {/* W-930: a person's save of changes accepted from a proposal. */}
379
+ {v.agent.tool === "accept_proposal" ? "Via agent" : "Agent"}
379
380
  </span>
380
381
  )}
381
382
  </button>
@@ -10,6 +10,7 @@ import {
10
10
  DeviceTabletIcon,
11
11
  FloppyDiskIcon,
12
12
  KeyboardIcon,
13
+ LaptopIcon,
13
14
  PaintBrushIcon,
14
15
  SignOutIcon,
15
16
  UploadSimpleIcon,
@@ -18,12 +19,13 @@ import {
18
19
  import { BUTTON, SOLID_PRIMARY } from "../ui.ts";
19
20
  import { statusLabel } from "../entry-status.ts";
20
21
  import type { SaveStatus } from "./useSave.ts";
21
- import type { PopupDevice } from "../../core/index.ts";
22
+ import type { Device } from "../../core/index.ts";
22
23
  import { useMediaQuery } from "./useMediaQuery.ts";
23
24
 
24
25
  /** Preview sizes (W-158): the canvas device widths, in a window of that size. */
25
26
  const PREVIEW_SIZES = [
26
27
  { device: "desktop", label: "Desktop", icon: DesktopIcon },
28
+ { device: "laptop", label: "Laptop (1200 px)", icon: LaptopIcon },
27
29
  { device: "tablet", label: "Tablet (768 px)", icon: DeviceTabletIcon },
28
30
  { device: "mobile", label: "Mobile (390 px)", icon: DeviceMobileIcon },
29
31
  ] as const;
@@ -91,7 +93,7 @@ export function TopBar({
91
93
  onShortcuts: () => void;
92
94
  onSiteStyles?: () => void;
93
95
  /** Opens the preview; with no device, at the device shown on the canvas (W-158). */
94
- onPreview: (device?: PopupDevice) => void;
96
+ onPreview: (device?: Device) => void;
95
97
  onSave: () => void;
96
98
  onPublish: () => void;
97
99
  /** Site styles have unpublished changes (W-153): the Publish button carries a dot. */
@@ -1,5 +1,5 @@
1
1
  import { createPortal } from "react-dom";
2
- import { isMultilineText, type Layout, type PopupDevice, type VNode } from "../../../core/index.ts";
2
+ import { isMultilineText, type Layout, type Device, type VNode } from "../../../core/index.ts";
3
3
  import type { PasteRefusal } from "../useClipboardActions.ts";
4
4
  import { CanvasTextEdit } from "./CanvasTextEdit.tsx";
5
5
  import { useFrameFocusRing } from "./frame-focus-ring.ts";
@@ -112,7 +112,7 @@ export function CanvasFrame({
112
112
  /** The style state chosen in the Style tab, shown on the selected element (W-089). */
113
113
  statePreview?: StatePreview | null;
114
114
  /** The previewed device (W-096): its page width, scaled to the stage (W-158, D-046). */
115
- device?: PopupDevice;
115
+ device?: Device;
116
116
  /** Fit to the stage or show at 100% (W-158). */
117
117
  zoom?: CanvasZoom;
118
118
  /** Told the on-screen scale whenever it changes, for the zoom readout (W-158). */
@@ -1,22 +1,30 @@
1
1
  import { Button, Tabs } from "@cloudflare/kumo";
2
- import { DesktopIcon, DeviceMobileIcon, DeviceTabletIcon, type Icon } from "@phosphor-icons/react";
2
+ import {
3
+ DesktopIcon,
4
+ DeviceMobileIcon,
5
+ DeviceTabletIcon,
6
+ type Icon,
7
+ LaptopIcon,
8
+ } from "@phosphor-icons/react";
3
9
  import * as React from "react";
4
- import { POPUP_DEVICES, type PopupDevice } from "../../../core/index.ts";
10
+ import { DEVICES, type Device } from "../../../core/index.ts";
5
11
 
6
- const LABELS: Record<PopupDevice, string> = {
12
+ const LABELS: Record<Device, string> = {
7
13
  desktop: "Desktop",
14
+ laptop: "Laptop",
8
15
  tablet: "Tablet",
9
16
  mobile: "Mobile",
10
17
  };
11
18
 
12
- const ICONS: Record<PopupDevice, Icon> = {
19
+ const ICONS: Record<Device, Icon> = {
13
20
  desktop: DesktopIcon,
21
+ laptop: LaptopIcon,
14
22
  tablet: DeviceTabletIcon,
15
23
  mobile: DeviceMobileIcon,
16
24
  };
17
25
 
18
26
  /** The device's icon (decorative) and its name, which stays the tab's accessible name (W-127). */
19
- function DeviceLabel({ device }: { device: PopupDevice }) {
27
+ function DeviceLabel({ device }: { device: Device }) {
20
28
  const DeviceIcon = ICONS[device];
21
29
  return (
22
30
  <span className="emvb-device-label">
@@ -38,13 +46,13 @@ export function DeviceBar({
38
46
  scale = 1,
39
47
  onZoom,
40
48
  }: {
41
- device: PopupDevice;
49
+ device: Device;
42
50
  /** Whether the selected element is hidden on `device`. */
43
51
  hidden: boolean;
44
52
  canHide: boolean;
45
53
  /** From the hide-on-device command, so the checkbox wording has one source. */
46
54
  hideLabel: string;
47
- onDevice: (device: PopupDevice) => void;
55
+ onDevice: (device: Device) => void;
48
56
  onToggleHidden: () => void;
49
57
  /** Fit or 100% (W-158), with the current on-screen scale for the readout. */
50
58
  zoom?: "fit" | "actual";
@@ -62,13 +70,13 @@ export function DeviceBar({
62
70
  variant="segmented"
63
71
  size="sm"
64
72
  className="emvb-device-tabs"
65
- tabs={POPUP_DEVICES.map((item) => ({
73
+ tabs={DEVICES.map((item) => ({
66
74
  value: item,
67
75
  label: <DeviceLabel device={item} />,
68
76
  }))}
69
77
  value={device}
70
78
  onValueChange={(next) => {
71
- if ((POPUP_DEVICES as readonly string[]).includes(next)) onDevice(next as PopupDevice);
79
+ if ((DEVICES as readonly string[]).includes(next)) onDevice(next as Device);
72
80
  }}
73
81
  />
74
82
  </div>
@@ -1,4 +1,4 @@
1
- import { DEVICE_PREVIEW_PX, type PopupDevice } from "../../../core/index.ts";
1
+ import { DEVICE_PREVIEW_PX, type Device } from "../../../core/index.ts";
2
2
 
3
3
  /** Fit scales the canvas down to the stage; Actual shows it at 100% and scrolls (W-158). */
4
4
  export type CanvasZoom = "fit" | "actual";
@@ -9,7 +9,7 @@ export type CanvasZoom = "fit" | "actual";
9
9
  * the stage width, never up; Actual keeps 100% and the stage scrolls sideways.
10
10
  */
11
11
  export function canvasScale(
12
- device: PopupDevice,
12
+ device: Device,
13
13
  stageWidth: number,
14
14
  zoom: CanvasZoom,
15
15
  ): { width: number; scale: number } {
@@ -4,7 +4,7 @@ import {
4
4
  isPlainTextNode,
5
5
  plainTextOf,
6
6
  type Layout,
7
- type PopupDevice,
7
+ type Device,
8
8
  type VNode,
9
9
  } from "../../../core/index.ts";
10
10
  import type { PasteRefusal, ClipboardActions } from "../useClipboardActions.ts";
@@ -65,7 +65,7 @@ export function useCanvasSession({
65
65
  layout: Layout | null;
66
66
  selection: CanvasSelection;
67
67
  statePreview: StatePreview | null;
68
- device: PopupDevice;
68
+ device: Device;
69
69
  zoom: CanvasZoom;
70
70
  onScale?: (scale: number) => void;
71
71
  refusal: PasteRefusal | null;
@@ -0,0 +1,190 @@
1
+ import { applyProposal, type Proposal, type ProposalRefusal } from "../../core/proposals.ts";
2
+ import type { DesignSystem } from "../../core/schema/design.ts";
3
+ import type { Layout, LayoutNode } from "../../core/schema/layout.ts";
4
+ import { findNode, forEachNode } from "../../core/tree-ops.ts";
5
+ import { ELEMENT_NAMES } from "./element-chrome.ts";
6
+ import { adminExtensionInstalled } from "./extension-manifests.ts";
7
+
8
+ const OPTIONS = { extensionInstalled: adminExtensionInstalled };
9
+
10
+ /**
11
+ * W-930 co-design review, as pure functions over the editor's own state. Accepting runs the same
12
+ * `applyProposal` the server checked with, on the page as it is in the editor now (unsaved edits
13
+ * included), so nothing an agent sent reaches the page without passing every save-time check.
14
+ */
15
+
16
+ export type Op = Proposal["ops"][number];
17
+ export type OpGroup = "added" | "changed" | "moved" | "removed" | "styles";
18
+ export const GROUP_LABELS: Record<OpGroup, string> = {
19
+ added: "Added",
20
+ changed: "Changed",
21
+ moved: "Moved",
22
+ removed: "Removed",
23
+ styles: "Site styles",
24
+ };
25
+ export const GROUP_ORDER: readonly OpGroup[] = ["added", "changed", "moved", "removed", "styles"];
26
+
27
+ /** What the editor knows about its page and styles, as a proposal base. */
28
+ export type EditorBase = {
29
+ rev: string | null;
30
+ layout: Layout | null;
31
+ design: DesignSystem;
32
+ /** The style draft's revision, or the published one when there is no draft (as the server). */
33
+ designRevision: string | null;
34
+ };
35
+
36
+ export const groupOf = (op: Op): OpGroup =>
37
+ op.kind === "insert"
38
+ ? "added"
39
+ : op.kind === "update"
40
+ ? "changed"
41
+ : op.kind === "move"
42
+ ? "moved"
43
+ : op.kind === "delete"
44
+ ? "removed"
45
+ : "styles";
46
+
47
+ const nameOf = (node: { type?: unknown } | undefined | null): string =>
48
+ (typeof node?.type === "string" && ELEMENT_NAMES[node.type]) ||
49
+ (typeof node?.type === "string" ? node.type : "Element");
50
+
51
+ const textOf = (node: unknown): string | undefined => {
52
+ const props = (node as { props?: Record<string, unknown> } | null)?.props;
53
+ const text = props?.["text"] ?? props?.["label"];
54
+ if (typeof text !== "string" || !text.trim()) return undefined;
55
+ // W-933: direction overrides and other invisible controls could make a change read as another.
56
+ const plain = text.replace(BIDI_AND_CONTROLS, "").trim().replace(/\s+/g, " ");
57
+ return plain.length > 48 ? `${plain.slice(0, 47)}…` : plain;
58
+ };
59
+
60
+ /** C0 controls (not tab or newline), zero-width and bidi formatting characters. */
61
+ const BIDI_AND_CONTROLS =
62
+ // oxlint-disable-next-line no-control-regex
63
+ /[\u0000-\u0008\u000B-\u001F\u007F\u200B-\u200F\u202A-\u202E\u2060-\u2069\uFEFF]/g;
64
+
65
+ const quoted = (text: string | undefined) => (text ? ` “${text}”` : "");
66
+
67
+ /** One line a person can read: what the change does, to which element. Agent text is quoted. */
68
+ export function describeOp(op: Op, layout: Layout | null): string {
69
+ const target = (id: string) => (layout ? findNode(layout, id) : null);
70
+ switch (op.kind) {
71
+ case "insert": {
72
+ const parent = target(op.parentId);
73
+ return `Add ${nameOf(op.node)}${quoted(textOf(op.node))} to ${nameOf(parent)}`;
74
+ }
75
+ case "update": {
76
+ const node = target(op.id);
77
+ const fields = Object.keys(op.set).join(", ");
78
+ const text = textOf({ props: op.set["props"] });
79
+ return text
80
+ ? `Change ${nameOf(node)} text to${quoted(text)}`
81
+ : `Change ${nameOf(node)}${quoted(textOf(node))}: ${fields}`;
82
+ }
83
+ case "move": {
84
+ const node = target(op.id);
85
+ return `Move ${nameOf(node)}${quoted(textOf(node))} into ${nameOf(target(op.parentId))}`;
86
+ }
87
+ case "delete": {
88
+ const node = target(op.id);
89
+ return `Remove ${nameOf(node)}${quoted(textOf(node))}`;
90
+ }
91
+ case "class":
92
+ return op.value === null
93
+ ? `Remove class ${op.id}`
94
+ : `Set class “${String(op.value["name"] ?? op.id)}”`;
95
+ case "variable":
96
+ return op.value === null
97
+ ? `Remove ${op.group} variable ${op.id}`
98
+ : `Set ${op.group} variable “${String(op.value["name"] ?? op.id)}”`;
99
+ }
100
+ }
101
+
102
+ const baseOf = (editor: EditorBase) => ({
103
+ revision: editor.rev ?? "",
104
+ layout: editor.layout,
105
+ design: editor.design,
106
+ designRevision: editor.designRevision,
107
+ });
108
+
109
+ /**
110
+ * The page and styles with the selected changes applied, or why they can't be. Never mutates the
111
+ * editor's state; the caller dispatches the result as one undoable edit.
112
+ */
113
+ export function acceptOps(
114
+ editor: EditorBase,
115
+ proposal: Proposal,
116
+ selected: readonly number[],
117
+ ): { ok: true; layout: Layout; design: DesignSystem; designChanged: boolean } | ProposalRefusal {
118
+ const applied = applyProposal(
119
+ baseOf(editor),
120
+ proposal,
121
+ [...selected].toSorted((a, b) => a - b),
122
+ OPTIONS,
123
+ );
124
+ if (!applied.ok) return applied;
125
+ const designChanged = selected.some((i) => groupOf(proposal.ops[i] as Op) === "styles");
126
+ return { ...applied, designChanged };
127
+ }
128
+
129
+ export type Ghost = {
130
+ layout: Layout;
131
+ added: Set<string>;
132
+ changed: Set<string>;
133
+ removed: Set<string>;
134
+ };
135
+
136
+ const idsOf = (layout: Layout): Set<string> => {
137
+ const ids = new Set<string>();
138
+ forEachNode(layout.root as LayoutNode, (node) => ids.add(node.id));
139
+ return ids;
140
+ };
141
+
142
+ /**
143
+ * W-930 ghost preview of pending changes: the layout with every pending insert, update and move
144
+ * applied, and removals kept in place so they can be shown struck through. A new layout object;
145
+ * the editor's own layout is never touched. Null when the pending changes don't apply.
146
+ */
147
+ export function ghostOf(
148
+ editor: EditorBase,
149
+ proposal: Proposal,
150
+ pending: readonly number[],
151
+ ): Ghost | null {
152
+ if (!editor.layout) return null;
153
+ const shown = pending.filter((i) => {
154
+ const op = proposal.ops[i];
155
+ return op && op.kind !== "delete" && groupOf(op) !== "styles";
156
+ });
157
+ const before = idsOf(editor.layout);
158
+ const applied =
159
+ shown.length === 0
160
+ ? { ok: true as const, layout: structuredClone(editor.layout) }
161
+ : applyProposal(baseOf(editor), proposal, shown, OPTIONS);
162
+ if (!applied.ok) return null;
163
+ const added = new Set([...idsOf(applied.layout)].filter((id) => !before.has(id)));
164
+ const changed = new Set<string>();
165
+ const removed = new Set<string>();
166
+ for (const i of pending) {
167
+ const op = proposal.ops[i];
168
+ if (op?.kind === "update" || op?.kind === "move") changed.add(op.id);
169
+ if (op?.kind === "delete") removed.add(op.id);
170
+ }
171
+ return { layout: applied.layout, added, changed, removed };
172
+ }
173
+
174
+ /** Canvas CSS that marks the ghost: added = blue outline, changed = dashed, removed = struck. */
175
+ const ghostSelector = (ids: Set<string>) =>
176
+ [...ids].map((id) => `[data-emvb-id="${id.replace(/[^A-Za-z0-9_-]/g, "")}"]`).join(",");
177
+
178
+ export function ghostCss(ghost: Ghost): string {
179
+ const sel = ghostSelector;
180
+ const rules: string[] = [];
181
+ if (ghost.added.size)
182
+ rules.push(`${sel(ghost.added)}{outline:2px solid #2563eb;outline-offset:2px}`);
183
+ if (ghost.changed.size)
184
+ rules.push(`${sel(ghost.changed)}{outline:2px dashed #2563eb;outline-offset:2px}`);
185
+ if (ghost.removed.size)
186
+ rules.push(
187
+ `${sel(ghost.removed)}{outline:2px dashed #dc2626;outline-offset:2px;opacity:.5;text-decoration:line-through}`,
188
+ );
189
+ return rules.join("\n");
190
+ }
@@ -1,11 +1,14 @@
1
1
  import {
2
2
  defaultElement,
3
3
  ELEMENTS,
4
+ isExtensionType,
4
5
  newNodeId,
5
6
  type ElementType,
6
7
  type Layout,
7
8
  type LayoutNode,
8
9
  } from "../../../core/index.ts";
10
+ import type { ThemePartType } from "../../../core/theme/part-types.ts";
11
+ import { isSharedPart } from "../panels/settings/heading-warning.ts";
9
12
 
10
13
  const hasH1 = (node: LayoutNode): boolean =>
11
14
  ((node.type === "heading" || node.type === "post-title") &&
@@ -14,10 +17,17 @@ const hasH1 = (node: LayoutNode): boolean =>
14
17
 
15
18
  /**
16
19
  * A new Heading is the page's H1 when the page has none yet, otherwise the default H2 (W-147).
17
- * Other nodes, and headings whose level was already chosen, are returned as they are.
20
+ * Other nodes, and headings whose level was already chosen, are returned as they are. In a
21
+ * header, footer, popup, float, synced section or loop item it stays H2: that part lands on pages
22
+ * that have their own H1 (W-946).
18
23
  */
19
- export function withPageHeadingLevel(node: LayoutNode, layout: Layout): LayoutNode {
20
- if (node.type !== "heading" || node.props.level !== 2 || hasH1(layout.root)) return node;
24
+ export function withPageHeadingLevel(
25
+ node: LayoutNode,
26
+ layout: Layout,
27
+ partType?: ThemePartType,
28
+ ): LayoutNode {
29
+ if (node.type !== "heading" || node.props.level !== 2) return node;
30
+ if (isSharedPart(partType) || hasH1(layout.root)) return node;
21
31
  return { ...node, props: { ...node.props, level: 1 } };
22
32
  }
23
33
 
@@ -55,7 +65,19 @@ export function newTabPanel(n: number, random?: () => number): LayoutNode {
55
65
  * Default node for a new element from the Add panel. Only new inserts get starter children;
56
66
  * saved Accordions and Tabs with no items keep working as they are (W-130).
57
67
  */
58
- export function newElement(type: string, random?: () => number): LayoutNode | null {
68
+ export function newElement(
69
+ type: string,
70
+ random?: () => number,
71
+ extensionDefaults?: Record<string, unknown>,
72
+ ): LayoutNode | null {
73
+ // W-927: extension elements are stored as UnknownNodes with namespaced types.
74
+ if (isExtensionType(type)) {
75
+ return {
76
+ id: newNodeId(random),
77
+ type,
78
+ props: extensionDefaults ? { ...extensionDefaults } : {},
79
+ };
80
+ }
59
81
  if (!(type in ELEMENTS)) return null;
60
82
  if (type === "tabs") {
61
83
  const tabs = defaultElement("tabs", newNodeId(random));
@@ -8,7 +8,7 @@ import {
8
8
  type A11yReport,
9
9
  type ElementType,
10
10
  type LayoutNode,
11
- type PopupDevice,
11
+ type Device,
12
12
  type ThemeDynamicData,
13
13
  } from "../../core/index.ts";
14
14
  import type { Fetcher } from "../api.ts";
@@ -167,7 +167,7 @@ async function revertToPublished({
167
167
  /** Hide or show the selected element on the current device (W-096). */
168
168
  export function hideSelectedOnDevice(
169
169
  state: EditorState,
170
- device: PopupDevice,
170
+ device: Device,
171
171
  dispatch: React.Dispatch<EditorAction>,
172
172
  ): void {
173
173
  const id = state.selectedId;
@@ -225,7 +225,7 @@ export function EditorDialogs({
225
225
  selectedNode: LayoutNode | null;
226
226
  formsAvailable: boolean;
227
227
  paletteActions: readonly EditorCommand[];
228
- addFromPanel: (type: ElementType) => void;
228
+ addFromPanel: (type: ElementType | string) => void;
229
229
  addRecipe: (id: string) => void;
230
230
  deleteAsk: { id: string; label: string; count: number } | null;
231
231
  setDeleteAsk: (ask: { id: string; label: string; count: number } | null) => void;
@@ -1,4 +1,4 @@
1
- import type { PasteMode, PopupDevice, WrapType } from "../../core/index.ts";
1
+ import type { PasteMode, Device, WrapType } from "../../core/index.ts";
2
2
 
3
3
  /** Where an editor command is offered. Shortcuts call `runCommand` for the same ids. */
4
4
  export type CommandSurface = "palette" | "layers" | "overlay" | "device";
@@ -39,7 +39,7 @@ export type CommandRunners = {
39
39
  openTimeline?: () => void;
40
40
  openShare?: () => void;
41
41
  openWeight?: () => void;
42
- setDevice?: (device: PopupDevice) => void;
42
+ setDevice?: (device: Device) => void;
43
43
  openShortcuts?: () => void;
44
44
  rename?: () => void;
45
45
  /** Opens Save as section for an element (W-876). */
@@ -53,7 +53,7 @@ export type CommandInput = {
53
53
  targetId: string | null;
54
54
  isRoot: boolean;
55
55
  isParent: boolean;
56
- device: PopupDevice;
56
+ device: Device;
57
57
  /** Duplicate and wrap. False on the root and when nothing is selected. */
58
58
  canDuplicate: boolean;
59
59
  /** Delete and the sibling moves. False on the root. */
@@ -185,6 +185,7 @@ const SPECS: readonly Spec[] = [
185
185
  surfaces: ["palette"],
186
186
  },
187
187
  { id: "device-desktop", labels: { palette: "View on desktop" }, surfaces: ["palette"] },
188
+ { id: "device-laptop", labels: { palette: "View on laptop" }, surfaces: ["palette"] },
188
189
  { id: "device-tablet", labels: { palette: "View on tablet" }, surfaces: ["palette"] },
189
190
  { id: "device-mobile", labels: { palette: "View on mobile" }, surfaces: ["palette"] },
190
191
  {
@@ -232,6 +233,7 @@ const ORDER: Record<CommandSurface, readonly string[]> = {
232
233
  "share",
233
234
  "weight",
234
235
  "device-desktop",
236
+ "device-laptop",
235
237
  "device-tablet",
236
238
  "device-mobile",
237
239
  "shortcuts",
@@ -370,6 +372,9 @@ export function runCommand(runners: CommandRunners, id: string, targetId: string
370
372
  case "device-desktop":
371
373
  runners.setDevice?.("desktop");
372
374
  return;
375
+ case "device-laptop":
376
+ runners.setDevice?.("laptop");
377
+ return;
373
378
  case "device-tablet":
374
379
  runners.setDevice?.("tablet");
375
380
  return;
@@ -19,6 +19,7 @@ import {
19
19
  ListBulletsIcon,
20
20
  ListIcon,
21
21
  ListNumbersIcon,
22
+ TranslateIcon,
22
23
  MinusIcon,
23
24
  NotePencilIcon,
24
25
  PaperPlaneRightIcon,
@@ -53,7 +54,7 @@ export const ELEMENT_ICONS: Record<string, Icon> = {
53
54
  container: SquaresFourIcon,
54
55
  "div-block": SquareIcon,
55
56
  "layout-section": RowsIcon,
56
- section: StackIcon,
57
+ "part-ref": StackIcon,
57
58
  flexbox: ColumnsIcon,
58
59
  grid: GridFourIcon,
59
60
  spacer: ArrowsVerticalIcon,
@@ -74,6 +75,7 @@ export const ELEMENT_ICONS: Record<string, Icon> = {
74
75
  menu: ListIcon,
75
76
  "menu-item": CaretDownIcon,
76
77
  toc: ListNumbersIcon,
78
+ "language-switcher": TranslateIcon,
77
79
  video: VideoCameraIcon,
78
80
  form: ArticleIcon,
79
81
  "text-input": TextboxIcon,
@@ -0,0 +1,20 @@
1
+ import type { ExtensionManifest } from "../../core/index.ts";
2
+
3
+ /** Admin-side cache of manifests from editor/config (no render functions). */
4
+ let cache: readonly ExtensionManifest[] = [];
5
+
6
+ export function setAdminExtensionManifests(manifests: readonly ExtensionManifest[]): void {
7
+ cache = manifests;
8
+ }
9
+
10
+ export function adminExtensionDefaults(type: string): Record<string, unknown> | undefined {
11
+ for (const ext of cache) {
12
+ const el = ext.elements.find((e) => e.type === type);
13
+ if (el) return { ...el.defaults };
14
+ }
15
+ return undefined;
16
+ }
17
+
18
+ /** W-933: whether the site registered the extension for `type`, as the editor's manifests say. */
19
+ export const adminExtensionInstalled = (type: string): boolean =>
20
+ cache.some((ext) => ext.elements.some((e) => e.type === type));
@@ -0,0 +1,26 @@
1
+ import { useExtensions } from "../extensions-context.tsx";
2
+
3
+ /**
4
+ * W-927 / D-067: Kumo-slot area for declarative extension panels. EmVB renders the
5
+ * panel copy with existing EmVB/Kumo tokens; extensions may not inject global admin CSS.
6
+ */
7
+ export function ExtensionPanels() {
8
+ const extensions = useExtensions();
9
+ const panels = extensions.flatMap((ext) => ext.panels.map((panel) => ({ ext, panel })));
10
+ if (panels.length === 0) return null;
11
+ return (
12
+ <div className="emvb-ext-panels emvb-add-group" data-emvb-ext-panels="">
13
+ <h3 className="emvb-add-group-title">Extensions</h3>
14
+ {panels.map(({ ext, panel }) => (
15
+ <div key={panel.id} className="emvb-ext-panel" data-emvb-ext-panel={panel.id}>
16
+ <h4 className="emvb-panel-title">{panel.label}</h4>
17
+ {panel.description ? <p className="emvb-helper">{panel.description}</p> : null}
18
+ <p className="emvb-helper">
19
+ From {ext.label}
20
+ {panel.source ? ` · source “${panel.source}”` : ""}
21
+ </p>
22
+ </div>
23
+ ))}
24
+ </div>
25
+ );
26
+ }
@@ -0,0 +1,27 @@
1
+ import * as React from "react";
2
+ import type { ExtensionManifest } from "../../core/index.ts";
3
+ import { extensionElementManifests } from "./useExtensions.ts";
4
+
5
+ const ExtensionsContext = React.createContext<readonly ExtensionManifest[]>([]);
6
+
7
+ export function ExtensionsProvider({
8
+ extensions,
9
+ children,
10
+ }: {
11
+ extensions: readonly ExtensionManifest[];
12
+ children: React.ReactNode;
13
+ }) {
14
+ return <ExtensionsContext.Provider value={extensions}>{children}</ExtensionsContext.Provider>;
15
+ }
16
+
17
+ export function useExtensions(): readonly ExtensionManifest[] {
18
+ return React.useContext(ExtensionsContext);
19
+ }
20
+
21
+ export function useExtensionElements() {
22
+ return extensionElementManifests(useExtensions());
23
+ }
24
+
25
+ export function useExtensionElement(type: string) {
26
+ return useExtensionElements().find((el) => el.type === type);
27
+ }
@@ -163,4 +163,21 @@ export const FEATURE_CSS = `
163
163
  /* UX-092: the fixed theme part type, its label and value on one line */
164
164
  .emvb-part-type { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0; }
165
165
  .emvb-part-type-value { font-size: 13px; line-height: 20px; font-weight: 600; color: var(--text-color-kumo-default); }
166
+ /* W-930: co-design review (Agent tab) and the canvas ghost-preview notice */
167
+ .emvb-codesign { display: grid; gap: 12px; padding: 12px; }
168
+ .emvb-codesign-status { display: flex; align-items: center; gap: 6px; margin: 0; }
169
+ .emvb-codesign-card { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--color-kumo-line); border-radius: 10px; background: var(--color-kumo-base); }
170
+ .emvb-codesign-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
171
+ .emvb-codesign-group { display: grid; gap: 4px; }
172
+ .emvb-codesign-group-title { margin: 0; font-size: 12px; font-weight: 600; color: var(--text-color-kumo-subtle); }
173
+ .emvb-codesign-ops { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
174
+ .emvb-codesign-op { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; padding: 2px 4px 2px 8px; border-radius: 6px; font-size: 13px; line-height: 18px; }
175
+ .emvb-codesign-op:hover { background: var(--color-kumo-tint); }
176
+ .emvb-codesign-op-text { min-width: 0; overflow-wrap: anywhere; }
177
+ .emvb-codesign-op-actions { display: inline-flex; flex: none; gap: 2px; }
178
+ .emvb-codesign-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
179
+ .emvb-codesign-ask { display: grid; gap: 8px; padding-block-end: 12px; border-block-end: 1px solid var(--color-kumo-line); }
180
+ .emvb-codesign-ask-form { display: grid; gap: 6px; }
181
+ .emvb-codesign-ask-form .emvb-helper { margin: 0; }
182
+ .emvb-codesign-preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 12px 0; padding: 8px 8px 8px 12px; border: 1px solid var(--color-kumo-line); border-radius: 10px; background: var(--color-kumo-tint); font-size: 13px; line-height: 18px; }
166
183
  `;
@@ -116,7 +116,7 @@ export function paletteItems(ctx: PaletteActions): PaletteItem[] {
116
116
  const walk = (node: LayoutNode, depth: number): void => {
117
117
  if (count >= MAX_LAYERS) return;
118
118
  count += 1;
119
- const name = node.label || ELEMENT_NAMES[node.type] || node.type;
119
+ const name = node.editorLabel || ELEMENT_NAMES[node.type] || node.type;
120
120
  const text = textOf(node);
121
121
  items.push({
122
122
  id: `layer:${node.id}`,
@@ -150,7 +150,7 @@ export function paletteItems(ctx: PaletteActions): PaletteItem[] {
150
150
  id: `class:${cls.id}`,
151
151
  group: "Apply class",
152
152
  label: `Apply .${cls.name}`,
153
- hint: `to ${selected.label || ELEMENT_NAMES[selected.type] || selected.type}`,
153
+ hint: `to ${selected.editorLabel || ELEMENT_NAMES[selected.type] || selected.type}`,
154
154
  keywords: cls.id,
155
155
  run: () => ctx.applyClass(selected.id, cls.id),
156
156
  });