@perkyzz/emvb 1.3.0 → 1.4.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 (134) hide show
  1. package/README.md +2 -2
  2. package/package.json +2 -2
  3. package/src/admin/bulk-api.ts +5 -1
  4. package/src/admin/editor/A11yCopilot.tsx +3 -1
  5. package/src/admin/editor/Editor.tsx +22 -2
  6. package/src/admin/editor/Timeline.tsx +1 -8
  7. package/src/admin/editor/canvas/DeviceBar.tsx +7 -2
  8. package/src/admin/editor/canvas/EmptyCanvas.tsx +11 -2
  9. package/src/admin/editor/canvas/use-canvas-dnd.ts +1 -20
  10. package/src/admin/editor/canvas/vnode-react.tsx +2 -0
  11. package/src/admin/editor/co-design.ts +36 -1
  12. package/src/admin/editor/dnd/dragged-source.ts +22 -0
  13. package/src/admin/editor/dnd/layer-drop.ts +141 -0
  14. package/src/admin/editor/dnd/new-element.ts +16 -0
  15. package/src/admin/editor/editor-css.ts +9 -1
  16. package/src/admin/editor/element-chrome.ts +6 -0
  17. package/src/admin/editor/feature-css.ts +22 -0
  18. package/src/admin/editor/inert-links.ts +8 -0
  19. package/src/admin/editor/panels/ColorControl.tsx +2 -2
  20. package/src/admin/editor/panels/FontFaces.tsx +342 -0
  21. package/src/admin/editor/panels/LayersPanel.tsx +56 -6
  22. package/src/admin/editor/panels/LeftPanel.tsx +153 -29
  23. package/src/admin/editor/panels/SettingsPanel.tsx +1 -0
  24. package/src/admin/editor/panels/SiteStylesDrawer.tsx +5 -0
  25. package/src/admin/editor/panels/TemplatesPanel.tsx +205 -0
  26. package/src/admin/editor/panels/TokenScales.tsx +2 -0
  27. package/src/admin/editor/panels/TriggersEditor.tsx +203 -9
  28. package/src/admin/editor/panels/VariableSection.tsx +111 -7
  29. package/src/admin/editor/panels/color-space.ts +71 -6
  30. package/src/admin/editor/panels/settings/AudienceEditor.tsx +3 -0
  31. package/src/admin/editor/panels/settings/FieldControl.tsx +18 -0
  32. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +9 -3
  33. package/src/admin/editor/panels/settings/StickyControl.tsx +97 -0
  34. package/src/admin/editor/panels/settings/StyleRow.tsx +14 -0
  35. package/src/admin/editor/panels/settings/style-sections.ts +19 -2
  36. package/src/admin/editor/panels/url-rules.ts +43 -0
  37. package/src/admin/editor/panels/use-layers-drop.ts +232 -0
  38. package/src/admin/editor/store.ts +4 -2
  39. package/src/admin/editor/useExtensions.ts +3 -1
  40. package/src/admin/editor/useNodeActions.ts +74 -1
  41. package/src/admin/editor/useSave.ts +116 -85
  42. package/src/admin/export-api.ts +25 -2
  43. package/src/admin/extension-outputs.ts +179 -0
  44. package/src/admin/font-files-api.ts +38 -0
  45. package/src/admin/pages/ImportButton.tsx +15 -4
  46. package/src/admin/pages/ImportElementorDialog.tsx +22 -188
  47. package/src/admin/pages/ImportHtmlDialog.tsx +209 -0
  48. package/src/admin/pages/ImportImageCopies.tsx +167 -0
  49. package/src/admin/pages/ImportReport.tsx +63 -0
  50. package/src/admin/pages/NewPageDialog.tsx +54 -32
  51. package/src/admin/pages/PageList.tsx +9 -0
  52. package/src/admin/pages/ThemePartList.tsx +9 -0
  53. package/src/astro/EmVBPage.astro +5 -2
  54. package/src/astro/extension-styles.ts +35 -0
  55. package/src/astro/forms/EmVBFormsClient.astro +3 -0
  56. package/src/astro/forms/enhance.ts +107 -0
  57. package/src/astro/popups/runtime.ts +47 -2
  58. package/src/astro/render.ts +19 -4
  59. package/src/astro/resolve-theme.ts +11 -4
  60. package/src/astro/widgets/EmVBStickyRuntime.astro +9 -0
  61. package/src/astro/widgets/EmVBThemeRuntime.astro +9 -0
  62. package/src/astro/widgets/EmVBWidgetRuntimes.astro +12 -0
  63. package/src/astro/widgets/alerts.ts +16 -2
  64. package/src/astro/widgets/carousel.ts +65 -24
  65. package/src/astro/widgets/countdown.ts +18 -7
  66. package/src/astro/widgets/extension-runtimes.ts +27 -0
  67. package/src/astro/widgets/headline.ts +14 -5
  68. package/src/astro/widgets/sticky.ts +87 -0
  69. package/src/astro/widgets/theme.ts +52 -0
  70. package/src/constants.ts +1 -1
  71. package/src/core/a11y/audit.ts +150 -2
  72. package/src/core/arrange.ts +19 -1
  73. package/src/core/css/font-face.ts +72 -0
  74. package/src/core/css/generate.ts +35 -1
  75. package/src/core/elements/form-elements.ts +119 -9
  76. package/src/core/elements/icon-svg.ts +14 -0
  77. package/src/core/elements/index.ts +24 -4
  78. package/src/core/elements/input-limits.ts +44 -0
  79. package/src/core/elements/menu.ts +109 -47
  80. package/src/core/elements/site.ts +108 -0
  81. package/src/core/elements/widgets.ts +13 -3
  82. package/src/core/export/runtimes.generated.ts +7 -5
  83. package/src/core/export/site.ts +50 -4
  84. package/src/core/extensions/classes.ts +114 -0
  85. package/src/core/extensions/index.ts +17 -2
  86. package/src/core/extensions/normalize.ts +13 -0
  87. package/src/core/extensions/registry.ts +134 -10
  88. package/src/core/extensions/render-ext.ts +66 -21
  89. package/src/core/extensions/safe-nodes.ts +67 -11
  90. package/src/core/extensions/types.ts +48 -1
  91. package/src/core/fonts/files.ts +74 -0
  92. package/src/core/fonts/google.ts +112 -0
  93. package/src/core/fonts/test-font.ts +9 -0
  94. package/src/core/import/elementor/context.ts +13 -4
  95. package/src/core/import/elementor/index.ts +32 -21
  96. package/src/core/import/elementor/widgets.ts +114 -12
  97. package/src/core/import/html/blocks.ts +602 -0
  98. package/src/core/import/html/index.ts +155 -0
  99. package/src/core/import/html/map.ts +958 -0
  100. package/src/core/import/html/parse.ts +430 -0
  101. package/src/core/index.ts +45 -0
  102. package/src/core/migrate/v18.ts +3 -0
  103. package/src/core/public-attributes.ts +17 -0
  104. package/src/core/render/extras.ts +31 -7
  105. package/src/core/render/form.ts +103 -10
  106. package/src/core/render/index.ts +151 -15
  107. package/src/core/render/section.ts +31 -1
  108. package/src/core/render/spacer-basis.ts +102 -0
  109. package/src/core/render/theme-boot.ts +16 -0
  110. package/src/core/render/vnode.ts +1 -1
  111. package/src/core/sanitize/css.ts +68 -3
  112. package/src/core/sanitize/motion.ts +12 -0
  113. package/src/core/schema/design.ts +40 -0
  114. package/src/core/schema/layout.ts +114 -5
  115. package/src/core/schema/style.ts +28 -0
  116. package/src/core/templates/index.ts +218 -0
  117. package/src/core/templates/pages.ts +29 -0
  118. package/src/core/templates/sections.ts +794 -0
  119. package/src/core/templates/types.ts +9 -0
  120. package/src/core/theme/dynamic.ts +9 -6
  121. package/src/core/theme/popup-markup.ts +21 -2
  122. package/src/core/theme/popup-rules.ts +36 -0
  123. package/src/core/theme/triggers.ts +64 -5
  124. package/src/core/translatable.ts +5 -2
  125. package/src/extension-build.ts +331 -0
  126. package/src/index.ts +25 -3
  127. package/src/mcp/brief.ts +191 -0
  128. package/src/mcp/prompts.ts +33 -0
  129. package/src/mcp/read.ts +29 -1
  130. package/src/mcp/tools.ts +40 -1
  131. package/src/mcp/write.ts +41 -1
  132. package/src/server/extension-routes.ts +73 -0
  133. package/src/server/font-routes.ts +301 -0
  134. package/src/server/plugin.ts +9 -0
