@perkyzz/emvb 1.1.0 → 1.3.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.
Files changed (99) hide show
  1. package/THIRD_PARTY_NOTICES.md +3 -2
  2. package/package.json +11 -10
  3. package/src/admin/agents-api.ts +5 -1
  4. package/src/admin/content-api.ts +29 -0
  5. package/src/admin/editor/Editor.tsx +6 -1
  6. package/src/admin/editor/ScheduleDialog.tsx +167 -0
  7. package/src/admin/editor/TopBar.tsx +33 -1
  8. package/src/admin/editor/canvas/vnode-react.tsx +3 -0
  9. package/src/admin/editor/dnd/new-element.ts +106 -0
  10. package/src/admin/editor/editor-chrome.tsx +9 -0
  11. package/src/admin/editor/element-chrome.ts +50 -0
  12. package/src/admin/editor/panels/ElementPanel.tsx +5 -1
  13. package/src/admin/editor/panels/settings/DraftTextField.tsx +33 -1
  14. package/src/admin/editor/panels/settings/FieldBindControl.tsx +6 -1
  15. package/src/admin/editor/panels/settings/FieldControl.tsx +10 -1
  16. package/src/admin/editor/panels/settings/IconPicker.tsx +4 -1
  17. package/src/admin/editor/panels/settings/ItemList.tsx +69 -2
  18. package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
  19. package/src/admin/editor/store.ts +7 -1
  20. package/src/admin/editor/useEditorData.ts +4 -0
  21. package/src/admin/editor/useSave.ts +47 -3
  22. package/src/admin/export-api.ts +20 -3
  23. package/src/admin/menus-api.ts +113 -0
  24. package/src/admin/pages/ImportElementorDialog.tsx +25 -1
  25. package/src/astro/EmVBPage.astro +3 -0
  26. package/src/astro/render.ts +43 -18
  27. package/src/astro/request-data.ts +9 -0
  28. package/src/astro/resolve-theme.ts +77 -44
  29. package/src/astro/resolve.ts +9 -0
  30. package/src/astro/visitor.ts +23 -4
  31. package/src/astro/widgets/EmVBAlertsRuntime.astro +8 -0
  32. package/src/astro/widgets/EmVBCarouselRuntime.astro +8 -0
  33. package/src/astro/widgets/EmVBCountdownRuntime.astro +8 -0
  34. package/src/astro/widgets/EmVBCounterRuntime.astro +8 -0
  35. package/src/astro/widgets/EmVBHeadlineRuntime.astro +9 -0
  36. package/src/astro/widgets/EmVBLightboxRuntime.astro +8 -0
  37. package/src/astro/widgets/EmVBMapRuntime.astro +8 -0
  38. package/src/astro/widgets/EmVBShareRuntime.astro +9 -0
  39. package/src/astro/widgets/EmVBWidgetRuntimes.astro +29 -0
  40. package/src/astro/widgets/alerts.ts +37 -0
  41. package/src/astro/widgets/carousel.ts +167 -0
  42. package/src/astro/widgets/countdown.ts +80 -0
  43. package/src/astro/widgets/counter.ts +98 -0
  44. package/src/astro/widgets/headline.ts +90 -0
  45. package/src/astro/widgets/index.ts +1 -0
  46. package/src/astro/widgets/lightbox.ts +123 -0
  47. package/src/astro/widgets/map.ts +37 -0
  48. package/src/astro/widgets/share.ts +21 -0
  49. package/src/constants.ts +1 -1
  50. package/src/core/a11y/audit.ts +127 -5
  51. package/src/core/arrange.ts +109 -1
  52. package/src/core/bounded-array.ts +16 -13
  53. package/src/core/canvas-collections.ts +28 -0
  54. package/src/core/contract.ts +4 -1
  55. package/src/core/elements/counter-format.ts +15 -0
  56. package/src/core/elements/icon-svg.ts +135 -0
  57. package/src/core/elements/index.ts +63 -127
  58. package/src/core/elements/marketing.ts +1490 -0
  59. package/src/core/elements/widgets.ts +932 -0
  60. package/src/core/export/runtimes.generated.ts +8 -0
  61. package/src/core/export/site.ts +25 -3
  62. package/src/core/extensions/schema.ts +2 -1
  63. package/src/core/geo-trust.ts +18 -0
  64. package/src/core/icons/social.generated.ts +29 -0
  65. package/src/core/image-edit/schema.ts +2 -1
  66. package/src/core/import/elementor/context.ts +18 -0
  67. package/src/core/import/elementor/index.ts +50 -7
  68. package/src/core/import/elementor/widgets.ts +783 -385
  69. package/src/core/issue-cap.ts +19 -0
  70. package/src/core/limits.ts +12 -0
  71. package/src/core/loop-collections.ts +33 -0
  72. package/src/core/proposals.ts +8 -2
  73. package/src/core/render/index.ts +48 -5
  74. package/src/core/render/vnode.ts +44 -6
  75. package/src/core/sanitize/svg-upload.ts +276 -23
  76. package/src/core/sanitize/svg.ts +3 -3
  77. package/src/core/schema/descriptors.ts +4 -0
  78. package/src/core/schema/design.ts +6 -5
  79. package/src/core/schema/layout.ts +798 -15
  80. package/src/core/schema/style.ts +2 -1
  81. package/src/core/shadowing-ids.ts +41 -0
  82. package/src/core/theme/conditions.ts +2 -1
  83. package/src/core/theme/dynamic.ts +2 -0
  84. package/src/core/theme/parse-doc.ts +10 -5
  85. package/src/core/theme/triggers.ts +3 -2
  86. package/src/core/validate.ts +3 -2
  87. package/src/index.ts +23 -2
  88. package/src/mcp/ports.ts +18 -7
  89. package/src/mcp/proposals.ts +36 -11
  90. package/src/mcp/tools.ts +1 -1
  91. package/src/server/agent-settings.ts +12 -1
  92. package/src/server/hooks.ts +41 -6
  93. package/src/server/mcp-routes.ts +11 -5
  94. package/src/server/plugin.ts +29 -3
  95. package/src/server/presence.ts +5 -1
  96. package/src/server/proposals.ts +16 -4
  97. package/src/server/requests.ts +60 -11
  98. package/src/server/site-origin.ts +13 -0
  99. package/src/server/targets.ts +26 -0
@@ -8,7 +8,7 @@ import { MAX_TABS, MAX_TEXT_LENGTH } from "../../limits.ts";
8
8
  import { FIELD_NAME_PATTERN, ICON_SVG_MAX } from "../../schema/layout.ts";
9
9
  import { sanitizeHref } from "../../sanitize/href.ts";
10
10
  import { sanitizeMediaUrl } from "../../sanitize/media-url.ts";
11
- import { type ImportContext, svgFileId } from "./context.ts";
11
+ import { type ImportContext, type MenuLink, svgFileId } from "./context.ts";
12
12
  import {
13
13
  type Block,
14
14
  cleanText,
@@ -719,18 +719,96 @@ function mediaBox(media: N | undefined, s: Settings, ctx: ImportContext, el: str
719
719
  ];
720
720
  }
721
721
 
722
- const iconBox: Widget = (s, ctx, el) => mediaBox(iconNode(s, ctx, el), s, ctx, el);
722
+ /** Elementor's title, text, link and position settings as an icon or image box's props. */
723
+ function mediaBoxProps(s: Settings, ctx: ImportContext): Record<string, unknown> {
724
+ const level = Number(/^h([1-6])$/.exec(str(s["title_size"]) ?? "h3")?.[1] ?? 3);
725
+ const position = str(s["position"]);
726
+ const linkProps = href(s["link"], ctx);
727
+ return {
728
+ title: short(plain(s["title_text"]).text, 200),
729
+ ...(level === 3 ? {} : { titleLevel: Math.max(2, level) }),
730
+ text: short(plain(s["description_text"]).text),
731
+ ...(position === "left" || position === "right" ? { position } : {}),
732
+ ...linkProps,
733
+ };
734
+ }
735
+
736
+ /** The box's own styles: alignment, and one colour for icon and words (EmVB's box has one). */
737
+ function mediaBoxStyle(s: Settings, ctx: ImportContext, el: string): Style {
738
+ const style: Style = {};
739
+ const where = textAlign(s["text_align"]);
740
+ if (where) style.textAlign = where;
741
+ const ink = colorAt(s, "title_color", ctx) ?? colorAt(s, "primary_color", ctx) ?? undefined;
742
+ if (ink) style.color = ink;
743
+ if (
744
+ s["title_typography_typography"] ||
745
+ s["description_typography_typography"] ||
746
+ s["description_color"]
747
+ )
748
+ ctx.note(
749
+ "approximated",
750
+ el,
751
+ "Icon and image boxes keep one text style; title and description fonts and colours were simplified.",
752
+ );
753
+ return style;
754
+ }
755
+
756
+ /** W-1020: Elementor's Icon Box → an Icon box; without a usable icon, the old layout. */
757
+ const iconBox: Widget = (s, ctx, el) => {
758
+ const icon = iconOf(s["selected_icon"] ?? s["icon"], ctx, el);
759
+ if (!icon) return mediaBox(undefined, s, ctx, el);
760
+ const size = slider(s["size"]);
761
+ const style = mediaBoxStyle(s, ctx, el);
762
+ return [
763
+ node(
764
+ ctx,
765
+ "icon-box",
766
+ {
767
+ iconId: icon.iconId,
768
+ ...(icon.iconSvg ? { iconSvg: icon.iconSvg } : {}),
769
+ ...(size && size.unit === "px"
770
+ ? { iconSize: Math.min(512, Math.max(8, Math.round(size.value))) }
771
+ : {}),
772
+ ...mediaBoxProps(s, ctx),
773
+ },
774
+ Object.keys(style).length > 0 ? { style } : {},
775
+ ),
776
+ ];
777
+ };
778
+
779
+ /** W-1021: Elementor's image width (a % of the box) as the nearest Image box size. */
780
+ function imageBoxSize(percent: number | undefined): string | undefined {
781
+ if (percent === undefined) return "small"; // Elementor's default is 30 %
782
+ if (percent <= 32) return "small";
783
+ if (percent <= 50) return undefined;
784
+ if (percent <= 75) return "large";
785
+ return "full";
786
+ }
723
787
 
