@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.
- package/README.md +2 -2
- package/package.json +2 -2
- package/src/admin/bulk-api.ts +5 -1
- package/src/admin/editor/A11yCopilot.tsx +3 -1
- package/src/admin/editor/Editor.tsx +22 -2
- package/src/admin/editor/Timeline.tsx +1 -8
- package/src/admin/editor/canvas/DeviceBar.tsx +7 -2
- package/src/admin/editor/canvas/EmptyCanvas.tsx +11 -2
- package/src/admin/editor/canvas/use-canvas-dnd.ts +1 -20
- package/src/admin/editor/canvas/vnode-react.tsx +2 -0
- package/src/admin/editor/co-design.ts +36 -1
- package/src/admin/editor/dnd/dragged-source.ts +22 -0
- package/src/admin/editor/dnd/layer-drop.ts +141 -0
- package/src/admin/editor/dnd/new-element.ts +16 -0
- package/src/admin/editor/editor-css.ts +9 -1
- package/src/admin/editor/element-chrome.ts +6 -0
- package/src/admin/editor/feature-css.ts +22 -0
- package/src/admin/editor/inert-links.ts +8 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/FontFaces.tsx +342 -0
- package/src/admin/editor/panels/LayersPanel.tsx +56 -6
- package/src/admin/editor/panels/LeftPanel.tsx +153 -29
- package/src/admin/editor/panels/SettingsPanel.tsx +1 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +5 -0
- package/src/admin/editor/panels/TemplatesPanel.tsx +205 -0
- package/src/admin/editor/panels/TokenScales.tsx +2 -0
- package/src/admin/editor/panels/TriggersEditor.tsx +203 -9
- package/src/admin/editor/panels/VariableSection.tsx +111 -7
- package/src/admin/editor/panels/color-space.ts +71 -6
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +3 -0
- package/src/admin/editor/panels/settings/FieldControl.tsx +18 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +9 -3
- package/src/admin/editor/panels/settings/StickyControl.tsx +97 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +14 -0
- package/src/admin/editor/panels/settings/style-sections.ts +19 -2
- package/src/admin/editor/panels/url-rules.ts +43 -0
- package/src/admin/editor/panels/use-layers-drop.ts +232 -0
- package/src/admin/editor/store.ts +4 -2
- package/src/admin/editor/useExtensions.ts +3 -1
- package/src/admin/editor/useNodeActions.ts +74 -1
- package/src/admin/editor/useSave.ts +116 -85
- package/src/admin/export-api.ts +25 -2
- package/src/admin/extension-outputs.ts +179 -0
- package/src/admin/font-files-api.ts +38 -0
- package/src/admin/pages/ImportButton.tsx +15 -4
- package/src/admin/pages/ImportElementorDialog.tsx +22 -188
- package/src/admin/pages/ImportHtmlDialog.tsx +209 -0
- package/src/admin/pages/ImportImageCopies.tsx +167 -0
- package/src/admin/pages/ImportReport.tsx +63 -0
- package/src/admin/pages/NewPageDialog.tsx +54 -32
- package/src/admin/pages/PageList.tsx +9 -0
- package/src/admin/pages/ThemePartList.tsx +9 -0
- package/src/astro/EmVBPage.astro +5 -2
- package/src/astro/extension-styles.ts +35 -0
- package/src/astro/forms/EmVBFormsClient.astro +3 -0
- package/src/astro/forms/enhance.ts +107 -0
- package/src/astro/popups/runtime.ts +47 -2
- package/src/astro/render.ts +19 -4
- package/src/astro/resolve-theme.ts +11 -4
- package/src/astro/widgets/EmVBStickyRuntime.astro +9 -0
- package/src/astro/widgets/EmVBThemeRuntime.astro +9 -0
- package/src/astro/widgets/EmVBWidgetRuntimes.astro +12 -0
- package/src/astro/widgets/alerts.ts +16 -2
- package/src/astro/widgets/carousel.ts +65 -24
- package/src/astro/widgets/countdown.ts +18 -7
- package/src/astro/widgets/extension-runtimes.ts +27 -0
- package/src/astro/widgets/headline.ts +14 -5
- package/src/astro/widgets/sticky.ts +87 -0
- package/src/astro/widgets/theme.ts +52 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +150 -2
- package/src/core/arrange.ts +19 -1
- package/src/core/css/font-face.ts +72 -0
- package/src/core/css/generate.ts +35 -1
- package/src/core/elements/form-elements.ts +119 -9
- package/src/core/elements/icon-svg.ts +14 -0
- package/src/core/elements/index.ts +24 -4
- package/src/core/elements/input-limits.ts +44 -0
- package/src/core/elements/menu.ts +109 -47
- package/src/core/elements/site.ts +108 -0
- package/src/core/elements/widgets.ts +13 -3
- package/src/core/export/runtimes.generated.ts +7 -5
- package/src/core/export/site.ts +50 -4
- package/src/core/extensions/classes.ts +114 -0
- package/src/core/extensions/index.ts +17 -2
- package/src/core/extensions/normalize.ts +13 -0
- package/src/core/extensions/registry.ts +134 -10
- package/src/core/extensions/render-ext.ts +66 -21
- package/src/core/extensions/safe-nodes.ts +67 -11
- package/src/core/extensions/types.ts +48 -1
- package/src/core/fonts/files.ts +74 -0
- package/src/core/fonts/google.ts +112 -0
- package/src/core/fonts/test-font.ts +9 -0
- package/src/core/import/elementor/context.ts +13 -4
- package/src/core/import/elementor/index.ts +32 -21
- package/src/core/import/elementor/widgets.ts +114 -12
- package/src/core/import/html/blocks.ts +602 -0
- package/src/core/import/html/index.ts +155 -0
- package/src/core/import/html/map.ts +958 -0
- package/src/core/import/html/parse.ts +430 -0
- package/src/core/index.ts +45 -0
- package/src/core/migrate/v18.ts +3 -0
- package/src/core/public-attributes.ts +17 -0
- package/src/core/render/extras.ts +31 -7
- package/src/core/render/form.ts +103 -10
- package/src/core/render/index.ts +151 -15
- package/src/core/render/section.ts +31 -1
- package/src/core/render/spacer-basis.ts +102 -0
- package/src/core/render/theme-boot.ts +16 -0
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +68 -3
- package/src/core/sanitize/motion.ts +12 -0
- package/src/core/schema/design.ts +40 -0
- package/src/core/schema/layout.ts +114 -5
- package/src/core/schema/style.ts +28 -0
- package/src/core/templates/index.ts +218 -0
- package/src/core/templates/pages.ts +29 -0
- package/src/core/templates/sections.ts +794 -0
- package/src/core/templates/types.ts +9 -0
- package/src/core/theme/dynamic.ts +9 -6
- package/src/core/theme/popup-markup.ts +21 -2
- package/src/core/theme/popup-rules.ts +36 -0
- package/src/core/theme/triggers.ts +64 -5
- package/src/core/translatable.ts +5 -2
- package/src/extension-build.ts +331 -0
- package/src/index.ts +25 -3
- package/src/mcp/brief.ts +191 -0
- package/src/mcp/prompts.ts +33 -0
- package/src/mcp/read.ts +29 -1
- package/src/mcp/tools.ts +40 -1
- package/src/mcp/write.ts +41 -1
- package/src/server/extension-routes.ts +73 -0
- package/src/server/font-routes.ts +301 -0
- package/src/server/plugin.ts +9 -0
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
[](https://emvb.dev) [](https://www.npmjs.com/package/@perkyzz/emvb)
|
|
13
13
|
|
|
14
|
-
A visual page builder plugin for [EmDash CMS](https://github.com/emdash-cms/emdash) 1.
|
|
14
|
+
A visual page builder plugin for [EmDash CMS](https://github.com/emdash-cms/emdash) 1.4 and 1.5 (built and tested on 1.5.0, tested on 1.4.0). Pages are built in a full-screen editor inside the EmDash admin and published as plain HTML and CSS. It runs on Node (SQLite) and Cloudflare Workers (D1).
|
|
15
15
|
|
|
16
16
|

|
|
17
17
|
|
|
@@ -25,7 +25,7 @@ Library pictures can be cropped, adjusted, filtered and saved as a new media ite
|
|
|
25
25
|
npm i @perkyzz/emvb
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
Peers, which an EmDash 1.
|
|
28
|
+
Peers, which an EmDash 1.4 or 1.5 site already has: `emdash` >=1.4.0 <2, `astro` ^7, `react` and `react-dom` ^19, `@cloudflare/kumo` 2.6.0 (EmDash 1.4) or 2.15.0 (EmDash 1.5) and `@phosphor-icons/react` ^2.1.10. `@emdash-cms/plugin-forms` is optional and enables forms: 0.2.13 on EmDash 1.5, 0.2.9 to 0.2.12 on EmDash 1.4. Use the Astro version your EmDash site already has: each release is installed on stock `create-emdash` sites of EmDash 1.4.0 and 1.5.0.
|
|
29
29
|
|
|
30
30
|
Dependencies installed with it: `zod` and [`@perkyzz/emvb-icons`](https://www.npmjs.com/package/@perkyzz/emvb-icons), the icon sets for the editor's Icon library. Only the editor loads them; a placed icon is saved into the page as SVG.
|
|
31
31
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perkyzz/emvb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Visual page builder plugin for EmDash CMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"test:astro": "bun --bun vitest run"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@perkyzz/emvb-icons": "1.
|
|
53
|
+
"@perkyzz/emvb-icons": "1.4.0",
|
|
54
54
|
"photocn": "0.1.2",
|
|
55
55
|
"zod": ">=4.5.4 <5"
|
|
56
56
|
},
|
package/src/admin/bulk-api.ts
CHANGED
|
@@ -59,7 +59,11 @@ export async function partsInUse(
|
|
|
59
59
|
const layout = item.data?.["layout"];
|
|
60
60
|
const text = typeof layout === "string" ? layout : JSON.stringify(layout ?? null);
|
|
61
61
|
for (const id of ids) {
|
|
62
|
-
|
|
62
|
+
// W-1069: a mega menu item's panel uses its part too.
|
|
63
|
+
const quoted = JSON.stringify(id);
|
|
64
|
+
if (!text.includes(`"partId":${quoted}`) && !text.includes(`"panelPartId":${quoted}`)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
63
67
|
used.set(id, [...(used.get(id) ?? []), titleOf(item, "Untitled")]);
|
|
64
68
|
}
|
|
65
69
|
}
|
|
@@ -28,7 +28,9 @@ export function A11yScoreButton({ report, onOpen }: { report: A11yReport; onOpen
|
|
|
28
28
|
? "Accessibility: no issues found"
|
|
29
29
|
: `Accessibility: ${count} issue${count === 1 ? "" : "s"}`
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
// W-1084: the name starts with the visible "A11y <score>" (WCAG 2.5.3, Label in Name), so a
|
|
32
|
+
// voice-control user can say what they see.
|
|
33
|
+
aria-label={`A11y ${report.score}: accessibility score of 100, ${count} issue${count === 1 ? "" : "s"}`}
|
|
32
34
|
onClick={onOpen}
|
|
33
35
|
>
|
|
34
36
|
A11y <b>{report.score}</b>
|
|
@@ -43,7 +43,7 @@ import { EditorOverlay } from "./EditorOverlay.tsx";
|
|
|
43
43
|
import { EditorToasts } from "./EditorToasts.tsx";
|
|
44
44
|
import { useCanvasStyles, useEditorHost } from "./host.ts";
|
|
45
45
|
import { LiveDataProvider, siteOrigin, useLiveData } from "./live-data.tsx";
|
|
46
|
-
import { newElement } from "./dnd/new-element.ts";
|
|
46
|
+
import { newElement, templateIdOf } from "./dnd/new-element.ts";
|
|
47
47
|
import { editorCommands } from "./editor-commands.ts";
|
|
48
48
|
import { ELEMENT_NAMES } from "./element-chrome.ts";
|
|
49
49
|
import { LeftPanel } from "./panels/LeftPanel.tsx";
|
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
import { EDITOR_MIN_WIDTH_QUERY, useMediaQuery } from "./useMediaQuery.ts";
|
|
64
64
|
import { partDraftLabel, usePartTemplates } from "./section-templates.ts";
|
|
65
65
|
import { useCollectionPreviews, withPartLayouts } from "./collection-previews.ts";
|
|
66
|
+
import { useExtensionOutputs } from "../extension-outputs.ts";
|
|
66
67
|
import { useEditorPresence } from "./presence.ts";
|
|
67
68
|
import { useCoDesign } from "./useCoDesign.ts";
|
|
68
69
|
import { useRemoteChange } from "./remote-change.ts";
|
|
@@ -226,6 +227,9 @@ function EditorApp({
|
|
|
226
227
|
wrap,
|
|
227
228
|
addFromPanel,
|
|
228
229
|
addRecipe,
|
|
230
|
+
layersDrop,
|
|
231
|
+
addTemplate,
|
|
232
|
+
dropTemplate,
|
|
229
233
|
items: itemActions,
|
|
230
234
|
} = useNodeActions({ state, latest, dispatch, announce: setAnnouncement, toasts });
|
|
231
235
|
// W-876: My sections and Save as section (D-060).
|
|
@@ -287,6 +291,8 @@ function EditorApp({
|
|
|
287
291
|
[state.page.layout, sectionTemplates, loopTemplates],
|
|
288
292
|
);
|
|
289
293
|
const collections = useCollectionPreviews(previewLayout, fetcher);
|
|
294
|
+
// W-1086: extension elements render on the server, which has their code; the canvas shows that.
|
|
295
|
+
const extensionOutputs = useExtensionOutputs(coDesign.ghost?.layout ?? previewLayout, fetcher);
|
|
290
296
|
// W-930: while previewing a proposal the canvas shows its ghost, never the editor's layout changed.
|
|
291
297
|
const canvasLayout = coDesign.ghost?.layout ?? state.page.layout;
|
|
292
298
|
const rendered = React.useMemo(
|
|
@@ -305,6 +311,7 @@ function EditorApp({
|
|
|
305
311
|
collections,
|
|
306
312
|
},
|
|
307
313
|
previewDevice: device,
|
|
314
|
+
extensionOutputs,
|
|
308
315
|
})
|
|
309
316
|
: null,
|
|
310
317
|
[
|
|
@@ -316,6 +323,8 @@ function EditorApp({
|
|
|
316
323
|
live.site,
|
|
317
324
|
live.params,
|
|
318
325
|
collections,
|
|
326
|
+
extensionOutputs,
|
|
327
|
+
extensionManifests,
|
|
319
328
|
],
|
|
320
329
|
);
|
|
321
330
|
// W-911: field mode previews the unsaved layout with the public renderer, in a sandboxed frame.
|
|
@@ -334,6 +343,7 @@ function EditorApp({
|
|
|
334
343
|
collections,
|
|
335
344
|
},
|
|
336
345
|
previewDevice,
|
|
346
|
+
extensionOutputs,
|
|
337
347
|
});
|
|
338
348
|
return previewDocument({
|
|
339
349
|
html: result.html,
|
|
@@ -380,7 +390,8 @@ function EditorApp({
|
|
|
380
390
|
if (!node) return "Element";
|
|
381
391
|
const name = node.editorLabel ?? ELEMENT_NAMES[node.type] ?? node.type;
|
|
382
392
|
// W-970: a synced section or Loop item drawn from unpublished changes says so on the canvas.
|
|
383
|
-
const
|
|
393
|
+
const props = node.props as { partId?: unknown; panelPartId?: unknown } | undefined;
|
|
394
|
+
const partId = props?.partId ?? props?.panelPartId;
|
|
384
395
|
const status = typeof partId === "string" ? partStatus?.[partId] : undefined;
|
|
385
396
|
return status && status !== "published" ? `${name} · ${partDraftLabel(status)}` : name;
|
|
386
397
|
},
|
|
@@ -568,6 +579,8 @@ function EditorApp({
|
|
|
568
579
|
onSelect={(id) => dispatch({ type: "select", id })}
|
|
569
580
|
onAdd={addFromPanel}
|
|
570
581
|
onRecipe={addRecipe}
|
|
582
|
+
onTemplate={addTemplate}
|
|
583
|
+
design={state.design}
|
|
571
584
|
formsAvailable={formsAvailable}
|
|
572
585
|
onDuplicate={duplicate}
|
|
573
586
|
onMoveUp={(id) => arrange(id, moveUp)}
|
|
@@ -577,6 +590,8 @@ function EditorApp({
|
|
|
577
590
|
saved={saved}
|
|
578
591
|
onSaveSection={setSaveAsk}
|
|
579
592
|
{...(!host.field && collection === PAGES_COLLECTION ? { coDesign } : {})}
|
|
593
|
+
onDropNew={layersDrop.add}
|
|
594
|
+
onMoveTo={layersDrop.move}
|
|
580
595
|
onRename={(id, label) =>
|
|
581
596
|
dispatch({
|
|
582
597
|
type: "update-node",
|
|
@@ -630,6 +645,11 @@ function EditorApp({
|
|
|
630
645
|
statePreview={statePreview}
|
|
631
646
|
refusal={refusalShown ? refusal : null}
|
|
632
647
|
onDropNew={(elementType, parentId, index) => {
|
|
648
|
+
const template = templateIdOf(elementType);
|
|
649
|
+
if (template !== null) {
|
|
650
|
+
dropTemplate(template, parentId, index);
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
633
653
|
const node = newElement(
|
|
634
654
|
elementType,
|
|
635
655
|
undefined,
|
|
@@ -19,6 +19,7 @@ import { ELEMENT_NAMES } from "./element-chrome.ts";
|
|
|
19
19
|
import { BUTTON } from "../ui.ts";
|
|
20
20
|
import { editedNounOf, type EditedNoun } from "./edited-noun.ts";
|
|
21
21
|
import { DialogCloseButton } from "./DialogCloseButton.tsx";
|
|
22
|
+
import { inertLinks } from "./inert-links.ts";
|
|
22
23
|
|
|
23
24
|
type RevisionItem = {
|
|
24
25
|
id: string;
|
|
@@ -160,14 +161,6 @@ const whenParts = (iso: string) => {
|
|
|
160
161
|
};
|
|
161
162
|
};
|
|
162
163
|
|
|
163
|
-
/**
|
|
164
|
-
* W-752: the picture is not a page to browse. A link in it took keyboard focus and Enter loaded the
|
|
165
|
-
* site (or the admin, for an in-page anchor) inside the picture. Inside a tag, core escapes `"`
|
|
166
|
-
* and `>` in attribute values, so the tag and its href are found exactly; text is left alone.
|
|
167
|
-
*/
|
|
168
|
-
const inertLinks = (html: string) =>
|
|
169
|
-
html.replaceAll(/<a\b[^>]*>/g, (tag) => tag.replace(/ href="[^"]*"/, ""));
|
|
170
|
-
|
|
171
164
|
/** A small, script-free picture of one version with its changed sections outlined (W-315). */
|
|
172
165
|
function Snapshot({
|
|
173
166
|
layout,
|
|
@@ -26,6 +26,10 @@ const ICONS: Record<EditorDevice, Icon> = {
|
|
|
26
26
|
mobile: DeviceMobileIcon,
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
+
/** The zoom button's text: the fitted scale, or 100% (W-158). */
|
|
30
|
+
const zoomText = (zoom: "fit" | "actual", scale: number) =>
|
|
31
|
+
zoom === "fit" ? `Fit · ${Math.round(scale * 100)}%` : "100%";
|
|
32
|
+
|
|
29
33
|
/** The device's icon (decorative) and its name, which stays the tab's accessible name (W-127). */
|
|
30
34
|
function DeviceLabel({ device }: { device: EditorDevice }) {
|
|
31
35
|
const DeviceIcon = ICONS[device];
|
|
@@ -103,11 +107,12 @@ export function DeviceBar({
|
|
|
103
107
|
size="sm"
|
|
104
108
|
className="emvb-zoom"
|
|
105
109
|
aria-pressed={zoom === "fit"}
|
|
106
|
-
|
|
110
|
+
// W-1084: the name starts with the visible text (WCAG 2.5.3, Label in Name).
|
|
111
|
+
aria-label={`${zoomText(zoom, scale)}, fit to canvas`}
|
|
107
112
|
title={zoom === "fit" ? "Scaled to fit. Show at 100%" : "At 100%. Scale to fit"}
|
|
108
113
|
onClick={() => onZoom(zoom === "fit" ? "actual" : "fit")}
|
|
109
114
|
>
|
|
110
|
-
{zoom
|
|
115
|
+
{zoomText(zoom, scale)}
|
|
111
116
|
</Button>
|
|
112
117
|
)}
|
|
113
118
|
</div>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { PlusIcon } from "@phosphor-icons/react";
|
|
2
2
|
import type * as React from "react";
|
|
3
3
|
import { NEW_ELEMENT_MIME } from "../dnd/drop-target.ts";
|
|
4
|
-
import {
|
|
4
|
+
import { templateSectionNode } from "../../../core/index.ts";
|
|
5
|
+
import { newElement, templateIdOf } from "../dnd/new-element.ts";
|
|
6
|
+
import { isSharedPart } from "../panels/settings/heading-warning.ts";
|
|
5
7
|
import type { EditorAction, EditorState } from "../store.ts";
|
|
6
8
|
|
|
7
9
|
/** The canvas of a page with no layout yet: a prompt and a drop zone that starts one (R-002). */
|
|
@@ -30,7 +32,14 @@ export function EmptyCanvas({
|
|
|
30
32
|
queueMicrotask(() => {
|
|
31
33
|
const layout = latest.current.page.layout;
|
|
32
34
|
if (!layout) return;
|
|
33
|
-
|
|
35
|
+
// W-1068: a starter template takes the site's styles, as when dropped on a page.
|
|
36
|
+
const template = templateIdOf(type);
|
|
37
|
+
const node =
|
|
38
|
+
template === null
|
|
39
|
+
? newElement(type)
|
|
40
|
+
: templateSectionNode(template, latest.current.design, layout, {
|
|
41
|
+
noH1: isSharedPart(latest.current.page.partType),
|
|
42
|
+
});
|
|
34
43
|
if (!node) return;
|
|
35
44
|
dispatch({ type: "add-node", node, parentId: layout.root.id, index: 0 });
|
|
36
45
|
});
|
|
@@ -13,16 +13,13 @@ import {
|
|
|
13
13
|
dropContainer,
|
|
14
14
|
dropIndex,
|
|
15
15
|
edgeDrop,
|
|
16
|
-
EXISTING_ELEMENT_MIME,
|
|
17
16
|
flowDirection,
|
|
18
17
|
idAt,
|
|
19
|
-
NEW_ELEMENT_MIME,
|
|
20
18
|
transferKinds,
|
|
21
19
|
type Direction,
|
|
22
20
|
type Rect,
|
|
23
21
|
} from "../dnd/drop-target.ts";
|
|
24
|
-
import {
|
|
25
|
-
import { newElement } from "../dnd/new-element.ts";
|
|
22
|
+
import { draggedSource } from "../dnd/dragged-source.ts";
|
|
26
23
|
import { useCanvasEvents } from "./canvas-events.ts";
|
|
27
24
|
import { dropLineBox } from "./drop-line.ts";
|
|
28
25
|
import type { Box, DropTarget, InvalidDrop } from "./SelectionOverlay.tsx";
|
|
@@ -60,22 +57,6 @@ const rectOf = (doc: Document, id: string): Rect | null => {
|
|
|
60
57
|
return box ? { top: box.top, left: box.left, width: box.width, height: box.height } : null;
|
|
61
58
|
};
|
|
62
59
|
|
|
63
|
-
/** What is being dragged over the canvas, or null while the browser still hides it. */
|
|
64
|
-
function draggedSource(transfer: DataTransfer | null, existing: boolean): DragSource | null {
|
|
65
|
-
if (existing) {
|
|
66
|
-
// Chromium may omit getData until drop, so the session stash wins during dragover.
|
|
67
|
-
const id =
|
|
68
|
-
dragStash.id() ??
|
|
69
|
-
(transfer?.getData(EXISTING_ELEMENT_MIME) ||
|
|
70
|
-
(transfer as DataTransfer & { emvbId?: string }).emvbId ||
|
|
71
|
-
"");
|
|
72
|
-
return id ? { kind: "existing", id } : null;
|
|
73
|
-
}
|
|
74
|
-
const type = transfer?.getData(NEW_ELEMENT_MIME) || dragStash.type() || "";
|
|
75
|
-
const node = type ? newElement(type) : null;
|
|
76
|
-
return node ? { kind: "new", node } : null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
60
|
/** Drop line, invalid outline and the canvas drag listeners. */
|
|
80
61
|
export function useCanvasDnD({
|
|
81
62
|
doc,
|
|
@@ -41,6 +41,8 @@ const BOOLEAN_ATTRS = new Set([
|
|
|
41
41
|
"autoplay",
|
|
42
42
|
"required",
|
|
43
43
|
"novalidate",
|
|
44
|
+
// W-1065: a form's Previous and Next buttons, shown only by the forms script.
|
|
45
|
+
"hidden",
|
|
44
46
|
]);
|
|
45
47
|
|
|
46
48
|
/** SVG tags the core keeps lowercase; the SVG namespace only knows their camelCase names. */
|
|
@@ -64,13 +64,48 @@ const BIDI_AND_CONTROLS =
|
|
|
64
64
|
|
|
65
65
|
const quoted = (text: string | undefined) => (text ? ` “${text}”` : "");
|
|
66
66
|
|
|
67
|
+
const childrenOf = (node: unknown): unknown[] => {
|
|
68
|
+
const children = (node as { children?: unknown } | null)?.children;
|
|
69
|
+
return Array.isArray(children) ? children : [];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* W-1064: a whole section arrives as one insert; name it by its first heading, depth first, so a
|
|
74
|
+
* whole-page proposal reads as a list of sections. Bounded like the proposal itself.
|
|
75
|
+
*/
|
|
76
|
+
function headingOf(node: unknown): string | undefined {
|
|
77
|
+
const stack = childrenOf(node).toReversed();
|
|
78
|
+
for (let seen = 0; stack.length > 0 && seen < 2000; seen++) {
|
|
79
|
+
const item = stack.pop();
|
|
80
|
+
if ((item as { type?: unknown } | null)?.type === "heading") {
|
|
81
|
+
const text = textOf(item);
|
|
82
|
+
if (text) return text;
|
|
83
|
+
}
|
|
84
|
+
stack.push(...childrenOf(item).toReversed());
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** How many elements an insert adds, so a person sees the size of what they accept. */
|
|
90
|
+
function countNodes(node: unknown): number {
|
|
91
|
+
const stack = [node];
|
|
92
|
+
let count = 0;
|
|
93
|
+
while (stack.length > 0 && count < 2000) {
|
|
94
|
+
count += 1;
|
|
95
|
+
stack.push(...childrenOf(stack.pop()));
|
|
96
|
+
}
|
|
97
|
+
return count;
|
|
98
|
+
}
|
|
99
|
+
|
|
67
100
|
/** One line a person can read: what the change does, to which element. Agent text is quoted. */
|
|
68
101
|
export function describeOp(op: Op, layout: Layout | null): string {
|
|
69
102
|
const target = (id: string) => (layout ? findNode(layout, id) : null);
|
|
70
103
|
switch (op.kind) {
|
|
71
104
|
case "insert": {
|
|
72
105
|
const parent = target(op.parentId);
|
|
73
|
-
|
|
106
|
+
const added = `Add ${nameOf(op.node)}${quoted(textOf(op.node) ?? headingOf(op.node))} to ${nameOf(parent)}`;
|
|
107
|
+
const count = countNodes(op.node);
|
|
108
|
+
return count > 1 ? `${added} (${count} elements)` : added;
|
|
74
109
|
}
|
|
75
110
|
case "update": {
|
|
76
111
|
const node = target(op.id);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DragSource } from "../../../core/index.ts";
|
|
2
|
+
import { dragStash } from "./drag-stash.ts";
|
|
3
|
+
import { EXISTING_ELEMENT_MIME, NEW_ELEMENT_MIME } from "./drop-target.ts";
|
|
4
|
+
import { newElement } from "./new-element.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What is being dragged (canvas and Layers), or null while the browser still hides it.
|
|
8
|
+
* Chromium may omit getData until drop, so the session stash wins during dragover.
|
|
9
|
+
*/
|
|
10
|
+
export function draggedSource(transfer: DataTransfer | null, existing: boolean): DragSource | null {
|
|
11
|
+
if (existing) {
|
|
12
|
+
const id =
|
|
13
|
+
dragStash.id() ??
|
|
14
|
+
(transfer?.getData(EXISTING_ELEMENT_MIME) ||
|
|
15
|
+
(transfer as (DataTransfer & { emvbId?: string }) | null)?.emvbId ||
|
|
16
|
+
"");
|
|
17
|
+
return id ? { kind: "existing", id } : null;
|
|
18
|
+
}
|
|
19
|
+
const type = transfer?.getData(NEW_ELEMENT_MIME) || dragStash.type() || "";
|
|
20
|
+
const node = type ? newElement(type) : null;
|
|
21
|
+
return node ? { kind: "new", node } : null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canDrop,
|
|
3
|
+
findNode,
|
|
4
|
+
isParentNode,
|
|
5
|
+
parentOf,
|
|
6
|
+
type DragSource,
|
|
7
|
+
type Layout,
|
|
8
|
+
} from "../../../core/index.ts";
|
|
9
|
+
|
|
10
|
+
/** W-1080: hovering a collapsed row this long during a drag opens it. */
|
|
11
|
+
export const EXPAND_DELAY_MS = 600;
|
|
12
|
+
/** W-1080: hovering the Layers tab this long during a drag from Add switches to it. */
|
|
13
|
+
export const TAB_SPRING_MS = 500;
|
|
14
|
+
|
|
15
|
+
/** Which part of a Layers row the pointer is over. */
|
|
16
|
+
export type LayerZone = "before" | "inside" | "after";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A row's top quarter drops before it and its bottom quarter after it; the middle half drops
|
|
20
|
+
* inside an element that holds others. Rows that hold nothing split in two. The page row always
|
|
21
|
+
* takes the drop inside.
|
|
22
|
+
*/
|
|
23
|
+
export function layerZone(
|
|
24
|
+
offsetY: number,
|
|
25
|
+
height: number,
|
|
26
|
+
holdsOthers: boolean,
|
|
27
|
+
isRoot: boolean,
|
|
28
|
+
): LayerZone {
|
|
29
|
+
if (isRoot) return "inside";
|
|
30
|
+
const part = height > 0 ? offsetY / height : 0.5;
|
|
31
|
+
if (!holdsOthers) return part < 0.5 ? "before" : "after";
|
|
32
|
+
return part < 0.25 ? "before" : part > 0.75 ? "after" : "inside";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The deepest level whose indent the pointer has passed (`x` from the row's left edge). */
|
|
36
|
+
export function depthAtX(x: number, indent: (depth: number) => number, maxDepth: number): number {
|
|
37
|
+
let depth = 0;
|
|
38
|
+
while (depth < maxDepth && x >= indent(depth + 1)) depth += 1;
|
|
39
|
+
return depth;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The row being hovered, as Layers shows it. */
|
|
43
|
+
export type LayerRowView = {
|
|
44
|
+
id: string;
|
|
45
|
+
depth: number;
|
|
46
|
+
/** Expanded with its children shown below it. */
|
|
47
|
+
open: boolean;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type LayerPlace = {
|
|
51
|
+
parentId: string;
|
|
52
|
+
index: number;
|
|
53
|
+
/** The depth the drop line is drawn at (the new element's depth). */
|
|
54
|
+
depth: number;
|
|
55
|
+
/** Line above or below the hovered row; null when the row itself is highlighted (inside). */
|
|
56
|
+
edge: "top" | "bottom" | null;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const siblingsOf = (layout: Layout, id: string) => {
|
|
60
|
+
const parentId = parentOf(layout, id);
|
|
61
|
+
const parent = parentId ? findNode(layout, parentId) : undefined;
|
|
62
|
+
return parent && isParentNode(parent)
|
|
63
|
+
? { parent, index: parent.children.findIndex((child) => child.id === id) }
|
|
64
|
+
: null;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Where a drop on `row` in `zone` goes. "after" an open element goes first inside it (the line
|
|
69
|
+
* sits between it and its first child). "after" the last child can climb out `outdent` levels,
|
|
70
|
+
* as the pointer moves left, to drop after its parent instead. Null when the row is gone.
|
|
71
|
+
*/
|
|
72
|
+
export function layerPlace(
|
|
73
|
+
layout: Layout,
|
|
74
|
+
row: LayerRowView,
|
|
75
|
+
zone: LayerZone,
|
|
76
|
+
outdent = 0,
|
|
77
|
+
): LayerPlace | null {
|
|
78
|
+
const node = findNode(layout, row.id);
|
|
79
|
+
if (!node) return null;
|
|
80
|
+
if (zone === "inside" || row.id === layout.root.id) {
|
|
81
|
+
if (!isParentNode(node)) return null;
|
|
82
|
+
return { parentId: node.id, index: node.children.length, depth: row.depth + 1, edge: null };
|
|
83
|
+
}
|
|
84
|
+
if (zone === "before") {
|
|
85
|
+
const at = siblingsOf(layout, row.id);
|
|
86
|
+
return at ? { parentId: at.parent.id, index: at.index, depth: row.depth, edge: "top" } : null;
|
|
87
|
+
}
|
|
88
|
+
if (row.open && isParentNode(node) && node.children.length > 0) {
|
|
89
|
+
return { parentId: node.id, index: 0, depth: row.depth + 1, edge: "bottom" };
|
|
90
|
+
}
|
|
91
|
+
let depth = row.depth;
|
|
92
|
+
let at = siblingsOf(layout, row.id);
|
|
93
|
+
while (at && outdent > 0 && at.index === at.parent.children.length - 1) {
|
|
94
|
+
const up = siblingsOf(layout, at.parent.id);
|
|
95
|
+
if (!up) break;
|
|
96
|
+
depth -= 1;
|
|
97
|
+
outdent -= 1;
|
|
98
|
+
at = up;
|
|
99
|
+
}
|
|
100
|
+
if (!at) return null;
|
|
101
|
+
return { parentId: at.parent.id, index: at.index + 1, depth, edge: "bottom" };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type LayerDrop =
|
|
105
|
+
| { ok: true; place: LayerPlace }
|
|
106
|
+
| { ok: false; reason: string; place: LayerPlace };
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A Layers drop, checked with the canvas's own rule (`canDrop`): into itself or a descendant,
|
|
110
|
+
* a parent that refuses the child, full Tabs and the like are refused with the canvas's reason.
|
|
111
|
+
* An unknown source (the browser hides it until drop) is allowed provisionally; the drop checks
|
|
112
|
+
* again.
|
|
113
|
+
*/
|
|
114
|
+
export function resolveLayerDrop(
|
|
115
|
+
layout: Layout,
|
|
116
|
+
row: LayerRowView,
|
|
117
|
+
zone: LayerZone,
|
|
118
|
+
source: DragSource | null,
|
|
119
|
+
outdent = 0,
|
|
120
|
+
): LayerDrop | null {
|
|
121
|
+
const place = layerPlace(layout, row, zone, outdent);
|
|
122
|
+
if (!place) return null;
|
|
123
|
+
if (!source) return { ok: true, place };
|
|
124
|
+
const allowed = canDrop(layout, source, place.parentId);
|
|
125
|
+
return allowed.ok ? { ok: true, place } : { ok: false, reason: allowed.reason, place };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Pixels to scroll the panel by for a pointer near its top or bottom edge during a drag. */
|
|
129
|
+
export function autoScrollStep(
|
|
130
|
+
pointerY: number,
|
|
131
|
+
top: number,
|
|
132
|
+
bottom: number,
|
|
133
|
+
edge = 32,
|
|
134
|
+
max = 14,
|
|
135
|
+
): number {
|
|
136
|
+
if (bottom - top < edge * 3) return 0;
|
|
137
|
+
const speed = (into: number) => Math.ceil(max * Math.min(1, into / edge));
|
|
138
|
+
if (pointerY < top + edge) return -speed(top + edge - pointerY);
|
|
139
|
+
if (pointerY > bottom - edge) return speed(pointerY - (bottom - edge));
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultElement,
|
|
3
|
+
emptyDesign,
|
|
4
|
+
templateSectionNode,
|
|
3
5
|
updateNode,
|
|
4
6
|
ELEMENTS,
|
|
5
7
|
isExtensionType,
|
|
@@ -159,6 +161,15 @@ export function newGalleryImage(random?: () => number): LayoutNode {
|
|
|
159
161
|
return { id: newNodeId(random), type: "gallery-image", props: { src: "", alt: "Image" } };
|
|
160
162
|
}
|
|
161
163
|
|
|
164
|
+
const TEMPLATE_PREFIX = "template:";
|
|
165
|
+
|
|
166
|
+
/** W-1068: the drag type of a starter section template, carried like a new element's type. */
|
|
167
|
+
export const templateDragType = (id: string) => `${TEMPLATE_PREFIX}${id}`;
|
|
168
|
+
|
|
169
|
+
/** The template id a drag type names, or null for an element type. */
|
|
170
|
+
export const templateIdOf = (type: string): string | null =>
|
|
171
|
+
type.startsWith(TEMPLATE_PREFIX) ? type.slice(TEMPLATE_PREFIX.length) : null;
|
|
172
|
+
|
|
162
173
|
/**
|
|
163
174
|
* Default node for a new element from the Add panel. Only new inserts get starter children;
|
|
164
175
|
* saved Accordions and Tabs with no items keep working as they are (W-130).
|
|
@@ -168,6 +179,11 @@ export function newElement(
|
|
|
168
179
|
random?: () => number,
|
|
169
180
|
extensionDefaults?: Record<string, unknown>,
|
|
170
181
|
): LayoutNode | null {
|
|
182
|
+
// W-1068: a dragged starter template. Drops build it again with the site's styles.
|
|
183
|
+
const template = templateIdOf(type);
|
|
184
|
+
if (template !== null) {
|
|
185
|
+
return templateSectionNode(template, emptyDesign(), null, random ? { random } : {}) ?? null;
|
|
186
|
+
}
|
|
171
187
|
// W-927: extension elements are stored as UnknownNodes with namespaced types.
|
|
172
188
|
if (isExtensionType(type)) {
|
|
173
189
|
return {
|
|
@@ -100,6 +100,7 @@ export const EDITOR_CSS = `${UI_CSS}
|
|
|
100
100
|
.emvb-check > input { width: 16px; height: 16px; margin: 0; }
|
|
101
101
|
@keyframes emvb-panel-enter { from { opacity: 0; } to { opacity: 1; } }
|
|
102
102
|
.emvb-left-panel > [data-emvb-panel],
|
|
103
|
+
.emvb-left-panel > .emvb-add-holder > [data-emvb-panel],
|
|
103
104
|
.emvb-panel-right [data-emvb-tab],
|
|
104
105
|
.emvb-site-styles-body { animation: emvb-panel-enter 150ms cubic-bezier(0, 0, 0.2, 1); }
|
|
105
106
|
/* UX-010: a section's rows fade in as it opens (closing stays instant); the Site styles drawer slides in. */
|
|
@@ -177,7 +178,7 @@ export const EDITOR_CSS = `${UI_CSS}
|
|
|
177
178
|
.emvb-gradient-stop { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; box-shadow: inset 0 1px 0 var(--color-kumo-line); }
|
|
178
179
|
.emvb-row-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
179
180
|
.emvb-layers { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 1px; }
|
|
180
|
-
.emvb-layer-row { display: flex; align-items: center; gap: 6px; width: 100%; height: var(--emvb-control); padding-
|
|
181
|
+
.emvb-layer-row { display: flex; align-items: center; gap: 6px; width: 100%; height: var(--emvb-control); padding-inline-end: 4px; border-radius: 6px; color: var(--text-color-kumo-default); font-size: 13px; }
|
|
181
182
|
.emvb-layer-select { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; height: var(--emvb-control); padding: 0 4px 0 0; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
|
|
182
183
|
.emvb-layer-row:hover, .emvb-layer-row:hover .emvb-layer-select { background: var(--color-kumo-tint); }
|
|
183
184
|
.emvb-layers:empty::after, .emvb-panel-body > .emvb-helper { color: var(--text-color-kumo-subtle); }
|
|
@@ -192,6 +193,13 @@ export const EDITOR_CSS = `${UI_CSS}
|
|
|
192
193
|
.emvb-layer-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
193
194
|
.emvb-layer-preview { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-color-kumo-subtle); }
|
|
194
195
|
.emvb-layer-select[aria-current="true"] .emvb-layer-preview { color: inherit; }
|
|
196
|
+
/* W-1080: drops on Layers. The line tracks the pointer without easing, like the canvas drop line.
|
|
197
|
+
Indents, the line and the refusal use logical sides so Layers reads right to left in RTL. */
|
|
198
|
+
.emvb-layers-body { position: relative; }
|
|
199
|
+
.emvb-layer-drop-line { position: absolute; inset-inline-end: 4px; height: 2px; border-radius: 1px; background: var(--color-kumo-brand); box-shadow: 0 0 0 1px var(--color-kumo-base, #fff); pointer-events: none; z-index: 2; }
|
|
200
|
+
.emvb-layer-row[data-emvb-drop="inside"] { box-shadow: inset 0 0 0 1px var(--color-kumo-brand); background: var(--color-kumo-tint); }
|
|
201
|
+
.emvb-layer-row[data-emvb-drop="invalid"] { outline: 1px dashed var(--color-kumo-danger); outline-offset: -1px; cursor: not-allowed; }
|
|
202
|
+
.emvb-layer-drop-refusal { inset-inline-end: 4px; height: auto; min-height: 24px; padding: 4px 6px; white-space: normal; }
|
|
195
203
|
.emvb-canvas { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--color-kumo-canvas); }
|
|
196
204
|
.emvb-device-bar { display: flex; flex: none; align-items: center; justify-content: center; gap: 12px; height: 36px; border-bottom: 1px solid var(--color-kumo-line); background: var(--color-kumo-surface); }
|
|
197
205
|
/* W-127: the segmented control hugs its three options; a fixed width left a gap on the right. */
|
|
@@ -33,6 +33,8 @@ import {
|
|
|
33
33
|
ListIcon,
|
|
34
34
|
ListNumbersIcon,
|
|
35
35
|
TranslateIcon,
|
|
36
|
+
MagnifyingGlassIcon,
|
|
37
|
+
MoonIcon,
|
|
36
38
|
MapPinIcon,
|
|
37
39
|
MegaphoneIcon,
|
|
38
40
|
MinusIcon,
|
|
@@ -63,6 +65,7 @@ import {
|
|
|
63
65
|
VideoCameraIcon,
|
|
64
66
|
WarningCircleIcon,
|
|
65
67
|
type Icon,
|
|
68
|
+
StepsIcon,
|
|
66
69
|
} from "@phosphor-icons/react";
|
|
67
70
|
import { ELEMENT_DESCRIPTORS } from "../../core/index.ts";
|
|
68
71
|
|
|
@@ -116,6 +119,8 @@ export const ELEMENT_ICONS: Record<string, Icon> = {
|
|
|
116
119
|
progress: GaugeIcon,
|
|
117
120
|
countdown: TimerIcon,
|
|
118
121
|
map: MapPinIcon,
|
|
122
|
+
"search-form": MagnifyingGlassIcon,
|
|
123
|
+
"theme-toggle": MoonIcon,
|
|
119
124
|
"price-table": TagIcon,
|
|
120
125
|
"price-list": ListDashesIcon,
|
|
121
126
|
"price-list-item": CurrencyDollarIcon,
|
|
@@ -128,6 +133,7 @@ export const ELEMENT_ICONS: Record<string, Icon> = {
|
|
|
128
133
|
hotspot: NumberCircleOneIcon,
|
|
129
134
|
video: VideoCameraIcon,
|
|
130
135
|
form: ArticleIcon,
|
|
136
|
+
"form-step": StepsIcon,
|
|
131
137
|
"text-input": TextboxIcon,
|
|
132
138
|
textarea: TextAaIcon,
|
|
133
139
|
select: CaretCircleDownIcon,
|
|
@@ -150,6 +150,20 @@ export const FEATURE_CSS = `
|
|
|
150
150
|
.emvb-recipe-tile:hover, .emvb-recipe-tile:focus-visible { border-color: var(--color-kumo-brand); }
|
|
151
151
|
.emvb-recipe-name { font-weight: 600; font-size: 13px; }
|
|
152
152
|
.emvb-recipe-desc { font-size: 12px; color: var(--text-color-kumo-subtle); }
|
|
153
|
+
/* W-1068: Add panel Elements | Templates, and the starter template tiles with their pictures. */
|
|
154
|
+
.emvb-add-switch-tabs { width: 100%; }
|
|
155
|
+
.emvb-add-switch-tabs [role="tablist"] { width: 100%; height: var(--emvb-control); min-height: var(--emvb-control); }
|
|
156
|
+
.emvb-add-switch-tabs [role="tab"] { flex: 1 1 0; justify-content: center; height: 100%; font-size: 13px; line-height: 18px; }
|
|
157
|
+
.emvb-add-switch-tabs [role="tab"][aria-selected="false"] { color: var(--text-color-kumo-default); }
|
|
158
|
+
.emvb-template-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
|
|
159
|
+
.emvb-template-tile { position: relative; display: grid; gap: 2px; padding: 0 0 8px; border-radius: 8px; border: 1px solid var(--color-kumo-line); background: var(--color-kumo-base, transparent); overflow: hidden; }
|
|
160
|
+
.emvb-template-tile:hover, .emvb-template-tile:has(.emvb-template-insert:focus-visible) { border-color: var(--color-kumo-brand); }
|
|
161
|
+
.emvb-template-tile:has(.emvb-template-insert:focus-visible) { outline: 2px solid var(--color-kumo-brand); outline-offset: 1px; }
|
|
162
|
+
.emvb-template-preview { position: relative; height: 104px; overflow: hidden; border-bottom: 1px solid var(--color-kumo-line); background: var(--color-kumo-recessed, transparent); }
|
|
163
|
+
.emvb-template-preview iframe { position: absolute; top: 0; left: 0; width: 1280px; height: 640px; border: 0; transform-origin: 0 0; pointer-events: none; }
|
|
164
|
+
.emvb-template-insert { all: unset; padding: 6px 10px 0; font-weight: 600; font-size: 13px; line-height: 18px; cursor: grab; }
|
|
165
|
+
.emvb-template-insert::after { content: ""; position: absolute; inset: 0; }
|
|
166
|
+
.emvb-template-desc { margin: 0; padding: 0 10px; font-size: 12px; line-height: 16px; color: var(--text-color-kumo-subtle); }
|
|
153
167
|
/* W-876: My sections, names only (D-060). */
|
|
154
168
|
.emvb-saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
|
|
155
169
|
.emvb-saved-row { display: flex; align-items: center; gap: 2px; min-width: 0; }
|
|
@@ -180,4 +194,12 @@ export const FEATURE_CSS = `
|
|
|
180
194
|
.emvb-codesign-ask-form { display: grid; gap: 6px; }
|
|
181
195
|
.emvb-codesign-ask-form .emvb-helper { margin: 0; }
|
|
182
196
|
.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; }
|
|
197
|
+
/* W-1072: a font variable's own files (Site styles, Fonts). */
|
|
198
|
+
.emvb-font-faces .emvb-bind-label { margin: 4px 0 0; }
|
|
199
|
+
.emvb-font-face-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
|
|
200
|
+
.emvb-font-face-list > li { display: flex; align-items: center; gap: 6px; min-height: 28px; font-size: 13px; }
|
|
201
|
+
.emvb-font-face-list > li > span:first-child { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
202
|
+
.emvb-font-face-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
|
|
203
|
+
.emvb-font-weights { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0; padding: 0; border: 0; font-size: 12px; }
|
|
204
|
+
.emvb-font-weights > legend { width: 100%; padding: 0; margin-bottom: 2px; }
|
|
183
205
|
`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W-752: a preview picture is not a page to browse. A link in it took keyboard focus and Enter
|
|
3
|
+
* loaded the site (or the admin, for an in-page anchor) inside the picture. Inside a tag, core
|
|
4
|
+
* escapes `"` and `>` in attribute values, so the tag and its href are found exactly; text is
|
|
5
|
+
* left alone. Used by the version timeline and the template previews (W-1068).
|
|
6
|
+
*/
|
|
7
|
+
export const inertLinks = (html: string) =>
|
|
8
|
+
html.replaceAll(/<a\b[^>]*>/g, (tag) => tag.replace(/ href="[^"]*"/, ""));
|