@perkyzz/emvb 1.0.0 → 1.2.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 (142) hide show
  1. package/README.md +9 -0
  2. package/THIRD_PARTY_NOTICES.md +1 -0
  3. package/package.json +10 -9
  4. package/src/admin/agents-api.ts +5 -1
  5. package/src/admin/bulk-api.ts +67 -0
  6. package/src/admin/content-api.ts +39 -6
  7. package/src/admin/copy-rich-text.ts +119 -0
  8. package/src/admin/dialog-tab-wrap.ts +78 -0
  9. package/src/admin/editor/A11yCopilot.tsx +2 -0
  10. package/src/admin/editor/Editor.tsx +24 -7
  11. package/src/admin/editor/ScheduleDialog.tsx +167 -0
  12. package/src/admin/editor/Timeline.tsx +6 -2
  13. package/src/admin/editor/TopBar.tsx +60 -8
  14. package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
  15. package/src/admin/editor/canvas/DeviceBar.tsx +22 -9
  16. package/src/admin/editor/canvas/canvas-scale.ts +3 -3
  17. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  18. package/src/admin/editor/dnd/new-element.ts +68 -0
  19. package/src/admin/editor/editor-chrome.tsx +16 -5
  20. package/src/admin/editor/editor-commands.ts +10 -4
  21. package/src/admin/editor/editor-css.ts +2 -1
  22. package/src/admin/editor/element-chrome.ts +22 -0
  23. package/src/admin/editor/panels/ElementPanel.tsx +34 -17
  24. package/src/admin/editor/panels/SettingsPanel.tsx +2 -2
  25. package/src/admin/editor/panels/settings/DraftTextField.tsx +33 -1
  26. package/src/admin/editor/panels/settings/EffectsControls.tsx +79 -1
  27. package/src/admin/editor/panels/settings/FieldBindControl.tsx +6 -1
  28. package/src/admin/editor/panels/settings/FieldControl.tsx +10 -1
  29. package/src/admin/editor/panels/settings/IconControls.tsx +11 -0
  30. package/src/admin/editor/panels/settings/IconPicker.tsx +4 -1
  31. package/src/admin/editor/panels/settings/ItemList.tsx +36 -2
  32. package/src/admin/editor/panels/settings/LengthRow.tsx +36 -3
  33. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +18 -0
  34. package/src/admin/editor/panels/settings/StyleRow.tsx +7 -0
  35. package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
  36. package/src/admin/editor/panels/settings/length-units.ts +15 -3
  37. package/src/admin/editor/panels/settings/style-sections.ts +1 -0
  38. package/src/admin/editor/panels/style-target.ts +17 -4
  39. package/src/admin/editor/section-templates.ts +26 -4
  40. package/src/admin/editor/store.ts +15 -3
  41. package/src/admin/editor/useEditorCommands.ts +7 -5
  42. package/src/admin/editor/useEditorData.ts +4 -0
  43. package/src/admin/editor/useNodeActions.ts +4 -2
  44. package/src/admin/editor/useSave.ts +47 -3
  45. package/src/admin/export-api.ts +238 -0
  46. package/src/admin/index.tsx +6 -1
  47. package/src/admin/menus-api.ts +113 -0
  48. package/src/admin/pages/ExportDialog.tsx +395 -0
  49. package/src/admin/pages/ImportElementorDialog.tsx +25 -1
  50. package/src/admin/pages/PageList.tsx +67 -2
  51. package/src/admin/pages/ThemePartList.tsx +37 -1
  52. package/src/admin/pages/bulk.tsx +303 -0
  53. package/src/admin/search.ts +20 -0
  54. package/src/admin/theme-api.ts +4 -0
  55. package/src/admin/ui.ts +11 -2
  56. package/src/admin/widgets/CanvasField.tsx +8 -0
  57. package/src/admin/widgets/ConvertToRichText.tsx +136 -0
  58. package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
  59. package/src/admin/widgets/convert-body.ts +73 -2
  60. package/src/astro/EmVBPage.astro +3 -0
  61. package/src/astro/render.ts +47 -22
  62. package/src/astro/request-data.ts +3 -0
  63. package/src/astro/resolve-theme.ts +88 -51
  64. package/src/astro/tabs/runtime.ts +16 -6
  65. package/src/astro/visitor.ts +23 -4
  66. package/src/astro/widgets/EmVBAlertsRuntime.astro +8 -0
  67. package/src/astro/widgets/EmVBCarouselRuntime.astro +8 -0
  68. package/src/astro/widgets/EmVBLightboxRuntime.astro +8 -0
  69. package/src/astro/widgets/EmVBWidgetRuntimes.astro +19 -0
  70. package/src/astro/widgets/alerts.ts +37 -0
  71. package/src/astro/widgets/carousel.ts +167 -0
  72. package/src/astro/widgets/index.ts +1 -0
  73. package/src/astro/widgets/lightbox.ts +123 -0
  74. package/src/constants.ts +1 -1
  75. package/src/core/a11y/audit.ts +103 -3
  76. package/src/core/arrange.ts +57 -1
  77. package/src/core/bounded-array.ts +16 -13
  78. package/src/core/contract.ts +26 -3
  79. package/src/core/css/generate.ts +83 -21
  80. package/src/core/css/scope.ts +10 -2
  81. package/src/core/css/trace.ts +33 -8
  82. package/src/core/design/classes.ts +25 -5
  83. package/src/core/design/devices.ts +78 -2
  84. package/src/core/design/variables.ts +14 -1
  85. package/src/core/elements/icon-svg.ts +135 -0
  86. package/src/core/elements/index.ts +33 -127
  87. package/src/core/elements/widgets.ts +907 -0
  88. package/src/core/export/runtimes.generated.ts +12 -0
  89. package/src/core/export/site.ts +579 -0
  90. package/src/core/export/zip.ts +95 -0
  91. package/src/core/extensions/schema.ts +2 -1
  92. package/src/core/geo-trust.ts +18 -0
  93. package/src/core/history/diff.ts +25 -0
  94. package/src/core/icons/social.generated.ts +29 -0
  95. package/src/core/image-edit/schema.ts +2 -1
  96. package/src/core/import/elementor/atomic.ts +22 -9
  97. package/src/core/import/elementor/context.ts +18 -0
  98. package/src/core/import/elementor/index.ts +72 -11
  99. package/src/core/import/elementor/style.ts +21 -1
  100. package/src/core/import/elementor/widgets.ts +394 -133
  101. package/src/core/index.ts +14 -0
  102. package/src/core/issue-cap.ts +19 -0
  103. package/src/core/json-schema.ts +8 -1
  104. package/src/core/limits.ts +6 -0
  105. package/src/core/loop-collections.ts +33 -0
  106. package/src/core/perf/meter.ts +37 -19
  107. package/src/core/portable-text-export.ts +243 -0
  108. package/src/core/proposals.ts +8 -2
  109. package/src/core/public-attributes.ts +30 -0
  110. package/src/core/render/index.ts +115 -13
  111. package/src/core/render/tabs.ts +18 -11
  112. package/src/core/render/vnode.ts +44 -6
  113. package/src/core/sanitize/css.ts +26 -0
  114. package/src/core/sanitize/svg-upload.ts +276 -23
  115. package/src/core/sanitize/svg.ts +3 -3
  116. package/src/core/schema/descriptors.ts +4 -0
  117. package/src/core/schema/design.ts +8 -7
  118. package/src/core/schema/layout.ts +406 -18
  119. package/src/core/schema/style.ts +49 -1
  120. package/src/core/search-text.ts +70 -0
  121. package/src/core/shadowing-ids.ts +41 -0
  122. package/src/core/theme/conditions.ts +2 -1
  123. package/src/core/theme/float.ts +1 -0
  124. package/src/core/theme/parse-doc.ts +10 -5
  125. package/src/core/theme/popup-rules.ts +16 -0
  126. package/src/core/theme/triggers.ts +3 -2
  127. package/src/core/validate.ts +3 -2
  128. package/src/index.ts +23 -2
  129. package/src/mcp/ports.ts +18 -7
  130. package/src/mcp/proposals.ts +36 -11
  131. package/src/mcp/read.ts +2 -3
  132. package/src/mcp/tools.ts +1 -1
  133. package/src/server/agent-settings.ts +12 -1
  134. package/src/server/hooks.ts +41 -6
  135. package/src/server/icon-routes.ts +52 -12
  136. package/src/server/mcp-routes.ts +11 -5
  137. package/src/server/plugin.ts +27 -2
  138. package/src/server/presence.ts +5 -1
  139. package/src/server/proposals.ts +16 -4
  140. package/src/server/requests.ts +60 -11
  141. package/src/server/site-origin.ts +13 -0
  142. 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
