@perkyzz/emvb 0.9.0 → 1.1.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 +10 -1
- package/package.json +2 -2
- package/src/admin/agents-api.ts +45 -0
- package/src/admin/bulk-api.ts +67 -0
- package/src/admin/content-api.ts +10 -6
- package/src/admin/copy-rich-text.ts +119 -0
- package/src/admin/dialog-tab-wrap.ts +78 -0
- package/src/admin/editor/A11yCopilot.tsx +3 -1
- package/src/admin/editor/Editor.tsx +311 -250
- package/src/admin/editor/Timeline.tsx +8 -3
- package/src/admin/editor/TopBar.tsx +29 -7
- package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
- package/src/admin/editor/canvas/DeviceBar.tsx +31 -10
- package/src/admin/editor/canvas/canvas-scale.ts +3 -3
- package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
- package/src/admin/editor/co-design.ts +190 -0
- package/src/admin/editor/dnd/new-element.ts +48 -4
- package/src/admin/editor/editor-chrome.tsx +8 -6
- package/src/admin/editor/editor-commands.ts +15 -4
- package/src/admin/editor/editor-css.ts +2 -1
- package/src/admin/editor/element-chrome.ts +3 -1
- package/src/admin/editor/extension-manifests.ts +20 -0
- package/src/admin/editor/extensions/ExtensionPanels.tsx +26 -0
- package/src/admin/editor/extensions-context.tsx +27 -0
- package/src/admin/editor/feature-css.ts +17 -0
- package/src/admin/editor/palette-items.ts +2 -2
- package/src/admin/editor/panels/AddPanel.tsx +31 -1
- package/src/admin/editor/panels/AgentRequestBox.tsx +116 -0
- package/src/admin/editor/panels/ClassesSection.tsx +9 -6
- package/src/admin/editor/panels/CoDesignPanel.tsx +170 -0
- package/src/admin/editor/panels/ColorControl.tsx +2 -2
- package/src/admin/editor/panels/ElementPanel.tsx +68 -20
- package/src/admin/editor/panels/LanguagesSection.tsx +152 -0
- package/src/admin/editor/panels/LayersPanel.tsx +10 -6
- package/src/admin/editor/panels/LeftPanel.tsx +33 -5
- package/src/admin/editor/panels/PageSettings.tsx +4 -0
- package/src/admin/editor/panels/SettingsPanel.tsx +21 -2
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +7 -7
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +72 -15
- package/src/admin/editor/panels/settings/BackgroundFill.tsx +8 -6
- package/src/admin/editor/panels/settings/BoxControl.tsx +5 -5
- package/src/admin/editor/panels/settings/EffectsControls.tsx +183 -10
- package/src/admin/editor/panels/settings/FieldControl.tsx +9 -3
- package/src/admin/editor/panels/settings/IconControls.tsx +25 -11
- package/src/admin/editor/panels/settings/LengthRow.tsx +63 -19
- package/src/admin/editor/panels/settings/LoopControl.tsx +269 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +19 -1
- package/src/admin/editor/panels/settings/MotionControl.tsx +12 -11
- package/src/admin/editor/panels/settings/QueryStyleRows.tsx +7 -4
- package/src/admin/editor/panels/settings/StyleRow.tsx +120 -13
- package/src/admin/editor/panels/settings/TextMarksControl.tsx +247 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +2 -2
- package/src/admin/editor/panels/settings/background-mode.ts +14 -11
- package/src/admin/editor/panels/settings/box-link-name.ts +1 -1
- package/src/admin/editor/panels/settings/box-sides.ts +22 -14
- package/src/admin/editor/panels/settings/heading-warning.ts +5 -1
- package/src/admin/editor/panels/settings/length-units.ts +68 -4
- package/src/admin/editor/panels/settings/query-style.ts +3 -3
- package/src/admin/editor/panels/settings/style-sections.ts +52 -10
- package/src/admin/editor/panels/style-target.ts +22 -7
- package/src/admin/editor/presence.ts +60 -0
- package/src/admin/editor/section-templates.ts +26 -4
- package/src/admin/editor/store.ts +14 -4
- package/src/admin/editor/useCoDesign.ts +177 -0
- package/src/admin/editor/useEditorCommands.ts +7 -5
- package/src/admin/editor/useExtensions.ts +45 -0
- package/src/admin/editor/useNodeActions.ts +18 -7
- package/src/admin/editor/useProposals.ts +81 -0
- package/src/admin/export-api.ts +221 -0
- package/src/admin/index.tsx +6 -1
- package/src/admin/languages-api.ts +61 -0
- package/src/admin/pages/AgentSetup.tsx +148 -0
- package/src/admin/pages/AgentsPage.tsx +9 -26
- package/src/admin/pages/CreateDialog.tsx +15 -0
- package/src/admin/pages/ExportDialog.tsx +395 -0
- package/src/admin/pages/ImportButton.tsx +18 -0
- package/src/admin/pages/ImportElementorDialog.tsx +669 -0
- package/src/admin/pages/ImportPageLinks.tsx +86 -0
- package/src/admin/pages/PageList.tsx +82 -3
- package/src/admin/pages/ThemePartList.tsx +52 -2
- package/src/admin/pages/bulk.tsx +303 -0
- package/src/admin/pages/section-head.tsx +27 -0
- package/src/admin/proposals-api.ts +91 -0
- package/src/admin/search.ts +20 -0
- package/src/admin/theme-api.ts +4 -0
- package/src/admin/ui.ts +50 -4
- package/src/admin/widgets/CanvasField.tsx +8 -0
- package/src/admin/widgets/ConvertToRichText.tsx +136 -0
- package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
- package/src/admin/widgets/convert-body.ts +73 -2
- package/src/astro/content-port.ts +14 -1
- package/src/astro/render.ts +6 -6
- package/src/astro/resolve-theme.ts +25 -8
- package/src/astro/resolve.ts +89 -2
- package/src/astro/tabs/runtime.ts +16 -6
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +45 -14
- package/src/core/arrange.ts +5 -1
- package/src/core/bounded-array.ts +31 -0
- package/src/core/clipboard.ts +9 -0
- package/src/core/contract.ts +305 -0
- package/src/core/css/generate.ts +151 -20
- package/src/core/css/scope.ts +10 -2
- package/src/core/css/trace.ts +47 -13
- package/src/core/css-keywords.ts +51 -1
- package/src/core/design/cascade.ts +12 -9
- package/src/core/design/classes.ts +28 -9
- package/src/core/design/devices.ts +89 -13
- package/src/core/design/states.ts +5 -3
- package/src/core/design/transfer.ts +5 -0
- package/src/core/design/variables.ts +31 -5
- package/src/core/elements/dynamic-elements.ts +3 -3
- package/src/core/elements/index.ts +73 -9
- package/src/core/export/runtimes.generated.ts +9 -0
- package/src/core/export/site.ts +562 -0
- package/src/core/export/zip.ts +95 -0
- package/src/core/extensions/define.ts +13 -0
- package/src/core/extensions/index.ts +41 -0
- package/src/core/extensions/namespace.ts +82 -0
- package/src/core/extensions/normalize.ts +141 -0
- package/src/core/extensions/placeholder.ts +41 -0
- package/src/core/extensions/registry.ts +94 -0
- package/src/core/extensions/render-ext.ts +118 -0
- package/src/core/extensions/safe-nodes.ts +93 -0
- package/src/core/extensions/schema.ts +112 -0
- package/src/core/extensions/types.ts +159 -0
- package/src/core/forms/binding.ts +1 -1
- package/src/core/history/diff.ts +26 -1
- package/src/core/import/elementor/atomic.ts +1608 -0
- package/src/core/import/elementor/classes.ts +127 -0
- package/src/core/import/elementor/context.ts +429 -0
- package/src/core/import/elementor/counter-steps.ts +72 -0
- package/src/core/import/elementor/css.ts +445 -0
- package/src/core/import/elementor/html.ts +500 -0
- package/src/core/import/elementor/index.ts +967 -0
- package/src/core/import/elementor/inline-marks.ts +81 -0
- package/src/core/import/elementor/snapshots.ts +48 -0
- package/src/core/import/elementor/style.ts +429 -0
- package/src/core/import/elementor/values.ts +241 -0
- package/src/core/import/elementor/widgets.ts +1897 -0
- package/src/core/index.ts +96 -0
- package/src/core/json-schema.ts +114 -0
- package/src/core/limits.ts +19 -0
- package/src/core/migrate/index.ts +6 -1
- package/src/core/migrate/v18.ts +222 -0
- package/src/core/perf/meter.ts +42 -24
- package/src/core/portable-text-export.ts +243 -0
- package/src/core/proposals-safety.ts +102 -0
- package/src/core/proposals.ts +357 -0
- package/src/core/public-attributes.ts +30 -0
- package/src/core/recipes/index.ts +2 -2
- package/src/core/render/extras.ts +3 -3
- package/src/core/render/index.ts +222 -23
- package/src/core/render/loop.ts +1 -1
- package/src/core/render/section.ts +4 -4
- package/src/core/render/tabs.ts +18 -11
- package/src/core/render/vnode.ts +1 -1
- package/src/core/sanitize/css.ts +151 -10
- package/src/core/sanitize/motion.ts +116 -0
- package/src/core/saved-sections.ts +6 -0
- package/src/core/schema/descriptors.ts +3 -1
- package/src/core/schema/design.ts +4 -3
- package/src/core/schema/layout.ts +92 -16
- package/src/core/schema/style.ts +296 -112
- package/src/core/search-text.ts +70 -0
- package/src/core/text-marks.ts +227 -0
- package/src/core/theme/dynamic.ts +9 -4
- package/src/core/theme/float.ts +2 -0
- package/src/core/theme/popup-rules.ts +33 -1
- package/src/core/translatable.ts +34 -0
- package/src/core/validate.ts +13 -1
- package/src/index.ts +24 -0
- package/src/mcp/errors.ts +3 -1
- package/src/mcp/ports.ts +67 -0
- package/src/mcp/prompts.ts +1 -11
- package/src/mcp/proposals.ts +281 -0
- package/src/mcp/read.ts +10 -10
- package/src/mcp/tools.ts +71 -3
- package/src/mcp/write.ts +66 -11
- package/src/server/agent-settings.ts +5 -1
- package/src/server/icon-routes.ts +52 -12
- package/src/server/mcp-routes.ts +15 -0
- package/src/server/plugin.ts +35 -2
- package/src/server/presence.ts +78 -0
- package/src/server/proposals.ts +261 -0
- package/src/server/requests.ts +196 -0
- package/src/server/tools-served.ts +45 -0
package/src/core/render/index.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
import { renderableDesign, renderableDynamic, renderableLayout } from "../contract.ts";
|
|
2
|
+
import { markColors } from "../text-marks.ts";
|
|
3
|
+
import type { TextMark } from "../schema/layout.ts";
|
|
4
|
+
import { LIST_MARKERS } from "../css-keywords.ts";
|
|
1
5
|
import { MAX_NODES } from "../limits.ts";
|
|
2
6
|
import { loneAbTests, variantShows } from "../audience/variants.ts";
|
|
3
7
|
import { audienceShows, audienceSummary } from "../audience/rules.ts";
|
|
4
|
-
import { generateCss } from "../css/generate.ts";
|
|
8
|
+
import { baseRulesFor, generateCss } from "../css/generate.ts";
|
|
5
9
|
import { printCss } from "../css/print.ts";
|
|
6
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
cssScopeToken,
|
|
12
|
+
scopeClassName,
|
|
13
|
+
scopeCss,
|
|
14
|
+
scopeCssAll,
|
|
15
|
+
scopeWrapperCss,
|
|
16
|
+
} from "../css/scope.ts";
|
|
7
17
|
import { ELEMENTS } from "../elements/index.ts";
|
|
8
18
|
import { controlId } from "../elements/field-id.ts";
|
|
9
19
|
import { layoutHasForm } from "../forms/binding.ts";
|
|
@@ -17,6 +27,7 @@ import {
|
|
|
17
27
|
isParentNode,
|
|
18
28
|
isSectionNode,
|
|
19
29
|
isTabsNode,
|
|
30
|
+
cssTypeName,
|
|
20
31
|
type Layout,
|
|
21
32
|
type LayoutNode,
|
|
22
33
|
type PaginationNode,
|
|
@@ -32,9 +43,11 @@ import {
|
|
|
32
43
|
} from "../sanitize/css.ts";
|
|
33
44
|
import { STYLE_STATES } from "../schema/state-names.ts";
|
|
34
45
|
import { resolveEmbedUrl } from "../sanitize/embed-url.ts";
|
|
46
|
+
import { sanitizeHref } from "../sanitize/href.ts";
|
|
35
47
|
import { resolvePostForRender, type ThemeDynamicData } from "../theme/dynamic.ts";
|
|
36
48
|
import type { FormDefinitions } from "../forms/definition.ts";
|
|
37
|
-
import type
|
|
49
|
+
import { DEVICES, type Device, type EditorDevice } from "../theme/popup-rules.ts";
|
|
50
|
+
import { hiddenOnEveryDevice } from "../design/devices.ts";
|
|
38
51
|
import type { RenderContext, RenderMode } from "./context.ts";
|
|
39
52
|
import { isDynamicPostNode, renderDynamicPost } from "./dynamic-post.ts";
|
|
40
53
|
import { renderForm, withFieldOptions } from "./form.ts";
|
|
@@ -43,6 +56,11 @@ import { renderPagination } from "./pagination.ts";
|
|
|
43
56
|
import { renderSection } from "./section.ts";
|
|
44
57
|
import { renderTabs } from "./tabs.ts";
|
|
45
58
|
import { serialize, type VNode } from "./vnode.ts";
|
|
59
|
+
import {
|
|
60
|
+
isExtensionType,
|
|
61
|
+
renderExtensionNode,
|
|
62
|
+
EXTENSION_PLACEHOLDER_CSS,
|
|
63
|
+
} from "../extensions/index.ts";
|
|
46
64
|
import { classStylesInListOrder, resolveCascade } from "../design/cascade.ts";
|
|
47
65
|
import { applyBindings, hasBindings, type BindingData } from "../data/bindings.ts";
|
|
48
66
|
import {
|
|
@@ -71,6 +89,8 @@ export type RenderResult = {
|
|
|
71
89
|
/** The site's text direction when set in Site styles, for the host's `<html dir>` (W-230). */
|
|
72
90
|
dir?: "ltr" | "rtl" | "auto";
|
|
73
91
|
warnings: RenderWarning[];
|
|
92
|
+
/** W-971: the element types whose base rules this sheet holds (see `sharedPartCss`). */
|
|
93
|
+
baseTypes: string[];
|
|
74
94
|
};
|
|
75
95
|
|
|
76
96
|
const ID = /^[A-Za-z0-9_-]{4,24}$/;
|
|
@@ -85,6 +105,8 @@ function focalPercent(value: unknown, fallback: number): number | undefined {
|
|
|
85
105
|
return value;
|
|
86
106
|
}
|
|
87
107
|
|
|
108
|
+
const LIST_MARKER_SET: ReadonlySet<string> = new Set(LIST_MARKERS);
|
|
109
|
+
|
|
88
110
|
/** `object-position` only when both axes are whole percentages. A string here would break the sheet. */
|
|
89
111
|
function objectPosition(x: unknown, y: unknown): string | undefined {
|
|
90
112
|
if (x === undefined && y === undefined) return undefined;
|
|
@@ -193,9 +215,47 @@ function renameIds(vnode: VNode, base: string, next: string): VNode {
|
|
|
193
215
|
/** Elements synced sections may add to one render, all copies together (W-653): 20 full pages. */
|
|
194
216
|
const MAX_SECTION_ELEMENTS = 20 * MAX_NODES;
|
|
195
217
|
|
|
218
|
+
const baseCss = new Map(Object.entries(ELEMENTS).map(([type, def]) => [type, def.baseCss]));
|
|
219
|
+
// W-927: placeholder + wrapper styles ship with every page that may hold an extension node.
|
|
220
|
+
baseCss.set("ext", EXTENSION_PLACEHOLDER_CSS);
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* W-971: theme parts on one page (header, footer, popups, floats) each repeated the scope wrapper
|
|
224
|
+
* rule, the print rules and the base rules of their element types. Given their sheets (each the
|
|
225
|
+
* `css` of a scoped `renderPage`), this writes the wrapper and the union of base rules once, scoped
|
|
226
|
+
* to every part, then each part's own rules, then the print rules once. Base rules have no
|
|
227
|
+
* specificity of their own beyond their element class and came before every class and local rule
|
|
228
|
+
* in each sheet, so writing them first keeps the cascade.
|
|
229
|
+
*/
|
|
230
|
+
export function sharedPartCss(
|
|
231
|
+
sheets: readonly { css: string; scope: string; baseTypes: readonly string[] }[],
|
|
232
|
+
): string {
|
|
233
|
+
const scopes = sheets.flatMap((s) => {
|
|
234
|
+
const token = cssScopeToken(s.scope);
|
|
235
|
+
return token ? [token] : [];
|
|
236
|
+
});
|
|
237
|
+
if (scopes.length !== sheets.length || sheets.length < 2)
|
|
238
|
+
return sheets.map((s) => s.css).join("\n");
|
|
239
|
+
const wrapper = scopeWrapperCss();
|
|
240
|
+
const print = printCss();
|
|
241
|
+
const own: string[] = [];
|
|
242
|
+
for (const sheet of sheets) {
|
|
243
|
+
const token = cssScopeToken(sheet.scope) as string;
|
|
244
|
+
const base = scopeCss(baseRulesFor(sheet.baseTypes, baseCss), token);
|
|
245
|
+
let css = sheet.css;
|
|
246
|
+
if (!css.startsWith(wrapper) || !css.endsWith(print) || (base && !css.includes(base)))
|
|
247
|
+
return sheets.map((s) => s.css).join("\n");
|
|
248
|
+
css = css.slice(wrapper.length, css.length - print.length);
|
|
249
|
+
own.push(base ? css.replace(base, "") : css);
|
|
250
|
+
}
|
|
251
|
+
const union = new Set(sheets.flatMap((s) => s.baseTypes));
|
|
252
|
+
const shared = scopeCssAll(baseRulesFor(union, baseCss), scopes);
|
|
253
|
+
return [wrapper + shared, ...own, print].filter(Boolean).join("\n");
|
|
254
|
+
}
|
|
255
|
+
|
|
196
256
|
export function renderPage(
|
|
197
|
-
|
|
198
|
-
|
|
257
|
+
storedLayout: Layout,
|
|
258
|
+
storedDesign: DesignSystem,
|
|
199
259
|
opts: {
|
|
200
260
|
mode?: RenderMode;
|
|
201
261
|
formDefinitions?: FormDefinitions;
|
|
@@ -203,7 +263,7 @@ export function renderPage(
|
|
|
203
263
|
/** Public renders: wrap the markup and scope the CSS to it, so sheets can't override each other (W-112). */
|
|
204
264
|
scope?: string;
|
|
205
265
|
/** Editor canvas: device rules follow this device, not the frame width (W-116). */
|
|
206
|
-
previewDevice?:
|
|
266
|
+
previewDevice?: EditorDevice;
|
|
207
267
|
/**
|
|
208
268
|
* Theme parts (header, footer, popup, float) render apart from the page, so a synced section
|
|
209
269
|
* on both gave form fields, honeypots and tab groups the same ids: a label in a popup focused
|
|
@@ -215,13 +275,20 @@ export function renderPage(
|
|
|
215
275
|
} = {},
|
|
216
276
|
): RenderResult {
|
|
217
277
|
const mode = opts.mode ?? "public";
|
|
218
|
-
|
|
278
|
+
// W-925: the renderer reads the 0.x flat style shape and known keys only (D-065), so keys a
|
|
279
|
+
// newer 1.x wrote are never rendered and the output matches 0.x byte for byte.
|
|
280
|
+
const layout = renderableLayout(storedLayout);
|
|
281
|
+
const design = renderableDesign(storedDesign);
|
|
282
|
+
const baseDynamic = renderableDynamic(opts.dynamic);
|
|
219
283
|
const warnings: RenderWarning[] = [];
|
|
220
284
|
const usedTypes = new Set<string>();
|
|
221
285
|
const localRules: {
|
|
222
286
|
id: string;
|
|
223
287
|
declarations: Declaration[];
|
|
224
288
|
states: StateDeclarations;
|
|
289
|
+
wide?: Declaration[];
|
|
290
|
+
wideHidden?: boolean;
|
|
291
|
+
laptop?: Declaration[];
|
|
225
292
|
tablet?: Declaration[];
|
|
226
293
|
mobile?: Declaration[];
|
|
227
294
|
hiddenOn?: LayoutNode["hiddenOn"];
|
|
@@ -248,6 +315,8 @@ export function renderPage(
|
|
|
248
315
|
const tocNodes: { node: LayoutNode; vnode: VNode }[] = [];
|
|
249
316
|
const knownVariables = new Set(design.variables.colors.map((c) => c.id));
|
|
250
317
|
let backgroundVideo = false;
|
|
318
|
+
/** W-952: any List drawn as numbered steps, so their rules are sent. */
|
|
319
|
+
let listSteps = false;
|
|
251
320
|
|
|
252
321
|
const domIds = new Map<string, number>();
|
|
253
322
|
const idSuffix = opts.partIds && opts.scope ? `-t${originHash(opts.scope)}` : "";
|
|
@@ -291,7 +360,7 @@ export function renderPage(
|
|
|
291
360
|
nodeId: string,
|
|
292
361
|
ruleId: string | undefined,
|
|
293
362
|
): Record<string, string> => {
|
|
294
|
-
const classes = [...(isRoot ? ["emvb-root"] : []), `emvb-${node.type}`];
|
|
363
|
+
const classes = [...(isRoot ? ["emvb-root"] : []), `emvb-${cssTypeName(node.type)}`];
|
|
295
364
|
for (const classId of node.classes ?? []) {
|
|
296
365
|
const name = styleClassName(classId);
|
|
297
366
|
if (name) classes.push(name);
|
|
@@ -327,12 +396,29 @@ export function renderPage(
|
|
|
327
396
|
const { declarations, rejected } = styleDeclarations(own);
|
|
328
397
|
// W-210: a device that sets one background layer keeps the layers it inherits.
|
|
329
398
|
const base = { ...classLayers, ...own };
|
|
399
|
+
// W-956: Laptop between Desktop and Tablet; each narrower device inherits the wider ones.
|
|
400
|
+
const laptopStyle = node.devices?.laptop;
|
|
401
|
+
const laptop = styleDeclarations(withInheritedLayers(laptopStyle, base));
|
|
330
402
|
const tabletStyle = node.devices?.tablet;
|
|
331
|
-
const tablet = styleDeclarations(withInheritedLayers(tabletStyle, base));
|
|
403
|
+
const tablet = styleDeclarations(withInheritedLayers(tabletStyle, { ...base, ...laptopStyle }));
|
|
332
404
|
const mobile = styleDeclarations(
|
|
333
|
-
withInheritedLayers(node.devices?.mobile, { ...base, ...tabletStyle }),
|
|
405
|
+
withInheritedLayers(node.devices?.mobile, { ...base, ...laptopStyle, ...tabletStyle }),
|
|
334
406
|
);
|
|
335
|
-
|
|
407
|
+
// W-959: Wide screen (2400 px and up) builds on Desktop; `renderableNode` moved `style.wide`
|
|
408
|
+
// here. The narrower devices never overlap it, so they don't inherit it.
|
|
409
|
+
const { devices: wideDevices, wideHidden } = node as {
|
|
410
|
+
devices?: { wide?: unknown };
|
|
411
|
+
wideHidden?: boolean;
|
|
412
|
+
};
|
|
413
|
+
const wideStyle = wideDevices?.wide;
|
|
414
|
+
const wide = styleDeclarations(withInheritedLayers(wideStyle, base));
|
|
415
|
+
for (const key of [
|
|
416
|
+
...rejected,
|
|
417
|
+
...wide.rejected,
|
|
418
|
+
...laptop.rejected,
|
|
419
|
+
...tablet.rejected,
|
|
420
|
+
...mobile.rejected,
|
|
421
|
+
]) {
|
|
336
422
|
warnings.push({ nodeId, code: "rejected-style", detail: key });
|
|
337
423
|
}
|
|
338
424
|
if (node.type === "spacer") {
|
|
@@ -371,6 +457,20 @@ export function renderPage(
|
|
|
371
457
|
declarations.push({ property: "object-fit", value: "cover" });
|
|
372
458
|
}
|
|
373
459
|
}
|
|
460
|
+
if (node.type === "heading" || node.type === "text") {
|
|
461
|
+
// W-950: each mark colour as a variable its words read.
|
|
462
|
+
markColors((node.props as { marks?: TextMark[] }).marks).forEach((color, n) =>
|
|
463
|
+
declarations.push({ property: `--emvb-mark-${n}`, value: color }),
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
if (node.type === "list") {
|
|
467
|
+
// W-952: the marker style; items inherit it. Steps draw their own numbers.
|
|
468
|
+
const marker = (node.props as { marker?: unknown }).marker;
|
|
469
|
+
if (marker === "steps") listSteps = true;
|
|
470
|
+
else if (typeof marker === "string" && LIST_MARKER_SET.has(marker)) {
|
|
471
|
+
declarations.push({ property: "list-style-type", value: marker });
|
|
472
|
+
}
|
|
473
|
+
}
|
|
374
474
|
if (node.type === "button") {
|
|
375
475
|
const gap = (node.props as { iconGap?: unknown }).iconGap;
|
|
376
476
|
if (typeof gap === "number" && Number.isInteger(gap) && gap >= 0 && gap <= 64) {
|
|
@@ -396,10 +496,14 @@ export function renderPage(
|
|
|
396
496
|
}
|
|
397
497
|
const grid = gridOf.get(node.id);
|
|
398
498
|
if (grid) {
|
|
399
|
-
|
|
400
|
-
const
|
|
499
|
+
// A grid's laptop columns are its desktop ones (column counts have no laptop value).
|
|
500
|
+
const [desktopCount, tabletCount, mobileCount] = gridColumnCounts(grid);
|
|
501
|
+
const counts = [desktopCount, desktopCount, tabletCount, mobileCount];
|
|
502
|
+
const laptopPlacement = { ...node.style, ...node.devices?.laptop };
|
|
503
|
+
const tabletPlacement = { ...laptopPlacement, ...node.devices?.tablet };
|
|
401
504
|
const levels = [
|
|
402
505
|
node.style ?? {},
|
|
506
|
+
laptopPlacement,
|
|
403
507
|
tabletPlacement,
|
|
404
508
|
{ ...tabletPlacement, ...node.devices?.mobile },
|
|
405
509
|
];
|
|
@@ -410,8 +514,29 @@ export function renderPage(
|
|
|
410
514
|
const at = (i: number) => ({ property: "grid-column", value: fitted[i]?.value ?? "auto" });
|
|
411
515
|
const kept = declarations.filter((d) => d.property !== "grid-column");
|
|
412
516
|
declarations.splice(0, declarations.length, ...kept, at(0));
|
|
413
|
-
|
|
414
|
-
|
|
517
|
+
// On laptop only when it differs from desktop or the laptop style places it itself
|
|
518
|
+
// (released pages, which have no laptop styles, keep their CSS).
|
|
519
|
+
const ownLaptop = laptop.declarations.some((d) => d.property === "grid-column");
|
|
520
|
+
if (ownLaptop || fitted[1]?.value !== fitted[0]?.value) {
|
|
521
|
+
const others = laptop.declarations.filter((d) => d.property !== "grid-column");
|
|
522
|
+
laptop.declarations.splice(0, laptop.declarations.length, ...others, at(1));
|
|
523
|
+
}
|
|
524
|
+
tablet.declarations.push(at(2));
|
|
525
|
+
mobile.declarations.push(at(3));
|
|
526
|
+
}
|
|
527
|
+
// W-959: a Wide screen placement of its own, on the Desktop column count.
|
|
528
|
+
const wideOwn = wideStyle as { gridColumnStart?: unknown; gridColumnSpan?: unknown };
|
|
529
|
+
if (
|
|
530
|
+
wideOwn &&
|
|
531
|
+
(wideOwn.gridColumnStart !== undefined || wideOwn.gridColumnSpan !== undefined)
|
|
532
|
+
) {
|
|
533
|
+
const place = { ...node.style, ...wideOwn } as typeof node.style & object;
|
|
534
|
+
const fit = fitGridColumn(place.gridColumnStart, place.gridColumnSpan, desktopCount);
|
|
535
|
+
const others = wide.declarations.filter((d) => d.property !== "grid-column");
|
|
536
|
+
wide.declarations.splice(0, wide.declarations.length, ...others, {
|
|
537
|
+
property: "grid-column",
|
|
538
|
+
value: fit.value ?? "auto",
|
|
539
|
+
});
|
|
415
540
|
}
|
|
416
541
|
}
|
|
417
542
|
const states = stateDeclarations(node.states);
|
|
@@ -426,6 +551,9 @@ export function renderPage(
|
|
|
426
551
|
// W-567: the root is the page itself; hiding it on a device blanked the whole page there.
|
|
427
552
|
const hiddenOn = isRoot ? undefined : node.hiddenOn;
|
|
428
553
|
const responsive =
|
|
554
|
+
wide.declarations.length > 0 ||
|
|
555
|
+
(!isRoot && wideHidden !== undefined) ||
|
|
556
|
+
laptop.declarations.length > 0 ||
|
|
429
557
|
tablet.declarations.length > 0 ||
|
|
430
558
|
mobile.declarations.length > 0 ||
|
|
431
559
|
(hiddenOn?.length ?? 0) > 0;
|
|
@@ -443,6 +571,9 @@ export function renderPage(
|
|
|
443
571
|
id: ruleId,
|
|
444
572
|
declarations,
|
|
445
573
|
states: states.states,
|
|
574
|
+
...(wide.declarations.length > 0 ? { wide: wide.declarations } : {}),
|
|
575
|
+
...(!isRoot && wideHidden !== undefined ? { wideHidden } : {}),
|
|
576
|
+
laptop: laptop.declarations,
|
|
446
577
|
tablet: tablet.declarations,
|
|
447
578
|
mobile: mobile.declarations,
|
|
448
579
|
hiddenOn,
|
|
@@ -490,6 +621,15 @@ export function renderPage(
|
|
|
490
621
|
const nodeId = id ?? "(invalid id)";
|
|
491
622
|
const type: string = node.type;
|
|
492
623
|
if (!Object.hasOwn(ELEMENTS, type)) {
|
|
624
|
+
// W-927: extension elements render via the Extensions API, or a placeholder when missing.
|
|
625
|
+
if (isExtensionType(type)) {
|
|
626
|
+
usedTypes.add("ext");
|
|
627
|
+
return renderExtensionNode(node, mode === "editor" ? "editor" : "public", (nodes) =>
|
|
628
|
+
nodes
|
|
629
|
+
.map((child) => visit(child, false, dynamic))
|
|
630
|
+
.filter((child): child is VNode => child !== undefined),
|
|
631
|
+
);
|
|
632
|
+
}
|
|
493
633
|
warnings.push({ nodeId, code: "unknown-type", detail: type });
|
|
494
634
|
if (mode === "public") return undefined;
|
|
495
635
|
return {
|
|
@@ -532,6 +672,12 @@ export function renderPage(
|
|
|
532
672
|
);
|
|
533
673
|
}
|
|
534
674
|
if (isTabsNode(node)) return finish(node, renderTabs(node, id, attrs, ctx, dynamic));
|
|
675
|
+
if (node.type === "language-switcher") {
|
|
676
|
+
const links = languageLinks(dynamic?.translations, mode);
|
|
677
|
+
// W-937: a page in one language has nothing to switch to; the public page shows nothing.
|
|
678
|
+
if (!links) return undefined;
|
|
679
|
+
return finish(node, { ...def.build(node as never, attrs, []), children: [links] });
|
|
680
|
+
}
|
|
535
681
|
if (node.type === "toc") {
|
|
536
682
|
const built = def.build(node as never, attrs, []);
|
|
537
683
|
const vnode = { ...built, children: [] as (VNode | string)[] };
|
|
@@ -541,9 +687,7 @@ export function renderPage(
|
|
|
541
687
|
if (node.type === "heading" && pageHeadings?.has(stored) && attrs.id) {
|
|
542
688
|
const text = String((node.props as { text?: unknown }).text ?? "").trim();
|
|
543
689
|
// W-409: a heading hidden on every device has nothing to jump to.
|
|
544
|
-
const hiddenEverywhere = (
|
|
545
|
-
node.hiddenOn?.includes(device),
|
|
546
|
-
);
|
|
690
|
+
const hiddenEverywhere = hiddenOnEveryDevice(node);
|
|
547
691
|
if (text && !hiddenEverywhere && !renderedHeadings.some((h) => h.id === attrs.id)) {
|
|
548
692
|
// W-793: a heading hidden on some devices (itself or an ancestor) hides its contents
|
|
549
693
|
// entry there too, or the entry was a dead link on those devices.
|
|
@@ -622,7 +766,6 @@ export function renderPage(
|
|
|
622
766
|
toc.vnode.children = [];
|
|
623
767
|
}
|
|
624
768
|
}
|
|
625
|
-
const baseCss = new Map(Object.entries(ELEMENTS).map(([type, def]) => [type, def.baseCss]));
|
|
626
769
|
const css = generateCss({
|
|
627
770
|
design,
|
|
628
771
|
usedTypes,
|
|
@@ -630,6 +773,7 @@ export function renderPage(
|
|
|
630
773
|
localRules,
|
|
631
774
|
previewStates: mode === "editor",
|
|
632
775
|
backgroundVideo,
|
|
776
|
+
listSteps,
|
|
633
777
|
...(mode === "editor" && opts.previewDevice ? { previewDevice: opts.previewDevice } : {}),
|
|
634
778
|
});
|
|
635
779
|
const scope = opts.scope === undefined ? undefined : cssScopeToken(opts.scope);
|
|
@@ -646,6 +790,7 @@ export function renderPage(
|
|
|
646
790
|
needsMenuRuntime: rendered.menuDropdown || layoutHasMenuDropdown(layout),
|
|
647
791
|
...(design.direction ? { dir: design.direction } : {}),
|
|
648
792
|
warnings,
|
|
793
|
+
baseTypes: [...usedTypes],
|
|
649
794
|
};
|
|
650
795
|
}
|
|
651
796
|
|
|
@@ -658,9 +803,9 @@ function treeHasType(node: LayoutNode, type: string): boolean {
|
|
|
658
803
|
* inside an element hidden on every device, which never show, so a contents link has nothing
|
|
659
804
|
* to jump to (W-409 covered only the heading's own visibility).
|
|
660
805
|
*/
|
|
661
|
-
function headingAnchors(root: LayoutNode): { node: LayoutNode; hiddenOn:
|
|
662
|
-
const out: { node: LayoutNode; hiddenOn:
|
|
663
|
-
const walk = (node: LayoutNode, inherited:
|
|
806
|
+
function headingAnchors(root: LayoutNode): { node: LayoutNode; hiddenOn: Device[] }[] {
|
|
807
|
+
const out: { node: LayoutNode; hiddenOn: Device[] }[] = [];
|
|
808
|
+
const walk = (node: LayoutNode, inherited: Device[]) => {
|
|
664
809
|
if (node !== root && HIDDEN_DEVICES.every((device) => node.hiddenOn?.includes(device))) return;
|
|
665
810
|
const own = node === root ? [] : (node.hiddenOn ?? []);
|
|
666
811
|
const hiddenOn = HIDDEN_DEVICES.filter((d) => inherited.includes(d) || own.includes(d));
|
|
@@ -672,7 +817,7 @@ function headingAnchors(root: LayoutNode): { node: LayoutNode; hiddenOn: PopupDe
|
|
|
672
817
|
return out;
|
|
673
818
|
}
|
|
674
819
|
|
|
675
|
-
const HIDDEN_DEVICES =
|
|
820
|
+
const HIDDEN_DEVICES = DEVICES;
|
|
676
821
|
|
|
677
822
|
/** Columns set by custom tracks or a count, or undefined when neither is set. */
|
|
678
823
|
const columnCount = (tracks: unknown, columns: unknown): number | undefined =>
|
|
@@ -755,3 +900,57 @@ function tocChildren(
|
|
|
755
900
|
});
|
|
756
901
|
return children;
|
|
757
902
|
}
|
|
903
|
+
|
|
904
|
+
/** A language's own name for itself ("Français"), or its code when the runtime doesn't know it. */
|
|
905
|
+
function autonym(locale: string): string {
|
|
906
|
+
try {
|
|
907
|
+
const name = new Intl.DisplayNames([locale], { type: "language" }).of(locale);
|
|
908
|
+
return name ? name.charAt(0).toLocaleUpperCase(locale) + name.slice(1) : locale;
|
|
909
|
+
} catch {
|
|
910
|
+
return locale;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* W-937: the Language switcher's list. Hosts pass only published translations (a draft is never
|
|
916
|
+
* linked); each link carries hreflang and lang, and the page being shown is aria-current. The
|
|
917
|
+
* editor shows a note when the page has no other language yet.
|
|
918
|
+
*/
|
|
919
|
+
function languageLinks(
|
|
920
|
+
translations: readonly { locale: string; href: string; current: boolean }[] | undefined,
|
|
921
|
+
mode: RenderMode,
|
|
922
|
+
): VNode | undefined {
|
|
923
|
+
const list = (translations ?? []).filter(
|
|
924
|
+
(t) => typeof t.locale === "string" && t.locale && sanitizeHref(t.href) !== undefined,
|
|
925
|
+
);
|
|
926
|
+
if (list.length < 2) {
|
|
927
|
+
if (mode !== "editor") return undefined;
|
|
928
|
+
return {
|
|
929
|
+
tag: "p",
|
|
930
|
+
attrs: {},
|
|
931
|
+
children: [
|
|
932
|
+
"Links to this page's other languages show here once it has a published translation.",
|
|
933
|
+
],
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
return {
|
|
937
|
+
tag: "ul",
|
|
938
|
+
attrs: {},
|
|
939
|
+
children: list.map((t) => ({
|
|
940
|
+
tag: "li",
|
|
941
|
+
attrs: {},
|
|
942
|
+
children: [
|
|
943
|
+
{
|
|
944
|
+
tag: "a",
|
|
945
|
+
attrs: {
|
|
946
|
+
href: sanitizeHref(t.href) as string,
|
|
947
|
+
hreflang: t.locale,
|
|
948
|
+
lang: t.locale,
|
|
949
|
+
...(t.current ? { "aria-current": "page" } : {}),
|
|
950
|
+
},
|
|
951
|
+
children: [autonym(t.locale)],
|
|
952
|
+
},
|
|
953
|
+
],
|
|
954
|
+
})),
|
|
955
|
+
};
|
|
956
|
+
}
|
package/src/core/render/loop.ts
CHANGED
|
@@ -63,7 +63,7 @@ export function renderLoop(
|
|
|
63
63
|
dynamic: ThemeDynamicData | undefined,
|
|
64
64
|
): VNode | undefined {
|
|
65
65
|
const posts = entriesFor(node, dynamic, ctx.mode);
|
|
66
|
-
const itemPartId = node.props.
|
|
66
|
+
const itemPartId = node.props.partId?.trim() ?? "";
|
|
67
67
|
const loopStack = dynamic?.loopStack ?? [];
|
|
68
68
|
// W-654: a loop item part holding a Loop that uses the same part (or one that leads back to it)
|
|
69
69
|
// recursed until the stack overflowed and the page failed to render.
|
|
@@ -38,16 +38,16 @@ export function renderSection(
|
|
|
38
38
|
const template =
|
|
39
39
|
partId && dynamic?.sectionTemplates ? dynamic.sectionTemplates[partId] : undefined;
|
|
40
40
|
if (!partId) {
|
|
41
|
-
return ELEMENTS.
|
|
41
|
+
return ELEMENTS["part-ref"].build(node as never, attrs, ctx.children(node.children, dynamic));
|
|
42
42
|
}
|
|
43
43
|
if (!template || stack.includes(partId) || stack.length >= MAX_SECTION_DEPTH) {
|
|
44
|
-
if (ctx.mode !== "editor") return ELEMENTS.
|
|
44
|
+
if (ctx.mode !== "editor") return ELEMENTS["part-ref"].build(node as never, attrs, []);
|
|
45
45
|
return { tag: "div", attrs, children: ["Synced section"] };
|
|
46
46
|
}
|
|
47
47
|
// W-653: past the render's budget a copy renders like a missing part. W-657: the editor
|
|
48
48
|
// says why, instead of the same placeholder a deleted part shows.
|
|
49
49
|
if (ctx.takeSectionBudget && !ctx.takeSectionBudget(partSize(template.root.children))) {
|
|
50
|
-
if (ctx.mode !== "editor") return ELEMENTS.
|
|
50
|
+
if (ctx.mode !== "editor") return ELEMENTS["part-ref"].build(node as never, attrs, []);
|
|
51
51
|
return {
|
|
52
52
|
tag: "div",
|
|
53
53
|
attrs,
|
|
@@ -60,5 +60,5 @@ export function renderSection(
|
|
|
60
60
|
sectionStack: [...stack, partId],
|
|
61
61
|
idOrigin: `${dynamic?.idOrigin ?? ""}/s:${partId}`,
|
|
62
62
|
};
|
|
63
|
-
return ELEMENTS.
|
|
63
|
+
return ELEMENTS["part-ref"].build(node as never, attrs, ctx.children(templateNodes, next));
|
|
64
64
|
}
|
package/src/core/render/tabs.ts
CHANGED
|
@@ -29,19 +29,26 @@ export function renderTabs(
|
|
|
29
29
|
inputs.push({ tag: "input", attrs: inputAttrs, children: [] });
|
|
30
30
|
const panelDomId = `${group}-panel-${i}`;
|
|
31
31
|
const tabDomId = `${group}-tab-${i}`;
|
|
32
|
+
// W-975: ARIA allows no role on a <label>, so the tab is a span inside it; the label still
|
|
33
|
+
// switches the radio, which keeps the tabs working without the script.
|
|
32
34
|
labels.push({
|
|
33
35
|
tag: "label",
|
|
34
|
-
attrs: {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
attrs: { class: "emvb-tab-label", for: inputId },
|
|
37
|
+
children: [
|
|
38
|
+
{
|
|
39
|
+
tag: "span",
|
|
40
|
+
attrs: {
|
|
41
|
+
class: "emvb-tab",
|
|
42
|
+
id: tabDomId,
|
|
43
|
+
role: "tab",
|
|
44
|
+
"aria-selected": i === 0 ? "true" : "false",
|
|
45
|
+
"aria-controls": panelDomId,
|
|
46
|
+
tabindex: i === 0 ? "0" : "-1",
|
|
47
|
+
},
|
|
48
|
+
// W-664: a label of only spaces made a zero-width tab nobody could click or hear.
|
|
49
|
+
children: [panel.props.label.trim() || `Tab ${i + 1}`],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
45
52
|
});
|
|
46
53
|
// W-598: the panel renders like any element, so its own style, classes and device
|
|
47
54
|
// visibility reach the page; the tab wiring is added on top.
|
package/src/core/render/vnode.ts
CHANGED
|
@@ -78,7 +78,7 @@ const TAGS = new Set([
|
|
|
78
78
|
const VOID = new Set(["hr", "img", "input", "br"]);
|
|
79
79
|
// iframe/video are not void — they need closing tags.
|
|
80
80
|
const ATTR_NAME =
|
|
81
|
-
/^(?:class|id|href|src|srcset|sizes|alt|width|height|loading|decoding|fetchpriority|dir|role|type|checked|target|rel|aria-[a-z][a-z0-9-]*|title|allow|referrerpolicy|preload|controls|allowfullscreen|sandbox|xmlns|viewBox|fill|stroke|stroke-width|stroke-linecap|stroke-linejoin|stroke-dasharray|stroke-opacity|fill-opacity|opacity|transform|focusable|d|cx|cy|r|x|y|x1|y1|x2|y2|points|rx|ry|xlink:href|preserveAspectRatio|gradientUnits|gradientTransform|offset|stop-color|stop-opacity|clipPathUnits|maskUnits|maskContentUnits|patternUnits|patternContentUnits|patternTransform|markerUnits|markerWidth|markerHeight|refX|refY|orient|font-size|font-family|font-weight|text-anchor|dominant-baseline|dx|dy|clip-path|method|action|name|value|placeholder|for|tabindex|autocomplete|open|datetime|muted|loop|playsinline|autoplay|required|novalidate|minlength|maxlength|min|max|pattern|step|data-[a-z][a-z0-9-]*)$/;
|
|
81
|
+
/^(?:class|id|href|src|srcset|sizes|alt|width|height|loading|decoding|fetchpriority|dir|lang|hreflang|role|type|checked|target|rel|aria-[a-z][a-z0-9-]*|title|allow|referrerpolicy|preload|controls|allowfullscreen|sandbox|xmlns|viewBox|fill|stroke|stroke-width|stroke-linecap|stroke-linejoin|stroke-dasharray|stroke-opacity|fill-opacity|opacity|transform|focusable|d|cx|cy|r|x|y|x1|y1|x2|y2|points|rx|ry|xlink:href|preserveAspectRatio|gradientUnits|gradientTransform|offset|stop-color|stop-opacity|clipPathUnits|maskUnits|maskContentUnits|patternUnits|patternContentUnits|patternTransform|markerUnits|markerWidth|markerHeight|refX|refY|orient|font-size|font-family|font-weight|text-anchor|dominant-baseline|dx|dy|clip-path|method|action|name|value|placeholder|for|tabindex|autocomplete|open|datetime|muted|loop|playsinline|autoplay|required|novalidate|minlength|maxlength|min|max|pattern|step|start|data-[a-z][a-z0-9-]*)$/;
|
|
82
82
|
|
|
83
83
|
export const isAllowedTag = (tag: string) => TAGS.has(tag);
|
|
84
84
|
export const isAllowedAttr = (name: string) => ATTR_NAME.test(name);
|