788
+ /** W-1021: Elementor's Image Box → an Image box; without a usable image, the old layout. */
724
789
  const imageBox: Widget = (s, ctx, el) => {
725
790
  const img = imageNode(ctx, el, s["image"]);
726
- if (img) {
727
- const width = slider(s["image_size"]);
728
- img["style"] = {
729
- width: width ? { value: width.value, unit: "%" } : { value: 30, unit: "%" },
730
- maxWidth: { value: 100, unit: "%" },
731
- };
732
- }
733
- return mediaBox(img, s, ctx, el);
791
+ if (!img) return mediaBox(undefined, s, ctx, el);
792
+ const picture = img["props"] as Record<string, unknown>;
793
+ const width = slider(s["image_size"]);
794
+ const size = imageBoxSize(width?.unit === "%" ? width.value : undefined);
795
+ const style = mediaBoxStyle(s, ctx, el);
796
+ return [
797
+ node(
798
+ ctx,
799
+ "image-box",
800
+ {
801
+ ...Object.fromEntries(
802
+ ["src", "alt", "decorative", "mediaId", "width", "height"]
803
+ .filter((key) => picture[key] !== undefined)
804
+ .map((key) => [key, picture[key]]),
805
+ ),
806
+ ...(size ? { imageSize: size } : {}),
807
+ ...mediaBoxProps(s, ctx),
808
+ },
809
+ Object.keys(style).length > 0 ? { style } : {},
810
+ ),
811
+ ];
734
812
  };
735
813
 