+ }
723
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
+ }
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) => {
@@ -912,117 +990,106 @@ const progress: Widget = (s, ctx, el) => {
912
990
  return [box(ctx, children, { gap: { value: 8, unit: "px" } })];
913
991
  };
914
992
 
993
+ /** W-1022: Elementor's Testimonial → a Testimonial: quote, photo, name and job. */
915
994
  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
- }
995
+ const quote = plain(s["testimonial_content"]).text;
944
996
  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
- );
997
+ if (!quote && !name) return [];
952
998
  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 [];
999
+ const img = imageNode(ctx, el, s["testimonial_image"]);
1000
+ const photo = (img?.["props"] ?? {}) as Record<string, unknown>;
961
1001
  const where = textAlign(s["testimonial_alignment"]) ?? "center";
1002
+ const style: Style = { textAlign: where };
1003
+ if (where !== "left") style.alignItems = where === "right" ? "flex-end" : "center";
1004
+ const ink = colorAt(s, "content_content_color", ctx);
1005
+ if (ink) style.color = ink;
1006
+ if (s["content_typography_typography"] || s["name_text_color"] || s["job_text_color"])
1007
+ ctx.note(
1008
+ "approximated",
1009
+ el,
1010
+ "Testimonials keep one text style; name and job colours and fonts were simplified.",
1011
+ );
962
1012
  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
