@perkyzz/emvb 0.7.0 → 0.9.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 +3 -3
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/package.json +7 -7
- package/src/admin/editor/DialogCloseButton.tsx +16 -0
- package/src/admin/editor/Editor.tsx +71 -1
- package/src/admin/editor/FieldPreview.tsx +164 -0
- package/src/admin/editor/PerfMeter.tsx +3 -9
- package/src/admin/editor/SavedSectionDialogs.tsx +169 -0
- package/src/admin/editor/ShareLink.tsx +2 -7
- package/src/admin/editor/ShortcutsDialog.tsx +19 -11
- package/src/admin/editor/Timeline.tsx +2 -7
- package/src/admin/editor/TopBar.tsx +32 -1
- package/src/admin/editor/dialogs.tsx +3 -14
- package/src/admin/editor/editor-chrome.tsx +8 -24
- package/src/admin/editor/editor-commands.ts +15 -1
- package/src/admin/editor/editor-css.ts +6 -2
- package/src/admin/editor/feature-css.ts +11 -1
- package/src/admin/editor/focus-when-lost.ts +23 -0
- package/src/admin/editor/host.ts +6 -0
- package/src/admin/editor/icons/IconLibraryDialog.tsx +2 -7
- package/src/admin/editor/palette-items.ts +17 -0
- package/src/admin/editor/panels/AddPanel.tsx +9 -1
- package/src/admin/editor/panels/ElementPanel.tsx +4 -1
- package/src/admin/editor/panels/LayersPanel.tsx +6 -1
- package/src/admin/editor/panels/LeftPanel.tsx +9 -1
- package/src/admin/editor/panels/SavedSectionsGroup.tsx +246 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +54 -10
- package/src/admin/editor/panels/TokenScales.tsx +16 -16
- package/src/admin/editor/panels/TriggersEditor.tsx +1 -1
- package/src/admin/editor/panels/color-space.ts +14 -26
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +36 -39
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +4 -5
- package/src/admin/editor/panels/settings/IconControls.tsx +21 -5
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +1 -1
- package/src/admin/editor/panels/settings/MediaPicker.tsx +5 -5
- package/src/admin/editor/panels/settings/length-units.ts +2 -1
- package/src/admin/editor/shortcuts.ts +14 -0
- package/src/admin/editor/useSavedSections.ts +197 -0
- package/src/admin/image-editor/Canvas.tsx +61 -17
- package/src/admin/image-editor/ImageEditorDialog.tsx +130 -1
- package/src/admin/image-editor/image-editor-css.ts +11 -8
- package/src/admin/image-editor/parts.tsx +18 -17
- package/src/admin/image-editor/save.ts +31 -1
- package/src/admin/index.tsx +5 -1
- package/src/admin/media-api.ts +27 -0
- package/src/admin/pages/AgentsPage.tsx +3 -3
- package/src/admin/pages/CollectionsPage.tsx +215 -0
- package/src/admin/pages/ThemePartList.tsx +32 -4
- package/src/admin/saved-sections-api.ts +51 -0
- package/src/admin/setup/host-collections.ts +100 -0
- package/src/admin/theme-api.ts +3 -2
- package/src/admin/ui.ts +9 -0
- package/src/admin/widgets/CanvasField.tsx +202 -0
- package/src/admin/widgets/convert-body.ts +54 -0
- package/src/admin/widgets/field-fetcher.ts +79 -0
- package/src/astro/index.ts +2 -0
- package/src/astro/page-count.ts +77 -0
- package/src/astro/popups/runtime.ts +8 -6
- package/src/astro/resolve-theme.ts +44 -2
- package/src/astro/resolve.ts +40 -4
- package/src/astro/responsive-images.ts +99 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +32 -7
- package/src/core/arrange.ts +21 -6
- package/src/core/canvas-collections.ts +20 -0
- package/src/core/css/print.ts +5 -0
- package/src/core/design/classes.ts +23 -9
- package/src/core/design/devices.ts +7 -13
- package/src/core/design/states.ts +7 -13
- package/src/core/elements/dynamic-elements.ts +27 -12
- package/src/core/elements/index.ts +1 -1
- package/src/core/elements/menu.ts +3 -0
- package/src/core/icons/animation-runs.ts +11 -0
- package/src/core/index.ts +22 -0
- package/src/core/migrate/index.ts +3 -0
- package/src/core/portable-text.ts +127 -0
- package/src/core/render/loop.ts +1 -1
- package/src/core/render/pagination.ts +20 -1
- package/src/core/sanitize/css.ts +14 -6
- package/src/core/saved-sections.ts +318 -0
- package/src/core/schema/design.ts +1 -1
- package/src/core/schema/layout.ts +6 -1
- package/src/core/schema/style.ts +4 -2
- package/src/core/theme/float.ts +3 -0
- package/src/core/theme/pagination.ts +34 -24
- package/src/core/theme/part-types.ts +4 -4
- package/src/index.ts +11 -1
- package/src/mcp/ports.ts +22 -1
- package/src/mcp/read.ts +1 -1
- package/src/mcp/sections.ts +183 -0
- package/src/mcp/tools.ts +44 -0
- package/src/mcp/write.ts +4 -4
- package/src/server/agent-settings.ts +16 -1
- package/src/server/hooks.ts +81 -0
- package/src/server/mcp-routes.ts +2 -0
- package/src/server/plugin.ts +34 -5
- package/src/server/saved-sections.ts +163 -0
|
@@ -18,6 +18,7 @@ import { PLUGIN_ID } from "../../constants.ts";
|
|
|
18
18
|
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
|
+
import { DialogCloseButton } from "./DialogCloseButton.tsx";
|
|
21
22
|
|
|
22
23
|
type RevisionItem = {
|
|
23
24
|
id: string;
|
|
@@ -469,13 +470,7 @@ export function TimelineDialog({
|
|
|
469
470
|
</div>
|
|
470
471
|
)}
|
|
471
472
|
<div className="emvb-dialog-actions" ref={actionsRef}>
|
|
472
|
-
<
|
|
473
|
-
render={(props) => (
|
|
474
|
-
<Button {...props} variant="secondary" className={BUTTON}>
|
|
475
|
-
Close
|
|
476
|
-
</Button>
|
|
477
|
-
)}
|
|
478
|
-
/>
|
|
473
|
+
<DialogCloseButton>Close</DialogCloseButton>
|
|
479
474
|
</div>
|
|
480
475
|
</div>
|
|
481
476
|
</Dialog>
|
|
@@ -3,6 +3,8 @@ import * as React from "react";
|
|
|
3
3
|
import {
|
|
4
4
|
ArrowSquareOutIcon,
|
|
5
5
|
CaretDownIcon,
|
|
6
|
+
CheckIcon,
|
|
7
|
+
EyeIcon,
|
|
6
8
|
DesktopIcon,
|
|
7
9
|
DeviceMobileIcon,
|
|
8
10
|
DeviceTabletIcon,
|
|
@@ -79,6 +81,7 @@ export function TopBar({
|
|
|
79
81
|
canRevert = false,
|
|
80
82
|
onRevert,
|
|
81
83
|
tools,
|
|
84
|
+
onApply,
|
|
82
85
|
}: {
|
|
83
86
|
page: TopBarPage | null;
|
|
84
87
|
dirty: boolean;
|
|
@@ -99,6 +102,8 @@ export function TopBar({
|
|
|
99
102
|
onRevert?: () => void;
|
|
100
103
|
/** Extra tools beside Site styles: the page weight and accessibility meters, … (W-310). */
|
|
101
104
|
tools?: React.ReactNode;
|
|
105
|
+
/** Field mode (W-900): one Apply button replaces Preview, Revert, Save draft and Publish. */
|
|
106
|
+
onApply?: () => void;
|
|
102
107
|
}) {
|
|
103
108
|
const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
104
109
|
// W-769: a disabled button drops focus to the page body, so the button that was focused when
|
|
@@ -186,7 +191,33 @@ export function TopBar({
|
|
|
186
191
|
)}
|
|
187
192
|
{page && tools}
|
|
188
193
|
</div>
|
|
189
|
-
{page && (
|
|
194
|
+
{page && onApply && (
|
|
195
|
+
// W-911: field mode previews in place; there is no saved draft for a new tab.
|
|
196
|
+
<Button
|
|
197
|
+
variant="secondary"
|
|
198
|
+
className={`${BUTTON} emvb-field-preview-button`}
|
|
199
|
+
icon={<EyeIcon aria-hidden="true" />}
|
|
200
|
+
onClick={() => onPreview()}
|
|
201
|
+
>
|
|
202
|
+
Preview
|
|
203
|
+
</Button>
|
|
204
|
+
)}
|
|
205
|
+
{page && onApply && (
|
|
206
|
+
<Button
|
|
207
|
+
variant="primary"
|
|
208
|
+
className={`${BUTTON} emvb-apply-button`}
|
|
209
|
+
style={SOLID_PRIMARY}
|
|
210
|
+
icon={<CheckIcon size={14} aria-hidden="true" />}
|
|
211
|
+
aria-disabled={busy !== null}
|
|
212
|
+
onClick={() => {
|
|
213
|
+
if (busy !== null) return;
|
|
214
|
+
onApply();
|
|
215
|
+
}}
|
|
216
|
+
>
|
|
217
|
+
Apply
|
|
218
|
+
</Button>
|
|
219
|
+
)}
|
|
220
|
+
{page && !onApply && (
|
|
190
221
|
<div
|
|
191
222
|
className="emvb-topbar-actions"
|
|
192
223
|
style={{
|
|
@@ -2,6 +2,7 @@ import { Button, Dialog, Loader } from "@cloudflare/kumo";
|
|
|
2
2
|
import { useMediaQuery } from "./useMediaQuery.ts";
|
|
3
3
|
import { useEditedNoun } from "./edited-noun.ts";
|
|
4
4
|
import { BUTTON, SOLID_DESTRUCTIVE, SOLID_PRIMARY, UI_CSS } from "../ui.ts";
|
|
5
|
+
import { DialogCloseButton } from "./DialogCloseButton.tsx";
|
|
5
6
|
|
|
6
7
|
type OpenProps = { open: boolean; onOpenChange: (open: boolean) => void };
|
|
7
8
|
|
|
@@ -59,13 +60,7 @@ export function RevertDialog({
|
|
|
59
60
|
live now. This can't be undone.
|
|
60
61
|
</Dialog.Description>
|
|
61
62
|
<div className="emvb-dialog-actions">
|
|
62
|
-
<
|
|
63
|
-
render={(props) => (
|
|
64
|
-
<Button {...props} variant="secondary" className={BUTTON}>
|
|
65
|
-
Cancel
|
|
66
|
-
</Button>
|
|
67
|
-
)}
|
|
68
|
-
/>
|
|
63
|
+
<DialogCloseButton>Cancel</DialogCloseButton>
|
|
69
64
|
<Button
|
|
70
65
|
variant="destructive"
|
|
71
66
|
className={BUTTON}
|
|
@@ -165,13 +160,7 @@ export function DeleteSubtreeDialog({
|
|
|
165
160
|
</Dialog.Title>
|
|
166
161
|
<Dialog.Description>You can undo this with Restore right after.</Dialog.Description>
|
|
167
162
|
<div className="emvb-dialog-actions">
|
|
168
|
-
<
|
|
169
|
-
render={(props) => (
|
|
170
|
-
<Button {...props} variant="secondary" className={BUTTON}>
|
|
171
|
-
Cancel
|
|
172
|
-
</Button>
|
|
173
|
-
)}
|
|
174
|
-
/>
|
|
163
|
+
<DialogCloseButton>Cancel</DialogCloseButton>
|
|
175
164
|
<Button
|
|
176
165
|
variant="destructive"
|
|
177
166
|
className={BUTTON}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { createKumoToastManager } from "@cloudflare/kumo";
|
|
2
|
+
import { focusWhenLost } from "./focus-when-lost.ts";
|
|
3
|
+
import type { SavedSectionActions } from "./useSavedSections.ts";
|
|
2
4
|
import * as React from "react";
|
|
3
5
|
import {
|
|
4
6
|
findNode,
|
|
@@ -72,30 +74,6 @@ const CLOSED = {
|
|
|
72
74
|
|
|
73
75
|
type ChromeKey = keyof typeof CLOSED;
|
|
74
76
|
|
|
75
|
-
/**
|
|
76
|
-
* Focuses the selected layer or the canvas if focus ends up on <body>. A closing dialog keeps
|
|
77
|
-
* focus until its close animation ends, so wait (up to 2 s) while focus is still in a dialog;
|
|
78
|
-
* other dialog-like layers (toasts) don't hold it up. Returns a cancel.
|
|
79
|
-
*/
|
|
80
|
-
function focusWhenLost(): () => void {
|
|
81
|
-
const started = Date.now();
|
|
82
|
-
let timer: number | undefined;
|
|
83
|
-
const settle = () => {
|
|
84
|
-
const now = document.activeElement;
|
|
85
|
-
if (now && now !== document.body) {
|
|
86
|
-
const inDialog = now.closest('[role="dialog"], [role="alertdialog"]') !== null;
|
|
87
|
-
if (inDialog && Date.now() - started < 2000) timer = window.setTimeout(settle, 30);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const target =
|
|
91
|
-
document.querySelector<HTMLElement>('.emvb-layer-select[aria-current="true"]') ??
|
|
92
|
-
document.querySelector<HTMLElement>("iframe[data-emvb-canvas]");
|
|
93
|
-
target?.focus({ preventScroll: true });
|
|
94
|
-
};
|
|
95
|
-
timer = window.setTimeout(settle, 30);
|
|
96
|
-
return () => window.clearTimeout(timer);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
77
|
/** Which editor dialog is open. They all start closed. */
|
|
100
78
|
export function useChromeFlags() {
|
|
101
79
|
const [flags, setFlags] = React.useState(CLOSED);
|
|
@@ -231,6 +209,7 @@ export function EditorDialogs({
|
|
|
231
209
|
playgroundUrl,
|
|
232
210
|
setAnnouncement,
|
|
233
211
|
parts,
|
|
212
|
+
saved,
|
|
234
213
|
}: {
|
|
235
214
|
chrome: ChromeFlags;
|
|
236
215
|
fetcher: Fetcher;
|
|
@@ -255,6 +234,8 @@ export function EditorDialogs({
|
|
|
255
234
|
setAnnouncement: (message: string) => void;
|
|
256
235
|
/** Synced sections and Loop Item parts loaded for the canvas (W-671). */
|
|
257
236
|
parts?: ThemeDynamicData;
|
|
237
|
+
/** My sections for the palette's Insert group (W-876). */
|
|
238
|
+
saved?: SavedSectionActions;
|
|
258
239
|
}) {
|
|
259
240
|
const [leaveSaving, setLeaveSaving] = React.useState(false);
|
|
260
241
|
return (
|
|
@@ -292,6 +273,9 @@ export function EditorDialogs({
|
|
|
292
273
|
formsAvailable,
|
|
293
274
|
insert: addFromPanel,
|
|
294
275
|
insertRecipe: addRecipe,
|
|
276
|
+
...(saved
|
|
277
|
+
? { savedSections: saved.list, insertSaved: (id) => void saved.insert(id) }
|
|
278
|
+
: {}),
|
|
295
279
|
select: (id) => dispatch({ type: "select", id }),
|
|
296
280
|
applyClass: (nodeId, classId) =>
|
|
297
281
|
dispatch({
|
|
@@ -42,6 +42,8 @@ export type CommandRunners = {
|
|
|
42
42
|
setDevice?: (device: PopupDevice) => void;
|
|
43
43
|
openShortcuts?: () => void;
|
|
44
44
|
rename?: () => void;
|
|
45
|
+
/** Opens Save as section for an element (W-876). */
|
|
46
|
+
saveSection?: (id: string) => void;
|
|
45
47
|
/** Set when the selection is an Image element the image editor can open (W-486). */
|
|
46
48
|
editImage?: () => void;
|
|
47
49
|
};
|
|
@@ -115,6 +117,12 @@ const SPECS: readonly Spec[] = [
|
|
|
115
117
|
surfaces: ["layers", "overlay", "palette"],
|
|
116
118
|
danger: true,
|
|
117
119
|
},
|
|
120
|
+
{
|
|
121
|
+
id: "save-section",
|
|
122
|
+
labels: { layers: "Save as section…", palette: "Save selected element as a section…" },
|
|
123
|
+
keywords: "my sections saved reuse synced template block segment",
|
|
124
|
+
surfaces: ["layers", "palette"],
|
|
125
|
+
},
|
|
118
126
|
{ id: "move-up", labels: { layers: "Move up" }, surfaces: ["layers"] },
|
|
119
127
|
{ id: "move-down", labels: { layers: "Move down" }, surfaces: ["layers"] },
|
|
120
128
|
{
|
|
@@ -131,7 +139,7 @@ const SPECS: readonly Spec[] = [
|
|
|
131
139
|
},
|
|
132
140
|
{
|
|
133
141
|
id: "wrap-div",
|
|
134
|
-
labels: { palette: "Wrap in Div
|
|
142
|
+
labels: { palette: "Wrap in Div block" },
|
|
135
143
|
keywords: "wrap box",
|
|
136
144
|
surfaces: ["palette"],
|
|
137
145
|
},
|
|
@@ -196,6 +204,7 @@ const ORDER: Record<CommandSurface, readonly string[]> = {
|
|
|
196
204
|
"paste",
|
|
197
205
|
"paste-inside",
|
|
198
206
|
"duplicate",
|
|
207
|
+
"save-section",
|
|
199
208
|
"copy-style",
|
|
200
209
|
"paste-style",
|
|
201
210
|
"move-up",
|
|
@@ -214,6 +223,7 @@ const ORDER: Record<CommandSurface, readonly string[]> = {
|
|
|
214
223
|
"redo",
|
|
215
224
|
"edit-image",
|
|
216
225
|
"duplicate",
|
|
226
|
+
"save-section",
|
|
217
227
|
"delete",
|
|
218
228
|
"deselect",
|
|
219
229
|
"site-styles",
|
|
@@ -237,6 +247,7 @@ function shown(id: string, input: CommandInput): boolean {
|
|
|
237
247
|
const clip = !!input.runners.copy;
|
|
238
248
|
if (id === "rename") return !!input.runners.rename;
|
|
239
249
|
if (id === "edit-image") return !!input.runners.editImage;
|
|
250
|
+
if (id === "save-section") return !!input.runners.saveSection && input.canDuplicate;
|
|
240
251
|
if (id === "paste-inside") return clip && input.isParent;
|
|
241
252
|
if (id === "paste") return clip && (input.surface !== "layers" || !input.isRoot);
|
|
242
253
|
if (CLIP_IDS.has(id)) return clip;
|
|
@@ -302,6 +313,9 @@ export function runCommand(runners: CommandRunners, id: string, targetId: string
|
|
|
302
313
|
case "duplicate":
|
|
303
314
|
if (targetId) runners.duplicate?.(targetId);
|
|
304
315
|
return;
|
|
316
|
+
case "save-section":
|
|
317
|
+
if (targetId) runners.saveSection?.(targetId);
|
|
318
|
+
return;
|
|
305
319
|
case "delete":
|
|
306
320
|
if (targetId) runners.remove?.(targetId);
|
|
307
321
|
return;
|
|
@@ -199,6 +199,9 @@ export const EDITOR_CSS = `${UI_CSS}
|
|
|
199
199
|
/* W-244: an unselected segmented option (Desktop | Tablet | Mobile, Normal | Hover | Focus | Active) takes the
|
|
200
200
|
default text colour: Kumo's subtle grey on the segmented track is 4.0:1. The raised white pill marks the selected one. */
|
|
201
201
|
.emvb-device-tabs [role="tab"][aria-selected="false"], .emvb-state-tabs [role="tab"][aria-selected="false"] { color: var(--text-color-kumo-default); }
|
|
202
|
+
/* W-905: Kumo animates every property of the active-tab pill, so a light/dark switch faded it
|
|
203
|
+
through white under light text; only its movement should animate. */
|
|
204
|
+
.emvb-device-tabs [role="tablist"] > div, .emvb-state-tabs [role="tablist"] > div { transition-property: translate, transform, width, height, top, left, scale, opacity; }
|
|
202
205
|
.emvb-device-label { display: inline-flex; align-items: center; gap: 6px; }
|
|
203
206
|
.emvb-device-hide { display: inline-flex; align-items: center; gap: 6px; color: var(--text-color-kumo-default); font-size: 13px; }
|
|
204
207
|
.emvb-stage { position: relative; display: flex; flex: 1 1 auto; justify-content: safe center; min-height: 0; width: 100%; overflow: hidden; }
|
|
@@ -239,7 +242,6 @@ iframe[data-emvb-canvas-focus="keyboard"] { outline: 2px solid var(--color-kumo-
|
|
|
239
242
|
font-size: 11px;
|
|
240
243
|
line-height: 14px;
|
|
241
244
|
font-weight: 600;
|
|
242
|
-
letter-spacing: 0.01em;
|
|
243
245
|
white-space: nowrap;
|
|
244
246
|
box-shadow: 0 1px 2px var(--color-kumo-shadow-edge), 0 2px 6px var(--color-kumo-shadow-drop);
|
|
245
247
|
pointer-events: none;
|
|
@@ -254,7 +256,9 @@ iframe[data-emvb-canvas-focus="keyboard"] { outline: 2px solid var(--color-kumo-
|
|
|
254
256
|
.emvb-small-screen { grid-row: 1 / -1; }
|
|
255
257
|
.emvb-shortcuts { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
256
258
|
.emvb-shortcuts td { padding: 6px 0; border-bottom: 1px solid var(--color-kumo-hairline); }
|
|
257
|
-
.emvb-shortcuts td:last-child { text-align: right;
|
|
259
|
+
.emvb-shortcuts td:last-child { text-align: right; white-space: nowrap; font-size: 11px; color: var(--text-color-kumo-subtle); }
|
|
260
|
+
/* W-864: the same key boxes as the command palette's tips. */
|
|
261
|
+
.emvb-shortcuts kbd { display: inline-block; min-width: 18px; margin: 0 2px; padding: 0 4px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--color-kumo-line); font-family: var(--font-mono); font-size: 11px; line-height: 16px; text-align: center; color: var(--text-color-kumo-default); }
|
|
258
262
|
|
|
259
263
|
.emvb-add-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
|
|
260
264
|
.emvb-element-tile {
|
|
@@ -22,12 +22,14 @@ export const FEATURE_CSS = `
|
|
|
22
22
|
.emvb-bind-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; align-items: center; }
|
|
23
23
|
.emvb-bind-row > .emvb-bind-label { grid-column: 1 / -1; font-size: 12px; color: var(--text-color-kumo-subtle); }
|
|
24
24
|
.emvb-bind-row > .emvb-panel-select:last-child { grid-column: 1 / -1; }
|
|
25
|
+
/* W-867: a row with one text field (Countries, Segments, Time zone) gives it the full width, as its selects. */
|
|
26
|
+
.emvb-bind-row > .emvb-bind-label + .emvb-field:last-child { grid-column: 1 / -1; }
|
|
25
27
|
.emvb-bind-live { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--text-color-kumo-default); overflow-wrap: anywhere; }
|
|
26
28
|
.emvb-bind-live > b { font-weight: 600; }
|
|
27
29
|
.emvb-bind-outside { grid-column: 1 / -1; display: grid; gap: 4px; }
|
|
28
30
|
.emvb-bind-outside > label { display: flex; gap: 6px; align-items: center; font-size: 12px; }
|
|
29
31
|
.emvb-bind-warning { margin: 0; padding: 6px 8px; border-radius: 6px; font-size: 12px; background: var(--color-kumo-warning-tint); color: var(--text-color-kumo-default); }
|
|
30
|
-
.emvb-js-badge { margin-left: auto; padding: 0 4px; border-radius: 4px; font-size: 10px; font-weight:
|
|
32
|
+
.emvb-js-badge { margin-left: auto; padding: 0 4px; border-radius: 4px; font-size: 10px; font-weight: 600; line-height: 16px; background: var(--color-kumo-warning-tint); color: var(--text-color-kumo-default); }
|
|
31
33
|
.emvb-element-tile { position: relative; }
|
|
32
34
|
.emvb-element-tile > .emvb-js-badge { position: absolute; top: 4px; right: 4px; }
|
|
33
35
|
.emvb-perf-bars { display: grid; gap: 8px; margin: 12px 0; padding: 0; list-style: none; }
|
|
@@ -148,6 +150,14 @@ export const FEATURE_CSS = `
|
|
|
148
150
|
.emvb-recipe-tile:hover, .emvb-recipe-tile:focus-visible { border-color: var(--color-kumo-brand); }
|
|
149
151
|
.emvb-recipe-name { font-weight: 600; font-size: 13px; }
|
|
150
152
|
.emvb-recipe-desc { font-size: 12px; color: var(--text-color-kumo-subtle); }
|
|
153
|
+
/* W-876: My sections, names only (D-060). */
|
|
154
|
+
.emvb-saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
|
|
155
|
+
.emvb-saved-row { display: flex; align-items: center; gap: 2px; min-width: 0; }
|
|
156
|
+
.emvb-saved-name { flex: 1 1 auto; min-width: 0; text-align: start; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--color-kumo-line); background: var(--color-kumo-base, transparent); cursor: pointer; font: inherit; font-size: 13px; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
157
|
+
.emvb-saved-name:hover:not(:disabled), .emvb-saved-name:focus-visible { border-color: var(--color-kumo-brand); }
|
|
158
|
+
.emvb-saved-name:disabled { cursor: not-allowed; color: var(--text-color-kumo-subtle); }
|
|
159
|
+
.emvb-saved-row .emvb-saved-rename { flex: 1 1 auto; }
|
|
160
|
+
.emvb-saved-error { display: grid; gap: 6px; justify-items: start; }
|
|
151
161
|
.emvb-motion-effect { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: end; }
|
|
152
162
|
.emvb-motion-name { grid-column: 1 / -1; font-size: 12px; font-weight: 600; }
|
|
153
163
|
/* UX-092: the fixed theme part type, its label and value on one line */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focuses the selected layer or the canvas if focus ends up on <body>. A closing dialog keeps
|
|
3
|
+
* focus until its close animation ends, so wait (up to 2 s) while focus is still in a dialog;
|
|
4
|
+
* other dialog-like layers (toasts) don't hold it up. Returns a cancel.
|
|
5
|
+
*/
|
|
6
|
+
export function focusWhenLost(): () => void {
|
|
7
|
+
const started = Date.now();
|
|
8
|
+
let timer: number | undefined;
|
|
9
|
+
const settle = () => {
|
|
10
|
+
const now = document.activeElement;
|
|
11
|
+
if (now && now !== document.body) {
|
|
12
|
+
const inDialog = now.closest('[role="dialog"], [role="alertdialog"]') !== null;
|
|
13
|
+
if (inDialog && Date.now() - started < 2000) timer = window.setTimeout(settle, 30);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const target =
|
|
17
|
+
document.querySelector<HTMLElement>('.emvb-layer-select[aria-current="true"]') ??
|
|
18
|
+
document.querySelector<HTMLElement>("iframe[data-emvb-canvas]");
|
|
19
|
+
target?.focus({ preventScroll: true });
|
|
20
|
+
};
|
|
21
|
+
timer = window.setTimeout(settle, 30);
|
|
22
|
+
return () => window.clearTimeout(timer);
|
|
23
|
+
}
|
package/src/admin/editor/host.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Layout } from "../../core/index.ts";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { PLUGIN_ID } from "../../constants.ts";
|
|
3
4
|
import { canvasStyleUrls } from "../../core/canvas-styles.ts";
|
|
@@ -25,6 +26,11 @@ export type EditorHost = {
|
|
|
25
26
|
* for the host's `emvb({ canvasStyles })`.
|
|
26
27
|
*/
|
|
27
28
|
canvasStyles?: readonly string[];
|
|
29
|
+
/**
|
|
30
|
+
* Field mode (W-900): the editor edits a host entry's emvb:canvas field. Apply hands the layout
|
|
31
|
+
* back to the entry form instead of saving or publishing anything.
|
|
32
|
+
*/
|
|
33
|
+
field?: { apply: (layout: Layout | null) => void };
|
|
28
34
|
};
|
|
29
35
|
|
|
30
36
|
const defaultEditorHost: EditorHost = {
|
|
@@ -12,6 +12,7 @@ import { BUTTON, SOLID_PRIMARY, UI_CSS } from "../../ui.ts";
|
|
|
12
12
|
import { ALL_ICONS, ICON_SETS, UPLOADS, type LibraryIcon, type loadIconSet } from "./library.ts";
|
|
13
13
|
import { fmt, useIconLibrary } from "./use-icon-library.ts";
|
|
14
14
|
import { isCommitEnter } from "../ime.ts";
|
|
15
|
+
import { DialogCloseButton } from "../DialogCloseButton.tsx";
|
|
15
16
|
|
|
16
17
|
/** Grid geometry, in px. Tiles stretch to fill the row; this is their narrowest. */
|
|
17
18
|
const TILE_MIN_WIDTH = 96;
|
|
@@ -535,13 +536,7 @@ function IconLibrary({
|
|
|
535
536
|
</Button>
|
|
536
537
|
</>
|
|
537
538
|
)}
|
|
538
|
-
<
|
|
539
|
-
render={(props) => (
|
|
540
|
-
<Button {...props} variant="secondary" className={BUTTON}>
|
|
541
|
-
Close
|
|
542
|
-
</Button>
|
|
543
|
-
)}
|
|
544
|
-
/>
|
|
539
|
+
<DialogCloseButton>Close</DialogCloseButton>
|
|
545
540
|
<Button
|
|
546
541
|
variant="primary"
|
|
547
542
|
className={`${BUTTON} ${SOLID_PRIMARY}`}
|
|
@@ -18,6 +18,9 @@ export type PaletteActions = {
|
|
|
18
18
|
insert: (type: ElementType) => void;
|
|
19
19
|
/** Adds a section recipe (W-320). */
|
|
20
20
|
insertRecipe?: (id: string) => void;
|
|
21
|
+
/** My sections (W-876), inserted by id. */
|
|
22
|
+
savedSections?: readonly { id: string; name: string; damaged?: true }[];
|
|
23
|
+
insertSaved?: (id: string) => void;
|
|
21
24
|
select: (id: string) => void;
|
|
22
25
|
applyClass: (nodeId: string, classId: string) => void;
|
|
23
26
|
actions: { id: string; label: string; hint?: string; keywords?: string; run: () => void }[];
|
|
@@ -94,6 +97,20 @@ export function paletteItems(ctx: PaletteActions): PaletteItem[] {
|
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
99
|
}
|
|
100
|
+
const insertSaved = ctx.insertSaved;
|
|
101
|
+
if (insertSaved) {
|
|
102
|
+
for (const section of ctx.savedSections ?? []) {
|
|
103
|
+
if (section.damaged) continue;
|
|
104
|
+
items.push({
|
|
105
|
+
id: `saved:${section.id}`,
|
|
106
|
+
group: "Insert",
|
|
107
|
+
label: `Insert ${section.name}`,
|
|
108
|
+
hint: "My sections",
|
|
109
|
+
keywords: "my sections saved section block template segment",
|
|
110
|
+
run: () => insertSaved(section.id),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
97
114
|
if (ctx.layout) {
|
|
98
115
|
let count = 0;
|
|
99
116
|
const walk = (node: LayoutNode, depth: number): void => {
|
|
@@ -12,6 +12,8 @@ import { BUTTON, FIELD } from "../../ui.ts";
|
|
|
12
12
|
import { isCancelEscape } from "../ime.ts";
|
|
13
13
|
import { matchesSearch } from "../../search.ts";
|
|
14
14
|
import { dragStash } from "../dnd/drag-stash.ts";
|
|
15
|
+
import type { SavedSectionActions } from "../useSavedSections.ts";
|
|
16
|
+
import { matchingSections, SavedSectionsGroup } from "./SavedSectionsGroup.tsx";
|
|
15
17
|
|
|
16
18
|
const GROUPS = [
|
|
17
19
|
{ id: "layout", label: "Layout" },
|
|
@@ -23,12 +25,15 @@ const GROUPS = [
|
|
|
23
25
|
export function AddPanel({
|
|
24
26
|
onAdd,
|
|
25
27
|
onRecipe,
|
|
28
|
+
saved,
|
|
26
29
|
defaultQuery = "",
|
|
27
30
|
formsAvailable = true,
|
|
28
31
|
}: {
|
|
29
32
|
onAdd: (type: ElementType) => void;
|
|
30
33
|
/** Adds a section recipe (W-320); without it, recipes are not offered. */
|
|
31
34
|
onRecipe?: (id: string) => void;
|
|
35
|
+
/** My sections (W-876); without it the group is not shown. */
|
|
36
|
+
saved?: SavedSectionActions;
|
|
32
37
|
/** Test-only initial search string. */
|
|
33
38
|
defaultQuery?: string;
|
|
34
39
|
/** Hide the Form group when the forms plugin is missing (W-036). */
|
|
@@ -68,7 +73,9 @@ export function AddPanel({
|
|
|
68
73
|
}}
|
|
69
74
|
placeholder="Search elements…"
|
|
70
75
|
/>
|
|
71
|
-
{matched.length === 0 &&
|
|
76
|
+
{matched.length === 0 &&
|
|
77
|
+
recipes.length === 0 &&
|
|
78
|
+
(!saved || matchingSections(saved, query).length === 0) ? (
|
|
72
79
|
<div className="emvb-add-nomatch" data-emvb-add-nomatch="">
|
|
73
80
|
<p className="emvb-helper" role="status">
|
|
74
81
|
No elements match "{query.trim()}".
|
|
@@ -146,6 +153,7 @@ export function AddPanel({
|
|
|
146
153
|
</div>
|
|
147
154
|
</div>
|
|
148
155
|
)}
|
|
156
|
+
{saved && <SavedSectionsGroup saved={saved} query={query} />}
|
|
149
157
|
</div>
|
|
150
158
|
);
|
|
151
159
|
}
|
|
@@ -325,6 +325,8 @@ const SHOWN_WHEN: Readonly<
|
|
|
325
325
|
> = {
|
|
326
326
|
"loop.columns": (props) => props["display"] === "grid" || props["display"] === "cards",
|
|
327
327
|
"pagination.countText": (props) => props["showCount"] === true,
|
|
328
|
+
"pagination.lastText": (props) => props["showLast"] === true,
|
|
329
|
+
"pagination.lastLabel": (props) => props["showLast"] === true,
|
|
328
330
|
// Post Link always links to its post, so its new-tab switch always applies.
|
|
329
331
|
"post-link.newTab": () => true,
|
|
330
332
|
// UX-075: each device's tracks show on that device, as Columns does (W-139).
|
|
@@ -688,7 +690,8 @@ function KnownElementPanel({
|
|
|
688
690
|
if (cls || styleState !== "normal") return null;
|
|
689
691
|
return section(
|
|
690
692
|
id,
|
|
691
|
-
|
|
693
|
+
// W-914: a per-element direction counts as a set Advanced value too.
|
|
694
|
+
(node.htmlId ? 1 : 0) + (node.dir ? 1 : 0) + (node.attributes?.length ?? 0),
|
|
692
695
|
<>
|
|
693
696
|
<HtmlIdField node={node} layout={layout} onChange={onChange} />
|
|
694
697
|
<DirectionField node={node} onChange={onChange} />
|
|
@@ -50,6 +50,8 @@ type LayerActions = {
|
|
|
50
50
|
clipboard?: ClipboardActions;
|
|
51
51
|
/** Sets or clears a node's editor-only name (W-157); without it rows can't be renamed. */
|
|
52
52
|
onRename?: (id: string, label: string | undefined) => void;
|
|
53
|
+
/** Opens Save as section (W-876); without it the menu has no such item. */
|
|
54
|
+
onSaveSection?: (id: string) => void;
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
type MenuItem = {
|
|
@@ -96,6 +98,7 @@ function menuItems(
|
|
|
96
98
|
runners: {
|
|
97
99
|
rename: actions.onRename ? rename : undefined,
|
|
98
100
|
duplicate: actions.onDuplicate,
|
|
101
|
+
saveSection: actions.onSaveSection,
|
|
99
102
|
remove: actions.onDelete,
|
|
100
103
|
moveUp: actions.onMoveUp,
|
|
101
104
|
moveDown: actions.onMoveDown,
|
|
@@ -209,6 +212,7 @@ export function LayersPanel({
|
|
|
209
212
|
const live = React.useRef(actions);
|
|
210
213
|
live.current = actions;
|
|
211
214
|
const canRename = !!actions.onRename;
|
|
215
|
+
const canSaveSection = !!actions.onSaveSection;
|
|
212
216
|
const rowActions = React.useMemo<LayerActions>(
|
|
213
217
|
() => ({
|
|
214
218
|
onSelect: (id) => live.current.onSelect(id),
|
|
@@ -217,8 +221,9 @@ export function LayersPanel({
|
|
|
217
221
|
onMoveDown: (id) => live.current.onMoveDown(id),
|
|
218
222
|
onDelete: (id) => live.current.onDelete(id),
|
|
219
223
|
onRename: canRename ? (id, label) => live.current.onRename?.(id, label) : undefined,
|
|
224
|
+
onSaveSection: canSaveSection ? (id) => live.current.onSaveSection?.(id) : undefined,
|
|
220
225
|
}),
|
|
221
|
-
[canRename],
|
|
226
|
+
[canRename, canSaveSection],
|
|
222
227
|
);
|
|
223
228
|
const onRowMenu = React.useCallback(
|
|
224
229
|
(id: string, open: boolean) => setMenuId(open ? id : null),
|
|
@@ -4,6 +4,7 @@ import type { ElementType, Layout } from "../../../core/index.ts";
|
|
|
4
4
|
import { AddPanel } from "./AddPanel.tsx";
|
|
5
5
|
import { LayersPanel } from "./LayersPanel.tsx";
|
|
6
6
|
import type { ClipboardActions } from "../useClipboardActions.ts";
|
|
7
|
+
import type { SavedSectionActions } from "../useSavedSections.ts";
|
|
7
8
|
|
|
8
9
|
const SESSION_KEY = "emvb-left-tab";
|
|
9
10
|
|
|
@@ -14,12 +15,14 @@ export function LeftPanel({
|
|
|
14
15
|
onSelect,
|
|
15
16
|
onAdd,
|
|
16
17
|
onRecipe,
|
|
18
|
+
saved,
|
|
17
19
|
onDuplicate,
|
|
18
20
|
onMoveUp,
|
|
19
21
|
onMoveDown,
|
|
20
22
|
onDelete,
|
|
21
23
|
clipboard,
|
|
22
24
|
onRename,
|
|
25
|
+
onSaveSection,
|
|
23
26
|
formsAvailable = true,
|
|
24
27
|
}: {
|
|
25
28
|
layout: Layout | null;
|
|
@@ -28,6 +31,8 @@ export function LeftPanel({
|
|
|
28
31
|
onAdd: (type: ElementType) => void;
|
|
29
32
|
/** Adds a section recipe (W-320). */
|
|
30
33
|
onRecipe?: (id: string) => void;
|
|
34
|
+
/** My sections (W-876). */
|
|
35
|
+
saved?: SavedSectionActions;
|
|
31
36
|
onDuplicate: (id: string) => void;
|
|
32
37
|
onMoveUp: (id: string) => void;
|
|
33
38
|
onMoveDown: (id: string) => void;
|
|
@@ -35,6 +40,8 @@ export function LeftPanel({
|
|
|
35
40
|
clipboard?: ClipboardActions;
|
|
36
41
|
/** Layers rename (W-157). */
|
|
37
42
|
onRename?: (id: string, label: string | undefined) => void;
|
|
43
|
+
/** Save as section in the row menu (W-876). */
|
|
44
|
+
onSaveSection?: (id: string) => void;
|
|
38
45
|
formsAvailable?: boolean;
|
|
39
46
|
}) {
|
|
40
47
|
const [tab, setTab] = React.useState(() => {
|
|
@@ -65,7 +72,7 @@ export function LeftPanel({
|
|
|
65
72
|
onValueChange={changeTab}
|
|
66
73
|
/>
|
|
67
74
|
{tab === "add" ? (
|
|
68
|
-
<AddPanel onAdd={onAdd} onRecipe={onRecipe} formsAvailable={formsAvailable} />
|
|
75
|
+
<AddPanel onAdd={onAdd} onRecipe={onRecipe} saved={saved} formsAvailable={formsAvailable} />
|
|
69
76
|
) : (
|
|
70
77
|
<LayersPanel
|
|
71
78
|
layout={layout}
|
|
@@ -77,6 +84,7 @@ export function LeftPanel({
|
|
|
77
84
|
onDelete={onDelete}
|
|
78
85
|
clipboard={clipboard}
|
|
79
86
|
onRename={onRename}
|
|
87
|
+
onSaveSection={onSaveSection}
|
|
80
88
|
/>
|
|
81
89
|
)}
|
|
82
90
|
</div>
|