@perkyzz/emvb 0.1.0 → 0.2.1
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 +6 -4
- package/THIRD_PARTY_NOTICES.md +32 -0
- package/licenses/fontawesome-free.LICENSE +165 -0
- package/licenses/lucide-static.LICENSE +43 -0
- package/licenses/remixicon.LICENSE +201 -0
- package/licenses/tabler-icons.LICENSE +21 -0
- package/package.json +9 -5
- package/src/admin/api.ts +27 -0
- package/src/admin/content-api.ts +72 -9
- package/src/admin/editor/Editor.tsx +89 -14
- package/src/admin/editor/EditorOverlay.tsx +12 -0
- package/src/admin/editor/SmallScreenNotice.tsx +4 -3
- package/src/admin/editor/TopBar.tsx +76 -12
- package/src/admin/editor/canvas/CanvasFrame.tsx +224 -43
- package/src/admin/editor/canvas/DeviceBar.tsx +43 -2
- package/src/admin/editor/canvas/SelectionOverlay.tsx +60 -6
- package/src/admin/editor/canvas/canvas-events.ts +20 -7
- package/src/admin/editor/canvas/tab-reveal.ts +66 -0
- package/src/admin/editor/canvas/vnode-react.tsx +21 -1
- package/src/admin/editor/dialogs.tsx +39 -0
- package/src/admin/editor/dnd/drop-target.ts +63 -16
- package/src/admin/editor/dnd/new-element.ts +76 -1
- package/src/admin/editor/editor-css.ts +101 -15
- package/src/admin/editor/host.ts +30 -0
- package/src/admin/editor/icons/IconLibraryDialog.tsx +850 -0
- package/src/admin/editor/icons/library.ts +243 -0
- package/src/admin/editor/icons/set-format.ts +29 -0
- package/src/admin/editor/icons/sets/fontawesome.json +1 -0
- package/src/admin/editor/icons/sets/lucide.json +1 -0
- package/src/admin/editor/icons/sets/remix.json +1 -0
- package/src/admin/editor/icons/sets/tabler.json +1 -0
- package/src/admin/editor/panels/AddPanel.tsx +7 -3
- package/src/admin/editor/panels/ClassesSection.tsx +44 -6
- package/src/admin/editor/panels/ColorControl.tsx +268 -21
- package/src/admin/editor/panels/ElementPanel.tsx +237 -93
- package/src/admin/editor/panels/LayersPanel.tsx +303 -66
- package/src/admin/editor/panels/LeftPanel.tsx +4 -0
- package/src/admin/editor/panels/PageSettings.tsx +134 -5
- package/src/admin/editor/panels/SettingsPanel.tsx +12 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +158 -2
- package/src/admin/editor/panels/TriggersEditor.tsx +19 -2
- package/src/admin/editor/panels/VariableSection.tsx +47 -9
- package/src/admin/editor/panels/color-space.ts +195 -0
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +119 -0
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +153 -55
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +221 -0
- package/src/admin/editor/panels/settings/BoxControl.tsx +271 -0
- package/src/admin/editor/panels/settings/ChoiceGroup.tsx +138 -0
- package/src/admin/editor/panels/settings/ClassChipInput.tsx +104 -2
- package/src/admin/editor/panels/settings/DraftTextField.tsx +44 -3
- package/src/admin/editor/panels/settings/EffectsControls.tsx +25 -16
- package/src/admin/editor/panels/settings/FieldBindControl.tsx +53 -17
- package/src/admin/editor/panels/settings/FieldControl.tsx +129 -9
- package/src/admin/editor/panels/settings/FormBindControl.tsx +14 -5
- package/src/admin/editor/panels/settings/IconControls.tsx +438 -0
- package/src/admin/editor/panels/settings/IconPicker.tsx +133 -72
- package/src/admin/editor/panels/settings/ItemList.tsx +199 -0
- package/src/admin/editor/panels/settings/LengthRow.tsx +97 -61
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +10 -4
- package/src/admin/editor/panels/settings/MediaPicker.tsx +4 -2
- package/src/admin/editor/panels/settings/StateSwitcher.tsx +1 -1
- package/src/admin/editor/panels/settings/StyleRow.tsx +158 -75
- package/src/admin/editor/panels/settings/VariableBinding.tsx +5 -1
- package/src/admin/editor/panels/settings/advanced-rules.ts +63 -0
- package/src/admin/editor/panels/settings/background-mode.ts +112 -0
- package/src/admin/editor/panels/settings/box-link-name.ts +38 -0
- package/src/admin/editor/panels/settings/box-sides.ts +153 -0
- package/src/admin/editor/panels/settings/button-url.ts +27 -0
- package/src/admin/editor/panels/settings/class-suggest.ts +5 -3
- package/src/admin/editor/panels/settings/form-names.ts +38 -0
- package/src/admin/editor/panels/settings/heading-warning.ts +25 -0
- package/src/admin/editor/panels/settings/image-alt.ts +25 -0
- package/src/admin/editor/panels/settings/length-units.ts +40 -7
- package/src/admin/editor/panels/settings/loop-context.ts +26 -0
- package/src/admin/editor/panels/settings/style-sections.ts +114 -11
- package/src/admin/editor/panels/settings/svg-images.ts +14 -0
- package/src/admin/editor/panels/site-list.tsx +3 -0
- package/src/admin/editor/restore-deleted.ts +80 -0
- package/src/admin/editor/shortcuts.ts +1 -1
- package/src/admin/editor/store.ts +35 -7
- package/src/admin/editor/useEditorCommands.ts +66 -5
- package/src/admin/editor/useEditorData.ts +29 -3
- package/src/admin/editor/useEditorShortcuts.ts +34 -2
- package/src/admin/editor/useNodeActions.ts +68 -6
- package/src/admin/editor/useSave.ts +60 -3
- package/src/admin/entry-status.ts +19 -0
- package/src/admin/icon-uploads-api.ts +44 -0
- package/src/admin/pages/PageList.tsx +22 -2
- package/src/admin/pages/ThemePartList.tsx +23 -4
- package/src/admin/pages/list-kit.tsx +52 -2
- package/src/admin/setup/spec.ts +7 -0
- package/src/admin/theme-api.ts +61 -14
- package/src/admin/ui.ts +17 -4
- package/src/astro/EmVBPage.astro +28 -2
- package/src/astro/floats/EmVBFloatsRuntime.astro +9 -0
- package/src/astro/floats/index.ts +1 -0
- package/src/astro/floats/runtime.ts +78 -0
- package/src/astro/forms-definitions.ts +22 -0
- package/src/astro/index.ts +1 -0
- package/src/astro/menu/EmVBMenuRuntime.astro +9 -0
- package/src/astro/menu/index.ts +1 -0
- package/src/astro/menu/runtime.ts +37 -0
- package/src/astro/popups/runtime.ts +54 -4
- package/src/astro/render.ts +47 -13
- package/src/astro/resolve-theme.ts +168 -24
- package/src/astro/tabs/runtime.ts +6 -1
- package/src/astro/theme-context.ts +25 -5
- package/src/astro/theme-posts.ts +19 -1
- package/src/constants.ts +1 -1
- package/src/core/arrange.ts +98 -10
- package/src/core/clipboard.ts +91 -9
- package/src/core/css/generate.ts +21 -4
- package/src/core/design/classes.ts +95 -9
- package/src/core/design/transfer.ts +101 -2
- package/src/core/design/variables.ts +51 -11
- package/src/core/elements/dynamic-elements.ts +57 -5
- package/src/core/elements/field-id.ts +6 -0
- package/src/core/elements/form-elements.ts +23 -8
- package/src/core/elements/index.ts +267 -49
- package/src/core/elements/menu.ts +190 -0
- package/src/core/forms/definition.ts +11 -0
- package/src/core/index.ts +67 -3
- package/src/core/limits.ts +2 -0
- package/src/core/migrate/index.ts +51 -1
- package/src/core/nesting.ts +51 -0
- package/src/core/render/context.ts +7 -0
- package/src/core/render/dynamic-post.ts +39 -11
- package/src/core/render/extras.ts +22 -3
- package/src/core/render/form.ts +134 -36
- package/src/core/render/index.ts +123 -25
- package/src/core/render/loop.ts +10 -3
- package/src/core/render/pagination.ts +76 -0
- package/src/core/render/section.ts +5 -1
- package/src/core/render/tabs.ts +8 -4
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +197 -17
- package/src/core/sanitize/embed-url.ts +64 -7
- package/src/core/sanitize/svg-upload.ts +203 -0
- package/src/core/sanitize/svg.ts +102 -21
- package/src/core/schema/descriptors.ts +4 -0
- package/src/core/schema/design.ts +7 -2
- package/src/core/schema/layout.ts +210 -19
- package/src/core/schema/style.ts +87 -8
- package/src/core/tabs/presence.ts +9 -0
- package/src/core/theme/conditions.ts +4 -1
- package/src/core/theme/dynamic.ts +10 -0
- package/src/core/theme/float.ts +113 -0
- package/src/core/theme/pagination.ts +97 -0
- package/src/core/theme/part-types.ts +2 -0
- package/src/core/theme/popup-markup.ts +3 -1
- package/src/core/theme/popup-rules.ts +4 -3
- package/src/server/hooks.ts +20 -0
- package/src/server/icon-routes.ts +79 -0
- package/src/server/plugin.ts +5 -1
package/src/core/clipboard.ts
CHANGED
|
@@ -12,9 +12,10 @@ import type { VariableKind } from "./design/variables.ts";
|
|
|
12
12
|
import { clearVariableRefs } from "./design/variables.ts";
|
|
13
13
|
import { ELEMENT_DESCRIPTORS, ELEMENTS, type ElementType } from "./elements/index.ts";
|
|
14
14
|
import { MAX_LAYOUT_BYTES } from "./limits.ts";
|
|
15
|
+
import { serialize } from "./render/vnode.ts";
|
|
15
16
|
import { sanitizeHref } from "./sanitize/href.ts";
|
|
16
17
|
import { sanitizeMediaUrl } from "./sanitize/media-url.ts";
|
|
17
|
-
import {
|
|
18
|
+
import { sanitizeSvgReport } from "./sanitize/svg.ts";
|
|
18
19
|
import type { DesignSystem } from "./schema/design.ts";
|
|
19
20
|
import {
|
|
20
21
|
isParentNode,
|
|
@@ -172,7 +173,14 @@ export const clipStyle = (clip: Clip): CopiedStyle =>
|
|
|
172
173
|
clip.kind === "style" ? clip.style : styleOf(clip.node);
|
|
173
174
|
|
|
174
175
|
/** What a paste left out because the target page or site doesn't allow or have it. */
|
|
175
|
-
export type Dropped = {
|
|
176
|
+
export type Dropped = {
|
|
177
|
+
classes: number;
|
|
178
|
+
variables: number;
|
|
179
|
+
htmlIds: number;
|
|
180
|
+
unsafe: number;
|
|
181
|
+
/** W-231: `<image>`s left out of pasted SVGs because they point outside the site. */
|
|
182
|
+
images?: number;
|
|
183
|
+
};
|
|
176
184
|
|
|
177
185
|
const none = (): Dropped => ({ classes: 0, variables: 0, htmlIds: 0, unsafe: 0 });
|
|
178
186
|
|
|
@@ -190,14 +198,14 @@ const asRef = (value: unknown): Ref | null =>
|
|
|
190
198
|
? { var: value["var"], kind: (value["from"] as VariableKind | undefined) ?? "color" }
|
|
191
199
|
: null;
|
|
192
200
|
|
|
193
|
-
/** Every variable ref in a style: each value, plus nested colours (
|
|
201
|
+
/** Every variable ref in a style: each value, plus nested colours (shadows, gradient, overlay). */
|
|
194
202
|
function refsInStyle(style: StyleProps | undefined): Ref[] {
|
|
195
203
|
if (!style) return [];
|
|
196
204
|
const values: unknown[] = [
|
|
197
205
|
...Object.values(style),
|
|
198
206
|
style.boxShadow?.color,
|
|
199
|
-
style.
|
|
200
|
-
style.gradient?.
|
|
207
|
+
style.iconShadow?.color,
|
|
208
|
+
...(style.gradient?.stops ?? []).map((stop) => stop.color),
|
|
201
209
|
style.overlay?.color,
|
|
202
210
|
];
|
|
203
211
|
return values.map(asRef).filter((ref): ref is Ref => ref !== null);
|
|
@@ -260,8 +268,29 @@ function withSafeProps(node: LayoutNode, dropped: Dropped): LayoutNode {
|
|
|
260
268
|
changed = true;
|
|
261
269
|
}
|
|
262
270
|
}
|
|
263
|
-
|
|
264
|
-
|
|
271
|
+
// W-234: a library icon's SVG gets the same check; a refused one leaves the icon on its id.
|
|
272
|
+
if (type === "icon" && typeof props["iconSvg"] === "string") {
|
|
273
|
+
const report = sanitizeSvgReport(props["iconSvg"]);
|
|
274
|
+
if (!report.tree) {
|
|
275
|
+
dropped.unsafe++;
|
|
276
|
+
changed = true;
|
|
277
|
+
delete props["iconSvg"];
|
|
278
|
+
} else if (report.images > 0) {
|
|
279
|
+
props["iconSvg"] = serialize(report.tree);
|
|
280
|
+
dropped.images = (dropped.images ?? 0) + report.images;
|
|
281
|
+
changed = true;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (type === "svg" && typeof props["markup"] === "string") {
|
|
285
|
+
const report = sanitizeSvgReport(props["markup"]);
|
|
286
|
+
if (!report.tree) fallBack("markup", false);
|
|
287
|
+
else if (report.images > 0) {
|
|
288
|
+
// Store what will render, so the pasted copy no longer names the external picture.
|
|
289
|
+
props["markup"] = serialize(report.tree);
|
|
290
|
+
dropped.images = (dropped.images ?? 0) + report.images;
|
|
291
|
+
changed = true;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
265
294
|
return changed ? ({ ...node, props } as LayoutNode) : node;
|
|
266
295
|
}
|
|
267
296
|
|
|
@@ -331,8 +360,60 @@ export function prepareStyle(
|
|
|
331
360
|
return { style: styleOf(holder), dropped };
|
|
332
361
|
}
|
|
333
362
|
|
|
334
|
-
/**
|
|
335
|
-
|
|
363
|
+
/** The Icon's glyph keys (W-237): they style an Icon's `<svg>` and do nothing anywhere else. */
|
|
364
|
+
const ICON_STYLE_KEYS = [
|
|
365
|
+
"iconRotate",
|
|
366
|
+
"iconFlip",
|
|
367
|
+
"iconScale",
|
|
368
|
+
"iconStrokeWidth",
|
|
369
|
+
"iconShadow",
|
|
370
|
+
"iconAnimation",
|
|
371
|
+
] as const;
|
|
372
|
+
|
|
373
|
+
/** `style` without the Icon glyph keys; undefined when nothing else was set. */
|
|
374
|
+
function withoutIconKeys(style: object | undefined): object | undefined {
|
|
375
|
+
if (!style) return style;
|
|
376
|
+
const next: Record<string, unknown> = { ...style };
|
|
377
|
+
let removed = false;
|
|
378
|
+
for (const key of ICON_STYLE_KEYS) {
|
|
379
|
+
if (key in next) {
|
|
380
|
+
delete next[key];
|
|
381
|
+
removed = true;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (!removed) return style;
|
|
385
|
+
return Object.keys(next).length > 0 ? next : undefined;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** A copied style ready for `type`: Icon glyph keys stay only on an Icon (W-292). */
|
|
389
|
+
function styleFor(type: string, style: CopiedStyle): CopiedStyle {
|
|
390
|
+
if (type === "icon") return style;
|
|
391
|
+
const out: CopiedStyle = { ...style };
|
|
392
|
+
out.style = withoutIconKeys(style.style) as CopiedStyle["style"];
|
|
393
|
+
for (const [field, groups] of [
|
|
394
|
+
["states", style.states],
|
|
395
|
+
["devices", style.devices],
|
|
396
|
+
] as const) {
|
|
397
|
+
if (!groups) continue;
|
|
398
|
+
const kept: Record<string, unknown> = {};
|
|
399
|
+
for (const [name, value] of Object.entries(groups)) {
|
|
400
|
+
const cleaned = withoutIconKeys(value);
|
|
401
|
+
if (cleaned) kept[name] = cleaned;
|
|
402
|
+
}
|
|
403
|
+
(out as Record<string, unknown>)[field] = Object.keys(kept).length > 0 ? kept : undefined;
|
|
404
|
+
}
|
|
405
|
+
for (const key of ["style", "states", "devices"] as const) {
|
|
406
|
+
if (out[key] === undefined) delete out[key];
|
|
407
|
+
}
|
|
408
|
+
return out;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Replaces the node's local style, states and device overrides; props, classes and children stay.
|
|
413
|
+
* Icon glyph keys are left out on anything but an Icon (W-292).
|
|
414
|
+
*/
|
|
415
|
+
export function applyStyle<T extends LayoutNode>(node: T, copied: CopiedStyle): T {
|
|
416
|
+
const style = styleFor(node.type, copied);
|
|
336
417
|
const next = { ...node };
|
|
337
418
|
delete next.style;
|
|
338
419
|
delete next.states;
|
|
@@ -411,6 +492,7 @@ export function droppedNotice(dropped: Dropped): string | null {
|
|
|
411
492
|
"link, image or SVG that isn't allowed",
|
|
412
493
|
"links, images or SVGs that aren't allowed",
|
|
413
494
|
);
|
|
495
|
+
count(dropped.images ?? 0, "external image", "external images");
|
|
414
496
|
if (parts.length === 0) return null;
|
|
415
497
|
const list =
|
|
416
498
|
parts.length === 1 ? parts[0] : `${parts.slice(0, -1).join(", ")} and ${parts.at(-1)}`;
|
package/src/core/css/generate.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
stateDeclarations,
|
|
11
11
|
styleClassName,
|
|
12
12
|
styleDeclarations,
|
|
13
|
+
withInheritedLayers,
|
|
13
14
|
type Declaration,
|
|
14
15
|
type StateDeclarations,
|
|
15
16
|
} from "../sanitize/css.ts";
|
|
@@ -48,6 +49,18 @@ const STATE_PSEUDO: Readonly<Record<StyleStateName, string>> = {
|
|
|
48
49
|
active: ":active",
|
|
49
50
|
};
|
|
50
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Heading and Icon put their link inside the element (`innerLink`), so keyboard focus lands on
|
|
54
|
+
* that link, never on the element itself. Their Focus state also matches then (W-242).
|
|
55
|
+
*/
|
|
56
|
+
const INNER_LINK_FOCUS = ":has(> :is(.emvb-heading-link,.emvb-icon-link):focus-visible)";
|
|
57
|
+
|
|
58
|
+
/** One state's selector list: Focus adds the inner-link form (W-242). */
|
|
59
|
+
const stateSelector = (selector: string, state: StyleStateName) =>
|
|
60
|
+
state === "focus"
|
|
61
|
+
? `${selector}${STATE_PSEUDO.focus},${selector}${INNER_LINK_FOCUS}`
|
|
62
|
+
: `${selector}${STATE_PSEUDO[state]}`;
|
|
63
|
+
|
|
51
64
|
const block = (selector: string, declarations: Declaration[]) =>
|
|
52
65
|
declarations.length === 0
|
|
53
66
|
? ""
|
|
@@ -117,8 +130,8 @@ export function generateCss({
|
|
|
117
130
|
...STYLE_STATES.map((state) =>
|
|
118
131
|
block(
|
|
119
132
|
previewStates
|
|
120
|
-
? `${selector
|
|
121
|
-
:
|
|
133
|
+
? `${stateSelector(selector, state)},${selector}[data-emvb-state="${state}"]`
|
|
134
|
+
: stateSelector(selector, state),
|
|
122
135
|
states[state] ?? [],
|
|
123
136
|
),
|
|
124
137
|
),
|
|
@@ -148,8 +161,12 @@ export function generateCss({
|
|
|
148
161
|
? [
|
|
149
162
|
{
|
|
150
163
|
selector: `.${className}`,
|
|
151
|
-
|
|
152
|
-
|
|
164
|
+
// W-210: a device that sets one background layer keeps the layers it inherits.
|
|
165
|
+
tablet: styleDeclarations(withInheritedLayers(cls.devices?.tablet, cls.style ?? {}))
|
|
166
|
+
.declarations,
|
|
167
|
+
mobile: styleDeclarations(
|
|
168
|
+
withInheritedLayers(cls.devices?.mobile, { ...cls.style, ...cls.devices?.tablet }),
|
|
169
|
+
).declarations,
|
|
153
170
|
hiddenOn: cls.hiddenOn,
|
|
154
171
|
},
|
|
155
172
|
]
|
|
@@ -80,7 +80,72 @@ export function moveDesignClass(
|
|
|
80
80
|
return { ...design, classes: next };
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
const filled = (style: object | undefined) =>
|
|
84
|
+
!!style && Object.values(style).some((value) => value !== undefined);
|
|
85
|
+
|
|
86
|
+
/** Whether an element has local styles: base, hover/focus/active or tablet/mobile (W-134). */
|
|
87
|
+
export function hasLocalStyles(node: LayoutNode): boolean {
|
|
88
|
+
return (
|
|
89
|
+
filled(node.style) ||
|
|
90
|
+
Object.values(node.states ?? {}).some(filled) ||
|
|
91
|
+
Object.values(node.devices ?? {}).some(filled)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Why "Save local styles as class" can't run, or null when it can (W-134). */
|
|
96
|
+
/** Most classes a site may have; the design schema refuses more (W-218). */
|
|
97
|
+
export const MAX_CLASSES = 100;
|
|
98
|
+
|
|
99
|
+
/** A class name as saved: control characters gone, trimmed, at most 60 characters (W-218). */
|
|
100
|
+
export function cleanClassName(name: string): string {
|
|
101
|
+
const spaced = Array.from(name, (ch) => {
|
|
102
|
+
const code = ch.charCodeAt(0);
|
|
103
|
+
return code < 32 || code === 127 ? " " : ch;
|
|
104
|
+
}).join("");
|
|
105
|
+
return spaced.replace(/ {2,}/g, " ").trim().slice(0, 60).trim();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function localToClassRefusal(design: DesignSystem, node: LayoutNode): string | null {
|
|
109
|
+
if (!hasLocalStyles(node)) return "This element has no local styles to save.";
|
|
110
|
+
if ((design.classes ?? []).length >= MAX_CLASSES)
|
|
111
|
+
return "This site already has 100 classes, the most allowed.";
|
|
112
|
+
if ((node.classes ?? []).length >= 20) return "20 classes is the most one element can have.";
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Moves an element's local, state and tablet/mobile styles into a new class, applied last on the
|
|
118
|
+
* element and added last in Site styles, so it wins over the element's other classes as the local
|
|
119
|
+
* styles did (W-134). Visibility (`hiddenOn`) stays on the element. Null when it can't run. Pure.
|
|
120
|
+
*/
|
|
121
|
+
export function localStylesToClass(
|
|
122
|
+
design: DesignSystem,
|
|
123
|
+
node: LayoutNode,
|
|
124
|
+
name: string,
|
|
125
|
+
): { design: DesignSystem; node: LayoutNode; classId: string } | null {
|
|
126
|
+
const trimmed = name.trim().slice(0, 60);
|
|
127
|
+
if (!trimmed || localToClassRefusal(design, node)) return null;
|
|
128
|
+
const classes = design.classes ?? [];
|
|
129
|
+
const base = slugify(trimmed).slice(0, 34) || "class";
|
|
130
|
+
const taken = new Set(classes.map((c) => c.id));
|
|
131
|
+
let id = base;
|
|
132
|
+
for (let n = 2; taken.has(id); n++) id = `${base}-${n}`;
|
|
133
|
+
const cls = {
|
|
134
|
+
id,
|
|
135
|
+
name: trimmed,
|
|
136
|
+
style: structuredClone(node.style ?? {}) as StyleProps,
|
|
137
|
+
...(node.states ? { states: structuredClone(node.states) } : {}),
|
|
138
|
+
...(node.devices ? { devices: structuredClone(node.devices) } : {}),
|
|
139
|
+
};
|
|
140
|
+
const { style: _style, states: _states, devices: _devices, ...rest } = node;
|
|
141
|
+
return {
|
|
142
|
+
design: { ...design, classes: [...classes, cls] },
|
|
143
|
+
node: { ...rest, classes: addClassId(node.classes ?? [], id) } as LayoutNode,
|
|
144
|
+
classId: id,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Duplicate a design class with a new id/name, deep-copying all its styles. Pure (W-071, W-135). */
|
|
84
149
|
export function duplicateClass(
|
|
85
150
|
design: DesignSystem,
|
|
86
151
|
classId: string,
|
|
@@ -88,24 +153,45 @@ export function duplicateClass(
|
|
|
88
153
|
): DesignSystem {
|
|
89
154
|
const classes = design.classes ?? [];
|
|
90
155
|
const source = classes.find((c) => c.id === classId);
|
|
91
|
-
|
|
92
|
-
|
|
156
|
+
// At the cap the copy would make the design invalid and the save fail (W-218).
|
|
157
|
+
if (!source || classes.length >= MAX_CLASSES) return design;
|
|
158
|
+
// W-277: "Card copy", then "Card copy 2"…, so the copy's name is free too.
|
|
159
|
+
const stem = `${source.name.slice(0, 52).trim()} copy`;
|
|
160
|
+
let baseName = stem;
|
|
161
|
+
for (let n = 2; n <= MAX_CLASSES && classNameTaken(design, baseName); n++) {
|
|
162
|
+
baseName = `${stem} ${n}`;
|
|
163
|
+
}
|
|
93
164
|
const base = slugify(baseName).slice(0, 34) || "class";
|
|
94
165
|
const taken = new Set(classes.map((c) => c.id));
|
|
95
166
|
let id = randomSuffix ? `${base}-${randomSuffix}`.slice(0, 40) : base;
|
|
96
167
|
for (let n = 2; taken.has(id); n++) id = `${base}-${n}`.slice(0, 40);
|
|
97
|
-
|
|
98
|
-
const copy = source
|
|
99
|
-
? { id, name: baseName, style, states: structuredClone(source.states) }
|
|
100
|
-
: { id, name: baseName, style };
|
|
168
|
+
// Every part of the class, tablet and mobile styles and Hide on included (W-135).
|
|
169
|
+
const copy = { ...structuredClone(source), id, name: baseName };
|
|
101
170
|
return { ...design, classes: [...classes, copy] };
|
|
102
171
|
}
|
|
103
172
|
|
|
104
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* W-277: whether another class already has this name (case-insensitive). Two classes with one
|
|
175
|
+
* name can't be told apart in the class picker or the Site styles list.
|
|
176
|
+
*/
|
|
177
|
+
export function classNameTaken(design: DesignSystem, name: string, exceptId?: string): boolean {
|
|
178
|
+
const wanted = cleanClassName(name).toLowerCase();
|
|
179
|
+
return (design.classes ?? []).some((c) => c.id !== exceptId && c.name.toLowerCase() === wanted);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** The message shown when a new or renamed class would take another class's name (W-277). */
|
|
183
|
+
export const classNameTakenMessage = (name: string) =>
|
|
184
|
+
`A class named "${cleanClassName(name)}" already exists. Pick another name.`;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Rename a design class; the id (and so its `.emvb-k-<id>` selector) stays. A name another class
|
|
188
|
+
* has is refused (W-277). Pure (W-087).
|
|
189
|
+
*/
|
|
105
190
|
export function renameClass(design: DesignSystem, classId: string, name: string): DesignSystem {
|
|
106
|
-
const trimmed = name
|
|
191
|
+
const trimmed = cleanClassName(name);
|
|
107
192
|
const classes = design.classes ?? [];
|
|
108
193
|
if (!trimmed || !classes.some((c) => c.id === classId)) return design;
|
|
194
|
+
if (classNameTaken(design, trimmed, classId)) return design;
|
|
109
195
|
return {
|
|
110
196
|
...design,
|
|
111
197
|
classes: classes.map((c) => (c.id === classId ? Object.assign({}, c, { name: trimmed }) : c)),
|
|
@@ -1,13 +1,67 @@
|
|
|
1
1
|
import { DesignSystem as DesignSystemSchema, DESIGN_SCHEMA_VERSION } from "../schema/design.ts";
|
|
2
2
|
import type { DesignSystem } from "../schema/design.ts";
|
|
3
3
|
import { DESIGN_MIGRATIONS, upgradeLayout } from "../migrate/index.ts";
|
|
4
|
+
import type { Layout } from "../schema/layout.ts";
|
|
5
|
+
import { findClassUsages } from "./classes.ts";
|
|
6
|
+
import { findVariableUsages } from "./variables.ts";
|
|
4
7
|
|
|
5
8
|
/** The design document as JSON. This file is the backup: there is no revision history. */
|
|
6
9
|
export function designToJson(design: DesignSystem): string {
|
|
7
10
|
return JSON.stringify(design, null, 2);
|
|
8
11
|
}
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
/** A name Import changed so names stay unique (W-283). */
|
|
14
|
+
export type ImportRename = { from: string; to: string };
|
|
15
|
+
|
|
16
|
+
export type DesignImport =
|
|
17
|
+
| { ok: true; design: DesignSystem; renamed: ImportRename[] }
|
|
18
|
+
| { ok: false; message: string };
|
|
19
|
+
|
|
20
|
+
/** Names are capped at 60 characters; "Card 2" keeps the number inside the cap. */
|
|
21
|
+
function freeName(name: string, taken: Set<string>): string {
|
|
22
|
+
for (let n = 2; ; n++) {
|
|
23
|
+
const suffix = ` ${n}`;
|
|
24
|
+
const next = `${name.slice(0, 60 - suffix.length).trim()}${suffix}`;
|
|
25
|
+
if (!taken.has(next.toLowerCase())) return next;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function dedupe<T extends { name: string }>(items: T[], renamed: ImportRename[]): T[] {
|
|
30
|
+
const taken = new Set(items.map((item) => item.name.toLowerCase()));
|
|
31
|
+
const seen = new Set<string>();
|
|
32
|
+
return items.map((item) => {
|
|
33
|
+
const key = item.name.toLowerCase();
|
|
34
|
+
if (!seen.has(key)) {
|
|
35
|
+
seen.add(key);
|
|
36
|
+
return item;
|
|
37
|
+
}
|
|
38
|
+
const to = freeName(item.name, taken);
|
|
39
|
+
taken.add(to.toLowerCase());
|
|
40
|
+
seen.add(to.toLowerCase());
|
|
41
|
+
renamed.push({ from: item.name, to });
|
|
42
|
+
return { ...item, name: to };
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* W-283: the editor keeps class names, and variable names within a kind, unique (W-277, W-278).
|
|
48
|
+
* A hand-edited file can still repeat one, so Import renames the later ones ("Card 2") and the
|
|
49
|
+
* confirm lists them. Ids, and so every reference, stay as they are.
|
|
50
|
+
*/
|
|
51
|
+
export function uniqueImportNames(design: DesignSystem): {
|
|
52
|
+
design: DesignSystem;
|
|
53
|
+
renamed: ImportRename[];
|
|
54
|
+
} {
|
|
55
|
+
const renamed: ImportRename[] = [];
|
|
56
|
+
const classes = design.classes ? dedupe(design.classes, renamed) : design.classes;
|
|
57
|
+
const variables = { ...design.variables };
|
|
58
|
+
for (const [group] of VARIABLE_GROUPS) {
|
|
59
|
+
const list = design.variables[group];
|
|
60
|
+
if (list) Object.assign(variables, { [group]: dedupe<{ name: string }>(list, renamed) });
|
|
61
|
+
}
|
|
62
|
+
if (renamed.length === 0) return { design, renamed };
|
|
63
|
+
return { design: { ...design, variables, ...(classes ? { classes } : {}) }, renamed };
|
|
64
|
+
}
|
|
11
65
|
|
|
12
66
|
/** Parse an exported design. Older schema versions are upgraded. A newer file is refused. */
|
|
13
67
|
export function designFromJson(text: string): DesignImport {
|
|
@@ -29,5 +83,50 @@ export function designFromJson(text: string): DesignImport {
|
|
|
29
83
|
}
|
|
30
84
|
const result = DesignSystemSchema.safeParse(upgraded.doc);
|
|
31
85
|
if (!result.success) return { ok: false, message: "That file is not an EmVB design document." };
|
|
32
|
-
return { ok: true,
|
|
86
|
+
return { ok: true, ...uniqueImportNames(result.data) };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The largest design file Import reads (W-214); the saved design is capped far lower. */
|
|
90
|
+
export const MAX_DESIGN_FILE_BYTES = 1024 * 1024;
|
|
91
|
+
|
|
92
|
+
export type ImportLosses = {
|
|
93
|
+
/** Classes and variables in the current design that the file doesn't have. */
|
|
94
|
+
classes: number;
|
|
95
|
+
variables: number;
|
|
96
|
+
/** Of those, how many this page uses (its elements would lose that styling). */
|
|
97
|
+
usedOnPage: number;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const VARIABLE_GROUPS = [
|
|
101
|
+
["colors", "color"],
|
|
102
|
+
["fonts", "font"],
|
|
103
|
+
["fontSizes", "fontSize"],
|
|
104
|
+
["spacings", "spacing"],
|
|
105
|
+
] as const;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* W-214: what Import would drop. It replaces the whole design and there is no revision history,
|
|
109
|
+
* so the editor confirms first and names the cost.
|
|
110
|
+
*/
|
|
111
|
+
export function importLosses(
|
|
112
|
+
current: DesignSystem,
|
|
113
|
+
incoming: DesignSystem,
|
|
114
|
+
layout: Layout | null,
|
|
115
|
+
): ImportLosses {
|
|
116
|
+
const keptClasses = new Set((incoming.classes ?? []).map((c) => c.id));
|
|
117
|
+
const lostClasses = (current.classes ?? []).filter((c) => !keptClasses.has(c.id));
|
|
118
|
+
let variables = 0;
|
|
119
|
+
let usedOnPage = 0;
|
|
120
|
+
for (const [group, kind] of VARIABLE_GROUPS) {
|
|
121
|
+
const kept = new Set((incoming.variables[group] ?? []).map((v) => v.id));
|
|
122
|
+
for (const variable of current.variables[group] ?? []) {
|
|
123
|
+
if (kept.has(variable.id)) continue;
|
|
124
|
+
variables += 1;
|
|
125
|
+
if (layout && findVariableUsages(layout, variable.id, kind).length > 0) usedOnPage += 1;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (layout) {
|
|
129
|
+
usedOnPage += lostClasses.filter((c) => findClassUsages(layout, c.id).length > 0).length;
|
|
130
|
+
}
|
|
131
|
+
return { classes: lostClasses.length, variables, usedOnPage };
|
|
33
132
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DesignSystem } from "../schema/design.ts";
|
|
2
2
|
import type { Layout, LayoutNode } from "../schema/layout.ts";
|
|
3
|
+
import { cleanClassName } from "./classes.ts";
|
|
3
4
|
import { STYLE_STATES } from "../schema/state-names.ts";
|
|
4
5
|
import type { DeviceStyles, StyleProps, StyleStates } from "../schema/style.ts";
|
|
5
6
|
import { nodeChildren, slugify, updateNode } from "../tree-ops.ts";
|
|
@@ -46,8 +47,10 @@ function collectStyleUsages(
|
|
|
46
47
|
if (matches(value, id, kind)) hit(prop);
|
|
47
48
|
}
|
|
48
49
|
if (shadowColorMatches(style, id, kind)) hit("boxShadow.color");
|
|
49
|
-
if (matches(style.
|
|
50
|
-
|
|
50
|
+
if (matches(style.iconShadow?.color, id, kind)) hit("iconShadow.color");
|
|
51
|
+
style.gradient?.stops.forEach((stop, index) => {
|
|
52
|
+
if (matches(stop.color, id, kind)) hit(`gradient.stops.${index}`);
|
|
53
|
+
});
|
|
51
54
|
if (matches(style.overlay?.color, id, kind)) hit("overlay.color");
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -125,10 +128,13 @@ function stripRefsFromStyle(
|
|
|
125
128
|
next["boxShadow"] = shadow;
|
|
126
129
|
changed = true;
|
|
127
130
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
// W-245: the icon drop shadow (W-237) keeps its offsets and blur, like the box shadow.
|
|
132
|
+
if (style.iconShadow && matches(style.iconShadow.color, id, kind)) {
|
|
133
|
+
const { color: _drop, ...shadow } = style.iconShadow;
|
|
134
|
+
next["iconShadow"] = shadow;
|
|
135
|
+
changed = true;
|
|
136
|
+
}
|
|
137
|
+
if (style.gradient?.stops.some((stop) => matches(stop.color, id, kind))) {
|
|
132
138
|
delete next["gradient"];
|
|
133
139
|
changed = true;
|
|
134
140
|
}
|
|
@@ -215,6 +221,14 @@ const KIND_TO_LIST = {
|
|
|
215
221
|
spacing: "spacings",
|
|
216
222
|
} as const;
|
|
217
223
|
|
|
224
|
+
/** Most variables of each kind a site may have; the design schema refuses more (W-219). */
|
|
225
|
+
export const MAX_VARIABLES = { color: 200, font: 50, fontSize: 50, spacing: 100 } as const;
|
|
226
|
+
|
|
227
|
+
/** True when a site already has the most variables of `kind` allowed (W-219). */
|
|
228
|
+
export function variableListFull(design: DesignSystem, kind: VariableKind): boolean {
|
|
229
|
+
return (design.variables[KIND_TO_LIST[kind]] ?? []).length >= MAX_VARIABLES[kind];
|
|
230
|
+
}
|
|
231
|
+
|
|
218
232
|
/** Drop every binding to the variable on class styles; a class left with none keeps `{}`. */
|
|
219
233
|
function clearClassStyleRefs(
|
|
220
234
|
classes: DesignSystem["classes"],
|
|
@@ -258,8 +272,14 @@ export function duplicateVariable(
|
|
|
258
272
|
const key = KIND_TO_LIST[kind];
|
|
259
273
|
const list = design.variables[key] ?? [];
|
|
260
274
|
const source = list.find((entry) => entry.id === id);
|
|
261
|
-
|
|
262
|
-
|
|
275
|
+
// A copy past the cap, or a name past 60 characters, would fail to save (W-219).
|
|
276
|
+
if (!source || variableListFull(design, kind)) return design;
|
|
277
|
+
// W-278: "Brand copy", then "Brand copy 2"…, so the copy's name is free too.
|
|
278
|
+
const stem = `${source.name.slice(0, 52).trim()} copy`;
|
|
279
|
+
let name = stem;
|
|
280
|
+
for (let n = 2; n <= MAX_VARIABLES[kind] && variableNameTaken(design, kind, name); n++) {
|
|
281
|
+
name = `${stem} ${n}`;
|
|
282
|
+
}
|
|
263
283
|
const base = slugify(name).slice(0, 34) || kind;
|
|
264
284
|
const taken = new Set(list.map((entry) => entry.id));
|
|
265
285
|
let nextId = base;
|
|
@@ -275,15 +295,35 @@ export function duplicateVariable(
|
|
|
275
295
|
};
|
|
276
296
|
}
|
|
277
297
|
|
|
278
|
-
/**
|
|
298
|
+
/**
|
|
299
|
+
* W-278: whether another variable of this kind already has the name (case-insensitive). Pickers
|
|
300
|
+
* list variables by name, so two with one name can't be told apart.
|
|
301
|
+
*/
|
|
302
|
+
export function variableNameTaken(
|
|
303
|
+
design: DesignSystem,
|
|
304
|
+
kind: VariableKind,
|
|
305
|
+
name: string,
|
|
306
|
+
exceptId?: string,
|
|
307
|
+
): boolean {
|
|
308
|
+
const wanted = cleanClassName(name).toLowerCase();
|
|
309
|
+
return (design.variables[KIND_TO_LIST[kind]] ?? []).some(
|
|
310
|
+
(v) => v.id !== exceptId && v.name.toLowerCase() === wanted,
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** The message shown when a new or renamed variable would take another's name (W-278). */
|
|
315
|
+
export const variableNameTakenMessage = (name: string) =>
|
|
316
|
+
`A variable named "${cleanClassName(name)}" already exists. Pick another name.`;
|
|
317
|
+
|
|
318
|
+
/** Rename is name-only; variable ids stay stable (slug at create time). A taken name is refused (W-278). */
|
|
279
319
|
export function renameVariable(
|
|
280
320
|
design: DesignSystem,
|
|
281
321
|
id: string,
|
|
282
322
|
kind: VariableKind,
|
|
283
323
|
name: string,
|
|
284
324
|
): DesignSystem {
|
|
285
|
-
const trimmed = name
|
|
286
|
-
if (!trimmed) return design;
|
|
325
|
+
const trimmed = cleanClassName(name);
|
|
326
|
+
if (!trimmed || variableNameTaken(design, kind, trimmed, id)) return design;
|
|
287
327
|
const key = KIND_TO_LIST[kind];
|
|
288
328
|
const list = design.variables[key] ?? [];
|
|
289
329
|
let changed = false;
|
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
PostImageNode,
|
|
9
9
|
PostLinkNode,
|
|
10
10
|
PostTitleNode,
|
|
11
|
+
PaginationNode,
|
|
11
12
|
} from "../schema/layout.ts";
|
|
12
13
|
import type { ElementDefinition } from "./definition.ts";
|
|
13
14
|
|
|
@@ -41,7 +42,15 @@ export const postExcerpt: ElementDefinition<PostExcerptNode> = {
|
|
|
41
42
|
name: "Post Excerpt",
|
|
42
43
|
group: "dynamic",
|
|
43
44
|
defaultTab: "style",
|
|
44
|
-
fields: [
|
|
45
|
+
fields: [
|
|
46
|
+
{
|
|
47
|
+
key: "maxWords",
|
|
48
|
+
kind: "int",
|
|
49
|
+
label: "Excerpt length (words)",
|
|
50
|
+
optional: true,
|
|
51
|
+
message: "Enter a whole number of words, or leave it blank for the whole excerpt.",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
45
54
|
},
|
|
46
55
|
build: (_node, attrs) => ({ tag: "p", attrs, children: ["Post excerpt…"] }),
|
|
47
56
|
};
|
|
@@ -88,7 +97,21 @@ export const postDate: ElementDefinition<PostDateNode> = {
|
|
|
88
97
|
name: "Post Date",
|
|
89
98
|
group: "dynamic",
|
|
90
99
|
defaultTab: "style",
|
|
91
|
-
fields: [
|
|
100
|
+
fields: [
|
|
101
|
+
{
|
|
102
|
+
key: "format",
|
|
103
|
+
kind: "select",
|
|
104
|
+
label: "Date format",
|
|
105
|
+
optional: true,
|
|
106
|
+
options: [
|
|
107
|
+
{ value: "medium", label: "Medium (Oct 6, 2026)" },
|
|
108
|
+
{ value: "short", label: "Short (10/6/26)" },
|
|
109
|
+
{ value: "long", label: "Long (October 6, 2026)" },
|
|
110
|
+
{ value: "full", label: "Full (Tuesday, October 6, 2026)" },
|
|
111
|
+
{ value: "numeric", label: "Numeric (2026-10-06)" },
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
92
115
|
},
|
|
93
116
|
build: (_node, attrs) => ({ tag: "time", attrs, children: ["Post date"] }),
|
|
94
117
|
};
|
|
@@ -129,7 +152,8 @@ export const postLink: ElementDefinition<PostLinkNode> = {
|
|
|
129
152
|
};
|
|
130
153
|
|
|
131
154
|
export const loop: ElementDefinition<LoopNode> = {
|
|
132
|
-
baseCss:
|
|
155
|
+
baseCss:
|
|
156
|
+
".emvb-loop{display:flex;flex-direction:column;min-width:0;gap:1rem}.emvb-loop[data-emvb-loop-empty]{min-height:48px;padding:12px;color:var(--text-color-kumo-subtle,#666);background:var(--color-kumo-tint,#eee)}",
|
|
133
157
|
defaults: () => ({ type: "loop", props: {}, children: [] }),
|
|
134
158
|
descriptor: {
|
|
135
159
|
type: "loop",
|
|
@@ -145,24 +169,52 @@ export const loop: ElementDefinition<LoopNode> = {
|
|
|
145
169
|
message:
|
|
146
170
|
"Optional published Loop Item theme part. Leave blank to use nested elements as the item template.",
|
|
147
171
|
},
|
|
172
|
+
{
|
|
173
|
+
key: "perPage",
|
|
174
|
+
kind: "int",
|
|
175
|
+
max: 50,
|
|
176
|
+
label: "Posts per page",
|
|
177
|
+
optional: true,
|
|
178
|
+
message:
|
|
179
|
+
"1 to 50 posts on each archive page. Leave it empty for 20. Add a Pagination element to link the pages.",
|
|
180
|
+
},
|
|
148
181
|
],
|
|
149
182
|
},
|
|
150
183
|
build: (_node, attrs, children) => ({ tag: "div", attrs, children }),
|
|
151
184
|
};
|
|
152
185
|
|
|
186
|
+
export const pagination: ElementDefinition<PaginationNode> = {
|
|
187
|
+
baseCss:
|
|
188
|
+
".emvb-pagination{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem}.emvb-pagination a{color:inherit}.emvb-pagination a[aria-current=page]{font-weight:700;text-decoration:none}",
|
|
189
|
+
defaults: () => ({ type: "pagination", props: {} }),
|
|
190
|
+
descriptor: {
|
|
191
|
+
type: "pagination",
|
|
192
|
+
name: "Pagination",
|
|
193
|
+
group: "dynamic",
|
|
194
|
+
defaultTab: "content",
|
|
195
|
+
fields: [
|
|
196
|
+
{ key: "prevText", kind: "text", label: "Previous text", optional: true },
|
|
197
|
+
{ key: "nextText", kind: "text", label: "Next text", optional: true },
|
|
198
|
+
],
|
|
199
|
+
},
|
|
200
|
+
// Rendered by core/render/pagination.ts from the archive's page data (W-222).
|
|
201
|
+
build: (_node, attrs) => ({ tag: "nav", attrs, children: [] }),
|
|
202
|
+
};
|
|
203
|
+
|
|
153
204
|
export const section: ElementDefinition<SectionNode> = {
|
|
154
205
|
baseCss: ".emvb-section{display:flex;flex-direction:column;min-width:0}",
|
|
155
206
|
defaults: () => ({ type: "section", props: {}, children: [] }),
|
|
156
207
|
descriptor: {
|
|
157
208
|
type: "section",
|
|
158
|
-
|
|
209
|
+
// "Theme section": it embeds a Section theme part; the layout Section is its own element (W-155).
|
|
210
|
+
name: "Theme section",
|
|
159
211
|
group: "layout",
|
|
160
212
|
defaultTab: "content",
|
|
161
213
|
fields: [
|
|
162
214
|
{
|
|
163
215
|
key: "partId",
|
|
164
216
|
kind: "text",
|
|
165
|
-
label: "Section",
|
|
217
|
+
label: "Section part",
|
|
166
218
|
optional: true,
|
|
167
219
|
message:
|
|
168
220
|
"Optional published Section theme part. When set, the part's contents replace the nested elements on every page that uses it.",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The control's HTML id, from the element's own id (W-187). A field name is not unique on a page
|
|
3
|
+
* (the same form twice, or a header and footer newsletter both asking for `email`) and can match a
|
|
4
|
+
* host theme id, so a label's `for` would focus another form's input.
|
|
5
|
+
*/
|
|
6
|
+
export const controlId = (nodeId: string): string => `emvb-field-${nodeId}`;
|