736
814
  const iconList: Widget = (s, ctx, el) => {
@@ -809,220 +887,173 @@ const video: Widget = (s, ctx, el) => {
809
887
  return [node(ctx, "video", { url: safe, title: "Video" })];
810
888
  };
811
889
 
890
+ /** A number a Counter can show. */
891
+ const clamp = (n: number) => Math.min(1e12, Math.max(-1e12, n));
892
+
893
+ /** W-1049: Elementor's Counter → a Counter that counts up as it does (5 s at most). */
812
894
  const counter: Widget = (s, ctx, el) => {
813
- const end = num(s["ending_number"]) ?? 100;
895
+ const end = clamp(num(s["ending_number"]) ?? 100);
896
+ const start = clamp(num(s["starting_number"]) ?? 0);
897
+ const sep = str(s["thousand_separator_char"]);
814
898
  const separator =
815
- str(s["thousand_separator"]) !== "" && s["thousand_separator"] !== undefined
816
- ? (str(s["thousand_separator_char"]) ?? ",")
817
- : "";
818
- const digits = String(Math.trunc(Math.abs(end))).replace(
819
- /\B(?=(\d{3})+(?!\d))/g,
820
- separator === "space" ? " " : separator,
821
- );
822
- const number = `${plain(s["prefix"]).text}${end < 0 ? "-" : ""}${digits}${plain(s["suffix"]).text}`;
823
- ctx.note("approximated", el, "Counters show their final number, without the counting animation.");
824
- const children = [
825
- styled(
826
- node(
827
- ctx,
828
- "text",
829
- { text: short(number), tag: "div" },
830
- { style: { fontSize: { value: 69, unit: "px" }, fontWeight: 600, lineHeight: 1 } },
831
- ),
832
- deviceStyles(s, ctx, el, [
833
- typographyReader("typography_number", "primary"),
834
- textReader("number_color", "primary"),
835
- ]),
836
- ),
837
- ];
899
+ s["thousand_separator"] === "yes" || (s["thousand_separator"] === undefined && sep)
900
+ ? sep === "." || sep === "'"
901
+ ? sep
902
+ : sep === " " || sep === "space"
903
+ ? " "
904
+ : ","
905
+ : undefined;
906
+ const decimals = (String(end).split(".")[1] ?? "").length;
907
+ const duration = num(s["duration"]) ?? 2000;
908
+ if (duration > 5000) ctx.note("approximated", el, "Counters count up in 5 seconds at most.");
838
909
  const title = plain(s["title"]).text;
839
- if (title) {
840
- children.push(
841
- styled(
842
- node(
843
- ctx,
844
- "text",
845
- { text: short(title), tag: "div" },
846
- { style: { fontSize: { value: 19, unit: "px" } } },
847
- ),
848
- deviceStyles(s, ctx, el, [
849
- typographyReader("typography_title", "secondary"),
850
- textReader("title_color", "secondary"),
851
- ]),
852
- ),
853
- );
854
- }
855
910
  return [
856
- box(ctx, children, {
857
- alignItems: "center",
858
- textAlign: "center",
859
- gap: { value: 5, unit: "px" },
860
- }),
911
+ styled(
912
+ node(ctx, "counter", {
913
+ value: end,
914
+ ...(start !== 0 ? { start } : {}),
915
+ ...(decimals ? { decimals: Math.min(3, decimals) } : {}),
916
+ ...(separator ? { separator } : {}),
917
+ ...(plain(s["prefix"]).text ? { prefix: plain(s["prefix"]).text.slice(0, 20) } : {}),
918
+ ...(plain(s["suffix"]).text ? { suffix: plain(s["suffix"]).text.slice(0, 20) } : {}),
919
+ ...(title ? { title: title.slice(0, 200) } : {}),
920
+ countUp: true,
921
+ duration: Math.min(5000, Math.max(300, Math.round(duration))),
922
+ }),
923
+ deviceStyles(s, ctx, el, [textReader("number_color", "primary")]),
924
+ ),
861
925
  ];
862
926
  };
863
927
 
928
+ /** W-1049: Elementor's Progress Bar → a Progress bar that grows in, as Elementor's does. */
864
929
  const progress: Widget = (s, ctx, el) => {
865
930
  const percent = Math.min(
866
931
  100,
867
- Math.max(
868
- 0,
869
- Math.round(num(isRecord(s["percent"]) ? s["percent"]["size"] : s["percent"]) ?? 50),
870
- ),
932
+ Math.max(0, num(isRecord(s["percent"]) ? s["percent"]["size"] : s["percent"]) ?? 50),
871
933
  );
934
+ const title = plain(s["title"]).text;
935
+ if (plain(s["inner_text"]).text)
936
+ ctx.note("approximated", el, "Text inside progress bars was left out; the title stays.");
872
937
  const bar =
873
938
  colorAt(s, "bar_color", ctx) ??
874
939
  (ctx.useDefaults ? ctx.globalColor("primary") : undefined) ??
875
940
  "#6ec1e4";
876
- const children: N[] = [];
877
- const title = plain(s["title"]).text;
878
- if (title) children.push(node(ctx, "text", { text: short(title), tag: "div" }));
879
- const inner = plain(s["inner_text"]).text;
880
- const fill = box(
881
- ctx,
882
- inner
883
- ? [
884
- node(
885
- ctx,
886
- "text",
887
- { text: short(inner), tag: "div" },
888
- {
889
- style: {
890
- color: "#ffffff",
891
- paddingLeft: { value: 15, unit: "px" },
892
- lineHeight: { value: 30, unit: "px" },
893
- },
894
- },
895
- ),
896
- ]
897
- : [],
898
- {
899
- width: { value: percent, unit: "%" },
900
- minHeight: { value: 30, unit: "px" },
901
- backgroundColor: bar,
902
- justifyContent: "center",
903
- },
904
- );
905
- children.push(
906
- box(ctx, [fill], {
907
- backgroundColor: colorAt(s, "bar_bg_color", ctx) ?? "#eeeeee",
908
- minHeight: { value: 30, unit: "px" },
909
- }),
910
- );
911
- ctx.note("approximated", el, "Progress bars are shown filled, without their animation.");
912
- return [box(ctx, children, { gap: { value: 8, unit: "px" } })];
941
+ return [
942
+ node(
943
+ ctx,
944
+ "progress",
945
+ {
946
+ value: Math.round(percent * 100) / 100,
947
+ ...(title ? { label: title.slice(0, 120) } : {}),
948
+ ...(str(s["display_percentage"]) === "hide" ? {} : { showValue: true }),
949
+ thickness: 30,
950
+ grow: true,
951
+ },
952
+ { style: { color: bar } },
953
+ ),
954
+ ];
913
955
  };
914
956
 
957
+ /** W-1022: Elementor's Testimonial → a Testimonial: quote, photo, name and job. */
915
958
  const testimonial: Widget = (s, ctx, el) => {
916
- const children: N[] = [];
917
- const content = plain(s["testimonial_content"]).text;
918
- if (content) {
919
- children.push(
920
- styled(
921
- node(
922
- ctx,
923
- "text",
924
- { text: short(content) },
925
- { style: { fontSize: { value: 1.3, unit: "em" } } },
926
- ),
927
- deviceStyles(s, ctx, el, [
928
- typographyReader("content_typography", "text"),
929
- textReader("content_content_color", "text"),
930
- ]),
931
- ),
932
- );
933
- }
934
- const img = imageNode(ctx, el, s["testimonial_image"]);
935
- if (img) {
936
- img["style"] = {
937
- width: { value: 60, unit: "px" },
938
- height: { value: 60, unit: "px" },
939
- borderRadius: { value: 50, unit: "%" },
940
- objectFit: "cover",
941
- };
942
- children.push(img);
943
- }
959
+ const quote = plain(s["testimonial_content"]).text;
944
960
  const name = plain(s["testimonial_name"]).text;
945
- if (name)
946
- children.push(
947
- styled(
948
- node(ctx, "text", { text: short(name), tag: "div" }, { style: { fontWeight: "bold" } }),
949
- deviceStyles(s, ctx, el, [textReader("name_text_color", "primary")]),
950
- ),
951
- );
961
+ if (!quote && !name) return [];
952
962
  const job = plain(s["testimonial_job"]).text;
953
- if (job)
954
- children.push(
955
- styled(
956
- node(ctx, "text", { text: short(job), tag: "div" }),
957
- deviceStyles(s, ctx, el, [textReader("job_text_color", "secondary")]),
958
- ),
959
- );
960
- if (children.length === 0) return [];
963
+ const img = imageNode(ctx, el, s["testimonial_image"]);
964
+ const photo = (img?.["props"] ?? {}) as Record<string, unknown>;
961
965
  const where = textAlign(s["testimonial_alignment"]) ?? "center";
966
+ const style: Style = { textAlign: where };
967
+ if (where !== "left") style.alignItems = where === "right" ? "flex-end" : "center";
968
+ const ink = colorAt(s, "content_content_color", ctx);
969
+ if (ink) style.color = ink;
970
+ if (s["content_typography_typography"] || s["name_text_color"] || s["job_text_color"])
971
+ ctx.note(
972
+ "approximated",
973
+ el,
974
+ "Testimonials keep one text style; name and job colours and fonts were simplified.",
975
+ );
962
976
  return [
963
- box(ctx, children, {
964
- gap: { value: 15, unit: "px" },
965
- textAlign: where,
966
- alignItems: where === "left" ? "flex-start" : where === "right" ? "flex-end" : "center",
967
- }),
977
+ node(
978
+ ctx,
979
+ "testimonial",
980
+ {
981
+ quote: short(quote),
982
+ name: short(name, 200),
983
+ ...(job ? { role: short(job, 200) } : {}),
984
+ ...Object.fromEntries(
985
+ ["src", "alt", "mediaId", "width", "height"]
986
+ .filter((key) => photo[key] !== undefined)
987
+ .map((key) => [key, photo[key]]),
988
+ ),
989
+ },
990
+ { style },
991
+ ),
968
992
  ];
969
993
  };
970
994
 
995
+ /** W-1023: Elementor's Star Rating → a Rating, with its title as text beside it. */
971
996
  const starRating: Widget = (s, ctx, el) => {
972
997
  const scale = Math.min(10, Math.max(1, Math.round(num(s["rating_scale"]) ?? 5)));
973
- const rating = Math.min(
998
+ const value = Math.min(
974
999
  scale,
975
1000
  Math.max(0, num(isRecord(s["rating"]) ? s["rating"]["size"] : s["rating"]) ?? scale),
976
1001
  );
977
- const full = Math.round(rating);
978
- const stars = `${"★".repeat(full)}${"☆".repeat(scale - full)}`;
1002
+ const size = num(isRecord(s["icon_size"]) ? s["icon_size"]["size"] : undefined);
1003
+ const rating = node(
1004
+ ctx,
1005
+ "rating",
1006
+ {
1007
+ value: Math.round(value * 10) / 10,
1008
+ max: scale,
1009
+ ...(size ? { size: Math.min(128, Math.max(8, Math.round(size))) } : {}),
1010
+ },
1011
+ { style: { color: colorAt(s, "stars_color", ctx) ?? "#f0ad4e" } },
1012
+ );
1013
+ if (s["star_style"] === "star_unicode" || s["unmarked_star_style"] === "outline")
1014
+ ctx.note("approximated", el, "Star ratings use EmVB's filled stars.");
979
1015
  const title = plain(s["title"]).text;
980
- ctx.note("approximated", el, "Star ratings are shown as star characters.");
1016
+ if (!title) return [rating];
981
1017
  return [
982
- node(
983
- ctx,
984
- "text",
985
- { text: short(`${title ? `${title} ` : ""}${stars} (${rating}/${scale})`) },
986
- {
987
- style: { color: colorAt(s, "stars_color", ctx) ?? "#f0ad4e" },
988
- },
989
- ),
1018
+ box(ctx, [node(ctx, "text", { text: short(title) }), rating], {
1019
+ flexDirection: "row",
1020
+ alignItems: "center",
1021
+ gap: { value: 8, unit: "px" },
1022
+ }),
990
1023
  ];
991
1024
  };
992
1025
 
993
- const INFO_ALERT: [string, string, string] = ["#d9edf7", "#bcdff1", "#31708f"];
994
- const ALERTS: Record<string, [string, string, string]> = {
995
- info: ["#d9edf7", "#bcdff1", "#31708f"],
996
- success: ["#dff0d8", "#cae6be", "#3c763d"],
997
- warning: ["#fcf8e3", "#f9f0c3", "#8a6d3b"],
998
- danger: ["#f2dede", "#e8c4c4", "#a94442"],
999
- };
1026
+ const ALERT_KINDS = new Set(["info", "success", "warning", "danger"]);
1000
1027
 
1001
- const alert: Widget = (s, ctx, el) => {
1002
- const [bg, border, ink] = ALERTS[str(s["alert_type"]) ?? "info"] ?? INFO_ALERT;
1003
- const children: N[] = [];
1028
+ /**
1029
+ * W-1025: Elementor's Alert → an Alert of the same kind. Elementor shows no icon, so neither does
1030
+ * the import; its own colours, when set, stay as the element's styles; Dismiss stays dismissible.
1031
+ */
1032
+ const alert: Widget = (s, ctx) => {
1004
1033
  const title = plain(s["alert_title"]).text;
1005
- if (title)
1006
- children.push(
1007
- node(ctx, "text", { text: short(title), tag: "div" }, { style: { fontWeight: "bold" } }),
1008
- );
1009
1034
  const description = plain(s["alert_description"]).text;
1010
- if (description) children.push(node(ctx, "text", { text: short(description) }));
1011
- if (children.length === 0) return [];
1012
- if (str(s["show_dismiss"]) === "show") ctx.note("approximated", el, "Alerts can't be dismissed.");
1035
+ if (!title && !description) return [];
1036
+ const kind = str(s["alert_type"]) ?? "info";
1037
+ const style: Style = {};
1038
+ const background = colorAt(s, "background", ctx);
1039
+ const border = colorAt(s, "border_color", ctx);
1040
+ const ink = colorAt(s, "title_color", ctx);
1041
+ if (background) style.backgroundColor = background;
1042
+ if (border) style.borderColor = border;
1043
+ if (ink) style.color = ink;
1013
1044
  return [
1014
- box(ctx, children, {
1015
- gap: { value: 5, unit: "px" },
1016
- backgroundColor: colorAt(s, "background", ctx) ?? bg,
1017
- borderStyle: "solid",
1018
- borderLeftWidth: { value: 5, unit: "px" },
1019
- borderColor: colorAt(s, "border_color", ctx) ?? border,
1020
- color: colorAt(s, "title_color", ctx) ?? ink,
1021
- paddingTop: { value: 15, unit: "px" },
1022
- paddingBottom: { value: 15, unit: "px" },
1023
- paddingLeft: { value: 15, unit: "px" },
1024
- paddingRight: { value: 15, unit: "px" },
1025
- }),
1045
+ node(
1046
+ ctx,
1047
+ "alert",
1048
+ {
1049
+ variant: ALERT_KINDS.has(kind) ? kind : "info",
1050
+ ...(title ? { title: short(title, 200) } : {}),
1051
+ text: short(description),
1052
+ hideIcon: true,
1053
+ ...(str(s["show_dismiss"]) === "show" ? { dismissible: true } : {}),
1054
+ },
1055
+ Object.keys(style).length > 0 ? { style } : {},
1056
+ ),
1026
1057
  ];
1027
1058
  };
1028
1059
 
@@ -1052,63 +1083,110 @@ const menuAnchor: Widget = (s, ctx, el) => {
1052
1083
  return [box(ctx, [], {}, { htmlId: anchor, editorLabel: `Anchor ${anchor}`.slice(0, 80) })];
1053
1084
  };
1054
1085
 
1086
+ /** W-1049: Elementor's Google Maps → a Map that loads Google's map when a visitor asks. */
1055
1087
  const googleMaps: Widget = (s, ctx, el) => {
1056
- const address = plain(s["address"]).text;
1057
- ctx.note("approximated", el, "Google Maps embeds became a link to the map.");
1088
+ const address = plain(s["address"]).text.slice(0, 300);
1058
1089
  if (!address) return [];
1090
+ const zoom = num(isRecord(s["zoom"]) ? s["zoom"]["size"] : s["zoom"]);
1091
+ const height = num(isRecord(s["height"]) ? s["height"]["size"] : s["height"]);
1092
+ ctx.note(
1093
+ "approximated",
1094
+ el,
1095
+ "Google Maps load when a visitor presses Show the map, so Google isn't contacted before.",
1096
+ );
1059
1097
  return [
1060
- node(ctx, "link", {
1061
- text: short(`View map: ${address}`),
1062
- href: `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(address.slice(0, 500))}`,
1063
- newTab: true,
1098
+ node(ctx, "map", {
1099
+ address,
1100
+ provider: "google",
1101
+ embed: true,
1102
+ ...(zoom ? { zoom: Math.min(19, Math.max(1, Math.round(zoom))) } : {}),
1103
+ ...(height ? { height: Math.min(800, Math.max(150, Math.round(height))) } : {}),
1064
1104
  }),
1065
1105
  ];
1066
1106
  };
1067
1107
 
1068
- /** Galleries and carousels → a grid of images. */
1069
- function gallery(
1108
+ /**
1109
+ * W-1019: Elementor's Image Gallery and Gallery → a Gallery of Gallery images (up to 60), with
1110
+ * Elementor's lightbox kept (on unless the widget turns it off) and masonry when it used it.
1111
+ */
1112
+ function galleryWidget(
1070
1113
  list: unknown,
1071
1114
  columns: number,
1115
+ s: Settings,
1072
1116
  ctx: ImportContext,
1073
1117
  el: string,
1074
- imageKey?: string,
1075
1118
  ): N[] {
1076
- const items = Array.isArray(list) ? list.slice(0, 100) : [];
1077
- const images: N[] = [];
1078
- for (const item of items) {
1119
+ const items = Array.isArray(list) ? list : [];
1120
+ if (items.length > 60) ctx.note("skipped", el, "Galleries keep their first 60 pictures.");
1121
+ const pictures: N[] = [];
1122
+ for (const item of items.slice(0, 60)) {
1079
1123
  if (ctx.overBudget) break;
1080
- const value = imageKey && isRecord(item) ? item[imageKey] : item;
1081
- const n = imageNode(ctx, el, value);
1082
- if (n) {
1083
- n["style"] = { width: { value: 100, unit: "%" }, height: "auto", objectFit: "cover" };
1084
- images.push(n);
1085
- }
1124
+ const img = imageNode(ctx, el, item);
1125
+ if (!img) continue;
1126
+ const props = img["props"] as Record<string, unknown>;
1127
+ pictures.push(
1128
+ node(
1129
+ ctx,
1130
+ "gallery-image",
1131
+ Object.fromEntries(
1132
+ ["src", "alt", "decorative", "mediaId", "width", "height"]
1133
+ .filter((key) => props[key] !== undefined)
1134
+ .map((key) => [key, props[key]]),
1135
+ ),
1136
+ ),
1137
+ );
1086
1138
  }
1087
- if (images.length === 0) return [];
1139
+ if (pictures.length === 0) return [];
1140
+ const lightbox = str(s["open_lightbox"]) !== "no";
1141
+ const masonry = str(s["gallery_layout"]) === "masonry" || s["masonry"] === "yes";
1088
1142
  return [
1089
1143
  node(
1090
1144
  ctx,
1091
- "grid",
1092
- { columns: Math.min(12, Math.max(1, Math.round(columns))) },
1145
+ "gallery",
1093
1146
  {
1094
- style: { gap: { value: 10, unit: "px" } },
1095
- children: images,
1147
+ ...(masonry ? { layout: "masonry" } : {}),
1148
+ columns: Math.min(6, Math.max(1, Math.round(columns))),
1149
+ ...(lightbox ? { lightbox: true } : {}),
1096
1150
  },
1151
+ { children: pictures },
1097
1152
  ),
1098
1153
  ];
1099
1154
  }
1100
1155
 
1101
1156
  const imageGallery: Widget = (s, ctx, el) =>
1102
- gallery(s["wp_gallery"], num(s["gallery_columns"]) ?? 4, ctx, el);
1103
- const proGallery: Widget = (s, ctx, el) => gallery(s["gallery"], num(s["columns"]) ?? 4, ctx, el);
1104
- const imageCarousel: Widget = (s, ctx, el) => {
1105
- ctx.note("approximated", el, "Carousels are shown as a grid of their slides.");
1106
- return gallery(s["carousel"], num(s["slides_to_show"]) ?? 3, ctx, el);
1107
- };
1108
- const mediaCarousel: Widget = (s, ctx, el) => {
1109
- ctx.note("approximated", el, "Carousels are shown as a grid of their slides.");
1110
- return gallery(s["slides"], num(s["slides_per_view"]) ?? 3, ctx, el, "image");
1111
- };
1157
+ galleryWidget(s["wp_gallery"], num(s["gallery_columns"]) ?? 4, s, ctx, el);
1158
+ const proGallery: Widget = (s, ctx, el) =>
1159
+ galleryWidget(s["gallery"], num(s["columns"]) ?? 4, s, ctx, el);
1160
+ /**
1161
+ * W-1018: Elementor's Image Carousel and Media Carousel → a Carousel with one picture per slide.
1162
+ * Navigation and looping follow Elementor's settings. Elementor plays by default; EmVB doesn't,
1163
+ * so autoplay comes over only when the widget turned it on explicitly (with its speed).
1164
+ */
1165
+ function carouselWidget(
1166
+ list: unknown,
1167
+ perView: number,
1168
+ s: Settings,
1169
+ ctx: ImportContext,
1170
+ el: string,
1171
+ imageKey?: string,
1172
+ ): N[] {
1173
+ const items = Array.isArray(list) ? list : [];
1174
+ if (items.length > 20) ctx.note("skipped", el, "Carousels keep their first 20 slides.");
1175
+ const slides: N[] = [];
1176
+ for (const item of items.slice(0, 20)) {
1177
+ if (ctx.overBudget) break;
1178
+ const img = imageNode(ctx, el, imageKey && isRecord(item) ? item[imageKey] : item);
1179
+ if (!img) continue;
1180
+ img["style"] = { width: { value: 100, unit: "%" }, height: "auto" };
1181
+ slides.push(node(ctx, "carousel-slide", {}, { children: [img] }));
1182
+ }
1183
+ return carouselFrom(slides, perView, s, ctx, el);
1184
+ }
1185
+
1186
+ const imageCarousel: Widget = (s, ctx, el) =>
1187
+ carouselWidget(s["carousel"], num(s["slides_to_show"]) ?? 3, s, ctx, el);
1188
+ const mediaCarousel: Widget = (s, ctx, el) =>
1189
+ carouselWidget(s["slides"], num(s["slides_per_view"]) ?? 3, s, ctx, el, "image");
1112
1190
 
1113
1191
  const BRANDS: Record<string, string> = {
1114
1192
  facebook: "#3b5998",
@@ -1137,7 +1215,103 @@ const BRANDS: Record<string, string> = {
1137
1215
  "square-x-twitter": "#000000",
1138
1216
  };
1139
1217
 
1140
- const socialIcons: Widget = (s, ctx, el) => {
1218
+ /** W-1024: Font Awesome icon names Elementor's Social Icons use → EmVB's Social link networks. */
1219
+ const SOCIAL_FROM_FA: Record<string, string> = {
1220
+ facebook: "facebook",
1221
+ "facebook-f": "facebook",
1222
+ "square-facebook": "facebook",
1223
+ instagram: "instagram",
1224
+ "square-instagram": "instagram",
1225
+ twitter: "x",
1226
+ "x-twitter": "x",
1227
+ "square-x-twitter": "x",
1228
+ "square-twitter": "x",
1229
+ linkedin: "linkedin",
1230
+ "linkedin-in": "linkedin",
1231
+ youtube: "youtube",
1232
+ "square-youtube": "youtube",
1233
+ tiktok: "tiktok",
1234
+ bluesky: "bluesky",
1235
+ mastodon: "mastodon",
1236
+ threads: "threads",
1237
+ "square-threads": "threads",
1238
+ github: "github",
1239
+ "square-github": "github",
1240
+ pinterest: "pinterest",
1241
+ "pinterest-p": "pinterest",
1242
+ "square-pinterest": "pinterest",
1243
+ whatsapp: "whatsapp",
1244
+ "square-whatsapp": "whatsapp",
1245
+ discord: "discord",
1246
+ twitch: "twitch",
1247
+ reddit: "reddit",
1248
+ "reddit-alien": "reddit",
1249
+ dribbble: "dribbble",
1250
+ behance: "behance",
1251
+ telegram: "telegram",
1252
+ "telegram-plane": "telegram",
1253
+ spotify: "spotify",
1254
+ envelope: "email",
1255
+ rss: "rss",
1256
+ globe: "website",
1257
+ };
1258
+
1259
+ /**
1260
+ * W-1024: Elementor's Social Icons → Social icons, one Social link per profile. Elementor's
1261
+ * default colours are the brands', so they stay brand colours; custom ones become the badge
1262
+ * colour. A network EmVB has no preset for (Vimeo, Snapchat…) keeps the whole widget as icons.
1263
+ */
1264
+ const socialIcons: Widget = (s, ctx, el, env, raw) => {
1265
+ const items = (Array.isArray(s["social_icon_list"]) ? s["social_icon_list"] : [])
1266
+ .filter(isRecord)
1267
+ .slice(0, 20);
1268
+ const networks = items.map((item) => {
1269
+ const value = item["social_icon"] ?? item["social"];
1270
+ const name = isRecord(value) ? str(value["value"]) : str(value);
1271
+ return SOCIAL_FROM_FA[(name ?? "").replace(/^fa[brs]? fa-/, "").replace(/^fa-/, "")];
1272
+ });
1273
+ if (items.length === 0 || networks.some((network) => !network))
1274
+ return socialIconsAsIcons(s, ctx, el, env, raw);
1275
+ const links = items.map((item, i) => {
1276
+ const linkProps = href(item["link"], ctx);
1277
+ return node(ctx, "social-link", {
1278
+ network: networks[i],
1279
+ href: linkProps.href ?? "",
1280
+ ...(linkProps.newTab ? { newTab: true } : {}),
1281
+ });
1282
+ });
1283
+ const shape = str(s["shape"]) ?? "rounded";
1284
+ const custom = str(s["icon_color"]) === "custom";
1285
+ const style: Style = {};
1286
+ const size = slider(s["icon_size"]);
1287
+ if (size && size.unit === "px") style.fontSize = { value: Math.round(size.value), unit: "px" };
1288
+ const gap = slider(s["icon_spacing"]);
1289
+ if (gap) style.gap = gap;
1290
+ const where = textAlign(s["align"]);
1291
+ if (where)
1292
+ style.justifyContent =
1293
+ where === "left" ? "flex-start" : where === "right" ? "flex-end" : "center";
1294
+ if (custom) {
1295
+ const badge = colorAt(s, "icon_primary_color", ctx);
1296
+ if (badge) style.color = badge;
1297
+ if (colorAt(s, "icon_secondary_color", ctx))
1298
+ ctx.note("approximated", el, "Social icons draw their icons in white on the badge colour.");
1299
+ }
1300
+ return [
1301
+ node(
1302
+ ctx,
1303
+ "social-icons",
1304
+ {
1305
+ shape: shape === "circle" || shape === "square" ? shape : "rounded",
1306
+ ...(custom ? {} : { brandColors: true }),
1307
+ },
1308
+ { children: links, ...(Object.keys(style).length > 0 ? { style } : {}) },
1309
+ ),
1310
+ ];
1311
+ };
1312
+
1313
+ /** Before W-1024, and still for networks without a preset: each icon an Icon on its colour. */
1314
+ const socialIconsAsIcons: Widget = (s, ctx, el) => {
1141
1315
  const items = Array.isArray(s["social_icon_list"]) ? s["social_icon_list"].slice(0, 50) : [];
1142
1316
  const size = slider(s["icon_size"]);
1143
1317
  const px = size && size.unit === "px" ? Math.round(size.value) : 25;
@@ -1338,14 +1512,46 @@ const form: Widget = (s, ctx, el) => {
1338
1512
  ];
1339
1513
  };
1340
1514
 
1341
- const navMenu: Widget = (s, ctx, el) => {
1342
- ctx.note(
1343
- "approximated",
1344
- el,
1345
- `The WordPress menu${str(s["menu"]) ? ` "${(str(s["menu"]) ?? "").slice(0, 40)}"` : ""} isn't in the export; add its links to the Menu in the editor.`,
1515
+ /** W-1026: a site menu's links as Menu items (three levels, as the Menu shows). */
1516
+ function menuItems(ctx: ImportContext, links: readonly MenuLink[], depth = 0): N[] {
1517
+ return links.slice(0, 50).map((entry) =>
1518
+ node(
1519
+ ctx,
1520
+ "menu-item",
1521
+ {
1522
+ text: short(entry.text || "Link", 200),
1523
+ ...(entry.href ? { href: entry.href.slice(0, 2000) } : {}),
1524
+ ...(entry.newTab ? { newTab: true } : {}),
1525
+ },
1526
+ { children: depth < 2 && entry.children ? menuItems(ctx, entry.children, depth + 1) : [] },
1527
+ ),
1346
1528
  );
1529
+ }
1530
+
1531
+ /**
1532
+ * Elementor's Nav Menu → a Menu. W-1026: filled with the site menu's links when the dialog
1533
+ * found it (EmDash's WordPress import keeps the menu's name); otherwise empty, with a note.
1534
+ */
1535
+ const navMenu: Widget = (s, ctx, el) => {
1536
+ const name = str(s["menu"])?.trim();
1347
1537
  const vertical = str(s["layout"]) === "vertical" || str(s["layout"]) === "dropdown";
1348
- return [node(ctx, "menu", { direction: vertical ? "column" : "row" }, { children: [] })];
1538
+ if (name) ctx.menus.add(name.slice(0, 100));
1539
+ const links = name ? ctx.menuOf?.(name) : undefined;
1540
+ if (!links || links.length === 0) {
1541
+ ctx.note(
1542
+ "approximated",
1543
+ el,
1544
+ `The WordPress menu${name ? ` "${name.slice(0, 40)}"` : ""} isn't on this site; add its links to the Menu in the editor.`,
1545
+ );
1546
+ }
1547
+ return [
1548
+ node(
1549
+ ctx,
1550
+ "menu",
1551
+ { direction: vertical ? "column" : "row" },
1552
+ { children: links ? menuItems(ctx, links) : [] },
1553
+ ),
1554
+ ];
1349
1555
  };
1350
1556
 
1351
1557
  const megaMenu: Widget = (s, ctx, _el, env, raw) => {
@@ -1369,142 +1575,153 @@ const megaMenu: Widget = (s, ctx, _el, env, raw) => {
1369
1575
  return [node(ctx, "menu", { direction: "row" }, { children })];
1370
1576
  };
1371
1577
 
1578
+ /** W-1049: Elementor's Call to Action → a Call to action: picture, title, text, button, ribbon. */
1372
1579
  const callToAction: Widget = (s, ctx, el) => {
1373
- const children: N[] = [];
1374
- const style: Style = {
1375
- gap: { value: 15, unit: "px" },
1376
- paddingTop: { value: 35, unit: "px" },
1377
- paddingBottom: { value: 35, unit: "px" },
1378
- paddingLeft: { value: 35, unit: "px" },
1379
- paddingRight: { value: 35, unit: "px" },
1380
- alignItems: "center",
1381
- textAlign: "center",
1382
- };
1580
+ const title = plain(s["title"]).text.slice(0, 200);
1581
+ if (!title) return [];
1582
+ const level = Number(/^h([2-6])$/.exec(str(s["title_tag"]) ?? "h2")?.[1] ?? 2);
1383
1583
  const bg = image(s["bg_image"]);
1384
- if (bg && !/[()\\\s"'`]/.test(bg.url)) {
1385
- style["backgroundImage"] = bg.url;
1386
- style["backgroundSize"] = "cover";
1387
- style["backgroundPosition"] = "center";
1388
- }
1389
- const fill = colorAt(s, "background_color", ctx);
1390
- if (fill) style["backgroundColor"] = fill;
1391
- const title = plain(s["title"]).text;
1392
- const level = Number(/^h([1-6])$/.exec(str(s["title_tag"]) ?? "h2")?.[1] ?? 2);
1393
- if (title) children.push(node(ctx, "heading", { text: short(title), level }));
1584
+ if (bg) ctx.externalImage(bg.url);
1585
+ const layout = str(s["layout"]);
1586
+ const where =
1587
+ str(s["skin"]) === "cover"
1588
+ ? "behind"
1589
+ : layout === "left"
1590
+ ? "left"
1591
+ : layout === "right"
1592
+ ? "right"
1593
+ : "top";
1594
+ const target = href(s["link"], ctx);
1595
+ const btn = plain(s["button"]).text.slice(0, 80);
1394
1596
  const description = plain(s["description"]).text;
1395
- if (description) children.push(node(ctx, "text", { text: short(description) }));
1396
- const btn = buttonNode(s, ctx, el, { text: "button", link: "link", icon: "selected_icon" });
1397
- if (btn) children.push(btn);
1398
- ctx.note(
1399
- "approximated",
1400
- el,
1401
- "Call to Action boxes keep their text, image and button, not their hover effects.",
1402
- );
1403
- return children.length > 0 ? [box(ctx, children, style)] : [];
1597
+ const ribbon = plain(s["ribbon_title"]).text.slice(0, 30);
1598
+ ctx.note("approximated", el, "Call to Action boxes keep their content, not their hover effects.");
1599
+ const fill = colorAt(s, "background_color", ctx);
1600
+ return [
1601
+ node(
1602
+ ctx,
1603
+ "cta",
1604
+ {
1605
+ title,
1606
+ ...(level !== 3 ? { titleLevel: level } : {}),
1607
+ ...(description ? { text: short(description) } : {}),
1608
+ ...(bg ? { src: bg.url, alt: bg.alt ?? "" } : {}),
1609
+ layout: where,
1610
+ ...(btn && target.href ? { buttonText: btn } : {}),
1611
+ ...target,
1612
+ ...(ribbon ? { ribbon } : {}),
1613
+ },
1614
+ fill ? { style: { backgroundColor: fill } } : {},
1615
+ ),
1616
+ ];
1404
1617
  };
1405
1618
 
1619
+ const CURRENCY_SYMBOLS: Record<string, string> = {
1620
+ dollar: "$",
1621
+ euro: "€",
1622
+ pound: "£",
1623
+ yen: "¥",
1624
+ rupee: "₹",
1625
+ franc: "₣",
1626
+ real: "R$",
1627
+ baht: "฿",
1628
+ krona: "kr",
1629
+ lira: "₺",
1630
+ peseta: "₧",
1631
+ peso: "₱",
1632
+ shekel: "₪",
1633
+ won: "₩",
1634
+ guilder: "ƒ",
1635
+ };
1636
+
1637
+ /** W-1049: Elementor's Price Table → a Price table: price, sale price, features, button, ribbon. */
1406
1638
  const priceTable: Widget = (s, ctx, el) => {
1407
- const children: N[] = [];
1408
- const headingText = plain(s["heading"]).text;
1409
- if (headingText)
1410
- children.push(
1411
- node(ctx, "heading", {
1412
- text: short(headingText),
1413
- level: Number(/^h([1-6])$/.exec(str(s["heading_tag"]) ?? "h3")?.[1] ?? 3),
1414
- }),
1415
- );
1416
- const sub = plain(s["sub_heading"]).text;
1417
- if (sub) children.push(node(ctx, "text", { text: short(sub) }));
1418
- const symbols: Record<string, string> = {
1419
- dollar: "$",
1420
- euro: "€",
1421
- pound: "£",
1422
- yen: "¥",
1423
- rupee: "₹",
1424
- franc: "₣",
1425
- real: "R$",
1426
- baht: "฿",
1427
- krona: "kr",
1428
- lira: "₺",
1429
- peseta: "₧",
1430
- peso: "₱",
1431
- shekel: "₪",
1432
- won: "₩",
1433
- guilder: "ƒ",
1434
- };
1435
- const currency =
1639
+ const title = plain(s["heading"]).text.slice(0, 120);
1640
+ const price = plain(s["price"]).text.slice(0, 20);
1641
+ if (!title && !price) return [];
1642
+ const currency = (
1436
1643
  str(s["currency_symbol"]) === "custom"
1437
1644
  ? plain(s["currency_symbol_custom"]).text
1438
- : (symbols[str(s["currency_symbol"]) ?? "dollar"] ?? "");
1439
- const price = plain(s["price"]).text;
1440
- if (price) {
1441
- const period = plain(s["period"]).text;
1442
- children.push(
1443
- node(
1444
- ctx,
1445
- "text",
1446
- { text: short(`${currency}${price}${period ? ` / ${period}` : ""}`), tag: "div" },
1447
- { style: { fontSize: { value: 2.5, unit: "em" }, fontWeight: 600 } },
1448
- ),
1449
- );
1450
- }
1645
+ : (CURRENCY_SYMBOLS[str(s["currency_symbol"]) ?? "dollar"] ?? "")
1646
+ ).slice(0, 5);
1647
+ const regular = s["sale"] === "yes" ? plain(s["original_price"]).text.slice(0, 20) : "";
1451
1648
  const features = (Array.isArray(s["features_list"]) ? s["features_list"] : [])
1452
1649
  .filter(isRecord)
1453
- .map((f) => short(plain(f["item_text"]).text))
1650
+ .map((f) => plain(f["item_text"]).text.slice(0, 200))
1454
1651
  .filter(Boolean)
1455
- .slice(0, 200);
1456
- if (features.length > 0) children.push(node(ctx, "list", { items: features }));
1457
- const btn = buttonNode(s, ctx, el, { text: "button_text", link: "link" });
1458
- if (btn) children.push(btn);
1652
+ .slice(0, 30);
1653
+ const sub = plain(s["sub_heading"]).text;
1459
1654
  const footer = plain(s["footer_additional_info"]).text;
1460
- if (footer) children.push(node(ctx, "text", { text: short(footer) }));
1461
- ctx.note(
1462
- "approximated",
1463
- el,
1464
- "Price tables keep their content in EmVB's default look; ribbons are left out.",
1465
- );
1466
- return children.length > 0
1467
- ? [
1468
- box(ctx, children, {
1469
- gap: { value: 12, unit: "px" },
1470
- alignItems: "center",
1471
- textAlign: "center",
1472
- }),
1473
- ]
1474
- : [];
1655
+ const description = [sub, footer].filter(Boolean).join("\n").slice(0, 500);
1656
+ const target = href(s["link"], ctx);
1657
+ const btn = plain(s["button_text"]).text.slice(0, 80);
1658
+ const ribbon = s["show_ribbon"] === "yes" ? plain(s["ribbon_title"]).text.slice(0, 30) : "";
1659
+ if (footer) ctx.note("approximated", el, "A price table's footer text joined its description.");
1660
+ const level = Number(/^h([2-6])$/.exec(str(s["heading_tag"]) ?? "h3")?.[1] ?? 3);
1661
+ return [
1662
+ node(ctx, "price-table", {
1663
+ title: title || price,
1664
+ ...(level !== 3 ? { titleLevel: level } : {}),
1665
+ ...(description ? { description } : {}),
1666
+ price: price || "0",
1667
+ ...(currency ? { currency } : {}),
1668
+ ...(plain(s["period"]).text ? { period: plain(s["period"]).text.slice(0, 40) } : {}),
1669
+ ...(regular ? { regularPrice: regular } : {}),
1670
+ ...(features.length > 0 ? { features } : {}),
1671
+ ...(btn && target.href ? { buttonText: btn, buttonHref: target.href } : {}),
1672
+ ...(target.newTab && btn ? { newTab: true } : {}),
1673
+ ...(s["show_ribbon"] === "yes" ? { featured: true, ...(ribbon ? { ribbon } : {}) } : {}),
1674
+ }),
1675
+ ];
1475
1676
  };
1476
1677
 
1678
+ /** W-1049: Elementor's Price List → a Price list, one item per row with its picture and link. */
1679
+ const priceList: Widget = (s, ctx, el) => {
1680
+ const rows = (Array.isArray(s["price_list"]) ? s["price_list"] : []).filter(isRecord);
1681
+ if (rows.length > 50) ctx.note("skipped", el, "Price lists keep their first 50 items.");
1682
+ const items: N[] = [];
1683
+ for (const row of rows.slice(0, 50)) {
1684
+ const title = plain(row["title"]).text.slice(0, 120);
1685
+ if (!title) continue;
1686
+ const img = image(row["image"]);
1687
+ if (img) ctx.externalImage(img.url);
1688
+ const target = href(row["link"], ctx);
1689
+ const description = plain(row["item_description"]).text.slice(0, 500);
1690
+ items.push(
1691
+ node(ctx, "price-list-item", {
1692
+ title,
1693
+ price: plain(row["price"]).text.slice(0, 20),
1694
+ ...(description ? { description } : {}),
1695
+ ...(img ? { src: img.url, ...(img.alt ? { alt: img.alt } : {}) } : {}),
1696
+ ...target,
1697
+ }),
1698
+ );
1699
+ }
1700
+ return items.length > 0 ? [node(ctx, "price-list", {}, { children: items })] : [];
1701
+ };
1702
+
1703
+ /** W-1049: Elementor's Flip Box → a Flip box: front and back, its direction and button. */
1477
1704
  const flipBox: Widget = (s, ctx, el) => {
1478
- const side = (suffix: "a" | "b") => {
1479
- const parts: N[] = [];
1480
- const title = plain(s[`title_text_${suffix}`]).text;
1481
- if (title) parts.push(node(ctx, "heading", { text: short(title), level: 3 }));
1482
- const text = plain(s[`description_text_${suffix}`]).text;
1483
- if (text) parts.push(node(ctx, "text", { text: short(text) }));
1484
- const fill = colorAt(s, `background_color_${suffix}`, ctx);
1485
- return parts.length > 0
1486
- ? box(ctx, parts, {
1487
- gap: { value: 10, unit: "px" },
1488
- alignItems: "center",
1489
- textAlign: "center",
1490
- ...(fill ? { backgroundColor: fill } : {}),
1491
- paddingTop: { value: 35, unit: "px" },
1492
- paddingBottom: { value: 35, unit: "px" },
1493
- paddingLeft: { value: 35, unit: "px" },
1494
- paddingRight: { value: 35, unit: "px" },
1495
- })
1496
- : undefined;
1497
- };
1498
- const front = side("a");
1499
- const back = side("b");
1500
- const btn = buttonNode(s, ctx, el, { text: "button_text", link: "link" });
1501
- if (back && btn) (back["children"] as N[]).push(btn);
1502
- ctx.note(
1503
- "approximated",
1504
- el,
1505
- "Flip boxes show their back side below the front, without the flip.",
1506
- );
1507
- return [front, back].filter((n): n is N => n !== undefined);
1705
+ const frontTitle = plain(s["title_text_a"]).text.slice(0, 200);
1706
+ const backTitle = plain(s["title_text_b"]).text.slice(0, 200);
1707
+ if (!frontTitle && !backTitle) return [];
1708
+ const frontText = plain(s["description_text_a"]).text;
1709
+ const backText = plain(s["description_text_b"]).text;
1710
+ const target = href(s["link"], ctx);
1711
+ const btn = plain(s["button_text"]).text.slice(0, 80);
1712
+ const direction = str(s["flip_direction"]);
1713
+ if (image(s["image"]) || isRecord(s["selected_icon"]))
1714
+ ctx.note("approximated", el, "A flip box's front image or icon was left out.");
1715
+ return [
1716
+ node(ctx, "flip-box", {
1717
+ frontTitle: frontTitle || backTitle,
1718
+ ...(frontText ? { frontText: short(frontText) } : {}),
1719
+ ...(backTitle ? { backTitle } : {}),
1720
+ ...(backText ? { backText: short(backText) } : {}),
1721
+ ...(btn && target.href ? { buttonText: btn, ...target } : {}),
1722
+ ...(direction === "left" || direction === "up" || direction === "down" ? { direction } : {}),
1723
+ }),
1724
+ ];
1508
1725
  };
1509
1726
 
1510
1727
  const blockquote: Widget = (s, ctx) => {
@@ -1533,25 +1750,45 @@ const blockquote: Widget = (s, ctx) => {
1533
1750
  ];
1534
1751
  };
1535
1752
 
1753
+ /** Elementor's highlight shapes → the closest Animated headline mark. */
1754
+ const HEADLINE_MARKERS: Record<string, "underline" | "circle" | "strike"> = {
1755
+ circle: "circle",
1756
+ curly: "underline",
1757
+ underline: "underline",
1758
+ double: "underline",
1759
+ double_underline: "underline",
1760
+ underline_zigzag: "underline",
1761
+ diagonal: "strike",
1762
+ strikethrough: "strike",
1763
+ x: "strike",
1764
+ };
1765
+
1766
+ /** W-1049: Elementor's Animated Headline → an Animated headline with its mark or rotating words. */
1536
1767
  const animatedHeadline: Widget = (s, ctx, el) => {
1537
- const rotating = (str(s["rotating_text"]) ?? "").split("\n")[0] ?? "";
1538
- const middle =
1539
- str(s["headline_style"]) === "rotate" ? rotating : (str(s["highlighted_text"]) ?? "");
1540
- const text = cleanText(
1541
- [plain(s["before_text"]).text, plain(middle).text, plain(s["after_text"]).text]
1542
- .filter(Boolean)
1543
- .join(" "),
1544
- );
1545
- if (!text) return [];
1546
- ctx.note(
1547
- "approximated",
1548
- el,
1549
- "Animated headlines are shown without their animation (rotating headlines show their first word).",
1550
- );
1768
+ const rotate = str(s["headline_style"]) === "rotate";
1769
+ const words = (str(s["rotating_text"]) ?? "")
1770
+ .split("\n")
1771
+ .map((w) => plain(w).text.slice(0, 120))
1772
+ .filter(Boolean);
1773
+ const highlight = (rotate ? words[0] : plain(s["highlighted_text"]).text)?.slice(0, 120) ?? "";
1774
+ const before = plain(s["before_text"]).text.slice(0, 200);
1775
+ const after = plain(s["after_text"]).text.slice(0, 200);
1776
+ if (!highlight && !before && !after) return [];
1551
1777
  const level = Number(/^h([1-6])$/.exec(str(s["tag"]) ?? "h3")?.[1] ?? 3);
1778
+ if (link(s["link"])) ctx.note("approximated", el, "An animated headline's link was left out.");
1779
+ const marker = HEADLINE_MARKERS[str(s["marker"]) ?? "circle"] ?? "underline";
1552
1780
  return [
1553
1781
  styled(
1554
- node(ctx, "heading", { text: short(text), level, ...href(s["link"], ctx) }),
1782
+ node(ctx, "headline", {
1783
+ level,
1784
+ ...(before ? { before } : {}),
1785
+ highlight: highlight || before || after,
1786
+ ...(after && highlight ? { after } : {}),
1787
+ mark: rotate ? "none" : marker,
1788
+ ...(rotate && words.length > 1
1789
+ ? { rotate: words.slice(1, 11), rotating: true, turns: s["loop"] === "yes" ? 5 : 1 }
1790
+ : {}),
1791
+ }),
1555
1792
  deviceStyles(s, ctx, el, [
1556
1793
  typographyReader("title_typography", "primary"),
1557
1794
  textReader("title_color", "secondary", "alignment"),
@@ -1610,11 +1847,55 @@ const siteLogo: Widget = (s, ctx, el, env) => {
1610
1847
  return [align(n, s["align"], env, "center")];
1611
1848
  };
1612
1849
 
1850
+ /**
1851
+ * W-1018 carousel settings from an Elementor carousel-like widget: arrows and dots from
1852
+ * `navigation`, autoplay and its speed, looping.
1853
+ */
1854
+ function carouselFrom(
1855
+ slides: N[],
1856
+ perView: number,
1857
+ s: Settings,
1858
+ ctx: ImportContext,
1859
+ el: string,
1860
+ ): N[] {
1861
+ if (slides.length === 0) return [];
1862
+ const navigation = str(s["navigation"]) ?? "both";
1863
+ const autoplay = str(s["autoplay"]);
1864
+ if (autoplay !== "yes" && autoplay !== "no")
1865
+ ctx.note(
1866
+ "approximated",
1867
+ el,
1868
+ "Carousels don't play by themselves unless you turn on Play automatically.",
1869
+ );
1870
+ const speed = num(s["autoplay_speed"]);
1871
+ return [
1872
+ node(
1873
+ ctx,
1874
+ "carousel",
1875
+ {
1876
+ perView: Math.min(4, Math.max(1, Math.round(perView))),
1877
+ ...(navigation === "both" || navigation === "arrows" ? { arrows: true } : {}),
1878
+ ...(navigation === "both" || navigation === "dots" ? { dots: true } : {}),
1879
+ ...(autoplay === "yes"
1880
+ ? {
1881
+ autoplay: true,
1882
+ ...(speed ? { interval: Math.min(30, Math.max(3, Math.round(speed / 1000))) } : {}),
1883
+ }
1884
+ : {}),
1885
+ ...(str(s["infinite"]) === "no" ? {} : { loop: true }),
1886
+ },
1887
+ { children: slides },
1888
+ ),
1889
+ ];
1890
+ }
1891
+
1892
+ /** W-1049: Elementor's Slides → a Carousel, one slide per Elementor slide with its content. */
1613
1893
  const slides: Widget = (s, ctx, el) => {
1614
- const list = (Array.isArray(s["slides"]) ? s["slides"] : []).filter(isRecord).slice(0, 20);
1894
+ const list = (Array.isArray(s["slides"]) ? s["slides"] : []).filter(isRecord);
1895
+ if (list.length > 20) ctx.note("skipped", el, "Carousels keep their first 20 slides.");
1615
1896
  const height = slider(s["slides_height"]) ?? { value: 400, unit: "px" as const };
1616
1897
  const out: N[] = [];
1617
- for (const slide of list) {
1898
+ for (const slide of list.slice(0, 20)) {
1618
1899
  const parts: N[] = [];
1619
1900
  const title = plain(slide["heading"]).text;
1620
1901
  if (title) parts.push(node(ctx, "heading", { text: short(title), level: 2 }));
@@ -1637,16 +1918,18 @@ const slides: Widget = (s, ctx, el) => {
1637
1918
  style["backgroundImage"] = bg.url;
1638
1919
  style["backgroundSize"] = "cover";
1639
1920
  }
1640
- out.push(box(ctx, parts, style));
1921
+ out.push(node(ctx, "carousel-slide", {}, { children: [box(ctx, parts, style)] }));
1641
1922
  }
1642
- if (out.length > 0) ctx.note("approximated", el, "Slides are shown stacked, one after another.");
1643
- return out;
1923
+ return carouselFrom(out, 1, s, ctx, el);
1644
1924
  };
1645
1925
 
1926
+ /** W-1049: Elementor's Testimonial Carousel and Reviews → a Carousel of Testimonials. */
1646
1927
  const testimonialCarousel: Widget = (s, ctx, el, env, raw) => {
1647
- const list = (Array.isArray(s["slides"]) ? s["slides"] : []).filter(isRecord).slice(0, 30);
1648
- const out = list.flatMap((slide) =>
1649
- testimonial(
1928
+ const list = (Array.isArray(s["slides"]) ? s["slides"] : []).filter(isRecord);
1929
+ if (list.length > 20) ctx.note("skipped", el, "Carousels keep their first 20 slides.");
1930
+ const out: N[] = [];
1931
+ for (const slide of list.slice(0, 20)) {
1932
+ const quote = testimonial(
1650
1933
  {
1651
1934
  testimonial_content: slide["content"],
1652
1935
  testimonial_name: slide["name"],
@@ -1657,20 +1940,134 @@ const testimonialCarousel: Widget = (s, ctx, el, env, raw) => {
1657
1940
  el,
1658
1941
  env,
1659
1942
  raw,
1660
- ),
1943
+ );
1944
+ if (quote.length > 0) out.push(node(ctx, "carousel-slide", {}, { children: quote }));
1945
+ }
1946
+ return carouselFrom(out, num(s["slides_per_view"]) ?? 1, s, ctx, el);
1947
+ };
1948
+
1949
+ /** Elementor's Countdown time (site time, no zone) as a Countdown target in UTC. */
1950
+ function countdownTarget(value: unknown): string | undefined {
1951
+ const m = /^(\d{4}-\d{2}-\d{2})[ T](\d{2}):(\d{2})/.exec(str(value) ?? "");
1952
+ return m ? `${m[1]}T${m[2]}:${m[3]}Z` : undefined;
1953
+ }
1954
+
1955
+ /** W-1049: Elementor's Countdown (due date) → a live Countdown with its ending action. */
1956
+ const countdown: Widget = (s, ctx, el) => {
1957
+ if (str(s["countdown_type"]) === "evergreen") {
1958
+ ctx.note("skipped", el, "Evergreen countdowns (a timer per visitor) weren't imported.");
1959
+ return [];
1960
+ }
1961
+ const target = countdownTarget(s["due_date"]);
1962
+ if (!target) return [];
1963
+ ctx.note(
1964
+ "approximated",
1965
+ el,
1966
+ "Countdown dates have no time zone in Elementor; they were read as UTC. Check the time.",
1661
1967
  );
1662
- if (out.length > 0)
1663
- ctx.note("approximated", el, "Carousels are shown as a grid of their slides.");
1664
- return out.length > 0
1665
- ? [
1666
- node(
1667
- ctx,
1668
- "grid",
1669
- { columns: Math.min(12, Math.max(1, num(s["slides_per_view"]) ?? 3)) },
1670
- { style: { gap: { value: 20, unit: "px" } }, children: out },
1671
- ),
1672
- ]
1673
- : [];
1968
+ const actions = Array.isArray(s["expire_actions"]) ? s["expire_actions"].map(String) : [];
1969
+ const message = plain(s["message_after_expire"]).text.slice(0, 200);
1970
+ const redirect = href(s["expire_redirect_url"], ctx).href;
1971
+ const expired = actions.includes("hide")
1972
+ ? { expired: "hide" }
1973
+ : redirect
1974
+ ? { expired: "link", expiredHref: redirect, ...(message ? { expiredText: message } : {}) }
1975
+ : message
1976
+ ? { expiredText: message }
1977
+ : {};
1978
+ if (actions.includes("redirect"))
1979
+ ctx.note("approximated", el, "A countdown that redirected now shows a link instead.");
1980
+ return [
1981
+ node(ctx, "countdown", {
1982
+ target,
1983
+ ticking: true,
1984
+ ...(s["show_seconds"] === "" || s["show_seconds"] === "no" ? { hideSeconds: true } : {}),
1985
+ ...expired,
1986
+ }),
1987
+ ];
1988
+ };
1989
+
1990
+ /** Elementor's share buttons → EmVB's Share link services. */
1991
+ const SHARE_FROM_ELEMENTOR: Record<string, string> = {
1992
+ facebook: "facebook",
1993
+ twitter: "x",
1994
+ "x-twitter": "x",
1995
+ linkedin: "linkedin",
1996
+ whatsapp: "whatsapp",
1997
+ telegram: "telegram",
1998
+ reddit: "reddit",
1999
+ threads: "threads",
2000
+ bluesky: "bluesky",
2001
+ email: "email",
2002
+ };
2003
+
2004
+ /** W-1049: Elementor's Share Buttons → Share buttons with the services EmVB has. */
2005
+ const shareButtons: Widget = (s, ctx, el) => {
2006
+ const list = (Array.isArray(s["share_buttons"]) ? s["share_buttons"] : []).filter(isRecord);
2007
+ const networks = list.map((b) => SHARE_FROM_ELEMENTOR[str(b["button"]) ?? ""]);
2008
+ if (networks.some((n) => !n))
2009
+ ctx.note("skipped", el, "Share buttons for services EmVB has no link for were left out.");
2010
+ const links = [...new Set(networks.filter((n): n is string => Boolean(n)))]
2011
+ .slice(0, 12)
2012
+ .map((network) => node(ctx, "share-link", { network }));
2013
+ if (links.length === 0) return [];
2014
+ const shape = str(s["shape"]);
2015
+ return [
2016
+ node(
2017
+ ctx,
2018
+ "share-buttons",
2019
+ {
2020
+ shape: shape === "circle" || shape === "rounded" ? shape : "square",
2021
+ ...(str(s["color_source"]) === "custom" ? {} : { brandColors: true }),
2022
+ },
2023
+ { children: links },
2024
+ ),
2025
+ ];
2026
+ };
2027
+
2028
+ /** One hotspot offset (Elementor's slider in %). */
2029
+ const offset = (value: unknown): number | undefined => {
2030
+ const n = num(isRecord(value) ? value["size"] : value);
2031
+ return n === undefined ? undefined : Math.min(100, Math.max(0, Math.round(n * 100) / 100));
2032
+ };
2033
+
2034
+ /** W-1049: Elementor's Hotspot → Hotspots: its picture and a marker per hotspot, per device. */
2035
+ const hotspotWidget: Widget = (s, ctx, el) => {
2036
+ const img = image(s["image"]);
2037
+ if (!img) return [];
2038
+ ctx.externalImage(img.url);
2039
+ const list = (Array.isArray(s["hotspot"]) ? s["hotspot"] : []).filter(isRecord);
2040
+ if (list.length > 20) ctx.note("skipped", el, "Hotspots keep their first 20 markers.");
2041
+ const markers = list.slice(0, 20).map((spot, i) => {
2042
+ const title = plain(spot["hotspot_label"]).text.slice(0, 120) || `Point ${i + 1}`;
2043
+ const text = plain(spot["hotspot_tooltip_content"]).text.slice(0, 1000);
2044
+ const at = (key: string) => offset(spot[key]);
2045
+ const place: Record<string, number> = {};
2046
+ for (const [prop, key] of [
2047
+ ["xTablet", "hotspot_offset_x_tablet"],
2048
+ ["yTablet", "hotspot_offset_y_tablet"],
2049
+ ["xMobile", "hotspot_offset_x_mobile"],
2050
+ ["yMobile", "hotspot_offset_y_mobile"],
2051
+ ] as const) {
2052
+ const v = at(key);
2053
+ if (v !== undefined) place[prop] = v;
2054
+ }
2055
+ return node(ctx, "hotspot", {
2056
+ title,
2057
+ ...(text ? { text } : {}),
2058
+ x: at("hotspot_offset_x") ?? 50,
2059
+ y: at("hotspot_offset_y") ?? 50,
2060
+ ...place,
2061
+ });
2062
+ });
2063
+ return [
2064
+ node(
2065
+ ctx,
2066
+ "hotspots",
2067
+ { src: img.url, alt: img.alt ?? altFromUrl(img.url) },
2068
+ { children: markers },
2069
+ ),
2070
+ ];
1674
2071
  };
1675
2072
 
1676
2073
  const codeHighlight: Widget = (s, ctx, el) => {
@@ -1746,6 +2143,7 @@ export const WIDGETS: Record<string, Widget> = {
1746
2143
  "mega-menu": megaMenu,
1747
2144
  "call-to-action": callToAction,
1748
2145
  "price-table": priceTable,
2146
+ "price-list": priceList,
1749
2147
  "flip-box": flipBox,
1750
2148
  blockquote,
1751
2149
  "animated-headline": animatedHeadline,
@@ -1785,12 +2183,12 @@ export const WIDGETS: Record<string, Widget> = {
1785
2183
  "theme-site-title": skip("The site title comes from WordPress settings; add it as a Heading."),
1786
2184
  "read-more": skip("WordPress's Read More tag has no EmVB equivalent."),
1787
2185
  sidebar: skip("WordPress sidebars weren't imported."),
1788
- countdown: skip("Countdown timers weren't imported."),
1789
- "share-buttons": skip("Share buttons weren't imported; add Icon links instead."),
2186
+ countdown,
2187
+ "share-buttons": shareButtons,
1790
2188
  "search-form": skip("Search forms weren't imported."),
1791
2189
  login: skip("Login forms weren't imported."),
1792
2190
  lottie: skip("Lottie animations weren't imported."),
1793
- hotspot: skip("Hotspots weren't imported."),
2191
+ hotspot: hotspotWidget,
1794
2192
  "paypal-button": skip("PayPal buttons weren't imported."),
1795
2193
  "progress-tracker": skip("Reading progress bars weren't imported."),
1796
2194
  posts: skip(LOOPS),