- }),
1013
+ node(
1014
+ ctx,
1015
+ "testimonial",
1016
+ {
1017
+ quote: short(quote),
1018
+ name: short(name, 200),
1019
+ ...(job ? { role: short(job, 200) } : {}),
1020
+ ...Object.fromEntries(
1021
+ ["src", "alt", "mediaId", "width", "height"]
1022
+ .filter((key) => photo[key] !== undefined)
1023
+ .map((key) => [key, photo[key]]),
1024
+ ),
1025
+ },
1026
+ { style },
1027
+ ),
968
1028
  ];
969
1029
  };
970
1030
 
1031
+ /** W-1023: Elementor's Star Rating → a Rating, with its title as text beside it. */
971
1032
  const starRating: Widget = (s, ctx, el) => {
972
1033
  const scale = Math.min(10, Math.max(1, Math.round(num(s["rating_scale"]) ?? 5)));
973
- const rating = Math.min(
1034
+ const value = Math.min(
974
1035
  scale,
975
1036
  Math.max(0, num(isRecord(s["rating"]) ? s["rating"]["size"] : s["rating"]) ?? scale),
976
1037
  );
977
- const full = Math.round(rating);
978
- const stars = `${"★".repeat(full)}${"☆".repeat(scale - full)}`;
1038
+ const size = num(isRecord(s["icon_size"]) ? s["icon_size"]["size"] : undefined);
1039
+ const rating = node(
1040
+ ctx,
1041
+ "rating",
1042
+ {
1043
+ value: Math.round(value * 10) / 10,
1044
+ max: scale,
1045
+ ...(size ? { size: Math.min(128, Math.max(8, Math.round(size))) } : {}),
1046
+ },
1047
+ { style: { color: colorAt(s, "stars_color", ctx) ?? "#f0ad4e" } },
1048
+ );
1049
+ if (s["star_style"] === "star_unicode" || s["unmarked_star_style"] === "outline")
1050
+ ctx.note("approximated", el, "Star ratings use EmVB's filled stars.");
979
1051
  const title = plain(s["title"]).text;
980
- ctx.note("approximated", el, "Star ratings are shown as star characters.");
1052
+ if (!title) return [rating];
981
1053
  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
- ),
1054
+ box(ctx, [node(ctx, "text", { text: short(title) }), rating], {
1055
+ flexDirection: "row",
1056
+ alignItems: "center",
1057
+ gap: { value: 8, unit: "px" },
1058
+ }),
990
1059
  ];
991
1060
  };
992
1061
 
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
- };
1062
+ const ALERT_KINDS = new Set(["info", "success", "warning", "danger"]);
1000
1063
 
