@perkyzz/emvb 1.3.0 → 1.4.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 +2 -2
- package/package.json +2 -2
- package/src/admin/bulk-api.ts +5 -1
- package/src/admin/editor/A11yCopilot.tsx +3 -1
- package/src/admin/editor/Editor.tsx +22 -2
- 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/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/feature-css.ts +22 -0
- package/src/admin/editor/inert-links.ts +8 -0
- package/src/admin/editor/panels/ColorControl.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 +18 -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/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 +25 -2
- package/src/admin/extension-outputs.ts +179 -0
- package/src/admin/font-files-api.ts +38 -0
- package/src/admin/pages/ImportButton.tsx +15 -4
- package/src/admin/pages/ImportElementorDialog.tsx +22 -188
- 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/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 +19 -4
- package/src/astro/resolve-theme.ts +11 -4
- 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 +35 -1
- 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 +50 -4
- package/src/core/extensions/classes.ts +114 -0
- package/src/core/extensions/index.ts +17 -2
- package/src/core/extensions/normalize.ts +13 -0
- package/src/core/extensions/registry.ts +134 -10
- package/src/core/extensions/render-ext.ts +66 -21
- 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 +13 -4
- package/src/core/import/elementor/index.ts +32 -21
- package/src/core/import/elementor/widgets.ts +114 -12
- 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 +45 -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 +151 -15
- 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 +114 -5
- 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/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/extension-build.ts +331 -0
- package/src/index.ts +25 -3
- package/src/mcp/brief.ts +191 -0
- package/src/mcp/prompts.ts +33 -0
- package/src/mcp/read.ts +29 -1
- package/src/mcp/tools.ts +40 -1
- package/src/mcp/write.ts +41 -1
- package/src/server/extension-routes.ts +73 -0
- package/src/server/font-routes.ts +301 -0
- package/src/server/plugin.ts +9 -0
|
@@ -5,7 +5,7 @@
|
|
|
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
11
|
import { type ImportContext, type MenuLink, svgFileId } from "./context.ts";
|
|
@@ -992,6 +992,24 @@ const testimonial: Widget = (s, ctx, el) => {
|
|
|
992
992
|
];
|
|
993
993
|
};
|
|
994
994
|
|
|
995
|
+
/**
|
|
996
|
+
* W-1073: Elementor Pro's Search Form becomes EmVB's, sending `?q=` to the site's /search page
|
|
997
|
+
* (WordPress's `?s=` doesn't apply on EmDash). The icon-only button and the full-screen skin
|
|
998
|
+
* become a field and a text button.
|
|
999
|
+
*/
|
|
1000
|
+
const searchForm: Widget = (s, ctx, el) => {
|
|
1001
|
+
const placeholder = plain(s["placeholder"]).text;
|
|
1002
|
+
const buttonText = plain(s["button_text"]).text;
|
|
1003
|
+
if (s["skin"] === "full_screen" || s["button_type"] === "icon")
|
|
1004
|
+
ctx.note("approximated", el, "Search forms show a field and a Search button.");
|
|
1005
|
+
return [
|
|
1006
|
+
node(ctx, "search-form", {
|
|
1007
|
+
...(placeholder ? { placeholder: placeholder.slice(0, 120) } : {}),
|
|
1008
|
+
...(buttonText && s["button_type"] !== "icon" ? { buttonText: buttonText.slice(0, 40) } : {}),
|
|
1009
|
+
}),
|
|
1010
|
+
];
|
|
1011
|
+
};
|
|
1012
|
+
|
|
995
1013
|
/** W-1023: Elementor's Star Rating → a Rating, with its title as text beside it. */
|
|
996
1014
|
const starRating: Widget = (s, ctx, el) => {
|
|
997
1015
|
const scale = Math.min(10, Math.max(1, Math.round(num(s["rating_scale"]) ?? 5)));
|
|
@@ -1472,13 +1490,60 @@ const FIELD_TYPES: Record<string, string> = {
|
|
|
1472
1490
|
acceptance: "checkbox",
|
|
1473
1491
|
};
|
|
1474
1492
|
|
|
1493
|
+
/** W-1065: an Elementor date limit as YYYY-MM-DD (its date picker also allows "today"). */
|
|
1494
|
+
const ELEMENTOR_DATE = /^[1-9]\d{3}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/;
|
|
1495
|
+
const isoDate = (value: unknown) => {
|
|
1496
|
+
const text = str(value)?.trim() ?? "";
|
|
1497
|
+
if (!ELEMENTOR_DATE.test(text)) return undefined;
|
|
1498
|
+
const [y, m, d] = text.split("-").map(Number) as [number, number, number];
|
|
1499
|
+
const day = new Date(Date.UTC(y, m - 1, d));
|
|
1500
|
+
return day.getUTCMonth() === m - 1 && day.getUTCDate() === d ? text : undefined;
|
|
1501
|
+
};
|
|
1502
|
+
const inputNumber = (value: unknown) => {
|
|
1503
|
+
const n = num(value);
|
|
1504
|
+
return n !== undefined && Math.abs(n) <= MAX_INPUT_NUMBER ? n : undefined;
|
|
1505
|
+
};
|
|
1506
|
+
|
|
1507
|
+
const defined = (props: Record<string, unknown>) =>
|
|
1508
|
+
Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined));
|
|
1509
|
+
|
|
1510
|
+
/** W-1065: a number or date field's own box and limits. */
|
|
1511
|
+
function typedField(type: string, raw: Settings): Record<string, unknown> {
|
|
1512
|
+
if (type === "number") {
|
|
1513
|
+
const min = inputNumber(raw["field_min"]);
|
|
1514
|
+
const max = inputNumber(raw["field_max"]);
|
|
1515
|
+
const range = min !== undefined && max !== undefined && min > max ? {} : { min, max };
|
|
1516
|
+
return defined({ inputType: "number", ...range });
|
|
1517
|
+
}
|
|
1518
|
+
if (type === "date") {
|
|
1519
|
+
const minDate = isoDate(raw["min_date"]);
|
|
1520
|
+
const maxDate = isoDate(raw["max_date"]);
|
|
1521
|
+
const range = minDate && maxDate && minDate > maxDate ? {} : { minDate, maxDate };
|
|
1522
|
+
return defined({ inputType: "date", ...range });
|
|
1523
|
+
}
|
|
1524
|
+
return {};
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
const MAX_FORM_STEPS = 20;
|
|
1528
|
+
|
|
1475
1529
|
const form: Widget = (s, ctx, el) => {
|
|
1476
1530
|
const fields = Array.isArray(s["form_fields"]) ? s["form_fields"].slice(0, 100) : [];
|
|
1477
|
-
const
|
|
1531
|
+
const loose: N[] = [];
|
|
1532
|
+
const steps: { title: string; children: N[] }[] = [];
|
|
1478
1533
|
const names = new Set<string>();
|
|
1534
|
+
let nextLabel = "";
|
|
1535
|
+
let prevLabel = "";
|
|
1479
1536
|
fields.forEach((raw, i) => {
|
|
1480
1537
|
if (!isRecord(raw)) return;
|
|
1481
1538
|
const type = str(raw["field_type"]) ?? "text";
|
|
1539
|
+
// W-1065: a Step field starts a step; the fields after it, up to the next, are its fields.
|
|
1540
|
+
if (type === "step") {
|
|
1541
|
+
if (steps.length >= MAX_FORM_STEPS) return;
|
|
1542
|
+
steps.push({ title: plain(raw["field_label"]).text.slice(0, 200), children: [] });
|
|
1543
|
+
nextLabel ||= plain(raw["next_button"]).text.slice(0, 80);
|
|
1544
|
+
prevLabel ||= plain(raw["previous_button"]).text.slice(0, 80);
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1482
1547
|
const nodeType = FIELD_TYPES[type];
|
|
1483
1548
|
if (!nodeType) {
|
|
1484
1549
|
ctx.note("skipped", el, `Form field type "${type}" was left out.`);
|
|
@@ -1492,14 +1557,24 @@ const form: Widget = (s, ctx, el) => {
|
|
|
1492
1557
|
plain(raw["field_label"]).text.slice(0, 200) ||
|
|
1493
1558
|
(type === "acceptance" ? plain(raw["acceptance_text"]).text.slice(0, 200) : "");
|
|
1494
1559
|
const placeholder = plain(raw["placeholder"]).text.slice(0, 200);
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1560
|
+
const field = node(ctx, nodeType, {
|
|
1561
|
+
field: name,
|
|
1562
|
+
...(label ? { label } : {}),
|
|
1563
|
+
...(placeholder && nodeType !== "checkbox" ? { placeholder } : {}),
|
|
1564
|
+
...typedField(type, raw),
|
|
1565
|
+
});
|
|
1566
|
+
const step = steps[steps.length - 1];
|
|
1567
|
+
if (step) step.children.push(field);
|
|
1568
|
+
else loose.push(field);
|
|
1502
1569
|
});
|
|
1570
|
+
// Fields before the first Step field are a step of their own, as Elementor shows them.
|
|
1571
|
+
if (steps.length > 0 && loose.length > 0) steps.unshift({ title: "", children: loose.splice(0) });
|
|
1572
|
+
const children: N[] = [
|
|
1573
|
+
...loose,
|
|
1574
|
+
...steps.map((step) =>
|
|
1575
|
+
node(ctx, "form-step", step.title ? { title: step.title } : {}, { children: step.children }),
|
|
1576
|
+
),
|
|
1577
|
+
];
|
|
1503
1578
|
const label = plain(s["button_text"]).text.slice(0, 80) || "Send";
|
|
1504
1579
|
children.push(node(ctx, "submit", { label }));
|
|
1505
1580
|
ctx.note(
|
|
@@ -1507,8 +1582,24 @@ const form: Widget = (s, ctx, el) => {
|
|
|
1507
1582
|
el,
|
|
1508
1583
|
"Connect each imported form to a form in the forms plugin; field options and email actions weren't imported.",
|
|
1509
1584
|
);
|
|
1585
|
+
if (steps.length > 0) {
|
|
1586
|
+
ctx.note(
|
|
1587
|
+
"approximated",
|
|
1588
|
+
el,
|
|
1589
|
+
'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".',
|
|
1590
|
+
);
|
|
1591
|
+
}
|
|
1592
|
+
const labels = {
|
|
1593
|
+
...(steps.length > 0 && nextLabel ? { nextLabel } : {}),
|
|
1594
|
+
...(steps.length > 0 && prevLabel ? { prevLabel } : {}),
|
|
1595
|
+
};
|
|
1510
1596
|
return [
|
|
1511
|
-
node(
|
|
1597
|
+
node(
|
|
1598
|
+
ctx,
|
|
1599
|
+
"form",
|
|
1600
|
+
{ formId: "", ...labels },
|
|
1601
|
+
{ style: { gap: { value: 10, unit: "px" } }, children },
|
|
1602
|
+
),
|
|
1512
1603
|
];
|
|
1513
1604
|
};
|
|
1514
1605
|
|
|
@@ -1554,11 +1645,18 @@ const navMenu: Widget = (s, ctx, el) => {
|
|
|
1554
1645
|
];
|
|
1555
1646
|
};
|
|
1556
1647
|
|
|
1648
|
+
/**
|
|
1649
|
+
* Elementor's Mega Menu → a Menu whose items hold their dropdown content. W-1069: Elementor's
|
|
1650
|
+
* dropdowns span the menu unless Content width is Fit to content, so those panels are wide. The
|
|
1651
|
+
* content stays in the item (Elementor keeps it in the widget, not in a shared template), so it
|
|
1652
|
+
* isn't turned into a Section theme part.
|
|
1653
|
+
*/
|
|
1557
1654
|
const megaMenu: Widget = (s, ctx, _el, env, raw) => {
|
|
1558
1655
|
const items = (Array.isArray(s["menu_items"]) ? s["menu_items"] : [])
|
|
1559
1656
|
.filter(isRecord)
|
|
1560
1657
|
.slice(0, 50);
|
|
1561
1658
|
const kids = Array.isArray(raw["elements"]) ? raw["elements"] : [];
|
|
1659
|
+
const wide = str(s["content_width"]) !== "fit_to_content";
|
|
1562
1660
|
const children = items.map((item, i) => {
|
|
1563
1661
|
const text = plain(item["item_title"]).text || "Item";
|
|
1564
1662
|
const panel =
|
|
@@ -1568,7 +1666,11 @@ const megaMenu: Widget = (s, ctx, _el, env, raw) => {
|
|
|
1568
1666
|
return node(
|
|
1569
1667
|
ctx,
|
|
1570
1668
|
"menu-item",
|
|
1571
|
-
{
|
|
1669
|
+
{
|
|
1670
|
+
text: short(text),
|
|
1671
|
+
...href(item["item_link"], ctx),
|
|
1672
|
+
...(wide && panel.length > 0 ? { wide: true } : {}),
|
|
1673
|
+
},
|
|
1572
1674
|
{ children: panel },
|
|
1573
1675
|
);
|
|
1574
1676
|
});
|
|
@@ -2185,7 +2287,7 @@ export const WIDGETS: Record<string, Widget> = {
|
|
|
2185
2287
|
sidebar: skip("WordPress sidebars weren't imported."),
|
|
2186
2288
|
countdown,
|
|
2187
2289
|
"share-buttons": shareButtons,
|
|
2188
|
-
"search-form":
|
|
2290
|
+
"search-form": searchForm,
|
|
2189
2291
|
login: skip("Login forms weren't imported."),
|
|
2190
2292
|
lottie: skip("Lottie animations weren't imported."),
|
|
2191
2293
|
hotspot: hotspotWidget,
|