@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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { sanitizeMediaUrl, type Layout } from "../core/index.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The part of Astro's `getImage` (astro:assets) this uses. The host passes its own, so EmVB stays
|
|
5
|
+
* free of the virtual module and the host's image service (sharp, Cloudflare Images) does the work.
|
|
6
|
+
*/
|
|
7
|
+
export type ResponsiveGetImage = (options: {
|
|
8
|
+
src: string;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
widths: number[];
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
src: string;
|
|
14
|
+
srcSet?: { values?: { url: string; descriptor?: string }[]; attribute?: string };
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
/** EmDash's library file path; only these pictures are the site's own to resize. */
|
|
18
|
+
const LIBRARY_PATH = "/_emdash/api/media/file/";
|
|
19
|
+
/** The layout allows six extra sizes per Image (W-344). */
|
|
20
|
+
const MAX_SOURCES = 6;
|
|
21
|
+
const BREAKPOINTS = [640, 960, 1280, 1600, 1920, 2560];
|
|
22
|
+
|
|
23
|
+
type Source = { src: string; width: number };
|
|
24
|
+
type Node = { type: string; props: Record<string, unknown>; children?: Node[] };
|
|
25
|
+
|
|
26
|
+
/** Widths up to 2x the shown width (for high-density screens), at most six. */
|
|
27
|
+
export function sourceWidths(width: number): number[] {
|
|
28
|
+
const cap = Math.min(width * 2, 8000);
|
|
29
|
+
const widths = BREAKPOINTS.filter((w) => w < cap && w !== width).slice(0, MAX_SOURCES - 1);
|
|
30
|
+
return [...widths, cap];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function candidates(result: Awaited<ReturnType<ResponsiveGetImage>>): Source[] {
|
|
34
|
+
const values =
|
|
35
|
+
result.srcSet?.values ??
|
|
36
|
+
(result.srcSet?.attribute ?? "").split(", ").map((part) => {
|
|
37
|
+
const [url = "", descriptor] = part.trim().split(/\s+/);
|
|
38
|
+
return { url, descriptor };
|
|
39
|
+
});
|
|
40
|
+
const sources: Source[] = [];
|
|
41
|
+
for (const { url, descriptor } of values) {
|
|
42
|
+
const width = Number(/^(\d+)w$/.exec(descriptor ?? "")?.[1]);
|
|
43
|
+
const safe = sanitizeMediaUrl(url);
|
|
44
|
+
// A space or comma would split into another srcset candidate (W-428).
|
|
45
|
+
if (!safe || safe.length > 2000 || /[\s,]/.test(safe)) continue;
|
|
46
|
+
if (!Number.isInteger(width) || width < 1 || width > 8000) continue;
|
|
47
|
+
if (sources.some((s) => s.width === width)) continue;
|
|
48
|
+
sources.push({ src: safe, width });
|
|
49
|
+
}
|
|
50
|
+
return sources.slice(0, MAX_SOURCES);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function fill(node: Node, getImage: ResponsiveGetImage, origin: string): Promise<void> {
|
|
54
|
+
if (node.type === "image") {
|
|
55
|
+
const { src, width, height, sources } = node.props;
|
|
56
|
+
const own = Array.isArray(sources) && sources.length > 0;
|
|
57
|
+
if (
|
|
58
|
+
!own &&
|
|
59
|
+
typeof src === "string" &&
|
|
60
|
+
src.startsWith(LIBRARY_PATH) &&
|
|
61
|
+
typeof width === "number" &&
|
|
62
|
+
typeof height === "number"
|
|
63
|
+
) {
|
|
64
|
+
try {
|
|
65
|
+
// Astro's services only resize absolute URLs; the host authorises its origin.
|
|
66
|
+
const absolute = new URL(src, origin).href;
|
|
67
|
+
const result = await getImage({
|
|
68
|
+
src: absolute,
|
|
69
|
+
width,
|
|
70
|
+
height,
|
|
71
|
+
widths: sourceWidths(width),
|
|
72
|
+
});
|
|
73
|
+
// Passed through unchanged: the origin isn't authorised, so a srcset would be a no-op.
|
|
74
|
+
if (result.src && result.src !== absolute) {
|
|
75
|
+
const found = candidates(result);
|
|
76
|
+
if (found.length > 0) node.props = { ...node.props, sources: found };
|
|
77
|
+
}
|
|
78
|
+
} catch {
|
|
79
|
+
// No image service, or it refused this file: the plain <img> stays.
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
await Promise.all((node.children ?? []).map((child) => fill(child, getImage, origin)));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* W-915: a copy of the layout whose library Images (with a size and no sizes of their own) get
|
|
88
|
+
* `sources` from the host's image service, so the public <img> has a srcset. Opt-in: only when
|
|
89
|
+
* the host passes `getImage`.
|
|
90
|
+
*/
|
|
91
|
+
export async function withResponsiveSources(
|
|
92
|
+
layout: Layout,
|
|
93
|
+
getImage: ResponsiveGetImage,
|
|
94
|
+
origin: string,
|
|
95
|
+
): Promise<Layout> {
|
|
96
|
+
const copy = structuredClone(layout);
|
|
97
|
+
await fill(copy.root as unknown as Node, getImage, origin);
|
|
98
|
+
return copy;
|
|
99
|
+
}
|
package/src/constants.ts
CHANGED
package/src/core/a11y/audit.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { clipText } from "../limits.ts";
|
|
|
2
2
|
import type { DesignSystem } from "../schema/design.ts";
|
|
3
3
|
import { isParentNode, type Layout, type LayoutNode } from "../schema/layout.ts";
|
|
4
4
|
import { boxBecomesLink } from "../render/extras.ts";
|
|
5
|
+
import { ICON_ANIMATION_LIMIT_MS, iconAnimationRuns } from "../icons/animation-runs.ts";
|
|
5
6
|
import { updateNode } from "../tree-ops.ts";
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -169,6 +170,22 @@ function effectiveStyle(
|
|
|
169
170
|
return { ...fromClasses, ...(node.style as Record<string, unknown> | undefined) };
|
|
170
171
|
}
|
|
171
172
|
|
|
173
|
+
/** Each device's style with the node's classes under the node's own (W-882). */
|
|
174
|
+
function deviceStyles(node: LayoutNode, design: DesignSystem): Record<string, unknown>[] {
|
|
175
|
+
const ids = new Set(node.classes ?? []);
|
|
176
|
+
const merged: Record<string, Record<string, unknown>> = {};
|
|
177
|
+
const layers = [
|
|
178
|
+
...(design.classes ?? []).filter((c) => ids.has(c.id)).map((c) => c.devices),
|
|
179
|
+
node.devices,
|
|
180
|
+
];
|
|
181
|
+
for (const devices of layers) {
|
|
182
|
+
for (const [key, st] of Object.entries(devices ?? {})) {
|
|
183
|
+
merged[key] = { ...merged[key], ...(st as Record<string, unknown>) };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return Object.values(merged);
|
|
187
|
+
}
|
|
188
|
+
|
|
172
189
|
/** Large text (24 px, or 18.66 px bold) needs 3:1; other text 4.5:1. H4 to H6 are not large (W-639). */
|
|
173
190
|
function largeText(node: LayoutNode, design: DesignSystem): boolean {
|
|
174
191
|
const style = effectiveStyle(node, design) as
|
|
@@ -308,19 +325,27 @@ export function auditPage(layout: Layout, design: DesignSystem): A11yReport {
|
|
|
308
325
|
fixLabel: "Mark as decorative",
|
|
309
326
|
});
|
|
310
327
|
}
|
|
311
|
-
// W-791:
|
|
312
|
-
//
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
328
|
+
// W-791: motion visitors can't pause breaks WCAG 2.2.2 past 5 seconds, unless it is essential.
|
|
329
|
+
// W-848: a spin or pulse now stops by itself after about 5 s, so only one whose single run
|
|
330
|
+
// (a pulse's there and back) is longer than that is still flagged.
|
|
331
|
+
// W-882: an animation from a class counts too, and the element's own style wins over it.
|
|
332
|
+
const tooLong = [effectiveStyle(node, design), ...deviceStyles(node, design)].some((st) => {
|
|
333
|
+
const anim = (
|
|
334
|
+
st as { iconAnimation?: { type?: unknown; duration?: unknown; loop?: unknown } } | undefined
|
|
335
|
+
)?.iconAnimation;
|
|
336
|
+
if (anim?.type !== "spin" && anim?.type !== "pulse") return false;
|
|
337
|
+
// W-853: Loop forever is motion without end, so it is flagged like before W-848.
|
|
338
|
+
if (anim.loop === true) return true;
|
|
339
|
+
const ms = typeof anim.duration === "number" ? anim.duration : 0;
|
|
340
|
+
return iconAnimationRuns(anim.type, ms) * ms > ICON_ANIMATION_LIMIT_MS;
|
|
316
341
|
});
|
|
317
|
-
if (
|
|
342
|
+
if (tooLong) {
|
|
318
343
|
add({
|
|
319
344
|
nodeId: node.id,
|
|
320
345
|
rule: "motion",
|
|
321
346
|
severity: "warning",
|
|
322
347
|
message:
|
|
323
|
-
"This icon animates
|
|
348
|
+
"This icon animates for more than 5 seconds and visitors can't pause it. Shorten the duration, or keep it only if the motion is essential.",
|
|
324
349
|
});
|
|
325
350
|
}
|
|
326
351
|
// W-403: with extra sizes but no Width, the main image is left out of srcset, so wide screens
|
package/src/core/arrange.ts
CHANGED
|
@@ -319,16 +319,31 @@ export function wrapNode(
|
|
|
319
319
|
type: WrapType,
|
|
320
320
|
random: () => number = Math.random,
|
|
321
321
|
): Arranged {
|
|
322
|
+
return wrapWith(layout, id, {
|
|
323
|
+
id: newNodeId(random),
|
|
324
|
+
type,
|
|
325
|
+
props: type === "grid" ? { columns: 2 } : {},
|
|
326
|
+
} as LayoutNode);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* W-876: puts `id` inside a Theme section that embeds the Section theme part `partId`. The element
|
|
331
|
+
* stays as the Theme section's own content, so the page looks the same until the part is published.
|
|
332
|
+
*/
|
|
333
|
+
export const wrapInThemeSection = (
|
|
334
|
+
layout: Layout,
|
|
335
|
+
id: string,
|
|
336
|
+
partId: string,
|
|
337
|
+
random: () => number = Math.random,
|
|
338
|
+
): Arranged =>
|
|
339
|
+
wrapWith(layout, id, { id: newNodeId(random), type: "section", props: { partId } } as LayoutNode);
|
|
340
|
+
|
|
341
|
+
function wrapWith(layout: Layout, id: string, shell: LayoutNode): Arranged {
|
|
322
342
|
const found = locate(layout, id);
|
|
323
343
|
if (!found) return refuse(REASONS.missing);
|
|
324
344
|
if (!found.parent) return refuse(REASONS.rootFixed);
|
|
325
345
|
if (size(layout.root) + 1 > MAX_NODES) return refuse(REASONS.tooMany);
|
|
326
|
-
const wrapper:
|
|
327
|
-
id: newNodeId(random),
|
|
328
|
-
type,
|
|
329
|
-
props: type === "grid" ? { columns: 2 } : {},
|
|
330
|
-
children: [found.node],
|
|
331
|
-
} as LayoutNode;
|
|
346
|
+
const wrapper = { ...shell, children: [found.node] } as LayoutNode;
|
|
332
347
|
// W-389: the same parent/child rules as a drop, so an accordion item, tab panel or menu item
|
|
333
348
|
// isn't wrapped into a page that can't save, and the extra level stays within the depth cap.
|
|
334
349
|
const inForm = underForm(layout, found.parent.id);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W-897 (W-P02): host collections whose entries carry an `emvb:canvas` field. Only EmDash-style
|
|
3
|
+
* slugs are kept; EmVB's own collections are left out because their hooks already cover them.
|
|
4
|
+
*/
|
|
5
|
+
export const MAX_CANVAS_COLLECTIONS = 20;
|
|
6
|
+
const OWN = new Set(["emvb_pages", "emvb_theme_parts"]);
|
|
7
|
+
const SLUG = /^[a-z][a-z0-9_]{0,62}$/;
|
|
8
|
+
|
|
9
|
+
export function canvasCollectionSlugs(input: unknown): string[] {
|
|
10
|
+
if (!Array.isArray(input)) return [];
|
|
11
|
+
const out: string[] = [];
|
|
12
|
+
for (const item of input) {
|
|
13
|
+
if (typeof item !== "string") continue;
|
|
14
|
+
const slug = item.trim();
|
|
15
|
+
if (!SLUG.test(slug) || OWN.has(slug) || out.includes(slug)) continue;
|
|
16
|
+
out.push(slug);
|
|
17
|
+
if (out.length === MAX_CANVAS_COLLECTIONS) break;
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
package/src/core/css/print.ts
CHANGED
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
* Print stylesheet (W-335). Chrome that only makes sense on screen is hidden.
|
|
3
3
|
* Appended after scoped page CSS so the selectors stay global: a header, float or popup
|
|
4
4
|
* is not inside the page's scope wrapper.
|
|
5
|
+
* W-845 (D-054): every tab panel and accordion panel prints, not just the open one. The tab rule
|
|
6
|
+
* matches the specificity of the screen rule that hides the other panels and comes later. A
|
|
7
|
+
* closed <details> opens through ::details-content, so a browser without it prints the summary.
|
|
5
8
|
*/
|
|
6
9
|
export function printCss(): string {
|
|
7
10
|
return (
|
|
8
11
|
"@media print{" +
|
|
9
12
|
".emvb-theme-header,.emvb-theme-footer,.emvb-float,.emvb-popup{display:none!important}" +
|
|
13
|
+
".emvb-tabs:has(> .emvb-tab-input:nth-of-type(n):checked) > .emvb-tab-panels > .emvb-tab-panel:nth-of-type(n){display:block!important}" +
|
|
14
|
+
".emvb-accordion-item::details-content{content-visibility:visible;display:block}" +
|
|
10
15
|
"}"
|
|
11
16
|
);
|
|
12
17
|
}
|
|
@@ -207,25 +207,39 @@ export function renameClass(design: DesignSystem, classId: string, name: string)
|
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
type DesignClass = NonNullable<DesignSystem["classes"]>[number];
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Replace one class with `edit(copy)`; the design comes back unchanged when no class has that id.
|
|
214
|
+
* The copy is shallow, so `edit` may set or delete keys on it. Pure.
|
|
215
|
+
*/
|
|
216
|
+
export function editClass(
|
|
212
217
|
design: DesignSystem,
|
|
213
218
|
classId: string,
|
|
214
|
-
|
|
219
|
+
edit: (copy: DesignClass) => DesignClass,
|
|
215
220
|
): DesignSystem {
|
|
216
221
|
const classes = design.classes ?? [];
|
|
217
222
|
if (!classes.some((c) => c.id === classId)) return design;
|
|
218
223
|
return {
|
|
219
224
|
...design,
|
|
220
|
-
classes: classes.map((c) => {
|
|
221
|
-
if (c.id !== classId) return c;
|
|
222
|
-
const style: Record<string, unknown> = { ...c.style, ...patch };
|
|
223
|
-
for (const [key, value] of Object.entries(patch)) if (value === undefined) delete style[key];
|
|
224
|
-
return Object.assign({}, c, { style: style as StyleProps });
|
|
225
|
-
}),
|
|
225
|
+
classes: classes.map((c) => (c.id === classId ? edit(Object.assign({}, c)) : c)),
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
/** Merge `patch` into a class's style; `undefined` values clear their property. Pure (W-087). */
|
|
230
|
+
export function patchClassStyle(
|
|
231
|
+
design: DesignSystem,
|
|
232
|
+
classId: string,
|
|
233
|
+
patch: Partial<StyleProps>,
|
|
234
|
+
): DesignSystem {
|
|
235
|
+
return editClass(design, classId, (next) => {
|
|
236
|
+
const style: Record<string, unknown> = { ...next.style, ...patch };
|
|
237
|
+
for (const [key, value] of Object.entries(patch)) if (value === undefined) delete style[key];
|
|
238
|
+
next.style = style as StyleProps;
|
|
239
|
+
return next;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
229
243
|
/** Swap one applied class id for another in place, keeping the cascade order. Pure (W-087). */
|
|
230
244
|
export function replaceClassId(ids: readonly string[], from: string, to: string): string[] {
|
|
231
245
|
if (ids.includes(to)) return removeClassId(ids, from);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DesignSystem } from "../schema/design.ts";
|
|
2
|
+
import { editClass } from "./classes.ts";
|
|
2
3
|
import type { DeviceStyles, StyleProps } from "../schema/style.ts";
|
|
3
4
|
import { POPUP_DEVICES, type PopupDevice } from "../theme/popup-rules.ts";
|
|
4
5
|
|
|
@@ -28,19 +29,12 @@ export function patchClassDevices(
|
|
|
28
29
|
device: ResponsiveDevice,
|
|
29
30
|
patch: Partial<StyleProps>,
|
|
30
31
|
): DesignSystem {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const next = Object.assign({}, c);
|
|
38
|
-
const devices = patchDeviceStyle(c.devices, device, patch);
|
|
39
|
-
if (devices) next.devices = devices;
|
|
40
|
-
else delete next.devices;
|
|
41
|
-
return next;
|
|
42
|
-
}),
|
|
43
|
-
};
|
|
32
|
+
return editClass(design, classId, (next) => {
|
|
33
|
+
const devices = patchDeviceStyle(next.devices, device, patch);
|
|
34
|
+
if (devices) next.devices = devices;
|
|
35
|
+
else delete next.devices;
|
|
36
|
+
return next;
|
|
37
|
+
});
|
|
44
38
|
}
|
|
45
39
|
|
|
46
40
|
/** Add or remove one device. The result stays in desktop, tablet, mobile order, or undefined. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DesignSystem } from "../schema/design.ts";
|
|
2
|
+
import { editClass } from "./classes.ts";
|
|
2
3
|
import { STYLE_STATES, type StyleStateName } from "../schema/state-names.ts";
|
|
3
4
|
import type { StyleProps, StyleStates } from "../schema/style.ts";
|
|
4
5
|
|
|
@@ -33,17 +34,10 @@ export function patchClassState(
|
|
|
33
34
|
state: StyleStateName,
|
|
34
35
|
patch: Partial<StyleProps>,
|
|
35
36
|
): DesignSystem {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const next = Object.assign({}, c);
|
|
43
|
-
const states = patchStates(c.states, state, patch);
|
|
44
|
-
if (states) next.states = states;
|
|
45
|
-
else delete next.states;
|
|
46
|
-
return next;
|
|
47
|
-
}),
|
|
48
|
-
};
|
|
37
|
+
return editClass(design, classId, (next) => {
|
|
38
|
+
const states = patchStates(next.states, state, patch);
|
|
39
|
+
if (states) next.states = states;
|
|
40
|
+
else delete next.states;
|
|
41
|
+
return next;
|
|
42
|
+
});
|
|
49
43
|
}
|
|
@@ -18,7 +18,7 @@ export const postTitle: ElementDefinition<PostTitleNode> = {
|
|
|
18
18
|
defaults: () => ({ type: "post-title", props: { level: 1 } }),
|
|
19
19
|
descriptor: {
|
|
20
20
|
type: "post-title",
|
|
21
|
-
name: "Post
|
|
21
|
+
name: "Post title",
|
|
22
22
|
group: "dynamic",
|
|
23
23
|
defaultTab: "content",
|
|
24
24
|
fields: [
|
|
@@ -40,7 +40,7 @@ export const postExcerpt: ElementDefinition<PostExcerptNode> = {
|
|
|
40
40
|
defaults: () => ({ type: "post-excerpt", props: {} }),
|
|
41
41
|
descriptor: {
|
|
42
42
|
type: "post-excerpt",
|
|
43
|
-
name: "Post
|
|
43
|
+
name: "Post excerpt",
|
|
44
44
|
group: "dynamic",
|
|
45
45
|
defaultTab: "style",
|
|
46
46
|
fields: [
|
|
@@ -61,7 +61,7 @@ export const postContent: ElementDefinition<PostContentNode> = {
|
|
|
61
61
|
defaults: () => ({ type: "post-content", props: {} }),
|
|
62
62
|
descriptor: {
|
|
63
63
|
type: "post-content",
|
|
64
|
-
name: "Post
|
|
64
|
+
name: "Post content",
|
|
65
65
|
group: "dynamic",
|
|
66
66
|
defaultTab: "style",
|
|
67
67
|
fields: [],
|
|
@@ -78,7 +78,7 @@ export const postImage: ElementDefinition<PostImageNode> = {
|
|
|
78
78
|
defaults: () => ({ type: "post-image", props: { decorative: false } }),
|
|
79
79
|
descriptor: {
|
|
80
80
|
type: "post-image",
|
|
81
|
-
name: "Post
|
|
81
|
+
name: "Post image",
|
|
82
82
|
group: "dynamic",
|
|
83
83
|
defaultTab: "content",
|
|
84
84
|
fields: [{ key: "decorative", kind: "boolean", label: "Decorative", optional: true }],
|
|
@@ -95,7 +95,7 @@ export const postDate: ElementDefinition<PostDateNode> = {
|
|
|
95
95
|
defaults: () => ({ type: "post-date", props: {} }),
|
|
96
96
|
descriptor: {
|
|
97
97
|
type: "post-date",
|
|
98
|
-
name: "Post
|
|
98
|
+
name: "Post date",
|
|
99
99
|
group: "dynamic",
|
|
100
100
|
defaultTab: "style",
|
|
101
101
|
fields: [
|
|
@@ -122,7 +122,7 @@ export const postAuthor: ElementDefinition<PostAuthorNode> = {
|
|
|
122
122
|
defaults: () => ({ type: "post-author", props: {} }),
|
|
123
123
|
descriptor: {
|
|
124
124
|
type: "post-author",
|
|
125
|
-
name: "Post
|
|
125
|
+
name: "Post author",
|
|
126
126
|
group: "dynamic",
|
|
127
127
|
defaultTab: "style",
|
|
128
128
|
fields: [],
|
|
@@ -135,7 +135,7 @@ export const postLink: ElementDefinition<PostLinkNode> = {
|
|
|
135
135
|
defaults: () => ({ type: "post-link", props: {} }),
|
|
136
136
|
descriptor: {
|
|
137
137
|
type: "post-link",
|
|
138
|
-
name: "Post
|
|
138
|
+
name: "Post link",
|
|
139
139
|
group: "dynamic",
|
|
140
140
|
defaultTab: "content",
|
|
141
141
|
fields: [
|
|
@@ -230,14 +230,14 @@ export const loop: ElementDefinition<LoopNode> = {
|
|
|
230
230
|
label: "Image field",
|
|
231
231
|
optional: true,
|
|
232
232
|
message:
|
|
233
|
-
"The field Post
|
|
233
|
+
"The field Post image shows, such as photo. Leave it empty for the featured image.",
|
|
234
234
|
},
|
|
235
235
|
{
|
|
236
236
|
key: "excerptField",
|
|
237
237
|
kind: "text",
|
|
238
238
|
label: "Excerpt field",
|
|
239
239
|
optional: true,
|
|
240
|
-
message: "The field Post
|
|
240
|
+
message: "The field Post excerpt shows, such as role. Leave it empty for the excerpt.",
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
key: "filter",
|
|
@@ -250,10 +250,10 @@ export const loop: ElementDefinition<LoopNode> = {
|
|
|
250
250
|
{
|
|
251
251
|
key: "itemPartId",
|
|
252
252
|
kind: "text",
|
|
253
|
-
label: "Loop
|
|
253
|
+
label: "Loop item",
|
|
254
254
|
optional: true,
|
|
255
255
|
message:
|
|
256
|
-
"Optional published Loop
|
|
256
|
+
"Optional published Loop item theme part. Leave blank to use nested elements as the item template.",
|
|
257
257
|
},
|
|
258
258
|
{
|
|
259
259
|
key: "perPage",
|
|
@@ -309,8 +309,16 @@ export const pagination: ElementDefinition<PaginationNode> = {
|
|
|
309
309
|
label: "Count text",
|
|
310
310
|
optional: true,
|
|
311
311
|
message:
|
|
312
|
-
'{page} and {total} are filled in. EmDash
|
|
312
|
+
'{page} and {total} are filled in. EmDash doesn\'t report a total, so the count shows "Page N" unless the site turns on page counting.',
|
|
313
313
|
},
|
|
314
|
+
{
|
|
315
|
+
key: "showLast",
|
|
316
|
+
kind: "boolean",
|
|
317
|
+
label: "Show Last link",
|
|
318
|
+
optional: true,
|
|
319
|
+
message: "Links to the last page when the site counts pages; otherwise it's left out.",
|
|
320
|
+
},
|
|
321
|
+
{ key: "lastText", kind: "text", label: "Last text", optional: true },
|
|
314
322
|
{
|
|
315
323
|
key: "titleText",
|
|
316
324
|
kind: "text",
|
|
@@ -357,6 +365,13 @@ export const pagination: ElementDefinition<PaginationNode> = {
|
|
|
357
365
|
optional: true,
|
|
358
366
|
message: 'Read out when Next text is only an arrow. Unset is "Next page".',
|
|
359
367
|
},
|
|
368
|
+
{
|
|
369
|
+
key: "lastLabel",
|
|
370
|
+
kind: "text",
|
|
371
|
+
label: "Last name",
|
|
372
|
+
optional: true,
|
|
373
|
+
message: 'Read out when Last text is only an arrow. Unset is "Last page".',
|
|
374
|
+
},
|
|
360
375
|
],
|
|
361
376
|
},
|
|
362
377
|
// Rendered by core/render/pagination.ts from the archive's page data (W-222).
|
|
@@ -962,7 +962,7 @@ const divBlock: ElementDefinition<DivBlockNode> = {
|
|
|
962
962
|
defaults: () => ({ type: "div-block", props: {}, children: [] }),
|
|
963
963
|
descriptor: {
|
|
964
964
|
type: "div-block",
|
|
965
|
-
name: "Div
|
|
965
|
+
name: "Div block",
|
|
966
966
|
group: "layout",
|
|
967
967
|
defaultTab: "style",
|
|
968
968
|
fields: BOX_LINK_FIELDS,
|
|
@@ -86,6 +86,9 @@ const MENU_CSS = [
|
|
|
86
86
|
".emvb-menu--column .emvb-menu-item__bar{position:relative;width:fit-content;max-width:100%}",
|
|
87
87
|
".emvb-menu--column .emvb-menu-panel{top:0;inset-inline-start:100%}",
|
|
88
88
|
".emvb-menu--column .emvb-menu-panel--wide{inset-inline:auto;inset-inline-start:100%;min-width:18rem}",
|
|
89
|
+
// W-847 (D-056): on a phone there is no room beside the item (the flyout overflowed by about
|
|
90
|
+
// 40-50 px), so a column flyout opens below its item instead, no wider than the screen.
|
|
91
|
+
"@media (max-width: 767.98px){.emvb-menu--column .emvb-menu-panel,.emvb-menu--column .emvb-menu-panel--wide{top:100%;inset-inline:auto;inset-inline-start:0;min-width:min(12rem,calc(100vw - 2rem));max-width:calc(100vw - 2rem)}}",
|
|
89
92
|
].join("");
|
|
90
93
|
|
|
91
94
|
export const menu: ElementDefinition<MenuNode> = {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W-848 (D-057): a spin or pulse stops on its own after about 5 seconds (WCAG 2.2.2), so it repeats
|
|
3
|
+
* as many whole times as fit. A pulse alternates, so it runs an even number of times and ends at
|
|
4
|
+
* rest. One spin longer than 5 s, or one pulse there and back longer than 5 s, still runs once.
|
|
5
|
+
*/
|
|
6
|
+
export const ICON_ANIMATION_LIMIT_MS = 5000;
|
|
7
|
+
|
|
8
|
+
export function iconAnimationRuns(type: "spin" | "pulse", durationMs: number): number {
|
|
9
|
+
if (type === "spin") return Math.max(1, Math.floor(ICON_ANIMATION_LIMIT_MS / durationMs));
|
|
10
|
+
return 2 * Math.max(1, Math.floor(ICON_ANIMATION_LIMIT_MS / (2 * durationMs)));
|
|
11
|
+
}
|
package/src/core/index.ts
CHANGED
|
@@ -272,6 +272,7 @@ export {
|
|
|
272
272
|
canDrop,
|
|
273
273
|
duplicateNode,
|
|
274
274
|
wrapNode,
|
|
275
|
+
wrapInThemeSection,
|
|
275
276
|
WRAP_TYPES,
|
|
276
277
|
type WrapType,
|
|
277
278
|
createVariantB,
|
|
@@ -517,6 +518,7 @@ export {
|
|
|
517
518
|
type ShareRead,
|
|
518
519
|
} from "./share/link.ts";
|
|
519
520
|
export { canvasStyleUrls, MAX_CANVAS_STYLES } from "./canvas-styles.ts";
|
|
521
|
+
export { canvasCollectionSlugs, MAX_CANVAS_COLLECTIONS } from "./canvas-collections.ts";
|
|
520
522
|
export {
|
|
521
523
|
IMAGE_EDIT_CURVE_POINTS_MAX,
|
|
522
524
|
IMAGE_EDIT_FORMATS,
|
|
@@ -527,3 +529,23 @@ export {
|
|
|
527
529
|
} from "./image-edit/schema.ts";
|
|
528
530
|
export { summarizeImageEdit } from "./image-edit/summary.ts";
|
|
529
531
|
export { boxLinkHeldBack } from "./render/extras.ts";
|
|
532
|
+
export {
|
|
533
|
+
classMergeNotice,
|
|
534
|
+
insertSavedSection,
|
|
535
|
+
MAX_SAVED_SECTIONS,
|
|
536
|
+
mergeSectionClasses,
|
|
537
|
+
prepareSavedSection,
|
|
538
|
+
readSavedSection,
|
|
539
|
+
SAVED_SECTION_NAME_MAX,
|
|
540
|
+
SAVED_SECTION_REASONS,
|
|
541
|
+
savedSectionName,
|
|
542
|
+
savedSectionRecord,
|
|
543
|
+
snapshotSection,
|
|
544
|
+
type ClassMerge,
|
|
545
|
+
type PreparedSection,
|
|
546
|
+
type SavedSection,
|
|
547
|
+
type SavedSectionRecord,
|
|
548
|
+
type SavedSectionSummary,
|
|
549
|
+
syncedPartLayout,
|
|
550
|
+
} from "./saved-sections.ts";
|
|
551
|
+
export { portableTextToLayout } from "./portable-text.ts";
|
|
@@ -59,6 +59,7 @@ function walkGradients(value: unknown): unknown {
|
|
|
59
59
|
|
|
60
60
|
const gradients: Migration = (doc) => walkGradients(doc) as Record<string, unknown>;
|
|
61
61
|
|
|
62
|
+
/** 0.8.0 (W-885, D-031, D-059): layout 16 -> 17 and design 15 -> 16 add only the optional `loop`. */
|
|
62
63
|
/** `LAYOUT_MIGRATIONS[n]` upgrades a version-n layout to version n + 1. Migrations must be pure. */
|
|
63
64
|
export const LAYOUT_MIGRATIONS: Readonly<Record<number, Migration>> = {
|
|
64
65
|
1: unchanged,
|
|
@@ -76,6 +77,7 @@ export const LAYOUT_MIGRATIONS: Readonly<Record<number, Migration>> = {
|
|
|
76
77
|
13: unchanged,
|
|
77
78
|
14: unchanged,
|
|
78
79
|
15: unchanged,
|
|
80
|
+
16: unchanged,
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
/** `DESIGN_MIGRATIONS[n]` upgrades a version-n design document to version n + 1. */
|
|
@@ -94,6 +96,7 @@ export const DESIGN_MIGRATIONS: Readonly<Record<number, Migration>> = {
|
|
|
94
96
|
12: unchanged,
|
|
95
97
|
13: unchanged,
|
|
96
98
|
14: unchanged,
|
|
99
|
+
15: unchanged,
|
|
97
100
|
};
|
|
98
101
|
|
|
99
102
|
export type UpgradeResult =
|