1001
- const alert: Widget = (s, ctx, el) => {
1002
- const [bg, border, ink] = ALERTS[str(s["alert_type"]) ?? "info"] ?? INFO_ALERT;
1003
- const children: N[] = [];
1064
+ /**
1065
+ * W-1025: Elementor's Alert → an Alert of the same kind. Elementor shows no icon, so neither does
1066
+ * the import; its own colours, when set, stay as the element's styles; Dismiss stays dismissible.
1067
+ */
1068
+ const alert: Widget = (s, ctx) => {
1004
1069
  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
1070
  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.");
1071
+ if (!title && !description) return [];
1072
+ const kind = str(s["alert_type"]) ?? "info";
1073
+ const style: Style = {};
1074
+ const background = colorAt(s, "background", ctx);
1075
+ const border = colorAt(s, "border_color", ctx);
1076
+ const ink = colorAt(s, "title_color", ctx);
1077
+ if (background) style.backgroundColor = background;
1078
+ if (border) style.borderColor = border;
1079
+ if (ink) style.color = ink;
1013
1080
  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
- }),
1081
+ node(
1082
+ ctx,
1083
+ "alert",
1084
+ {
1085
+ variant: ALERT_KINDS.has(kind) ? kind : "info",
1086
+ ...(title ? { title: short(title, 200) } : {}),
1087
+ text: short(description),
1088
+ hideIcon: true,
1089
+ ...(str(s["show_dismiss"]) === "show" ? { dismissible: true } : {}),
1090
+ },
1091
+ Object.keys(style).length > 0 ? { style } : {},
1092
+ ),
1026
1093
  ];
1027
1094
  };
1028
1095
 
@@ -1065,50 +1132,116 @@ const googleMaps: Widget = (s, ctx, el) => {
1065
1132
  ];
1066
1133
  };
1067
1134
 
