@perkyzz/emvb 1.3.0 → 1.4.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 +2 -2
- package/package.json +2 -2
- package/src/admin/bulk-api.ts +5 -1
- package/src/admin/content-item.ts +3 -0
- package/src/admin/copy-rich-text.ts +99 -9
- package/src/admin/editor/A11yCopilot.tsx +3 -1
- package/src/admin/editor/Editor.tsx +28 -3
- package/src/admin/editor/Timeline.tsx +1 -8
- package/src/admin/editor/canvas/DeviceBar.tsx +7 -2
- package/src/admin/editor/canvas/EmptyCanvas.tsx +11 -2
- package/src/admin/editor/canvas/use-canvas-dnd.ts +1 -20
- package/src/admin/editor/canvas/vnode-react.tsx +2 -0
- package/src/admin/editor/co-design.ts +36 -1
- package/src/admin/editor/collection-previews.ts +7 -8
- package/src/admin/editor/dnd/dragged-source.ts +22 -0
- package/src/admin/editor/dnd/layer-drop.ts +141 -0
- package/src/admin/editor/dnd/new-element.ts +16 -0
- package/src/admin/editor/editor-css.ts +9 -1
- package/src/admin/editor/element-chrome.ts +6 -0
- package/src/admin/editor/extensions/ExtensionPanels.tsx +33 -1
- package/src/admin/editor/extensions-context.tsx +16 -1
- package/src/admin/editor/feature-css.ts +27 -0
- package/src/admin/editor/inert-links.ts +8 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/ConditionsEditor.tsx +18 -0
- package/src/admin/editor/panels/ElementPanel.tsx +2 -2
- package/src/admin/editor/panels/FontFaces.tsx +342 -0
- package/src/admin/editor/panels/LayersPanel.tsx +56 -6
- package/src/admin/editor/panels/LeftPanel.tsx +153 -29
- package/src/admin/editor/panels/SettingsPanel.tsx +1 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +5 -0
- package/src/admin/editor/panels/TemplatesPanel.tsx +205 -0
- package/src/admin/editor/panels/TokenScales.tsx +2 -0
- package/src/admin/editor/panels/TriggersEditor.tsx +203 -9
- package/src/admin/editor/panels/VariableSection.tsx +111 -7
- package/src/admin/editor/panels/color-space.ts +71 -6
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +3 -0
- package/src/admin/editor/panels/settings/FieldControl.tsx +33 -0
- package/src/admin/editor/panels/settings/FormBindControl.tsx +27 -31
- package/src/admin/editor/panels/settings/ImageFieldControl.tsx +106 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +9 -3
- package/src/admin/editor/panels/settings/StickyControl.tsx +97 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +14 -0
- package/src/admin/editor/panels/settings/loop-context.ts +34 -3
- package/src/admin/editor/panels/settings/style-sections.ts +19 -2
- package/src/admin/editor/panels/url-rules.ts +43 -0
- package/src/admin/editor/panels/use-layers-drop.ts +232 -0
- package/src/admin/editor/store.ts +4 -2
- package/src/admin/editor/useExtensions.ts +3 -1
- package/src/admin/editor/useNodeActions.ts +74 -1
- package/src/admin/editor/useSave.ts +116 -85
- package/src/admin/export-api.ts +27 -2
- package/src/admin/extension-outputs.ts +236 -0
- package/src/admin/font-files-api.ts +38 -0
- package/src/admin/import-forms.ts +133 -0
- package/src/admin/pages/ImportButton.tsx +15 -4
- package/src/admin/pages/ImportElementorDialog.tsx +53 -187
- package/src/admin/pages/ImportForms.tsx +71 -0
- package/src/admin/pages/ImportHtmlDialog.tsx +209 -0
- package/src/admin/pages/ImportImageCopies.tsx +167 -0
- package/src/admin/pages/ImportReport.tsx +63 -0
- package/src/admin/pages/NewPageDialog.tsx +54 -32
- package/src/admin/pages/PageList.tsx +9 -0
- package/src/admin/pages/ThemePartList.tsx +9 -0
- package/src/admin/setup/plan.ts +2 -0
- package/src/admin/ui.ts +7 -0
- package/src/admin/widgets/ConvertToRichText.tsx +3 -2
- package/src/astro/EmVBPage.astro +5 -2
- package/src/astro/extension-styles.ts +35 -0
- package/src/astro/forms/EmVBFormsClient.astro +3 -0
- package/src/astro/forms/enhance.ts +107 -0
- package/src/astro/popups/runtime.ts +47 -2
- package/src/astro/render.ts +25 -4
- package/src/astro/resolve-theme.ts +11 -4
- package/src/astro/resolve.ts +2 -0
- package/src/astro/theme-posts.ts +17 -23
- package/src/astro/visitor.ts +14 -5
- package/src/astro/widgets/EmVBStickyRuntime.astro +9 -0
- package/src/astro/widgets/EmVBThemeRuntime.astro +9 -0
- package/src/astro/widgets/EmVBWidgetRuntimes.astro +12 -0
- package/src/astro/widgets/alerts.ts +16 -2
- package/src/astro/widgets/carousel.ts +65 -24
- package/src/astro/widgets/countdown.ts +18 -7
- package/src/astro/widgets/extension-runtimes.ts +27 -0
- package/src/astro/widgets/headline.ts +14 -5
- package/src/astro/widgets/sticky.ts +87 -0
- package/src/astro/widgets/theme.ts +52 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +150 -2
- package/src/core/arrange.ts +19 -1
- package/src/core/css/font-face.ts +72 -0
- package/src/core/css/generate.ts +41 -2
- package/src/core/css/trace.ts +8 -0
- package/src/core/data/bindings.ts +7 -4
- package/src/core/elements/dynamic-elements.ts +1 -1
- package/src/core/elements/element-nouns.ts +48 -0
- package/src/core/elements/form-elements.ts +119 -9
- package/src/core/elements/icon-svg.ts +14 -0
- package/src/core/elements/index.ts +24 -4
- package/src/core/elements/input-limits.ts +44 -0
- package/src/core/elements/menu.ts +109 -47
- package/src/core/elements/site.ts +108 -0
- package/src/core/elements/widgets.ts +13 -3
- package/src/core/export/runtimes.generated.ts +7 -5
- package/src/core/export/site.ts +53 -4
- package/src/core/extensions/classes.ts +114 -0
- package/src/core/extensions/index.ts +19 -2
- package/src/core/extensions/normalize.ts +13 -0
- package/src/core/extensions/placeholder.ts +7 -2
- package/src/core/extensions/registry.ts +134 -10
- package/src/core/extensions/render-ext.ts +115 -36
- package/src/core/extensions/safe-nodes.ts +67 -11
- package/src/core/extensions/types.ts +48 -1
- package/src/core/fonts/files.ts +74 -0
- package/src/core/fonts/google.ts +112 -0
- package/src/core/fonts/test-font.ts +9 -0
- package/src/core/import/elementor/context.ts +42 -4
- package/src/core/import/elementor/index.ts +55 -23
- package/src/core/import/elementor/widgets.ts +242 -20
- package/src/core/import/html/blocks.ts +602 -0
- package/src/core/import/html/index.ts +155 -0
- package/src/core/import/html/map.ts +958 -0
- package/src/core/import/html/parse.ts +430 -0
- package/src/core/index.ts +54 -0
- package/src/core/migrate/v18.ts +3 -0
- package/src/core/public-attributes.ts +17 -0
- package/src/core/render/extras.ts +31 -7
- package/src/core/render/form.ts +103 -10
- package/src/core/render/index.ts +165 -16
- package/src/core/render/section.ts +31 -1
- package/src/core/render/spacer-basis.ts +102 -0
- package/src/core/render/theme-boot.ts +16 -0
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +68 -3
- package/src/core/sanitize/motion.ts +12 -0
- package/src/core/schema/design.ts +40 -0
- package/src/core/schema/layout.ts +118 -6
- package/src/core/schema/style.ts +28 -0
- package/src/core/templates/index.ts +218 -0
- package/src/core/templates/pages.ts +29 -0
- package/src/core/templates/sections.ts +794 -0
- package/src/core/templates/types.ts +9 -0
- package/src/core/theme/dynamic.ts +9 -6
- package/src/core/theme/media-value.ts +88 -0
- package/src/core/theme/popup-markup.ts +21 -2
- package/src/core/theme/popup-rules.ts +36 -0
- package/src/core/theme/triggers.ts +64 -5
- package/src/core/translatable.ts +5 -2
- package/src/core/visitor-cookie.ts +91 -0
- package/src/extension-build.ts +331 -0
- package/src/index.ts +53 -4
- package/src/mcp/agent-defaults.ts +40 -0
- package/src/mcp/brief.ts +191 -0
- package/src/mcp/extensions.ts +138 -0
- package/src/mcp/prompts.ts +33 -0
- package/src/mcp/read.ts +84 -20
- package/src/mcp/tools.ts +42 -3
- package/src/mcp/write.ts +124 -9
- package/src/server/extension-routes.ts +110 -0
- package/src/server/font-routes.ts +301 -0
- package/src/server/plugin.ts +15 -0
|
@@ -52,7 +52,12 @@ function start(mark: HTMLElement, r: Rotation): void {
|
|
|
52
52
|
const timer = setInterval(() => {
|
|
53
53
|
step++;
|
|
54
54
|
text.textContent = r.words[step % r.words.length] ?? "";
|
|
55
|
-
if (step
|
|
55
|
+
if (step < last) return;
|
|
56
|
+
// W-1059: the button goes away at the end; if it had focus, focus moves on as after Pause.
|
|
57
|
+
const focused = doc.activeElement === pause;
|
|
58
|
+
const next = pause.nextElementSibling;
|
|
59
|
+
stop();
|
|
60
|
+
if (focused) moveOn(next);
|
|
56
61
|
}, r.interval * 1000);
|
|
57
62
|
|
|
58
63
|
function stop(): void {
|
|
@@ -62,10 +67,8 @@ function start(mark: HTMLElement, r: Rotation): void {
|
|
|
62
67
|
spoken.remove();
|
|
63
68
|
pause.remove();
|
|
64
69
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const next = pause.nextElementSibling;
|
|
68
|
-
stop();
|
|
70
|
+
/** Focus after the removed button: the control that followed it, else the heading. */
|
|
71
|
+
function moveOn(next: Element | null): void {
|
|
69
72
|
if (
|
|
70
73
|
next instanceof HTMLElement &&
|
|
71
74
|
next.matches("a[href], button, input, select, textarea, [tabindex]")
|
|
@@ -75,6 +78,12 @@ function start(mark: HTMLElement, r: Rotation): void {
|
|
|
75
78
|
heading.tabIndex = -1;
|
|
76
79
|
heading.focus();
|
|
77
80
|
}
|
|
81
|
+
}
|
|
82
|
+
// Pausing ends the rotation for good, back on the first word.
|
|
83
|
+
pause.addEventListener("click", () => {
|
|
84
|
+
const next = pause.nextElementSibling;
|
|
85
|
+
stop();
|
|
86
|
+
moveOn(next);
|
|
78
87
|
});
|
|
79
88
|
}
|
|
80
89
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W-1070: the opt-in sticky script. An element marked `data-emvb-sticky-hide` (its style's "Hide
|
|
3
|
+
* while scrolling down") slides out of view once the page scrolls down past it, and back as soon
|
|
4
|
+
* as the visitor scrolls up. Its CSS custom property `--emvb-sticky-hide` says whether that is on
|
|
5
|
+
* at the current width (`0` turns it off on a device). A bar held at the top slides up; one held
|
|
6
|
+
* at the bottom slides down. It never hides while focus is inside it (WCAG 2.4.11), and it moves
|
|
7
|
+
* without animation for visitors who prefer reduced motion. The slide is a Web Animation, so the
|
|
8
|
+
* element's own CSS transitions stay as they are.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Scrolls smaller than this (px) don't change direction: trackpads jitter. */
|
|
12
|
+
const SLACK = 4;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Moves `el` to `to` (`""` is its place), sliding from where it was unless motion is reduced. A
|
|
16
|
+
* slide started before is left to finish: the newer one sits above it and wins.
|
|
17
|
+
*/
|
|
18
|
+
function move(el: HTMLElement, to: string, reduced: boolean): void {
|
|
19
|
+
const from = el.style.translate;
|
|
20
|
+
if (from === to) return;
|
|
21
|
+
el.style.translate = to;
|
|
22
|
+
if (reduced || typeof el.animate !== "function") return;
|
|
23
|
+
el.animate([{ translate: from || "0 0" }, { translate: to || "0 0" }], {
|
|
24
|
+
duration: 250,
|
|
25
|
+
easing: "ease",
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function show(el: HTMLElement, reduced: boolean): void {
|
|
30
|
+
delete el.dataset["emvbAway"];
|
|
31
|
+
move(el, "", reduced);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Whether hiding is on at this width; an older page without the property always hides. */
|
|
35
|
+
function hidesHere(style: CSSStyleDeclaration): boolean {
|
|
36
|
+
return style.getPropertyValue("--emvb-sticky-hide").trim() !== "0";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Held in the lower half of the screen (a bar fixed or stuck to the bottom): it leaves downwards.
|
|
41
|
+
* Read from where it sits, as the computed `top` of a placed element is a length, never `auto`.
|
|
42
|
+
*/
|
|
43
|
+
function heldAtBottom(el: HTMLElement): boolean {
|
|
44
|
+
const { top, height } = el.getBoundingClientRect();
|
|
45
|
+
return top + height / 2 > globalThis.innerHeight / 2;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function initSticky(root: ParentNode = document): void {
|
|
49
|
+
const all = [...root.querySelectorAll<HTMLElement>("[data-emvb-sticky-hide]")].filter(
|
|
50
|
+
(el) => el.dataset["emvbReady"] === undefined,
|
|
51
|
+
);
|
|
52
|
+
if (all.length === 0) return;
|
|
53
|
+
const reduced = globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;
|
|
54
|
+
for (const el of all) {
|
|
55
|
+
el.dataset["emvbReady"] = "";
|
|
56
|
+
// Focus moving in (a Tab from the address bar, a skip link) brings it back at once.
|
|
57
|
+
el.addEventListener("focusin", () => show(el, reduced));
|
|
58
|
+
}
|
|
59
|
+
let last = globalThis.scrollY;
|
|
60
|
+
let frame = 0;
|
|
61
|
+
const update = () => {
|
|
62
|
+
const y = globalThis.scrollY;
|
|
63
|
+
if (Math.abs(y - last) < SLACK) return;
|
|
64
|
+
const down = y > last;
|
|
65
|
+
last = y;
|
|
66
|
+
for (const el of all) {
|
|
67
|
+
const style = getComputedStyle(el);
|
|
68
|
+
if (!hidesHere(style)) {
|
|
69
|
+
if (el.dataset["emvbAway"] !== undefined) show(el, reduced);
|
|
70
|
+
} else if (down && y > el.offsetHeight && !el.contains(document.activeElement)) {
|
|
71
|
+
if (el.dataset["emvbAway"] !== undefined) continue;
|
|
72
|
+
el.dataset["emvbAway"] = "";
|
|
73
|
+
move(el, heldAtBottom(el) ? "0 100%" : "0 -100%", reduced);
|
|
74
|
+
} else if (!down) {
|
|
75
|
+
show(el, reduced);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
globalThis.addEventListener(
|
|
80
|
+
"scroll",
|
|
81
|
+
() => {
|
|
82
|
+
cancelAnimationFrame(frame);
|
|
83
|
+
frame = requestAnimationFrame(update);
|
|
84
|
+
},
|
|
85
|
+
{ passive: true },
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W-1067: the opt-in Theme toggle runtime. A choice made with a Theme toggle is kept in this
|
|
3
|
+
* browser and marks `<html data-emvb-theme="light|dark">`, which the page CSS reads before the
|
|
4
|
+
* visitor's system setting. Each toggle shows once this runs, and says whether dark is on. The
|
|
5
|
+
* page itself puts a saved choice back before it is drawn (THEME_BOOT_SCRIPT).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { THEME_STORAGE_KEY } from "../../core/render/theme-boot.ts";
|
|
9
|
+
|
|
10
|
+
function stored(): "light" | "dark" | null {
|
|
11
|
+
try {
|
|
12
|
+
const value = localStorage.getItem(THEME_STORAGE_KEY);
|
|
13
|
+
return value === "light" || value === "dark" ? value : null;
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const systemDark = () => globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches === true;
|
|
20
|
+
|
|
21
|
+
/** Dark is on: chosen, or by the system with no choice made. */
|
|
22
|
+
const isDark = () => {
|
|
23
|
+
const chosen = document.documentElement.dataset["emvbTheme"];
|
|
24
|
+
return chosen === "dark" || (chosen !== "light" && systemDark());
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function sync(): void {
|
|
28
|
+
const dark = String(isDark());
|
|
29
|
+
for (const toggle of document.querySelectorAll<HTMLElement>("[data-emvb-theme-toggle]"))
|
|
30
|
+
toggle.setAttribute("aria-pressed", dark);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function initTheme(root: ParentNode = document): void {
|
|
34
|
+
const choice = stored();
|
|
35
|
+
if (choice) document.documentElement.dataset["emvbTheme"] = choice;
|
|
36
|
+
for (const toggle of root.querySelectorAll<HTMLElement>("[data-emvb-theme-toggle]")) {
|
|
37
|
+
if (toggle.dataset["emvbReady"] !== undefined) continue;
|
|
38
|
+
toggle.dataset["emvbReady"] = "";
|
|
39
|
+
toggle.addEventListener("click", () => {
|
|
40
|
+
const next = isDark() ? "light" : "dark";
|
|
41
|
+
document.documentElement.dataset["emvbTheme"] = next;
|
|
42
|
+
try {
|
|
43
|
+
localStorage.setItem(THEME_STORAGE_KEY, next);
|
|
44
|
+
} catch {
|
|
45
|
+
// Private mode: the choice lasts for this page only.
|
|
46
|
+
}
|
|
47
|
+
sync();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
globalThis.matchMedia?.("(prefers-color-scheme: dark)").addEventListener?.("change", sync);
|
|
51
|
+
sync();
|
|
52
|
+
}
|
package/src/constants.ts
CHANGED
package/src/core/a11y/audit.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { DesignSystem } from "../schema/design.ts";
|
|
|
4
4
|
import { isParentNode, type Layout, type LayoutNode } from "../schema/layout.ts";
|
|
5
5
|
import { boxBecomesLink } from "../render/extras.ts";
|
|
6
6
|
import { ICON_ANIMATION_LIMIT_MS, iconAnimationRuns } from "../icons/animation-runs.ts";
|
|
7
|
-
import { updateNode } from "../tree-ops.ts";
|
|
7
|
+
import { someNode, updateNode } from "../tree-ops.ts";
|
|
8
8
|
import { DEVICES } from "../theme/popup-rules.ts";
|
|
9
9
|
import { hiddenOnEveryDevice } from "../design/devices.ts";
|
|
10
10
|
import { sanitizeHref } from "../sanitize/href.ts";
|
|
@@ -46,7 +46,12 @@ export type A11yIssue = {
|
|
|
46
46
|
| "landmark-name"
|
|
47
47
|
| "motion"
|
|
48
48
|
| "empty-alert"
|
|
49
|
-
| "counter-title"
|
|
49
|
+
| "counter-title"
|
|
50
|
+
| "flip-box-face"
|
|
51
|
+
| "countdown-title"
|
|
52
|
+
| "hotspot-names"
|
|
53
|
+
| "mega-panel"
|
|
54
|
+
| "form-steps";
|
|
50
55
|
severity: "error" | "warning";
|
|
51
56
|
message: string;
|
|
52
57
|
/** The one-click fix, when there is a safe one. */
|
|
@@ -130,6 +135,7 @@ const TEXT_TYPES = new Set([
|
|
|
130
135
|
"post-excerpt",
|
|
131
136
|
]);
|
|
132
137
|
const FIELD_TYPES = new Set(["text-input", "textarea", "select", "checkbox", "radio"]);
|
|
138
|
+
const isStep = (node: LayoutNode) => node.type === "form-step";
|
|
133
139
|
const LINKISH = new Set(["link", "button", "menu-item"]);
|
|
134
140
|
|
|
135
141
|
function px(value: unknown, design?: DesignSystem): number | undefined {
|
|
@@ -259,6 +265,10 @@ export function auditPage(layout: Layout, design: DesignSystem): A11yReport {
|
|
|
259
265
|
let fade = 1;
|
|
260
266
|
// W-445: per device, like H1s, so a desktop menu and a mobile menu may share a name.
|
|
261
267
|
const menuNames = DEVICES.map(() => new Set<string>());
|
|
268
|
+
// W-1076: carousels are regions, listed by name like menus.
|
|
269
|
+
const carouselNames = DEVICES.map(() => new Set<string>());
|
|
270
|
+
// W-1069: inside a menu item's dropdown, where a mega panel would open from a flyout.
|
|
271
|
+
let inDropdown = false;
|
|
262
272
|
const walk = (node: LayoutNode, bg: string | undefined, color: string | undefined): void => {
|
|
263
273
|
// W-413: an element hidden on every device (and what's inside it) is never shown or read.
|
|
264
274
|
if (node !== layout.root && hiddenOnEveryDevice(node)) {
|
|
@@ -581,6 +591,119 @@ export function auditPage(layout: Layout, design: DesignSystem): A11yReport {
|
|
|
581
591
|
'This counter has no title, so its number doesn\'t say what it counts. Add a title such as "Happy clients".',
|
|
582
592
|
});
|
|
583
593
|
}
|
|
594
|
+
// W-1076: screen readers list carousels as regions by name; two with one name sound the same.
|
|
595
|
+
if (node.type === "carousel") {
|
|
596
|
+
const name = spoken(props["label"]) || "Carousel";
|
|
597
|
+
const key = name.toLowerCase();
|
|
598
|
+
if (carouselNames.some((names, i) => shownOn[i] && names.has(key))) {
|
|
599
|
+
add({
|
|
600
|
+
nodeId: node.id,
|
|
601
|
+
rule: "landmark-name",
|
|
602
|
+
severity: "warning",
|
|
603
|
+
message: `Another carousel on this page is also named "${name}"; give each carousel its own name, such as "Customer stories".`,
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
carouselNames.forEach((listed, i) => {
|
|
607
|
+
if (shownOn[i]) listed.add(key);
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
// W-1076: a Flip box's faces are headings and text; an empty one turns over to nothing.
|
|
611
|
+
if (node.type === "flip-box" && !node.bind) {
|
|
612
|
+
if (!spoken(props["frontTitle"])) {
|
|
613
|
+
add({
|
|
614
|
+
nodeId: node.id,
|
|
615
|
+
rule: "flip-box-face",
|
|
616
|
+
severity: "warning",
|
|
617
|
+
message:
|
|
618
|
+
"This flip box's front has no title, so its heading is empty. Add a front title.",
|
|
619
|
+
});
|
|
620
|
+
} else if (
|
|
621
|
+
!spoken(props["backTitle"]) &&
|
|
622
|
+
!spoken(props["backText"]) &&
|
|
623
|
+
!spoken(props["buttonText"])
|
|
624
|
+
) {
|
|
625
|
+
add({
|
|
626
|
+
nodeId: node.id,
|
|
627
|
+
rule: "flip-box-face",
|
|
628
|
+
severity: "warning",
|
|
629
|
+
message:
|
|
630
|
+
"This flip box's back is empty, so turning it over shows nothing. Add a back title, text or button.",
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
// The back's button is a link: with no address it can use, the page leaves it out.
|
|
634
|
+
const href = typeof props["href"] === "string" ? props["href"].trim() : "";
|
|
635
|
+
if (spoken(props["buttonText"]) && (!href || !sanitizeHref(href))) {
|
|
636
|
+
add({
|
|
637
|
+
nodeId: node.id,
|
|
638
|
+
rule: "link-name",
|
|
639
|
+
severity: "warning",
|
|
640
|
+
message:
|
|
641
|
+
"This flip box's button has no link it can use, so the page leaves the button out. Add a button link, or clear the button text.",
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
// W-1076: "Ends 1 Dec 2026" alone doesn't say what ends.
|
|
646
|
+
if (node.type === "countdown" && !spoken(props["title"]) && !node.bind) {
|
|
647
|
+
add({
|
|
648
|
+
nodeId: node.id,
|
|
649
|
+
rule: "countdown-title",
|
|
650
|
+
severity: "warning",
|
|
651
|
+
message:
|
|
652
|
+
'This countdown has no title, so its date doesn\'t say what ends. Add a title such as "Launch sale".',
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
// W-1076: each marker is a button named by its title; two alike can't be told apart.
|
|
656
|
+
if (node.type === "hotspots" && isParentNode(node)) {
|
|
657
|
+
const seen = new Set<string>();
|
|
658
|
+
for (const marker of node.children) {
|
|
659
|
+
const title = spoken((marker.props as Record<string, unknown>)["title"]).toLowerCase();
|
|
660
|
+
if (title && seen.has(title)) {
|
|
661
|
+
add({
|
|
662
|
+
nodeId: marker.id,
|
|
663
|
+
rule: "hotspot-names",
|
|
664
|
+
severity: "warning",
|
|
665
|
+
message: `Another marker on this picture is also called "${spoken((marker.props as Record<string, unknown>)["title"])}"; screen readers can't tell them apart. Give each its own title.`,
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
seen.add(title);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
// W-1065: a form with steps shows one step at a time; each is read out by its title.
|
|
672
|
+
if (node.type === "form" && isParentNode(node) && node.children.some(isStep)) {
|
|
673
|
+
let place = 0;
|
|
674
|
+
for (const child of node.children) {
|
|
675
|
+
if (!isStep(child)) {
|
|
676
|
+
if (someNode(child, (n) => FIELD_TYPES.has(n.type))) {
|
|
677
|
+
add({
|
|
678
|
+
nodeId: child.id,
|
|
679
|
+
rule: "form-steps",
|
|
680
|
+
severity: "warning",
|
|
681
|
+
message:
|
|
682
|
+
"This field is outside the form's steps, so it shows on every step and isn't checked before Next. Move it into a step.",
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
place += 1;
|
|
688
|
+
const title = spoken((child.props as Record<string, unknown>)["title"]);
|
|
689
|
+
if (!title && !child.bind) {
|
|
690
|
+
add({
|
|
691
|
+
nodeId: child.id,
|
|
692
|
+
rule: "form-steps",
|
|
693
|
+
severity: "warning",
|
|
694
|
+
message: `This form step has no title, so screen readers only hear "Step ${place}". Give it a title, such as "Your details".`,
|
|
695
|
+
});
|
|
696
|
+
} else if (!someNode(child, (n) => FIELD_TYPES.has(n.type))) {
|
|
697
|
+
add({
|
|
698
|
+
nodeId: child.id,
|
|
699
|
+
rule: "form-steps",
|
|
700
|
+
severity: "warning",
|
|
701
|
+
message:
|
|
702
|
+
"This form step has no fields, so Next opens an empty step. Add fields or remove it.",
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
584
707
|
// W-419: an empty heading still shows up in screen readers' heading list, with nothing to say.
|
|
585
708
|
if (node.type === "heading" && !spoken(props["text"]) && !node.bind) {
|
|
586
709
|
add({
|
|
@@ -626,6 +749,28 @@ export function auditPage(layout: Layout, design: DesignSystem): A11yReport {
|
|
|
626
749
|
message: "This box is a link, but nothing inside it has text, so the link has no name.",
|
|
627
750
|
});
|
|
628
751
|
}
|
|
752
|
+
// W-1069: a mega panel's toggle is named by its item's text ("Open Products", or the text
|
|
753
|
+
// itself), so a vague one says nothing about what opens; and one in a dropdown is a whole
|
|
754
|
+
// layout opened from a flyout, two disclosures deep for keyboard and screen reader users.
|
|
755
|
+
if (node.type === "menu-item" && spoken(props["panelPartId"])) {
|
|
756
|
+
const text = spoken(props["text"]);
|
|
757
|
+
if (inDropdown) {
|
|
758
|
+
add({
|
|
759
|
+
nodeId: node.id,
|
|
760
|
+
rule: "mega-panel",
|
|
761
|
+
severity: "warning",
|
|
762
|
+
message:
|
|
763
|
+
"This mega panel opens from inside another dropdown; put the item straight in the Menu so it opens from the menu bar.",
|
|
764
|
+
});
|
|
765
|
+
} else if (text && VAGUE.test(text)) {
|
|
766
|
+
add({
|
|
767
|
+
nodeId: node.id,
|
|
768
|
+
rule: "mega-panel",
|
|
769
|
+
severity: "warning",
|
|
770
|
+
message: `"${text}" doesn't say what this item's panel holds; name it for its contents, such as "Products".`,
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
}
|
|
629
774
|
if (LINKISH.has(node.type) || (node.type === "icon" && props["href"])) {
|
|
630
775
|
const text = spoken(props["text"] ?? props["title"]);
|
|
631
776
|
const hasHref = typeof props["href"] === "string" && props["href"].trim() !== "";
|
|
@@ -717,9 +862,12 @@ export function auditPage(layout: Layout, design: DesignSystem): A11yReport {
|
|
|
717
862
|
});
|
|
718
863
|
}
|
|
719
864
|
const outerHidden = ariaHiddenAbove;
|
|
865
|
+
const outerDropdown = inDropdown;
|
|
720
866
|
if (ownAriaHidden) ariaHiddenAbove = true;
|
|
867
|
+
if (node.type === "menu-item") inDropdown = true;
|
|
721
868
|
if (isParentNode(node)) for (const child of node.children) walk(child, nextBg, nextColor);
|
|
722
869
|
ariaHiddenAbove = outerHidden;
|
|
870
|
+
inDropdown = outerDropdown;
|
|
723
871
|
};
|
|
724
872
|
walk(layout.root, undefined, undefined);
|
|
725
873
|
if (h1s.every((count) => count === 0) && layout.root.children.length > 0) {
|
package/src/core/arrange.ts
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
newNodeId,
|
|
29
29
|
nodeChildren,
|
|
30
30
|
removeNode,
|
|
31
|
+
someNode,
|
|
31
32
|
starterLayout,
|
|
32
33
|
updateNode,
|
|
33
34
|
} from "./tree-ops.ts";
|
|
@@ -66,7 +67,9 @@ export const REASONS = {
|
|
|
66
67
|
top: "It's already at the top level.",
|
|
67
68
|
noContainerAbove: "There's no container just above it to move into.",
|
|
68
69
|
nestedForm: "A form can't go inside another form.",
|
|
70
|
+
searchInForm: "A Search form can't go inside a form.",
|
|
69
71
|
fieldOutsideForm: "Form fields must be placed inside a form.",
|
|
72
|
+
stepOutsideForm: "Form steps can only go directly inside a form.",
|
|
70
73
|
formIntoField: "A form can only go inside a layout container.",
|
|
71
74
|
tabOutsideTabs: "Tab panels can only go inside Tabs.",
|
|
72
75
|
onlyTabPanels: "Tabs can only hold tab panels.",
|
|
@@ -204,7 +207,11 @@ export function parentChildRefusal(
|
|
|
204
207
|
}
|
|
205
208
|
if (parent.type === "hotspots" && child.type !== "hotspot") return REASONS.onlyHotspots;
|
|
206
209
|
if (isFormNode(child) && inForm) return REASONS.nestedForm;
|
|
210
|
+
// W-1073: a Search form is a <form> too; inside a form its button sent that form.
|
|
211
|
+
if (child.type === "search-form" && inForm) return REASONS.searchInForm;
|
|
207
212
|
if (isFormFieldType(child.type) && !inForm) return REASONS.fieldOutsideForm;
|
|
213
|
+
// W-1065: the forms script pages through the form's own steps; a nested one would never show.
|
|
214
|
+
if (child.type === "form-step" && !isFormNode(parent)) return REASONS.stepOutsideForm;
|
|
208
215
|
return undefined;
|
|
209
216
|
}
|
|
210
217
|
|
|
@@ -295,8 +302,19 @@ export function canDrop(layout: Layout, source: DragSource, parentId: string): A
|
|
|
295
302
|
const moving = dragged(layout, source, parentId);
|
|
296
303
|
if (!moving.ok) return moving;
|
|
297
304
|
if (!isParentNode(into.node)) return refuse(REASONS.notContainer);
|
|
298
|
-
const
|
|
305
|
+
const inForm = underForm(layout, into.node.id);
|
|
306
|
+
const placed = parentChildRefusal(into.node, moving.node, inForm);
|
|
299
307
|
if (placed) return refuse(placed);
|
|
308
|
+
// A box holding a form or Search form can't go into a form either: the save would refuse it.
|
|
309
|
+
if (inForm) {
|
|
310
|
+
const inner = nodeChildren(moving.node).find((child) =>
|
|
311
|
+
someNode(child, (n) => isFormNode(n) || n.type === "search-form"),
|
|
312
|
+
);
|
|
313
|
+
if (inner) {
|
|
314
|
+
const nested = someNode(inner, isFormNode);
|
|
315
|
+
return refuse(nested ? REASONS.nestedForm : REASONS.searchInForm);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
300
318
|
const drop: Drop = { layout, node: moving.node, into, isNew: source.kind === "new" };
|
|
301
319
|
const broken = DROP_RULES.find(([breaks]) => breaks(drop));
|
|
302
320
|
return broken ? refuse(broken[1]) : { ok: true };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { FONT_FAMILY_NAME, UNICODE_RANGE } from "../schema/design.ts";
|
|
2
|
+
import type { FontFace, FontVariable } from "../schema/design.ts";
|
|
3
|
+
import { fontVariableName } from "../sanitize/css.ts";
|
|
4
|
+
import { sanitizeMediaUrl } from "../sanitize/media-url.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* W-1072: the characters a font file URL may hold in the emitted CSS. A URL that passes the media
|
|
8
|
+
* URL check may still hold braces, parentheses, `;` or spaces, which are harmless inside a quoted
|
|
9
|
+
* `url("…")` but would confuse the scoping pass, so those URLs are left out.
|
|
10
|
+
*/
|
|
11
|
+
const SRC_CHARS = /^[A-Za-z0-9\-._~:/?#[\]@!$&*+,=%]+$/;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A font file URL safe to write in `url("…")`, or undefined. Only a path on the site itself
|
|
15
|
+
* (`/…`, never `//host`): a page must not ask Google Fonts or any other host for a font, even when
|
|
16
|
+
* a design was edited by hand, imported or written by an agent.
|
|
17
|
+
*/
|
|
18
|
+
export function fontFaceSrc(src: string): string | undefined {
|
|
19
|
+
const url = sanitizeMediaUrl(src);
|
|
20
|
+
if (!url?.startsWith("/") || url.startsWith("//")) return undefined;
|
|
21
|
+
return SRC_CHARS.test(url) ? url : undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A double-quoted CSS string. Letters, digits, spaces, `_`, `.` and `-` stay as they are; any
|
|
26
|
+
* other character (a quote, a backslash, a newline, `<`) is written as a hex escape.
|
|
27
|
+
*/
|
|
28
|
+
export function cssString(value: string): string {
|
|
29
|
+
let out = "";
|
|
30
|
+
for (const ch of value) {
|
|
31
|
+
out += /^[\p{L}\p{N} _.-]$/u.test(ch) ? ch : `\\${(ch.codePointAt(0) ?? 0).toString(16)} `;
|
|
32
|
+
}
|
|
33
|
+
return `"${out}"`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function faceRule(family: string, face: FontFace): string | undefined {
|
|
37
|
+
const src = fontFaceSrc(face.src);
|
|
38
|
+
if (!src) return undefined;
|
|
39
|
+
if (!Number.isInteger(face.weight) || face.weight < 1 || face.weight > 1000) return undefined;
|
|
40
|
+
if (face.style !== "normal" && face.style !== "italic") return undefined;
|
|
41
|
+
const range =
|
|
42
|
+
face.unicodeRange !== undefined && face.unicodeRange.length <= 1000
|
|
43
|
+
? UNICODE_RANGE.test(face.unicodeRange)
|
|
44
|
+
? `;unicode-range:${face.unicodeRange}`
|
|
45
|
+
: undefined
|
|
46
|
+
: "";
|
|
47
|
+
if (range === undefined) return undefined;
|
|
48
|
+
return `@font-face{font-family:${cssString(family)};src:url("${src}") format("woff2");font-weight:${face.weight};font-style:${face.style};font-display:swap${range}}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Every `@font-face` rule of one font variable, whether a page uses it or not. */
|
|
52
|
+
export function fontFaceRules(font: Pick<FontVariable, "family" | "faces">): string[] {
|
|
53
|
+
const family = font.family;
|
|
54
|
+
if (!family || !FONT_FAMILY_NAME.test(family)) return [];
|
|
55
|
+
const rules = (font.faces ?? []).flatMap((face) => faceRule(family, face) ?? []);
|
|
56
|
+
return [...new Set(rules)];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* W-1072: the `@font-face` rules of the font variables `sheet` uses (`var(--emvb-f-<id>)`), so a
|
|
61
|
+
* page downloads only the fonts it shows. Empty when no used variable has custom faces, so every
|
|
62
|
+
* existing design keeps the exact CSS it had.
|
|
63
|
+
*/
|
|
64
|
+
export function fontFaceCss(fonts: readonly FontVariable[] | undefined, sheet: string): string {
|
|
65
|
+
const rules = (fonts ?? []).flatMap((font) => {
|
|
66
|
+
const name = fontVariableName(font.id);
|
|
67
|
+
if (!name || !font.faces?.length) return [];
|
|
68
|
+
if (!sheet.includes(`var(${name})`) && !sheet.includes(`var(${name},`)) return [];
|
|
69
|
+
return fontFaceRules(font);
|
|
70
|
+
});
|
|
71
|
+
return [...new Set(rules)].join("");
|
|
72
|
+
}
|
package/src/core/css/generate.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cssTypeName } from "../schema/layout.ts";
|
|
2
2
|
import { MARK_CSS } from "../text-marks.ts";
|
|
3
|
+
import { fontFaceCss } from "./font-face.ts";
|
|
3
4
|
import { DEFAULT_FLUID_RANGE, fluidClamp } from "../design/tokens.ts";
|
|
4
5
|
import type { FluidRange, LengthVariable } from "../schema/design.ts";
|
|
5
6
|
import type { DesignSystem } from "../schema/design.ts";
|
|
@@ -20,7 +21,12 @@ import {
|
|
|
20
21
|
} from "../sanitize/css.ts";
|
|
21
22
|
import { STYLE_STATES, type StyleStateName } from "../schema/state-names.ts";
|
|
22
23
|
import { DEVICE_MEDIA, type Device, type EditorDevice } from "../theme/popup-rules.ts";
|
|
23
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
LOOP_KEYFRAMES,
|
|
26
|
+
MOTION_KEYFRAMES,
|
|
27
|
+
STICKY_KEYFRAMES,
|
|
28
|
+
usesSticky,
|
|
29
|
+
} from "../sanitize/motion.ts";
|
|
24
30
|
|
|
25
31
|
export type CssInput = {
|
|
26
32
|
design: DesignSystem;
|
|
@@ -113,7 +119,12 @@ function tagDefaultCss(
|
|
|
113
119
|
if (!style) continue;
|
|
114
120
|
// W-670: tracked like classes, so a tag default's entrance gets its keyframes and turns off
|
|
115
121
|
// for reduced motion.
|
|
116
|
-
|
|
122
|
+
// W-1090 (#30): a Button with a URL renders as `<a>`, and the `button` default reaches it
|
|
123
|
+
// too, at the same tag weight and after the `a` default. Link elements are not Buttons.
|
|
124
|
+
const selector =
|
|
125
|
+
tag === "button"
|
|
126
|
+
? ":where(.emvb-root) button,:where(.emvb-root) a:where(.emvb-button)"
|
|
127
|
+
: `:where(.emvb-root) ${tag}`;
|
|
117
128
|
css += block(selector, track(selector, styleDeclarations(style).declarations));
|
|
118
129
|
}
|
|
119
130
|
return css;
|
|
@@ -145,6 +156,25 @@ function declare<T extends { id: string }>(
|
|
|
145
156
|
});
|
|
146
157
|
}
|
|
147
158
|
|
|
159
|
+
/**
|
|
160
|
+
* W-1067: colour variables' dark values. They apply when the visitor's system prefers dark and no
|
|
161
|
+
* Theme toggle chose light, and whenever it chose dark; the toggle marks `<html>` with
|
|
162
|
+
* `data-emvb-theme`. Written as `.emvb-root:is([…] *)` so the sheet's scope prefix still matches.
|
|
163
|
+
*/
|
|
164
|
+
function darkCss(colors: DesignSystem["variables"]["colors"]): string {
|
|
165
|
+
const dark = declare(
|
|
166
|
+
colors.filter((color) => color.dark !== undefined),
|
|
167
|
+
colorVariableName,
|
|
168
|
+
(color) => safe(color.dark ?? ""),
|
|
169
|
+
);
|
|
170
|
+
if (dark.length === 0) return "";
|
|
171
|
+
const declarations = [...dark, { property: "color-scheme", value: "dark" }];
|
|
172
|
+
return (
|
|
173
|
+
`@media (prefers-color-scheme: dark){${block('.emvb-root:not(:is([data-emvb-theme="light"] *))', declarations)}}` +
|
|
174
|
+
block('.emvb-root:is([data-emvb-theme="dark"] *)', declarations)
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
148
178
|
/** W-319: declarations that play scroll motion. */
|
|
149
179
|
const usesMotion = (declarations: readonly Declaration[]) =>
|
|
150
180
|
declarations.some((d) => d.property === "animation" && /\bemvb-m[otsrb]\b/.test(d.value));
|
|
@@ -199,6 +229,8 @@ export function generateCss({
|
|
|
199
229
|
let motion = false;
|
|
200
230
|
/** W-938: any loop on the page, so its keyframes are sent. */
|
|
201
231
|
let loops = false;
|
|
232
|
+
/** W-1070: any sticky effect, so its keyframes are sent. */
|
|
233
|
+
let sticky = false;
|
|
202
234
|
const rules = (selector: string, declarations: Declaration[], states: StateDeclarations) => [
|
|
203
235
|
block(selector, declarations),
|
|
204
236
|
...STYLE_STATES.map((state) =>
|
|
@@ -215,6 +247,7 @@ export function generateCss({
|
|
|
215
247
|
if (declarations.some((d) => d.property === "animation")) entrances.push(selector);
|
|
216
248
|
if (usesMotion(declarations)) motion = true;
|
|
217
249
|
if (usesLoop(declarations)) loops = true;
|
|
250
|
+
if (usesSticky(declarations)) sticky = true;
|
|
218
251
|
return declarations;
|
|
219
252
|
};
|
|
220
253
|
const classes = (design.classes ?? []).flatMap((cls) => {
|
|
@@ -338,6 +371,7 @@ export function generateCss({
|
|
|
338
371
|
const devices = [rule.wide ?? [], rule.laptop, rule.tablet, rule.mobile];
|
|
339
372
|
if (devices.some(usesMotion)) motion = true;
|
|
340
373
|
if (devices.some(usesLoop)) loops = true;
|
|
374
|
+
if (devices.some(usesSticky)) sticky = true;
|
|
341
375
|
if (
|
|
342
376
|
!entrances.includes(rule.selector) &&
|
|
343
377
|
devices.flat().some((d) => d.property === "animation")
|
|
@@ -353,6 +387,7 @@ export function generateCss({
|
|
|
353
387
|
const selector = `.emvb-e-${rule.id}`;
|
|
354
388
|
if (usesMotion(query)) motion = true;
|
|
355
389
|
if (usesLoop(query)) loops = true;
|
|
390
|
+
if (usesSticky(query)) sticky = true;
|
|
356
391
|
if (!entrances.includes(selector) && query.some((d) => d.property === "animation")) {
|
|
357
392
|
entrances.push(selector);
|
|
358
393
|
}
|
|
@@ -366,7 +401,9 @@ export function generateCss({
|
|
|
366
401
|
: "",
|
|
367
402
|
entrances.length > 0 && motion ? MOTION_KEYFRAMES : "",
|
|
368
403
|
entrances.length > 0 && loops ? LOOP_KEYFRAMES : "",
|
|
404
|
+
entrances.length > 0 && sticky ? STICKY_KEYFRAMES : "",
|
|
369
405
|
block(".emvb-root", variables),
|
|
406
|
+
darkCss(colors),
|
|
370
407
|
defaultsCss,
|
|
371
408
|
backgroundVideo
|
|
372
409
|
? ".emvb-has-bg-video{position:relative;overflow:hidden}.emvb-bg-video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;z-index:0;pointer-events:none}.emvb-has-bg-video>:not(.emvb-bg-video){position:relative;z-index:1}" +
|
|
@@ -406,6 +443,8 @@ export function generateCss({
|
|
|
406
443
|
// W-952: list marker colour and size, and numbered steps, only on pages that use them, so
|
|
407
444
|
// every page saved before them keeps the exact CSS it had.
|
|
408
445
|
return [
|
|
446
|
+
// W-1072: the custom fonts this sheet uses, first; nothing for a design without them.
|
|
447
|
+
fontFaceCss(fonts, sheet),
|
|
409
448
|
sheet,
|
|
410
449
|
sheet.includes("--emvb-marker-") ? LIST_MARKER_CSS : "",
|
|
411
450
|
listSteps ? LIST_STEPS_CSS : "",
|
package/src/core/css/trace.ts
CHANGED
|
@@ -94,6 +94,14 @@ export function styleLayers(
|
|
|
94
94
|
style: tagStyle,
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
|
+
// W-1090 (#30): a link Button gets the `button` default too, above the `a` one.
|
|
98
|
+
const buttonStyle = design.defaults?.button;
|
|
99
|
+
if (tag === "a" && node.type === "button" && buttonStyle) {
|
|
100
|
+
layers.push({
|
|
101
|
+
source: { kind: "default", label: "Site default (BUTTON)", layer: "Desktop" },
|
|
102
|
+
style: buttonStyle,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
97
105
|
const applied = new Set(node.classes ?? []);
|
|
98
106
|
const owners: Owner[] = [];
|
|
99
107
|
for (const cls of design.classes ?? []) {
|
|
@@ -95,8 +95,11 @@ function postValue(post: ThemePostFields | undefined, key: string): string | und
|
|
|
95
95
|
return scalar(fields[key]);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
/**
|
|
99
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Text with control characters removed and its length capped. W-1088: extension source values
|
|
100
|
+
* are cleaned with it too, with their own (longer) cap.
|
|
101
|
+
*/
|
|
102
|
+
export function cleanBoundText(value: string, max = MAX_BOUND_LENGTH): string {
|
|
100
103
|
let out = "";
|
|
101
104
|
for (const char of value) {
|
|
102
105
|
const code = char.codePointAt(0) ?? 0;
|
|
@@ -109,7 +112,7 @@ function clean(value: string): string {
|
|
|
109
112
|
(code >= 0x2066 && code <= 0x2069);
|
|
110
113
|
const kept = code === 9 ? " " : code === 10 || (code >= 32 && !dropped) ? char : "";
|
|
111
114
|
// W-502: cutting at a UTF-16 length split an emoji at the limit into a broken half.
|
|
112
|
-
if (out.length + kept.length >
|
|
115
|
+
if (out.length + kept.length > max) break;
|
|
113
116
|
out += kept;
|
|
114
117
|
}
|
|
115
118
|
return out.trim();
|
|
@@ -126,7 +129,7 @@ export function resolveBinding(binding: Binding, data: BindingData): string | un
|
|
|
126
129
|
data.params && Object.hasOwn(data.params, binding.key) ? data.params[binding.key] : undefined;
|
|
127
130
|
}
|
|
128
131
|
if (raw === undefined) return undefined;
|
|
129
|
-
const value =
|
|
132
|
+
const value = cleanBoundText(raw);
|
|
130
133
|
return value.length > 0 ? value : undefined;
|
|
131
134
|
}
|
|
132
135
|
|