@@ -338,8 +338,8 @@ function CustomColor({
338
338
  />
339
339
  {clipped !== null && clipped === draft && !error && (
340
340
  <p className="emvb-helper" role="status" data-emvb-clipped="">
341
- Clipped to {clipped}: that OKLCH colour is outside sRGB, so its out-of-range channels were
342
- cut to fit.
341
+ Mapped to {clipped}: that OKLCH colour is outside sRGB, so it keeps its lightness and hue
342
+ with less chroma.
343
343
  </p>
344
344
  )}
345
345
  </div>
@@ -0,0 +1,342 @@
1
+ import { Button, Checkbox, Input } from "@cloudflare/kumo";
2
+ import { TrashIcon, UploadSimpleIcon } from "@phosphor-icons/react";
3
+ import * as React from "react";
4
+ import {
5
+ FONT_FAMILY_NAME,
6
+ fontFaceRules,
7
+ GOOGLE_FAMILY,
8
+ GOOGLE_WEIGHTS,
9
+ type FontFace,
10
+ type FontVariable,
11
+ } from "../../../core/index.ts";
12
+ import type { Fetcher } from "../../api.ts";
13
+ import { importGoogleFont, uploadFontFile } from "../../font-files-api.ts";
14
+ import { BUTTON, FIELD } from "../../ui.ts";
15
+ import { InlineError } from "./inline-error.tsx";
16
+ import { PanelSelect } from "./settings/PanelSelect.tsx";
17
+
18
+ const WEIGHT_NAMES: Record<number, string> = {
19
+ 100: "Thin",
20
+ 200: "Extra light",
21
+ 300: "Light",
22
+ 400: "Regular",
23
+ 500: "Medium",
24
+ 600: "Semibold",
25
+ 700: "Bold",
26
+ 800: "Extra bold",
27
+ 900: "Black",
28
+ };
29
+
30
+ /** Subsets offered for Google fonts besides Latin, which is always downloaded. */
31
+ const EXTRA_SUBSETS = [
32
+ { value: "latin-ext", label: "Latin Extended" },
33
+ { value: "cyrillic", label: "Cyrillic" },
34
+ { value: "greek", label: "Greek" },
35
+ { value: "vietnamese", label: "Vietnamese" },
36
+ ] as const;
37
+
38
+ const faceLabel = (weight: number, style: string) =>
39
+ `${WEIGHT_NAMES[weight] ?? "Weight"} ${weight}${style === "italic" ? " italic" : ""}`;
40
+
41
+ /** The first family of a font stack, unquoted, when it can name a custom font. */
42
+ function firstFamily(stack: string): string {
43
+ const first = (stack.split(",")[0] ?? "").trim().replace(/^(['"])(.*)\1$/, "$2");
44
+ return FONT_FAMILY_NAME.test(first) ? first : "";
45
+ }
46
+
47
+ /** The stack with `family` first (quoted), unless it already starts with it. */
48
+ export function stackWithFamily(stack: string, family: string): string {
49
+ if (firstFamily(stack) === family) return stack;
50
+ const next = `'${family}', ${stack}`;
51
+ return next.length <= 200 ? next : `'${family}', sans-serif`;
52
+ }
53
+
54
+ /** Faces of one weight and style replace the ones the variable had for it. */
55
+ function mergeFaces(current: readonly FontFace[], added: readonly FontFace[]): FontFace[] {
56
+ const replaced = new Set(added.map((face) => `${face.weight}/${face.style}`));
57
+ return [...current.filter((face) => !replaced.has(`${face.weight}/${face.style}`)), ...added];
58
+ }
59
+
60
+ /**
61
+ * W-1072: a font variable's own font files. Uploaded WOFF2 files, or a Google font downloaded
62
+ * once by the server, are served from this site, so pages make no request to another host.
63
+ */
64
+ export function FontFaces({
65
+ font,
66
+ fetcher,
67
+ onSave,
68
+ }: {
69
+ font: FontVariable;
70
+ fetcher: Fetcher;
71
+ onSave: (next: FontVariable) => Promise<boolean | void>;
72
+ }) {
73
+ const id = React.useId();
74
+ const fileRef = React.useRef<HTMLInputElement | null>(null);
75
+ const [family, setFamily] = React.useState(font.family ?? firstFamily(font.value));
76
+ const [weight, setWeight] = React.useState("400");
77
+ const [style, setStyle] = React.useState<"normal" | "italic">("normal");
78
+ const [google, setGoogle] = React.useState(font.source === "google" ? (font.family ?? "") : "");
79
+ const [weights, setWeights] = React.useState<number[]>([400, 700]);
80
+ const [italic, setItalic] = React.useState(false);
81
+ const [subsets, setSubsets] = React.useState<string[]>(["latin-ext"]);
82
+ const [busy, setBusy] = React.useState<string | null>(null);
83
+ const [error, setError] = React.useState<string | null>(null);
84
+ const [done, setDone] = React.useState<string | null>(null);
85
+ const faces = font.faces ?? [];
86
+ const groups = [...new Set(faces.map((face) => `${face.weight}/${face.style}`))].map((key) => {
87
+ const [w, s] = key.split("/");
88
+ return {
89
+ weight: Number(w),
90
+ style: s ?? "normal",
91
+ files: faces.filter((f) => `${f.weight}/${f.style}` === key).length,
92
+ };
93
+ });
94
+
95
+ const save = async (next: FontVariable, message: string) => {
96
+ if ((await onSave(next)) === false) return;
97
+ setDone(message);
98
+ };
99
+
100
+ const upload = async (file: File) => {
101
+ const name = (font.family ?? family).trim();
102
+ if (!FONT_FAMILY_NAME.test(name)) {
103
+ setError("Name the font family first: letters, digits, spaces, _ . or -.");
104
+ return;
105
+ }
106
+ setError(null);
107
+ setDone(null);
108
+ setBusy("Uploading…");
109
+ try {
110
+ const { url } = await uploadFontFile(fetcher, file);
111
+ const face: FontFace = { weight: Number(weight), style, src: url };
112
+ const sameFamily = font.family === name;
113
+ await save(
114
+ {
115
+ ...font,
116
+ value: stackWithFamily(font.value, name),
117
+ family: name,
118
+ faces: mergeFaces(sameFamily ? faces : [], [face]),
119
+ source: "upload",
120
+ },
121
+ `Added ${faceLabel(face.weight, face.style)}.`,
122
+ );
123
+ } catch (failure) {
124
+ setError(failure instanceof Error ? failure.message : "Couldn't upload the font.");
125
+ } finally {
126
+ setBusy(null);
127
+ }
128
+ };
129
+
130
+ const download = async () => {
131
+ const name = google.trim().replace(/\s+/g, " ");
132
+ if (!GOOGLE_FAMILY.test(name)) {
133
+ setError("Type a Google Fonts family name, such as Open Sans.");
134
+ return;
135
+ }
136
+ if (weights.length === 0) {
137
+ setError("Pick at least one weight.");
138
+ return;
139
+ }
140
+ setError(null);
141
+ setDone(null);
142
+ const styles: ("normal" | "italic")[] = italic ? ["normal", "italic"] : ["normal"];
143
+ const wanted = weights.flatMap((w) => styles.map((s) => ({ weight: w, style: s })));
144
+ let added: FontFace[] = [];
145
+ try {
146
+ // One weight and style per request keeps each server call small (Workers limits).
147
+ for (const [index, face] of wanted.entries()) {
148
+ setBusy(`Downloading ${index + 1} of ${wanted.length}…`);
149
+ // oxlint-disable-next-line no-await-in-loop -- one request at a time, with progress
150
+ const got = await importGoogleFont(fetcher, {
151
+ family: name,
152
+ ...face,
153
+ subsets: ["latin", ...subsets],
154
+ });
155
+ added = mergeFaces(added, got);
156
+ }
157
+ } catch (failure) {
158
+ setError(failure instanceof Error ? failure.message : "Couldn't download the font.");
159
+ setBusy(null);
160
+ return;
161
+ }
162
+ setBusy(null);
163
+ await save(
164
+ {
165
+ ...font,
166
+ value: stackWithFamily(font.value, name),
167
+ family: name,
168
+ faces: mergeFaces(font.family === name ? faces : [], added),
169
+ source: "google",
170
+ },
171
+ `Downloaded ${name}. Pages load it from this site.`,
172
+ );
173
+ };
174
+
175
+ const removeFace = (w: number, s: string) => {
176
+ const left = faces.filter((face) => !(face.weight === w && face.style === s));
177
+ const { family: _family, faces: _faces, source: _source, ...plain } = font;
178
+ void save(left.length > 0 ? { ...font, faces: left } : plain, `Removed ${faceLabel(w, s)}.`);
179
+ };
180
+
181
+ const previewCss = fontFaceRules(font).join("");
182
+ return (
183
+ <div className="emvb-site-item-body emvb-font-faces" data-emvb-font-faces="">
184
+ {previewCss ? <style>{previewCss}</style> : null}
185
+ <h4 className="emvb-bind-label">Custom font</h4>
186
+ {font.family && groups.length > 0 ? (
187
+ <>
188
+ <p className="emvb-helper" data-emvb-font-family="">
189
+ {`${font.family} · ${font.source === "google" ? "from Google Fonts, " : ""}served by this site`}
190
+ </p>
191
+ <ul className="emvb-font-face-list" data-emvb-font-face-list="">
192
+ {groups.map((group) => (
193
+ <li
194
+ key={`${group.weight}/${group.style}`}
195
+ data-emvb-font-face={`${group.weight}/${group.style}`}
196
+ >
197
+ <span
198
+ style={{
199
+ fontFamily: `'${font.family}'`,
200
+ fontWeight: group.weight,
201
+ fontStyle: group.style,
202
+ }}
203
+ >
204
+ {faceLabel(group.weight, group.style)}
205
+ </span>
206
+ {group.files > 1 ? (
207
+ <span className="emvb-helper">{` · ${group.files} files`}</span>
208
+ ) : null}
209
+ <button
210
+ type="button"
211
+ className="emvb-site-menu-btn"
212
+ aria-label={`Remove ${faceLabel(group.weight, group.style)}`}
213
+ onClick={() => removeFace(group.weight, group.style)}
214
+ >
215
+ <TrashIcon size={14} aria-hidden="true" />
216
+ </button>
217
+ </li>
218
+ ))}
219
+ </ul>
220
+ </>
221
+ ) : (
222
+ <p className="emvb-helper">
223
+ Upload WOFF2 files or download a Google font. Pages load it from this site only.
224
+ </p>
225
+ )}
226
+ {!font.family && (
227
+ <Input
228
+ label="Font family name"
229
+ className={FIELD}
230
+ value={family}
231
+ data-emvb-font-family-input=""
232
+ onChange={(event) => setFamily(event.target.value)}
233
+ />
234
+ )}
235
+ <div className="emvb-font-face-row">
236
+ <PanelSelect
237
+ label="Weight"
238
+ value={weight}
239
+ data={{ "data-emvb-font-weight": "" }}
240
+ options={GOOGLE_WEIGHTS.map((w) => ({ value: String(w), label: faceLabel(w, "normal") }))}
241
+ onChange={setWeight}
242
+ />
243
+ <PanelSelect
244
+ label="Style"
245
+ value={style}
246
+ data={{ "data-emvb-font-style": "" }}
247
+ options={[
248
+ { value: "normal", label: "Normal" },
249
+ { value: "italic", label: "Italic" },
250
+ ]}
251
+ onChange={(value) => setStyle(value === "italic" ? "italic" : "normal")}
252
+ />
253
+ </div>
254
+ <Button
255
+ type="button"
256
+ variant="secondary"
257
+ size="sm"
258
+ className={BUTTON}
259
+ icon={<UploadSimpleIcon size={14} aria-hidden="true" />}
260
+ disabled={busy !== null}
261
+ onClick={() => fileRef.current?.click()}
262
+ >
263
+ Upload WOFF2
264
+ </Button>
265
+ <input
266
+ ref={fileRef}
267
+ type="file"
268
+ accept=".woff2,font/woff2"
269
+ hidden
270
+ data-emvb-font-upload=""
271
+ onChange={(event) => {
272
+ const file = event.target.files?.[0];
273
+ event.target.value = "";
274
+ if (file) void upload(file);
275
+ }}
276
+ />
277
+ <h4 className="emvb-bind-label" id={`${id}-google`}>
278
+ Google font
279
+ </h4>
280
+ <Input
281
+ label="Family"
282
+ className={FIELD}
283
+ placeholder="Open Sans"
284
+ value={google}
285
+ data-emvb-font-google=""
286
+ onChange={(event) => setGoogle(event.target.value)}
287
+ />
288
+ <fieldset className="emvb-font-weights" aria-labelledby={`${id}-google`}>
289
+ <legend className="emvb-bind-label">Weights</legend>
290
+ {GOOGLE_WEIGHTS.map((w) => (
291
+ <Checkbox
292
+ key={w}
293
+ label={String(w)}
294
+ checked={weights.includes(w)}
295
+ onCheckedChange={(checked) =>
296
+ setWeights((now) =>
297
+ checked
298
+ ? [...new Set([...now, w])].toSorted((a, b) => a - b)
299
+ : now.filter((x) => x !== w),
300
+ )
301
+ }
302
+ />
303
+ ))}
304
+ </fieldset>
305
+ <Checkbox label="Italic too" checked={italic} onCheckedChange={setItalic} />
306
+ <fieldset className="emvb-font-weights">
307
+ <legend className="emvb-bind-label">Also for</legend>
308
+ {EXTRA_SUBSETS.map((subset) => (
309
+ <Checkbox
310
+ key={subset.value}
311
+ label={subset.label}
312
+ checked={subsets.includes(subset.value)}
313
+ onCheckedChange={(checked) =>
314
+ setSubsets((now) =>
315
+ checked ? [...now, subset.value] : now.filter((x) => x !== subset.value),
316
+ )
317
+ }
318
+ />
319
+ ))}
320
+ </fieldset>
321
+ <Button
322
+ type="button"
323
+ variant="secondary"
324
+ size="sm"
325
+ className={BUTTON}
326
+ disabled={busy !== null}
327
+ data-emvb-font-google-go=""
328
+ onClick={() => void download()}
329
+ >
330
+ Download from Google Fonts
331
+ </Button>
332
+ <p className="emvb-helper">
333
+ The files are copied to this site once; visitors never contact Google. Google fonts are open
334
+ source (mostly the SIL Open Font License), so self-hosting them is allowed.
335
+ </p>
336
+ <p className="emvb-helper" aria-live="polite" data-emvb-font-status="">
337
+ {busy ?? done ?? ""}
338
+ </p>
339
+ {error ? <InlineError>{error}</InlineError> : null}
340
+ </div>
341
+ );
342
+ }
@@ -1,4 +1,4 @@
1
- import { CaretDownIcon, CaretRightIcon, DotsThreeIcon } from "@phosphor-icons/react";
1
+ import { CaretDownIcon, CaretRightIcon, DotsThreeIcon, ProhibitIcon } from "@phosphor-icons/react";
2
2
  import * as React from "react";
3
3
  import {
4
4
  firstChild,
@@ -21,6 +21,7 @@ import { ELEMENT_NAMES, elementIcon } from "../element-chrome.ts";
21
21
  import { editorCommands } from "../editor-commands.ts";
22
22
  import { dragStash } from "../dnd/drag-stash.ts";
23
23
  import { StateDot } from "./settings/StateSwitcher.tsx";
24
+ import { useLayersDrop, type LayersDropCallbacks } from "./use-layers-drop.ts";
24
25
  import type { ClipboardActions } from "../useClipboardActions.ts";
25
26
 
26
27
  /**
@@ -199,11 +200,14 @@ export function layerPreview(node: LayoutNode): string | undefined {
199
200
  export function LayersPanel({
200
201
  layout,
201
202
  selectedId,
203
+ onDropNew,
204
+ onMoveTo,
202
205
  ...actions
203
206
  }: {
204
207
  layout: Layout | null;
205
208
  selectedId: string | null;
206
- } & LayerActions) {
209
+ } & LayerActions &
210
+ LayersDropCallbacks) {
207
211
  const [collapsed, setCollapsed] = React.useState<Set<string>>(() => new Set());
208
212
  const [menuId, setMenuId] = React.useState<string | null>(null);
209
213
  const listRef = React.useRef<HTMLUListElement>(null);
@@ -230,6 +234,29 @@ export function LayersPanel({
230
234
  [],
231
235
  );
232
236
  const toggle = React.useMemo(() => toggleIn(setCollapsed), []);
237
+ const expand = React.useCallback(
238
+ (id: string) =>
239
+ setCollapsed((current) => {
240
+ if (!current.has(id)) return current;
241
+ const next = new Set(current);
242
+ next.delete(id);
243
+ return next;
244
+ }),
245
+ [],
246
+ );
247
+ const items = layout ? rows(layout.root, 0, collapsed) : [];
248
+ const drag = useLayersDrop(
249
+ {
250
+ layout,
251
+ depths: new Map(items.map((row) => [row.node.id, row.depth])),
252
+ collapsed,
253
+ expand,
254
+ onDropNew,
255
+ onMoveTo,
256
+ },
257
+ layerIndent,
258
+ listRef,
259
+ );
233
260
 
234
261
  // W-612: an open row menu closes when a press lands outside it, focus leaves the panel's
235
262
  // window (a click in the canvas frame), or focus moves out of it (Tab).
@@ -279,11 +306,10 @@ export function LayersPanel({
279
306
  }, [selectedId]);
280
307
 
281
308
  if (!layout) return <p className="emvb-helper">This page is empty.</p>;
282
-
283
- const items = rows(layout.root, 0, collapsed);
309
+ const shown = drag.shown;
284
310
 
285
311
  return (
286
- <div className="emvb-panel-body" data-emvb-panel="layers">
312
+ <div className="emvb-panel-body emvb-layers-body" data-emvb-panel="layers" {...drag.handlers}>
287
313
  <ul
288
314
  ref={listRef}
289
315
  className="emvb-layers"
@@ -315,9 +341,29 @@ export function LayersPanel({
315
341
  actions={rowActions}
316
342
  hasClipboard={!!actions.clipboard}
317
343
  clip={menuId === node.id ? actions.clipboard : undefined}
344
+ dropMark={shown?.mark?.id === node.id ? shown.mark.kind : undefined}
318
345
  />
319
346
  ))}
320
347
  </ul>
348
+ {shown?.line && (
349
+ <div
350
+ className="emvb-layer-drop-line"
351
+ data-emvb-layer-drop-line=""
352
+ aria-hidden="true"
353
+ style={{ top: shown.line.top, insetInlineStart: shown.line.start }}
354
+ />
355
+ )}
356
+ {shown?.refusal && (
357
+ <div
358
+ className="emvb-invalid-label emvb-layer-drop-refusal"
359
+ data-emvb-layer-drop-refusal=""
360
+ aria-hidden="true"
361
+ style={{ top: shown.refusal.top, insetInlineStart: shown.refusal.start }}
362
+ >
363
+ <ProhibitIcon size={14} aria-hidden="true" />
364
+ <span>{shown.refusal.reason}</span>
365
+ </div>
366
+ )}
321
367
  </div>
322
368
  );
323
369
  }
@@ -344,6 +390,7 @@ const LayerRow = React.memo(function LayerRow({
344
390
  actions,
345
391
  hasClipboard,
346
392
  clip,
393
+ dropMark,
347
394
  }: {
348
395
  node: LayoutNode;
349
396
  depth: number;
@@ -358,6 +405,8 @@ const LayerRow = React.memo(function LayerRow({
358
405
  hasClipboard: boolean;
359
406
  /** The clipboard, passed only to the row whose menu is open so the other rows stay memoized. */
360
407
  clip: ClipboardActions | undefined;
408
+ /** W-1080: outlined as the drop's container, or as a refused drop. */
409
+ dropMark?: "inside" | "invalid";
361
410
  }) {
362
411
  const onToggle = () => toggleRow(node.id);
363
412
  const onMenu = (open: boolean) => menuRow(node.id, open);
@@ -446,7 +495,8 @@ const LayerRow = React.memo(function LayerRow({
446
495
  <div
447
496
  className="emvb-layer-row"
448
497
  data-emvb-layer={node.id}
449
- style={{ paddingLeft: layerIndent(depth) }}
498
+ data-emvb-drop={dropMark}
499
+ style={{ paddingInlineStart: layerIndent(depth) }}
450
500
  onClick={() => actions.onSelect(node.id)}
451
501
  >
452
502
  {hasChildren ? (