1068
- /** Galleries and carousels → a grid of images. */
1069
- function gallery(
1135
+ /**
1136
+ * W-1019: Elementor's Image Gallery and Gallery → a Gallery of Gallery images (up to 60), with
1137
+ * Elementor's lightbox kept (on unless the widget turns it off) and masonry when it used it.
1138
+ */
1139
+ function galleryWidget(
1070
1140
  list: unknown,
1071
1141
  columns: number,
1142
+ s: Settings,
1072
1143
  ctx: ImportContext,
1073
1144
  el: string,
1074
- imageKey?: string,
1075
1145
  ): N[] {
1076
- const items = Array.isArray(list) ? list.slice(0, 100) : [];
1077
- const images: N[] = [];
1078
- for (const item of items) {
1146
+ const items = Array.isArray(list) ? list : [];
1147
+ if (items.length > 60) ctx.note("skipped", el, "Galleries keep their first 60 pictures.");
1148
+ const pictures: N[] = [];
1149
+ for (const item of items.slice(0, 60)) {
1079
1150
  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
- }
1151
+ const img = imageNode(ctx, el, item);
1152
+ if (!img) continue;
1153
+ const props = img["props"] as Record<string, unknown>;
1154
+ pictures.push(
1155
+ node(
1156
+ ctx,
1157
+ "gallery-image",
1158
+ Object.fromEntries(
1159
+ ["src", "alt", "decorative", "mediaId", "width", "height"]
1160
+ .filter((key) => props[key] !== undefined)
1161
+ .map((key) => [key, props[key]]),
1162
+ ),
1163
+ ),
1164
+ );
1086
1165
  }
1087
- if (images.length === 0) return [];
1166
+ if (pictures.length === 0) return [];
1167
+ const lightbox = str(s["open_lightbox"]) !== "no";
1168
+ const masonry = str(s["gallery_layout"]) === "masonry" || s["masonry"] === "yes";
1088
1169
  return [
1089
1170
  node(
1090
1171
  ctx,
1091
- "grid",
1092
- { columns: Math.min(12, Math.max(1, Math.round(columns))) },
1172
+ "gallery",
1093
1173
  {
1094
- style: { gap: { value: 10, unit: "px" } },
1095
- children: images,
1174
+ ...(masonry ? { layout: "masonry" } : {}),
1175
+ columns: Math.min(6, Math.max(1, Math.round(columns))),
1176
+ ...(lightbox ? { lightbox: true } : {}),
1096
1177
  },
1178
+ { children: pictures },
1097
1179
  ),
1098
1180
  ];
1099
1181
  }
1100
1182
 
1101
1183
  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
- };
1184
+ galleryWidget(s["wp_gallery"], num(s["gallery_columns"]) ?? 4, s, ctx, el);
1185
+ const proGallery: Widget = (s, ctx, el) =>
1186
+ galleryWidget(s["gallery"], num(s["columns"]) ?? 4, s, ctx, el);
1187
+ /**
1188
+ * W-1018: Elementor's Image Carousel and Media Carousel → a Carousel with one picture per slide.
1189
+ * Navigation and looping follow Elementor's settings. Elementor plays by default; EmVB doesn't,
1190
+ * so autoplay comes over only when the widget turned it on explicitly (with its speed).
1191
+ */
1192
+ function carouselWidget(
1193
+ list: unknown,
1194
+ perView: number,
1195
+ s: Settings,
1196
+ ctx: ImportContext,
1197
+ el: string,
1198
+ imageKey?: string,
1199
+ ): N[] {
1200
+ const items = Array.isArray(list) ? list : [];
1201
+ if (items.length > 20) ctx.note("skipped", el, "Carousels keep their first 20 slides.");
1202
+ const slides: N[] = [];
1203
+ for (const item of items.slice(0, 20)) {
1204
+ if (ctx.overBudget) break;
1205
+ const img = imageNode(ctx, el, imageKey && isRecord(item) ? item[imageKey] : item);
1206
+ if (!img) continue;
1207
+ img["style"] = { width: { value: 100, unit: "%" }, height: "auto" };
1208
+ slides.push(node(ctx, "carousel-slide", {}, { children: [img] }));
1209
+ }
1210
+ if (slides.length === 0) return [];
1211
+ const navigation = str(s["navigation"]) ?? "both";
1212
+ const autoplay = str(s["autoplay"]);
1213
+ if (autoplay !== "yes" && autoplay !== "no")
1214
+ ctx.note(
1215
+ "approximated",
1216
+ el,
1217
+ "Carousels don't play by themselves unless you turn on Play automatically.",
1218
+ );
1219
+ const speed = num(s["autoplay_speed"]);
1220
+ return [
1221
+ node(
1222
+ ctx,
1223
+ "carousel",
1224
+ {
1225
+ perView: Math.min(4, Math.max(1, Math.round(perView))),
1226
+ ...(navigation === "both" || navigation === "arrows" ? { arrows: true } : {}),
1227
+ ...(navigation === "both" || navigation === "dots" ? { dots: true } : {}),
1228
+ ...(autoplay === "yes"
1229
+ ? {
1230
+ autoplay: true,
1231
+ ...(speed ? { interval: Math.min(30, Math.max(3, Math.round(speed / 1000))) } : {}),
1232
+ }
1233
+ : {}),
1234
+ ...(str(s["infinite"]) === "no" ? {} : { loop: true }),
1235
+ },
1236
+ { children: slides },
1237
+ ),
1238
+ ];
1239
+ }
1240
+
1241
+ const imageCarousel: Widget = (s, ctx, el) =>
1242
+ carouselWidget(s["carousel"], num(s["slides_to_show"]) ?? 3, s, ctx, el);
1243
+ const mediaCarousel: Widget = (s, ctx, el) =>
1244
+ carouselWidget(s["slides"], num(s["slides_per_view"]) ?? 3, s, ctx, el, "image");
1112
1245
 
