@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
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W-1072: Google fonts, self-hosted. The server asks Google's CSS API for one family, weight and
|
|
3
|
+
* style, downloads the WOFF2 files it lists and stores them like uploads, so public pages only
|
|
4
|
+
* load the site's own URLs. Google Fonts are under the SIL Open Font License (a few under Apache
|
|
5
|
+
* 2.0 or the Ubuntu Font Licence), which allow self-hosting.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const GOOGLE_CSS_HOST = "fonts.googleapis.com";
|
|
9
|
+
export const GOOGLE_FILE_HOST = "fonts.gstatic.com";
|
|
10
|
+
|
|
11
|
+
/** Google family names: Latin letters, digits and single spaces ("Open Sans", "Noto Sans JP"). */
|
|
12
|
+
export const GOOGLE_FAMILY = /^[A-Za-z0-9](?:[A-Za-z0-9]| (?=[A-Za-z0-9])){0,59}$/;
|
|
13
|
+
|
|
14
|
+
/** Subset labels as the CSS API writes them in its comments ("latin-ext", "[12]"). */
|
|
15
|
+
export const GOOGLE_SUBSET = /^(?:[a-z0-9-]{1,30}|\[\d{1,3}\])$/;
|
|
16
|
+
|
|
17
|
+
/** The subsets a new import downloads unless the editor picks others. */
|
|
18
|
+
export const DEFAULT_GOOGLE_SUBSETS = ["latin", "latin-ext"] as const;
|
|
19
|
+
|
|
20
|
+
/** The most files one weight and style may bring (one per subset). */
|
|
21
|
+
export const GOOGLE_FILES_PER_FACE = 12;
|
|
22
|
+
|
|
23
|
+
export const GOOGLE_WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900] as const;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A modern browser's User-Agent: the CSS API picks the file format from it, and only answers
|
|
27
|
+
* WOFF2 to browsers it knows support it.
|
|
28
|
+
*/
|
|
29
|
+
export const GOOGLE_USER_AGENT =
|
|
30
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";
|
|
31
|
+
|
|
32
|
+
/** The CSS API URL for one family, weight and style. */
|
|
33
|
+
export function googleCssUrl(family: string, weight: number, style: "normal" | "italic"): string {
|
|
34
|
+
const name = family.replace(/ /g, "+");
|
|
35
|
+
const axes = style === "italic" ? `ital,wght@1,${weight}` : `wght@${weight}`;
|
|
36
|
+
return `https://${GOOGLE_CSS_HOST}/css2?family=${name}:${axes}&display=swap`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type GoogleFace = {
|
|
40
|
+
style: "normal" | "italic";
|
|
41
|
+
weight: number;
|
|
42
|
+
/** A fonts.gstatic.com HTTPS URL. */
|
|
43
|
+
url: string;
|
|
44
|
+
unicodeRange?: string;
|
|
45
|
+
/** The subset label from the comment before the rule, when there is one. */
|
|
46
|
+
subset?: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** A font file URL on fonts.gstatic.com over HTTPS, with no credentials or port, or undefined. */
|
|
50
|
+
export function googleFileUrl(raw: string): string | undefined {
|
|
51
|
+
let url: URL;
|
|
52
|
+
try {
|
|
53
|
+
url = new URL(raw);
|
|
54
|
+
} catch {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
if (url.protocol !== "https:" || url.hostname !== GOOGLE_FILE_HOST) return undefined;
|
|
58
|
+
if (url.port || url.username || url.password) return undefined;
|
|
59
|
+
return url.href;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const UNICODE_RANGE_VALUE =
|
|
63
|
+
/^U\+[0-9A-Fa-f?]{1,6}(?:-[0-9A-Fa-f]{1,6})?(?:, ?U\+[0-9A-Fa-f?]{1,6}(?:-[0-9A-Fa-f]{1,6})?)*$/;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The WOFF2 faces in a CSS API answer. Rules that don't read as expected (another format, another
|
|
67
|
+
* host, a weight range) are skipped, never guessed at.
|
|
68
|
+
*/
|
|
69
|
+
export function parseGoogleFontCss(css: string): GoogleFace[] {
|
|
70
|
+
const faces: GoogleFace[] = [];
|
|
71
|
+
const rule = /(?:\/\*\s*([^*]{1,40}?)\s*\*\/\s*)?@font-face\s*\{([^{}]{1,2000})\}/g;
|
|
72
|
+
for (const match of css.matchAll(rule)) {
|
|
73
|
+
const label = match[1]?.trim();
|
|
74
|
+
const body = match[2] ?? "";
|
|
75
|
+
const style = /(?:^|;)\s*font-style:\s*(normal|italic)\s*(?:;|$)/.exec(body)?.[1];
|
|
76
|
+
const weight = /(?:^|;)\s*font-weight:\s*(\d{1,4})\s*(?:;|$)/.exec(body)?.[1];
|
|
77
|
+
const src =
|
|
78
|
+
/(?:^|;)\s*src:\s*url\(([^()\s'"]{1,500})\)\s*format\(['"]woff2['"]\)\s*(?:;|$)/.exec(
|
|
79
|
+
body,
|
|
80
|
+
)?.[1];
|
|
81
|
+
const range = /(?:^|;)\s*unicode-range:\s*([^;]{1,1000}?)\s*(?:;|$)/.exec(body)?.[1];
|
|
82
|
+
if (!style || !weight || !src) continue;
|
|
83
|
+
const url = googleFileUrl(src);
|
|
84
|
+
const n = Number(weight);
|
|
85
|
+
if (!url || n < 1 || n > 1000) continue;
|
|
86
|
+
if (range !== undefined && !UNICODE_RANGE_VALUE.test(range)) continue;
|
|
87
|
+
faces.push({
|
|
88
|
+
style: style === "italic" ? "italic" : "normal",
|
|
89
|
+
weight: n,
|
|
90
|
+
url,
|
|
91
|
+
...(range !== undefined ? { unicodeRange: range } : {}),
|
|
92
|
+
...(label && GOOGLE_SUBSET.test(label) ? { subset: label } : {}),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return faces;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The faces of one import: the requested weight and style, in the chosen subsets. A rule without
|
|
100
|
+
* a subset label is kept (an answer with a single file has none).
|
|
101
|
+
*/
|
|
102
|
+
export function pickGoogleFaces(
|
|
103
|
+
faces: readonly GoogleFace[],
|
|
104
|
+
wanted: { weight: number; style: "normal" | "italic"; subsets: readonly string[] },
|
|
105
|
+
): GoogleFace[] {
|
|
106
|
+
return faces.filter(
|
|
107
|
+
(face) =>
|
|
108
|
+
face.weight === wanted.weight &&
|
|
109
|
+
face.style === wanted.style &&
|
|
110
|
+
(face.subset === undefined || wanted.subsets.includes(face.subset)),
|
|
111
|
+
);
|
|
112
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A minimal byte string that passes the WOFF2 header check (tests only). */
|
|
2
|
+
export function fakeWoff2(size = 64, fill = 0): Uint8Array {
|
|
3
|
+
const bytes = new Uint8Array(size).fill(fill);
|
|
4
|
+
const view = new DataView(bytes.buffer);
|
|
5
|
+
view.setUint32(0, 0x774f4632);
|
|
6
|
+
view.setUint32(4, 0x00010000);
|
|
7
|
+
view.setUint32(8, size);
|
|
8
|
+
return bytes;
|
|
9
|
+
}
|
|
@@ -63,6 +63,33 @@ export type ImportOptions = {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
/** W-1026: one link of a site menu, with the links under it. */
|
|
66
|
+
/**
|
|
67
|
+
* W-1091 (#27): an Elementor Pro form as the forms plugin would hold it, so the import can say
|
|
68
|
+
* what needs connecting and (when asked) create it: its fields in order, by page when it has
|
|
69
|
+
* steps, with their Elementor types, and its messages. `nodeId` is the EmVB Form it became.
|
|
70
|
+
*/
|
|
71
|
+
export type ImportedFormField = {
|
|
72
|
+
name: string;
|
|
73
|
+
label: string;
|
|
74
|
+
/** A forms-plugin field type: text, email, tel, url, number, date, textarea, select, radio, checkbox. */
|
|
75
|
+
type: string;
|
|
76
|
+
required: boolean;
|
|
77
|
+
placeholder?: string;
|
|
78
|
+
options?: { label: string; value: string }[];
|
|
79
|
+
min?: number;
|
|
80
|
+
max?: number;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type ImportedForm = {
|
|
84
|
+
nodeId: string;
|
|
85
|
+
name: string;
|
|
86
|
+
pages: { title?: string; fields: ImportedFormField[] }[];
|
|
87
|
+
submitLabel: string;
|
|
88
|
+
successMessage?: string;
|
|
89
|
+
nextLabel?: string;
|
|
90
|
+
prevLabel?: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
66
93
|
export type MenuLink = {
|
|
67
94
|
text: string;
|
|
68
95
|
href?: string;
|
|
@@ -87,6 +114,8 @@ const DEFAULT_TYPOGRAPHY: Record<string, GlobalTypography> = {
|
|
|
87
114
|
|
|
88
115
|
/** Old-site images listed for copying; an export with more lists the first ones. */
|
|
89
116
|
const MAX_IMAGES = 300;
|
|
117
|
+
/** The longest old-site address (`https://old.example/blog`) looked for before `/wp-content/`. */
|
|
118
|
+
const MAX_SITE_URL = 512;
|
|
90
119
|
|
|
91
120
|
/** Notes kept per import; the rest are counted into one line. */
|
|
92
121
|
const MAX_NOTES = 300;
|
|
@@ -110,6 +139,8 @@ export class ImportContext {
|
|
|
110
139
|
readonly menuOf: ImportOptions["menu"];
|
|
111
140
|
/** W-1026: the menu names the export's Nav Menus point at, so the dialog can fetch them. */
|
|
112
141
|
readonly menus = new Set<string>();
|
|
142
|
+
/** W-1091 (#27): the Elementor forms imported, to connect or create in the forms plugin. */
|
|
143
|
+
readonly forms: ImportedForm[] = [];
|
|
113
144
|
/** W-958: Elementor class id → its EmVB class, or undefined when it can't be one. */
|
|
114
145
|
readonly imported = new Map<string, ImportedClass | undefined>();
|
|
115
146
|
readonly useClasses: boolean;
|
|
@@ -213,16 +244,23 @@ export class ImportContext {
|
|
|
213
244
|
*/
|
|
214
245
|
findOldSite(text: string): void {
|
|
215
246
|
const found = new Map<string, URL>();
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
247
|
+
// W-1074: only the text just before each `/wp-content/` is searched, so input full of
|
|
248
|
+
// addresses that never reach one (`http://http://…`) reads in linear time, not quadratic.
|
|
249
|
+
const marker = "/wp-content/";
|
|
250
|
+
let at = 0;
|
|
251
|
+
for (let hits = 0; hits < 200 && found.size < 5; hits++) {
|
|
252
|
+
const hit = text.indexOf(marker, at);
|
|
253
|
+
if (hit === -1) break;
|
|
254
|
+
at = hit + marker.length;
|
|
255
|
+
const window = text.slice(Math.max(0, hit - MAX_SITE_URL), hit + marker.length);
|
|
256
|
+
const match = /https?:\/\/[^"'<>\s/\\]+(?:\/[^"'<>/\\]*)*?(?=\/wp-content\/$)/i.exec(window);
|
|
257
|
+
if (!match) continue;
|
|
219
258
|
try {
|
|
220
259
|
const url = new URL(match[0]);
|
|
221
260
|
found.set(url.href.toLowerCase(), url);
|
|
222
261
|
} catch {
|
|
223
262
|
// Not an address: ignore it.
|
|
224
263
|
}
|
|
225
|
-
if (found.size >= 5) break;
|
|
226
264
|
}
|
|
227
265
|
this.oldSites = [...found.values()];
|
|
228
266
|
}
|
|
@@ -13,7 +13,13 @@ import { atomicElement } from "./atomic.ts";
|
|
|
13
13
|
import { readSnapshots } from "./snapshots.ts";
|
|
14
14
|
import { customCss, wordRules } from "./css.ts";
|
|
15
15
|
import { type CounterItem, counterItems, counterOf } from "./counter-steps.ts";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
ImportContext,
|
|
18
|
+
type ImportedForm,
|
|
19
|
+
type ImportNote,
|
|
20
|
+
type ImportOptions,
|
|
21
|
+
type StyleClass,
|
|
22
|
+
} from "./context.ts";
|
|
17
23
|
import {
|
|
18
24
|
boxReader,
|
|
19
25
|
deviceStyles,
|
|
@@ -39,7 +45,7 @@ import {
|
|
|
39
45
|
WIDGETS,
|
|
40
46
|
} from "./widgets.ts";
|
|
41
47
|
|
|
42
|
-
export type { ImportNote, ImportOptions } from "./context.ts";
|
|
48
|
+
export type { ImportedForm, ImportedFormField, ImportNote, ImportOptions } from "./context.ts";
|
|
43
49
|
|
|
44
50
|
/** Pasted or uploaded JSON larger than this is refused before parsing. */
|
|
45
51
|
export const MAX_IMPORT_CHARS = 8 * 1024 * 1024;
|
|
@@ -73,6 +79,11 @@ export type ElementorImport =
|
|
|
73
79
|
menus: string[];
|
|
74
80
|
/** W-958: images on the old site the page uses (`media` gives their library copies). */
|
|
75
81
|
images: string[];
|
|
82
|
+
/**
|
|
83
|
+
* W-1091 (#27): the Elementor forms the page has, each an EmVB Form (`nodeId`) that needs
|
|
84
|
+
* connecting to a forms-plugin form: their fields, types and messages, to list or create.
|
|
85
|
+
*/
|
|
86
|
+
forms: ImportedForm[];
|
|
76
87
|
/** W-958: with `classes`, the EmVB classes the page's elements point at, to add to the site. */
|
|
77
88
|
classes: StyleClass[];
|
|
78
89
|
}
|
|
@@ -911,32 +922,53 @@ export function importElementor(input: unknown, options: ImportOptions = {}): El
|
|
|
911
922
|
});
|
|
912
923
|
if (pageStyle.devices) root["devices"] = pageStyle.devices;
|
|
913
924
|
if (options.media) pointAtCopies(root, ctx);
|
|
925
|
+
const checked = validImport(root, ctx);
|
|
926
|
+
if (!checked.ok) return checked;
|
|
927
|
+
const partType = source.type ? PART_TYPES[source.type] : undefined;
|
|
928
|
+
return {
|
|
929
|
+
ok: true,
|
|
930
|
+
layout: checked.layout,
|
|
931
|
+
...(source.title ? { title: source.title } : {}),
|
|
932
|
+
...(partType ? { partType } : {}),
|
|
933
|
+
elements: ctx.elements,
|
|
934
|
+
mapped: ctx.mapped,
|
|
935
|
+
notes: ctx.report(),
|
|
936
|
+
fonts: [...ctx.fonts].toSorted(),
|
|
937
|
+
svgFiles: [...ctx.svgFiles],
|
|
938
|
+
pageLinks: [...ctx.pageLinks].toSorted((a, b) => a - b),
|
|
939
|
+
menus: [...ctx.menus].toSorted(),
|
|
940
|
+
images: [...ctx.images],
|
|
941
|
+
forms: ctx.forms.filter((f) => hasNode(checked.layout.root, f.nodeId)),
|
|
942
|
+
classes: usedClasses(checked.layout, ctx).map((cls) =>
|
|
943
|
+
options.media ? (pointAtCopies(structuredClone(cls), ctx) as StyleClass) : cls,
|
|
944
|
+
),
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/** Whether the layout still holds the node (pruning may have dropped it). */
|
|
949
|
+
function hasNode(tree: { id: string; children?: unknown }, id: string): boolean {
|
|
950
|
+
if (tree.id === id) return true;
|
|
951
|
+
return (
|
|
952
|
+
Array.isArray(tree.children) &&
|
|
953
|
+
tree.children.some((child) => hasNode(child as { id: string; children?: unknown }, id))
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* The imported tree as a layout EmVB accepts: whatever validation or the nesting rules refuse is
|
|
959
|
+
* pruned (and noted) until it passes. Shared with the HTML import (W-1074).
|
|
960
|
+
*/
|
|
961
|
+
export function validImport(
|
|
962
|
+
root: N,
|
|
963
|
+
ctx: ImportContext,
|
|
964
|
+
): { ok: true; layout: Layout } | { ok: false; error: string } {
|
|
914
965
|
const candidate: Record<string, unknown> = { schemaVersion: LAYOUT_SCHEMA_VERSION, root };
|
|
915
966
|
const tried = new Set<string>();
|
|
916
967
|
for (let attempt = 0; attempt < 500; attempt++) {
|
|
917
968
|
const checked = validateLayout(candidate);
|
|
918
969
|
// The save hook also refuses misplaced elements (a field outside a form, …): prune those too.
|
|
919
970
|
const misplaced = checked.ok ? nestingIssues(checked.layout, 1)[0] : undefined;
|
|
920
|
-
if (checked.ok && !misplaced) {
|
|
921
|
-
const partType = source.type ? PART_TYPES[source.type] : undefined;
|
|
922
|
-
return {
|
|
923
|
-
ok: true,
|
|
924
|
-
layout: checked.layout,
|
|
925
|
-
...(source.title ? { title: source.title } : {}),
|
|
926
|
-
...(partType ? { partType } : {}),
|
|
927
|
-
elements: ctx.elements,
|
|
928
|
-
mapped: ctx.mapped,
|
|
929
|
-
notes: ctx.report(),
|
|
930
|
-
fonts: [...ctx.fonts].toSorted(),
|
|
931
|
-
svgFiles: [...ctx.svgFiles],
|
|
932
|
-
pageLinks: [...ctx.pageLinks].toSorted((a, b) => a - b),
|
|
933
|
-
menus: [...ctx.menus].toSorted(),
|
|
934
|
-
images: [...ctx.images],
|
|
935
|
-
classes: usedClasses(checked.layout, ctx).map((cls) =>
|
|
936
|
-
options.media ? (pointAtCopies(structuredClone(cls), ctx) as StyleClass) : cls,
|
|
937
|
-
),
|
|
938
|
-
};
|
|
939
|
-
}
|
|
971
|
+
if (checked.ok && !misplaced) return { ok: true, layout: checked.layout };
|
|
940
972
|
const issue = checked.ok ? misplaced : checked.issues[0];
|
|
941
973
|
if (!issue || !prune(root, issue, ctx, tried)) {
|
|
942
974
|
return {
|
|
@@ -952,7 +984,7 @@ export function importElementor(input: unknown, options: ImportOptions = {}): El
|
|
|
952
984
|
* W-958: points every use of an old-site image at its media library copy: image sources (which
|
|
953
985
|
* also get the library id), backgrounds and any other stored address equal to it.
|
|
954
986
|
*/
|
|
955
|
-
function pointAtCopies(value: unknown, ctx: ImportContext): unknown {
|
|
987
|
+
export function pointAtCopies(value: unknown, ctx: ImportContext): unknown {
|
|
956
988
|
if (typeof value === "string")
|
|
957
989
|
return /^https?:\/\//i.test(value) ? (ctx.copied(value)?.url ?? value) : value;
|
|
958
990
|
if (Array.isArray(value)) {
|
|
@@ -5,10 +5,16 @@
|
|
|
5
5
|
* EmVB's sanitizers before it lands in a node.
|
|
6
6
|
*/
|
|
7
7
|
import { MAX_TABS, MAX_TEXT_LENGTH } from "../../limits.ts";
|
|
8
|
-
import { FIELD_NAME_PATTERN, ICON_SVG_MAX } from "../../schema/layout.ts";
|
|
8
|
+
import { FIELD_NAME_PATTERN, ICON_SVG_MAX, MAX_INPUT_NUMBER } from "../../schema/layout.ts";
|
|
9
9
|
import { sanitizeHref } from "../../sanitize/href.ts";
|
|
10
10
|
import { sanitizeMediaUrl } from "../../sanitize/media-url.ts";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
type ImportContext,
|
|
13
|
+
type ImportedForm,
|
|
14
|
+
type ImportedFormField,
|
|
15
|
+
type MenuLink,
|
|
16
|
+
svgFileId,
|
|
17
|
+
} from "./context.ts";
|
|
12
18
|
import {
|
|
13
19
|
type Block,
|
|
14
20
|
cleanText,
|
|
@@ -992,6 +998,24 @@ const testimonial: Widget = (s, ctx, el) => {
|
|
|
992
998
|
];
|
|
993
999
|
};
|
|
994
1000
|
|
|
1001
|
+
/**
|
|
1002
|
+
* W-1073: Elementor Pro's Search Form becomes EmVB's, sending `?q=` to the site's /search page
|
|
1003
|
+
* (WordPress's `?s=` doesn't apply on EmDash). The icon-only button and the full-screen skin
|
|
1004
|
+
* become a field and a text button.
|
|
1005
|
+
*/
|
|
1006
|
+
const searchForm: Widget = (s, ctx, el) => {
|
|
1007
|
+
const placeholder = plain(s["placeholder"]).text;
|
|
1008
|
+
const buttonText = plain(s["button_text"]).text;
|
|
1009
|
+
if (s["skin"] === "full_screen" || s["button_type"] === "icon")
|
|
1010
|
+
ctx.note("approximated", el, "Search forms show a field and a Search button.");
|
|
1011
|
+
return [
|
|
1012
|
+
node(ctx, "search-form", {
|
|
1013
|
+
...(placeholder ? { placeholder: placeholder.slice(0, 120) } : {}),
|
|
1014
|
+
...(buttonText && s["button_type"] !== "icon" ? { buttonText: buttonText.slice(0, 40) } : {}),
|
|
1015
|
+
}),
|
|
1016
|
+
];
|
|
1017
|
+
};
|
|
1018
|
+
|
|
995
1019
|
/** W-1023: Elementor's Star Rating → a Rating, with its title as text beside it. */
|
|
996
1020
|
const starRating: Widget = (s, ctx, el) => {
|
|
997
1021
|
const scale = Math.min(10, Math.max(1, Math.round(num(s["rating_scale"]) ?? 5)));
|
|
@@ -1472,44 +1496,231 @@ const FIELD_TYPES: Record<string, string> = {
|
|
|
1472
1496
|
acceptance: "checkbox",
|
|
1473
1497
|
};
|
|
1474
1498
|
|
|
1499
|
+
/** W-1065: an Elementor date limit as YYYY-MM-DD (its date picker also allows "today"). */
|
|
1500
|
+
const ELEMENTOR_DATE = /^[1-9]\d{3}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/;
|
|
1501
|
+
const isoDate = (value: unknown) => {
|
|
1502
|
+
const text = str(value)?.trim() ?? "";
|
|
1503
|
+
if (!ELEMENTOR_DATE.test(text)) return undefined;
|
|
1504
|
+
const [y, m, d] = text.split("-").map(Number) as [number, number, number];
|
|
1505
|
+
const day = new Date(Date.UTC(y, m - 1, d));
|
|
1506
|
+
return day.getUTCMonth() === m - 1 && day.getUTCDate() === d ? text : undefined;
|
|
1507
|
+
};
|
|
1508
|
+
const inputNumber = (value: unknown) => {
|
|
1509
|
+
const n = num(value);
|
|
1510
|
+
return n !== undefined && Math.abs(n) <= MAX_INPUT_NUMBER ? n : undefined;
|
|
1511
|
+
};
|
|
1512
|
+
|
|
1513
|
+
const defined = (props: Record<string, unknown>) =>
|
|
1514
|
+
Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined));
|
|
1515
|
+
|
|
1516
|
+
/** W-1065: a number or date field's own box and limits. */
|
|
1517
|
+
function typedField(type: string, raw: Settings): Record<string, unknown> {
|
|
1518
|
+
if (type === "number") {
|
|
1519
|
+
const min = inputNumber(raw["field_min"]);
|
|
1520
|
+
const max = inputNumber(raw["field_max"]);
|
|
1521
|
+
const range = min !== undefined && max !== undefined && min > max ? {} : { min, max };
|
|
1522
|
+
return defined({ inputType: "number", ...range });
|
|
1523
|
+
}
|
|
1524
|
+
if (type === "date") {
|
|
1525
|
+
const minDate = isoDate(raw["min_date"]);
|
|
1526
|
+
const maxDate = isoDate(raw["max_date"]);
|
|
1527
|
+
const range = minDate && maxDate && minDate > maxDate ? {} : { minDate, maxDate };
|
|
1528
|
+
return defined({ inputType: "date", ...range });
|
|
1529
|
+
}
|
|
1530
|
+
return {};
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
const MAX_FORM_STEPS = 20;
|
|
1534
|
+
|
|
1535
|
+
/** W-1091 (#27): the forms plugin's field type for an Elementor field type. */
|
|
1536
|
+
const PLUGIN_FIELD_TYPES: Record<string, string> = {
|
|
1537
|
+
text: "text",
|
|
1538
|
+
email: "email",
|
|
1539
|
+
url: "url",
|
|
1540
|
+
tel: "tel",
|
|
1541
|
+
number: "number",
|
|
1542
|
+
date: "date",
|
|
1543
|
+
time: "text",
|
|
1544
|
+
password: "text",
|
|
1545
|
+
textarea: "textarea",
|
|
1546
|
+
select: "select",
|
|
1547
|
+
radio: "radio",
|
|
1548
|
+
checkbox: "checkbox",
|
|
1549
|
+
acceptance: "checkbox",
|
|
1550
|
+
};
|
|
1551
|
+
|
|
1552
|
+
/**
|
|
1553
|
+
* W-1091 (#27): a field name the forms plugin accepts (a letter, then letters, digits, `_`, `-`):
|
|
1554
|
+
* Elementor's own id when it has one, cleaned up, else the label's words, else the field type.
|
|
1555
|
+
* Each name is used once per form; a repeat gets `_2`, `_3`.
|
|
1556
|
+
*/
|
|
1557
|
+
function formFieldName(
|
|
1558
|
+
candidates: readonly { text: string | undefined; lower?: boolean }[],
|
|
1559
|
+
taken: ReadonlySet<string>,
|
|
1560
|
+
fallback: string,
|
|
1561
|
+
): string {
|
|
1562
|
+
let base = "";
|
|
1563
|
+
for (const { text, lower } of candidates) {
|
|
1564
|
+
const clean = (text ?? "")
|
|
1565
|
+
.normalize("NFKD")
|
|
1566
|
+
.replaceAll(/[\u0300-\u036f]/g, "")
|
|
1567
|
+
.trim()
|
|
1568
|
+
.replaceAll(/[^a-zA-Z0-9_-]+/g, "_")
|
|
1569
|
+
.replace(/^[^a-zA-Z]+/, "")
|
|
1570
|
+
.replace(/[_-]+$/, "")
|
|
1571
|
+
.slice(0, 72);
|
|
1572
|
+
if (clean && FIELD_NAME_PATTERN.test(clean)) {
|
|
1573
|
+
base = lower ? clean.toLowerCase() : clean;
|
|
1574
|
+
break;
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
base ||= fallback;
|
|
1578
|
+
let name = base;
|
|
1579
|
+
for (let n = 2; taken.has(name); n++) name = `${base}_${n}`;
|
|
1580
|
+
return name;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
/** W-1091 (#27): Elementor's `field_options` lines ("Label" or "Label|value") as options. */
|
|
1584
|
+
function formOptions(value: unknown): { label: string; value: string }[] {
|
|
1585
|
+
const options: { label: string; value: string }[] = [];
|
|
1586
|
+
const seen = new Set<string>();
|
|
1587
|
+
for (const line of (str(value) ?? "").split(/\r?\n/).slice(0, 100)) {
|
|
1588
|
+
const [rawLabel = "", rawValue] = line.split("|");
|
|
1589
|
+
const label = plain(rawLabel).text.trim().slice(0, 200);
|
|
1590
|
+
const option = (rawValue === undefined ? label : plain(rawValue).text.trim()).slice(0, 200);
|
|
1591
|
+
if (!label || !option || seen.has(option)) continue;
|
|
1592
|
+
seen.add(option);
|
|
1593
|
+
options.push({ label, value: option });
|
|
1594
|
+
}
|
|
1595
|
+
return options;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
const isOn = (value: unknown) => value === true || value === "true" || value === "yes";
|
|
1599
|
+
|
|
1475
1600
|
const form: Widget = (s, ctx, el) => {
|
|
1476
1601
|
const fields = Array.isArray(s["form_fields"]) ? s["form_fields"].slice(0, 100) : [];
|
|
1477
|
-
const
|
|
1602
|
+
const loose: N[] = [];
|
|
1603
|
+
const steps: { title: string; children: N[] }[] = [];
|
|
1604
|
+
// W-1091 (#27): the same fields as the forms plugin holds them, page by page.
|
|
1605
|
+
const loosePlan: ImportedFormField[] = [];
|
|
1606
|
+
const stepPlans: ImportedFormField[][] = [];
|
|
1478
1607
|
const names = new Set<string>();
|
|
1608
|
+
let nextLabel = "";
|
|
1609
|
+
let prevLabel = "";
|
|
1610
|
+
let checkboxLists = 0;
|
|
1479
1611
|
fields.forEach((raw, i) => {
|
|
1480
1612
|
if (!isRecord(raw)) return;
|
|
1481
1613
|
const type = str(raw["field_type"]) ?? "text";
|
|
1614
|
+
// W-1065: a Step field starts a step; the fields after it, up to the next, are its fields.
|
|
1615
|
+
if (type === "step") {
|
|
1616
|
+
if (steps.length >= MAX_FORM_STEPS) return;
|
|
1617
|
+
steps.push({ title: plain(raw["field_label"]).text.slice(0, 200), children: [] });
|
|
1618
|
+
stepPlans.push([]);
|
|
1619
|
+
nextLabel ||= plain(raw["next_button"]).text.slice(0, 80);
|
|
1620
|
+
prevLabel ||= plain(raw["previous_button"]).text.slice(0, 80);
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1482
1623
|
const nodeType = FIELD_TYPES[type];
|
|
1483
1624
|
if (!nodeType) {
|
|
1484
1625
|
ctx.note("skipped", el, `Form field type "${type}" was left out.`);
|
|
1485
1626
|
return;
|
|
1486
1627
|
}
|
|
1487
|
-
let name = str(raw["custom_id"]) ?? "";
|
|
1488
|
-
if (!FIELD_NAME_PATTERN.test(name) || name.length > 80 || names.has(name))
|
|
1489
|
-
name = `field_${i + 1}`;
|
|
1490
|
-
names.add(name);
|
|
1491
1628
|
const label =
|
|
1492
1629
|
plain(raw["field_label"]).text.slice(0, 200) ||
|
|
1493
1630
|
(type === "acceptance" ? plain(raw["acceptance_text"]).text.slice(0, 200) : "");
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
...(placeholder && nodeType !== "checkbox" ? { placeholder } : {}),
|
|
1500
|
-
}),
|
|
1631
|
+
// W-1091 (#27): Elementor's field id (cleaned), else the label, so `name` and `email` stay.
|
|
1632
|
+
const name = formFieldName(
|
|
1633
|
+
[{ text: str(raw["custom_id"]) }, { text: label, lower: true }, { text: type }],
|
|
1634
|
+
names,
|
|
1635
|
+
`field_${i + 1}`,
|
|
1501
1636
|
);
|
|
1637
|
+
names.add(name);
|
|
1638
|
+
const placeholder = plain(raw["placeholder"]).text.slice(0, 200);
|
|
1639
|
+
const field = node(ctx, nodeType, {
|
|
1640
|
+
field: name,
|
|
1641
|
+
...(label ? { label } : {}),
|
|
1642
|
+
...(placeholder && nodeType !== "checkbox" ? { placeholder } : {}),
|
|
1643
|
+
...typedField(type, raw),
|
|
1644
|
+
});
|
|
1645
|
+
const options =
|
|
1646
|
+
nodeType === "select" || nodeType === "radio" ? formOptions(raw["field_options"]) : [];
|
|
1647
|
+
if (type === "checkbox" && formOptions(raw["field_options"]).length > 1) checkboxLists += 1;
|
|
1648
|
+
const typed = typedField(type, raw) as { min?: number; max?: number };
|
|
1649
|
+
const planned: ImportedFormField = {
|
|
1650
|
+
name,
|
|
1651
|
+
label: label || name,
|
|
1652
|
+
type: PLUGIN_FIELD_TYPES[type] ?? "text",
|
|
1653
|
+
required: isOn(raw["required"]) || type === "acceptance",
|
|
1654
|
+
...(placeholder && nodeType !== "checkbox" ? { placeholder } : {}),
|
|
1655
|
+
...(options.length > 0 ? { options } : {}),
|
|
1656
|
+
...(typed.min !== undefined ? { min: typed.min } : {}),
|
|
1657
|
+
...(typed.max !== undefined ? { max: typed.max } : {}),
|
|
1658
|
+
};
|
|
1659
|
+
const step = steps[steps.length - 1];
|
|
1660
|
+
if (step) {
|
|
1661
|
+
step.children.push(field);
|
|
1662
|
+
stepPlans[stepPlans.length - 1]?.push(planned);
|
|
1663
|
+
} else {
|
|
1664
|
+
loose.push(field);
|
|
1665
|
+
loosePlan.push(planned);
|
|
1666
|
+
}
|
|
1502
1667
|
});
|
|
1668
|
+
// Fields before the first Step field are a step of their own, as Elementor shows them.
|
|
1669
|
+
if (steps.length > 0 && loose.length > 0) {
|
|
1670
|
+
steps.unshift({ title: "", children: loose.splice(0) });
|
|
1671
|
+
stepPlans.unshift(loosePlan.splice(0));
|
|
1672
|
+
}
|
|
1673
|
+
const children: N[] = [
|
|
1674
|
+
...loose,
|
|
1675
|
+
...steps.map((step) =>
|
|
1676
|
+
node(ctx, "form-step", step.title ? { title: step.title } : {}, { children: step.children }),
|
|
1677
|
+
),
|
|
1678
|
+
];
|
|
1503
1679
|
const label = plain(s["button_text"]).text.slice(0, 80) || "Send";
|
|
1504
1680
|
children.push(node(ctx, "submit", { label }));
|
|
1505
1681
|
ctx.note(
|
|
1506
1682
|
"approximated",
|
|
1507
1683
|
el,
|
|
1508
|
-
"
|
|
1684
|
+
"Each form needs connecting to an EmDash form before it shows on your site; the import can create it in EmDash Forms. Email actions weren't imported.",
|
|
1509
1685
|
);
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1686
|
+
if (checkboxLists > 0) {
|
|
1687
|
+
ctx.note("approximated", el, "A checkbox list became one checkbox; its options weren't kept.");
|
|
1688
|
+
}
|
|
1689
|
+
if (steps.length > 0) {
|
|
1690
|
+
ctx.note(
|
|
1691
|
+
"approximated",
|
|
1692
|
+
el,
|
|
1693
|
+
'Form steps became EmVB form steps; one Next and one Previous label serve every step, and the step indicator is EmDash\'s "Step 1 of 3".',
|
|
1694
|
+
);
|
|
1695
|
+
}
|
|
1696
|
+
const labels = {
|
|
1697
|
+
...(steps.length > 0 && nextLabel ? { nextLabel } : {}),
|
|
1698
|
+
...(steps.length > 0 && prevLabel ? { prevLabel } : {}),
|
|
1699
|
+
};
|
|
1700
|
+
const built = node(
|
|
1701
|
+
ctx,
|
|
1702
|
+
"form",
|
|
1703
|
+
{ formId: "", ...labels },
|
|
1704
|
+
{ style: { gap: { value: 10, unit: "px" } }, children },
|
|
1705
|
+
);
|
|
1706
|
+
const successMessage = plain(s["success_message"]).text.trim().slice(0, 500);
|
|
1707
|
+
const plan: ImportedForm = {
|
|
1708
|
+
nodeId: built.id,
|
|
1709
|
+
name: plain(s["form_name"]).text.trim().slice(0, 200) || "Imported form",
|
|
1710
|
+
pages:
|
|
1711
|
+
steps.length > 0
|
|
1712
|
+
? steps.map((step, i) =>
|
|
1713
|
+
step.title
|
|
1714
|
+
? { title: step.title, fields: stepPlans[i] ?? [] }
|
|
1715
|
+
: { fields: stepPlans[i] ?? [] },
|
|
1716
|
+
)
|
|
1717
|
+
: [{ fields: loosePlan }],
|
|
1718
|
+
submitLabel: label,
|
|
1719
|
+
...(successMessage ? { successMessage } : {}),
|
|
1720
|
+
...labels,
|
|
1721
|
+
};
|
|
1722
|
+
if (ctx.forms.length < 50) ctx.forms.push(plan);
|
|
1723
|
+
return [built];
|
|
1513
1724
|
};
|
|
1514
1725
|
|
|
1515
1726
|
/** W-1026: a site menu's links as Menu items (three levels, as the Menu shows). */
|
|
@@ -1554,11 +1765,18 @@ const navMenu: Widget = (s, ctx, el) => {
|
|
|
1554
1765
|
];
|
|
1555
1766
|
};
|
|
1556
1767
|
|
|
1768
|
+
/**
|
|
1769
|
+
* Elementor's Mega Menu → a Menu whose items hold their dropdown content. W-1069: Elementor's
|
|
1770
|
+
* dropdowns span the menu unless Content width is Fit to content, so those panels are wide. The
|
|
1771
|
+
* content stays in the item (Elementor keeps it in the widget, not in a shared template), so it
|
|
1772
|
+
* isn't turned into a Section theme part.
|
|
1773
|
+
*/
|
|
1557
1774
|
const megaMenu: Widget = (s, ctx, _el, env, raw) => {
|
|
1558
1775
|
const items = (Array.isArray(s["menu_items"]) ? s["menu_items"] : [])
|
|
1559
1776
|
.filter(isRecord)
|
|
1560
1777
|
.slice(0, 50);
|
|
1561
1778
|
const kids = Array.isArray(raw["elements"]) ? raw["elements"] : [];
|
|
1779
|
+
const wide = str(s["content_width"]) !== "fit_to_content";
|
|
1562
1780
|
const children = items.map((item, i) => {
|
|
1563
1781
|
const text = plain(item["item_title"]).text || "Item";
|
|
1564
1782
|
const panel =
|
|
@@ -1568,7 +1786,11 @@ const megaMenu: Widget = (s, ctx, _el, env, raw) => {
|
|
|
1568
1786
|
return node(
|
|
1569
1787
|
ctx,
|
|
1570
1788
|
"menu-item",
|
|
1571
|
-
{
|
|
1789
|
+
{
|
|
1790
|
+
text: short(text),
|
|
1791
|
+
...href(item["item_link"], ctx),
|
|
1792
|
+
...(wide && panel.length > 0 ? { wide: true } : {}),
|
|
1793
|
+
},
|
|
1572
1794
|
{ children: panel },
|
|
1573
1795
|
);
|
|
1574
1796
|
});
|
|
@@ -2185,7 +2407,7 @@ export const WIDGETS: Record<string, Widget> = {
|
|
|
2185
2407
|
sidebar: skip("WordPress sidebars weren't imported."),
|
|
2186
2408
|
countdown,
|
|
2187
2409
|
"share-buttons": shareButtons,
|
|
2188
|
-
"search-form":
|
|
2410
|
+
"search-form": searchForm,
|
|
2189
2411
|
login: skip("Login forms weren't imported."),
|
|
2190
2412
|
lottie: skip("Lottie animations weren't imported."),
|
|
2191
2413
|
hotspot: hotspotWidget,
|