1113
1246
  const BRANDS: Record<string, string> = {
1114
1247
  facebook: "#3b5998",
@@ -1137,7 +1270,103 @@ const BRANDS: Record<string, string> = {
1137
1270
  "square-x-twitter": "#000000",
1138
1271
  };
1139
1272
 
1140
- const socialIcons: Widget = (s, ctx, el) => {
1273
+ /** W-1024: Font Awesome icon names Elementor's Social Icons use → EmVB's Social link networks. */
1274
+ const SOCIAL_FROM_FA: Record<string, string> = {
1275
+ facebook: "facebook",
1276
+ "facebook-f": "facebook",
1277
+ "square-facebook": "facebook",
1278
+ instagram: "instagram",
1279
+ "square-instagram": "instagram",
1280
+ twitter: "x",
1281
+ "x-twitter": "x",
1282
+ "square-x-twitter": "x",
1283
+ "square-twitter": "x",
1284
+ linkedin: "linkedin",
1285
+ "linkedin-in": "linkedin",
1286
+ youtube: "youtube",
1287
+ "square-youtube": "youtube",
1288
+ tiktok: "tiktok",
1289
+ bluesky: "bluesky",
1290
+ mastodon: "mastodon",
1291
+ threads: "threads",
1292
+ "square-threads": "threads",
1293
+ github: "github",
1294
+ "square-github": "github",
1295
+ pinterest: "pinterest",
1296
+ "pinterest-p": "pinterest",
1297
+ "square-pinterest": "pinterest",
1298
+ whatsapp: "whatsapp",
1299
+ "square-whatsapp": "whatsapp",
1300
+ discord: "discord",
1301
+ twitch: "twitch",
1302
+ reddit: "reddit",
1303
+ "reddit-alien": "reddit",
1304
+ dribbble: "dribbble",
1305
+ behance: "behance",
1306
+ telegram: "telegram",
1307
+ "telegram-plane": "telegram",
1308
+ spotify: "spotify",
1309
+ envelope: "email",
1310
+ rss: "rss",
1311
+ globe: "website",
1312
+ };
1313
+
1314
+ /**
1315
+ * W-1024: Elementor's Social Icons → Social icons, one Social link per profile. Elementor's
1316
+ * default colours are the brands', so they stay brand colours; custom ones become the badge
1317
+ * colour. A network EmVB has no preset for (Vimeo, Snapchat…) keeps the whole widget as icons.
1318
+ */
1319
+ const socialIcons: Widget = (s, ctx, el, env, raw) => {
1320
+ const items = (Array.isArray(s["social_icon_list"]) ? s["social_icon_list"] : [])
1321
+ .filter(isRecord)
1322
+ .slice(0, 20);
1323
+ const networks = items.map((item) => {
1324
+ const value = item["social_icon"] ?? item["social"];
1325
+ const name = isRecord(value) ? str(value["value"]) : str(value);
1326
+ return SOCIAL_FROM_FA[(name ?? "").replace(/^fa[brs]? fa-/, "").replace(/^fa-/, "")];
1327
+ });
1328
+ if (items.length === 0 || networks.some((network) => !network))
1329
+ return socialIconsAsIcons(s, ctx, el, env, raw);
1330
+ const links = items.map((item, i) => {
1331
+ const linkProps = href(item["link"], ctx);
1332
+ return node(ctx, "social-link", {
1333
+ network: networks[i],
1334
+ href: linkProps.href ?? "",
1335
+ ...(linkProps.newTab ? { newTab: true } : {}),
1336
+ });
1337
+ });
1338
+ const shape = str(s["shape"]) ?? "rounded";
1339
+ const custom = str(s["icon_color"]) === "custom";
1340
+ const style: Style = {};
1341
+ const size = slider(s["icon_size"]);
1342
+ if (size && size.unit === "px") style.fontSize = { value: Math.round(size.value), unit: "px" };
1343
+ const gap = slider(s["icon_spacing"]);
1344
+ if (gap) style.gap = gap;
1345
+ const where = textAlign(s["align"]);
1346
+ if (where)
1347
+ style.justifyContent =
1348
+ where === "left" ? "flex-start" : where === "right" ? "flex-end" : "center";
1349
+ if (custom) {
1350
+ const badge = colorAt(s, "icon_primary_color", ctx);
1351
+ if (badge) style.color = badge;
1352
+ if (colorAt(s, "icon_secondary_color", ctx))
1353
+ ctx.note("approximated", el, "Social icons draw their icons in white on the badge colour.");
1354
+ }
1355
+ return [
1356
+ node(
1357
+ ctx,
1358
+ "social-icons",
1359
+ {
1360
+ shape: shape === "circle" || shape === "square" ? shape : "rounded",
1361
+ ...(custom ? {} : { brandColors: true }),
1362
+ },
1363
+ { children: links, ...(Object.keys(style).length > 0 ? { style } : {}) },
1364
+ ),
1365
+ ];
1366
+ };
1367
+
1368
+ /** Before W-1024, and still for networks without a preset: each icon an Icon on its colour. */
1369
+ const socialIconsAsIcons: Widget = (s, ctx, el) => {
1141
1370
  const items = Array.isArray(s["social_icon_list"]) ? s["social_icon_list"].slice(0, 50) : [];
1142
1371
  const size = slider(s["icon_size"]);
1143
1372
  const px = size && size.unit === "px" ? Math.round(size.value) : 25;
@@ -1338,14 +1567,46 @@ const form: Widget = (s, ctx, el) => {
1338
1567
  ];
1339
1568
  };
1340
1569
 
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.`,
1570
+ /** W-1026: a site menu's links as Menu items (three levels, as the Menu shows). */
1571
+ function menuItems(ctx: ImportContext, links: readonly MenuLink[], depth = 0): N[] {
1572
+ return links.slice(0, 50).map((entry) =>
1573
+ node(
1574
+ ctx,
1575
+ "menu-item",
1576
+ {
1577
+ text: short(entry.text || "Link", 200),
1578
+ ...(entry.href ? { href: entry.href.slice(0, 2000) } : {}),
1579
+ ...(entry.newTab ? { newTab: true } : {}),
1580
+ },
1581
+ { children: depth < 2 && entry.children ? menuItems(ctx, entry.children, depth + 1) : [] },
1582
+ ),
1346
1583
  );
1584
+ }
1585
+
1586
+ /**
1587
+ * Elementor's Nav Menu → a Menu. W-1026: filled with the site menu's links when the dialog
1588
+ * found it (EmDash's WordPress import keeps the menu's name); otherwise empty, with a note.
1589
+ */
1590
+ const navMenu: Widget = (s, ctx, el) => {
1591
+ const name = str(s["menu"])?.trim();
1347
1592
  const vertical = str(s["layout"]) === "vertical" || str(s["layout"]) === "dropdown";
1348
- return [node(ctx, "menu", { direction: vertical ? "column" : "row" }, { children: [] })];
1593
+ if (name) ctx.menus.add(name.slice(0, 100));
1594
+ const links = name ? ctx.menuOf?.(name) : undefined;
1595
+ if (!links || links.length === 0) {
1596
+ ctx.note(
1597
+ "approximated",
1598
+ el,
1599
+ `The WordPress menu${name ? ` "${name.slice(0, 40)}"` : ""} isn't on this site; add its links to the Menu in the editor.`,
1600
+ );
1601
+ }
1602
+ return [
1603
+ node(
1604
+ ctx,
1605
+ "menu",
1606
+ { direction: vertical ? "column" : "row" },
1607
+ { children: links ? menuItems(ctx, links) : [] },
1608
+ ),
1609
+ ];
1349
1610
  };
1350
1611
 
1351
1612
  const megaMenu: Widget = (s, ctx, _el, env, raw) => {
package/src/core/index.ts CHANGED
@@ -93,6 +93,7 @@ export {
93
93
  plainTextOf,
94
94
  withPlainText,
95
95
  } from "./elements/plain-text.ts";
96
+ export { layoutSearchText } from "./search-text.ts";
96
97
  export {
97
98
  StyleProps,
98
99
  FlatStyleProps,
@@ -100,6 +101,8 @@ export {
100
101
  type StylePatch,
101
102
  StyleStates,
102
103
  DeviceStyles,
104
+ OwnStyle,
105
+ WideStyle,
103
106
  HiddenOn,
104
107
  ColorValue,
105
108
  Length,
@@ -217,13 +220,20 @@ export {
217
220
  type ImportLosses,
218
221
  } from "./design/transfer.ts";
219
222
  export {
223
+ hiddenOnDevice,
224
+ hiddenOnEveryDevice,
220
225
  patchClassDevices,
226
+ patchClassWide,
221
227
  patchDeviceStyle,
228
+ patchWideStyle,
222
229
  toggleHidden,
230
+ toggleHiddenOn,
231
+ wideHideIsOwn,
223
232
  type ResponsiveDevice,
224
233
  } from "./design/devices.ts";
225
234
  export {
226
235
  renderPage,
236
+ sharedPartCss,
227
237
  type RenderMode,
228
238
  type RenderResult,
229
239
  type RenderWarning,
@@ -379,6 +389,10 @@ export {
379
389
  POPUP_DEVICES,
380
390
  DEVICES,
381
391
  type Device,
392
+ EDITOR_DEVICES,
393
+ type EditorDevice,
394
+ WIDE_MIN_PX,
395
+ WIDE_PREVIEW_PX,
382
396
  STYLE_DEVICES,
383
397
  type StyleDevice,
384
398
  DEVICE_MEDIA,