@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
@@ -1,8 +1,17 @@
1
+ import { boundedArray } from "../bounded-array.ts";
1
2
  import { z } from "zod";
2
3
  import { LIST_MARKERS } from "../css-keywords.ts";
3
4
  import { MAX_TEXT_LENGTH } from "../limits.ts";
4
5
  import { ImageEdit } from "../image-edit/schema.ts";
5
- import { ColorValue, DeviceStyles, HiddenOn, Length, StyleProps, StyleStates } from "./style.ts";
6
+ import {
7
+ ColorValue,
8
+ DeviceStyles,
9
+ HiddenOn,
10
+ Length,
11
+ OwnStyle,
12
+ StyleProps,
13
+ StyleStates,
14
+ } from "./style.ts";
6
15
 
7
16
  /**
8
17
  * 16 since W-481 (D-061): an optional editor-only `edit` record on images (image editor).
@@ -33,7 +42,7 @@ export const CONTRACT_VERSION = "1.0";
33
42
  export const NodeId = z
34
43
  .string()
35
44
  .regex(/^[A-Za-z0-9_-]{4,24}$/, "Ids are 4-24 letters, digits, _ or -");
36
- const ClassIds = z.array(z.string().regex(/^[a-z0-9-]{1,40}$/)).max(20);
45
+ const ClassIds = boundedArray(z.string().regex(/^[a-z0-9-]{1,40}$/), 20);
37
46
  /** CSS id attribute (Advanced). Letters first; unique on the page (checked in validateLayout). */
38
47
  const HtmlId = z
39
48
  .string()
@@ -68,7 +77,7 @@ const HtmlAttribute = z.strictObject({
68
77
  value: z.string().max(200),
69
78
  });
70
79
 
71
- const HtmlAttributes = z.array(HtmlAttribute).max(20);
80
+ const HtmlAttributes = boundedArray(HtmlAttribute, 20);
72
81
 
73
82
  /** Where a bound field reads its live value (W-307). */
74
83
  export const BIND_SOURCES = ["post", "site", "param"] as const;
@@ -132,14 +141,14 @@ export const Audience = z.strictObject({
132
141
  .min(1)
133
142
  .max(50)
134
143
  .optional(),
135
- devices: z.array(z.enum(AUDIENCE_DEVICES)).min(1).max(3).optional(),
144
+ devices: boundedArray(z.enum(AUDIENCE_DEVICES), 3, 1).optional(),
136
145
  visitor: z.enum(["new", "returning"]).optional(),
137
146
  /** From hour `from` up to (not including) hour `to`, 0–24; wraps past midnight when to < from. */
138
147
  hours: z
139
148
  .strictObject({ from: z.number().int().min(0).max(23), to: z.number().int().min(0).max(24) })
140
149
  .optional(),
141
150
  /** Days of the week, 0 = Sunday. */
142
- days: z.array(z.number().int().min(0).max(6)).min(1).max(7).optional(),
151
+ days: boundedArray(z.number().int().min(0).max(6), 7, 1).optional(),
143
152
  /** IANA time zone for hours and days, e.g. America/Toronto. Unset = UTC. */
144
153
  timeZone: z
145
154
  .string()
@@ -150,7 +159,7 @@ export const Audience = z.strictObject({
150
159
  * Visitor segments the host passes (W-329), e.g. `member`, `plan:pro`: the rule matches a
151
160
  * visitor in any of them. A letter or digit, then letters, digits, `:`, `_` or `-`, up to 64.
152
161
  */
153
- segments: z.array(z.string().regex(AUDIENCE_SEGMENT, SEGMENT_HINT)).min(1).max(20).optional(),
162
+ segments: boundedArray(z.string().regex(AUDIENCE_SEGMENT, SEGMENT_HINT), 20, 1).optional(),
154
163
  hide: z.boolean().optional(),
155
164
  });
156
165
  export type Audience = z.infer<typeof Audience>;
@@ -167,7 +176,7 @@ const BoxLink = {
167
176
  * `dir`, `container` and `query` before this.
168
177
  */
169
178
  const sharedNodeFields = {
170
- style: StyleProps.optional(),
179
+ style: OwnStyle.optional(),
171
180
  states: StyleStates.optional(),
172
181
  devices: DeviceStyles.optional(),
173
182
  hiddenOn: HiddenOn.optional(),
@@ -210,7 +219,7 @@ const parentNode = <T extends string, P extends z.ZodType>(type: T, props: P) =>
210
219
  z.strictObject({
211
220
  ...nodeFields(type, props),
212
221
  get children(): z.ZodType<LayoutNode[]> {
213
- return z.array(LayoutNode);
222
+ return ChildList;
214
223
  },
215
224
  });
216
225
 
@@ -232,7 +241,7 @@ export const TextMark = z.strictObject({
232
241
  newTab: z.literal(true).optional(),
233
242
  });
234
243
  export type TextMark = z.infer<typeof TextMark>;
235
- const TextMarks = z.array(TextMark).max(MAX_TEXT_MARKS);
244
+ const TextMarks = boundedArray(TextMark, MAX_TEXT_MARKS);
236
245
 
237
246
  export const HeadingNode = leafNode(
238
247
  "heading",
@@ -305,7 +314,7 @@ export const ListNode = leafNode(
305
314
  marker: z.enum(LIST_MARKERS).optional(),
306
315
  /** W-952: the first number of a numbered list. */
307
316
  start: z.number().int().min(1).max(9999).optional(),
308
- items: z.array(z.string().max(MAX_TEXT_LENGTH)).max(200),
317
+ items: boundedArray(z.string().max(MAX_TEXT_LENGTH), 200),
309
318
  }),
310
319
  );
311
320
 
@@ -437,7 +446,7 @@ export const FlexboxNode = parentNode("flexbox", z.strictObject({ ...BoxLink }))
437
446
  */
438
447
  const GRID_TRACK =
439
448
  /^(?:1fr|2fr|3fr|auto|min-content|max-content|0|(?:\d+(?:\.\d+)?)(?:px|rem|em|%|vw|vh|ch))$/;
440
- const GridTracks = z.array(z.string().regex(GRID_TRACK)).min(1).max(12);
449
+ const GridTracks = boundedArray(z.string().regex(GRID_TRACK), 12, 1);
441
450
 
442
451
  export const GridNode = parentNode(
443
452
  "grid",
@@ -762,6 +771,17 @@ export const KNOWN_ELEMENT_TYPES = [
762
771
  "layout-section",
763
772
  "toc",
764
773
  "language-switcher",
774
+ "rating",
775
+ "alert",
776
+ "icon-box",
777
+ "image-box",
778
+ "testimonial",
779
+ "social-icons",
780
+ "social-link",
781
+ "gallery",
782
+ "gallery-image",
783
+ "carousel",
784
+ "carousel-slide",
765
785
  ] as const;
766
786
 
767
787
  /** Headings on this page, as a list of links. No script (W-345). */
@@ -783,6 +803,251 @@ export const LanguageSwitcherNode = leafNode(
783
803
  }),
784
804
  );
785
805
 
806
+ /** W-1023: most stars a Rating shows. */
807
+ export const MAX_RATING = 10;
808
+
809
+ /**
810
+ * W-1023: a star rating, `value` out of `max` (5 when unset), in steps as fine as a tenth. Screen
811
+ * readers hear `label` with {value} and {max} filled in; unset it says "Rated 4.5 out of 5".
812
+ * A value above `max` shows as `max`, so lowering the number of stars never makes a page invalid.
813
+ */
814
+ export const RatingNode = leafNode(
815
+ "rating",
816
+ z.strictObject({
817
+ value: z.number().min(0).max(MAX_RATING),
818
+ max: z.number().int().min(1).max(MAX_RATING).optional(),
819
+ label: z.string().max(120).optional(),
820
+ /** Each star's width and height in px. Unset = 20. */
821
+ size: z.number().int().min(8).max(128).optional(),
822
+ }),
823
+ );
824
+
825
+ /** W-1025: the kinds of Alert, each with its own colours and icon. */
826
+ export const ALERT_VARIANTS = ["info", "success", "warning", "danger"] as const;
827
+
828
+ /**
829
+ * W-1025: a notice: an optional title and text in the variant's colours, with its icon unless
830
+ * `hideIcon`. `dismissible` adds a close button that the opt-in alerts runtime shows and wires;
831
+ * without that script the notice simply stays.
832
+ */
833
+ export const AlertNode = leafNode(
834
+ "alert",
835
+ z.strictObject({
836
+ variant: z.enum(ALERT_VARIANTS),
837
+ title: z.string().max(200).optional(),
838
+ text: z.string().max(MAX_TEXT_LENGTH),
839
+ hideIcon: z.boolean().optional(),
840
+ dismissible: z.boolean().optional(),
841
+ /** The close button's name for screen readers. Unset = "Dismiss". */
842
+ dismissLabel: z.string().max(80).optional(),
843
+ }),
844
+ );
845
+
846
+ /** W-1020: where a media box puts its icon or image: above, or before or after the words. */
847
+ export const MEDIA_BOX_POSITIONS = ["top", "left", "right"] as const;
848
+
849
+ /** W-1020 / W-1021: what an icon box and an image box share: title, text, link, layout. */
850
+ const MediaBoxText = {
851
+ title: z.string().max(200),
852
+ /** The title's heading level. Unset = 3. */
853
+ titleLevel: z.number().int().min(2).max(6).optional(),
854
+ text: z.string().max(MAX_TEXT_LENGTH),
855
+ position: z.enum(MEDIA_BOX_POSITIONS).optional(),
856
+ /** Optional link: the title is the link, and the whole box is clickable. */
857
+ href: z.string().max(2000).optional(),
858
+ newTab: z.boolean().optional(),
859
+ };
860
+
861
+ /**
862
+ * W-1020: an icon above (or beside) a title and text, like Elementor's Icon Box. The icon is
863
+ * decorative: the title says what the box is. `iconId` and `iconSvg` work as on an Icon.
864
+ */
865
+ export const IconBoxNode = leafNode(
866
+ "icon-box",
867
+ z.strictObject({
868
+ iconId: z.string().min(1).max(64),
869
+ iconSvg: z.string().max(ICON_SVG_MAX).optional(),
870
+ /** The icon's width and height in px. Unset = 48. */
871
+ iconSize: z.number().int().min(8).max(512).optional(),
872
+ ...MediaBoxText,
873
+ }),
874
+ );
875
+
876
+ /** W-1021: how much of the box's width an image box's picture takes when beside the words. */
877
+ export const IMAGE_BOX_SIZES = ["small", "medium", "large", "full"] as const;
878
+
879
+ /**
880
+ * W-1021: a picture above (or beside) a title and text, like Elementor's Image Box. The picture
881
+ * keys are an Image's, so the media library fills them the same way; alt text is required unless
882
+ * the picture is decorative.
883
+ */
884
+ export const ImageBoxNode = leafNode(
885
+ "image-box",
886
+ z.strictObject({
887
+ src: z.string().max(2000),
888
+ alt: z.string().max(500),
889
+ decorative: z.boolean().optional(),
890
+ mediaId: z.string().min(1).max(128).optional(),
891
+ width: z.number().int().positive().max(10000).optional(),
892
+ height: z.number().int().positive().max(10000).optional(),
893
+ focalX: z.number().int().min(0).max(100).optional(),
894
+ focalY: z.number().int().min(0).max(100).optional(),
895
+ /** Beside the words: small 25 %, medium 40 %, large 60 % of the box. Unset = medium. */
896
+ imageSize: z.enum(IMAGE_BOX_SIZES).optional(),
897
+ ...MediaBoxText,
898
+ }),
899
+ ).refine((node) => node.props.decorative === true || node.props.alt.length > 0, {
900
+ message: "Alt text is required unless the image is marked decorative.",
901
+ path: ["props", "alt"],
902
+ });
903
+
904
+ /**
905
+ * W-1022: a quote in a figure: the words as a blockquote, then who said them (name and role) with
906
+ * an optional photo, and an optional star rating read as "Rated 5 out of 5". The photo is shown
907
+ * beside the name, so it is decorative; its keys are an Image's so the media library fills them.
908
+ */
909
+ export const TestimonialNode = leafNode(
910
+ "testimonial",
911
+ z.strictObject({
912
+ quote: z.string().max(MAX_TEXT_LENGTH),
913
+ name: z.string().max(200),
914
+ role: z.string().max(200).optional(),
915
+ src: z.string().max(2000).optional(),
916
+ /** Written by the media library; never rendered (the photo is beside the name). */
917
+ alt: z.string().max(500).optional(),
918
+ mediaId: z.string().min(1).max(128).optional(),
919
+ width: z.number().int().positive().max(10000).optional(),
920
+ height: z.number().int().positive().max(10000).optional(),
921
+ focalX: z.number().int().min(0).max(100).optional(),
922
+ focalY: z.number().int().min(0).max(100).optional(),
923
+ /** Stars out of `ratingMax` (unset 5); no stars when unset. */
924
+ rating: z.number().min(0).max(MAX_RATING).optional(),
925
+ ratingMax: z.number().int().min(1).max(MAX_RATING).optional(),
926
+ }),
927
+ );
928
+
929
+ /** W-1024: the Social icons presets (Font Awesome Free brand icons, plus email, RSS, website). */
930
+ export const SOCIAL_NETWORKS = [
931
+ "facebook",
932
+ "instagram",
933
+ "x",
934
+ "linkedin",
935
+ "youtube",
936
+ "tiktok",
937
+ "bluesky",
938
+ "mastodon",
939
+ "threads",
940
+ "github",
941
+ "pinterest",
942
+ "whatsapp",
943
+ "discord",
944
+ "twitch",
945
+ "reddit",
946
+ "dribbble",
947
+ "behance",
948
+ "telegram",
949
+ "spotify",
950
+ "email",
951
+ "rss",
952
+ "website",
953
+ ] as const;
954
+ /** W-1024: how each icon is drawn: on its own, or in a circle, rounded or square badge. */
955
+ export const SOCIAL_SHAPES = ["plain", "circle", "rounded", "square"] as const;
956
+
957
+ /**
958
+ * W-1024: a list of links to the site's social profiles, each a brand icon named for screen
959
+ * readers ("Instagram"). Holds Social links only. `label` names the list (unset "Social media");
960
+ * `brandColors` paints each icon in its network's colour; icons follow the font size.
961
+ */
962
+ export const SocialIconsNodeSchema = parentNode(
963
+ "social-icons",
964
+ z.strictObject({
965
+ label: z.string().max(80).optional(),
966
+ shape: z.enum(SOCIAL_SHAPES).optional(),
967
+ brandColors: z.boolean().optional(),
968
+ }),
969
+ );
970
+
971
+ /** W-1024: one profile link in Social icons. `label` replaces the network's name. */
972
+ export const SocialLinkNode = leafNode(
973
+ "social-link",
974
+ z.strictObject({
975
+ network: z.enum(SOCIAL_NETWORKS),
976
+ href: z.string().max(2000),
977
+ label: z.string().max(80).optional(),
978
+ newTab: z.boolean().optional(),
979
+ }),
980
+ );
981
+
982
+ /** W-1019: a Gallery's layout: equal squares in a grid, or each picture its own height. */
983
+ export const GALLERY_LAYOUTS = ["grid", "masonry"] as const;
984
+
985
+ /**
986
+ * W-1019: pictures from the media library in a grid or masonry columns (1–6 on wide screens; at
987
+ * most 2 on tablets and 1 on phones). Holds Gallery images only. `lightbox` opts in to a script
988
+ * that opens each picture large in a native dialog; without it the gallery uses no script.
989
+ */
990
+ export const GalleryNodeSchema = parentNode(
991
+ "gallery",
992
+ z.strictObject({
993
+ layout: z.enum(GALLERY_LAYOUTS).optional(),
994
+ columns: z.number().int().min(1).max(6).optional(),
995
+ lightbox: z.boolean().optional(),
996
+ /** Names the list for screen readers. Unset = no name. */
997
+ label: z.string().max(80).optional(),
998
+ }),
999
+ );
1000
+
1001
+ /** W-1019: one picture in a Gallery: an Image's picture keys, alt text and an optional caption. */
1002
+ export const GalleryImageNode = leafNode(
1003
+ "gallery-image",
1004
+ z.strictObject({
1005
+ src: z.string().max(2000),
1006
+ alt: z.string().max(500),
1007
+ decorative: z.boolean().optional(),
1008
+ mediaId: z.string().min(1).max(128).optional(),
1009
+ width: z.number().int().positive().max(10000).optional(),
1010
+ height: z.number().int().positive().max(10000).optional(),
1011
+ focalX: z.number().int().min(0).max(100).optional(),
1012
+ focalY: z.number().int().min(0).max(100).optional(),
1013
+ caption: z.string().max(500).optional(),
1014
+ }),
1015
+ ).refine((node) => node.props.decorative === true || node.props.alt.length > 0, {
1016
+ message: "Alt text is required unless the picture is marked decorative.",
1017
+ path: ["props", "alt"],
1018
+ });
1019
+
1020
+ /**
1021
+ * W-1018: slides on a horizontal track that snaps to each one, swiped, scrolled or moved with
1022
+ * the arrow keys, with no script. `arrows`, `dots` and `autoplay` opt in to the carousel
1023
+ * script, which adds those controls. Autoplay is off unless set; when on, a visible Pause button
1024
+ * comes first, hovering or focusing the carousel pauses it, and under reduced motion it starts
1025
+ * paused (WCAG 2.2.2). `perView` slides show at once (at most 2 on tablets, 1 on phones).
1026
+ */
1027
+ export const CarouselNodeSchema = parentNode(
1028
+ "carousel",
1029
+ z.strictObject({
1030
+ /** Names the carousel for screen readers. Unset = "Carousel". */
1031
+ label: z.string().max(80).optional(),
1032
+ perView: z.number().int().min(1).max(4).optional(),
1033
+ arrows: z.boolean().optional(),
1034
+ dots: z.boolean().optional(),
1035
+ autoplay: z.boolean().optional(),
1036
+ /** Seconds per slide while playing. Unset = 6. */
1037
+ interval: z.number().int().min(3).max(30).optional(),
1038
+ /** After the last slide, Next and autoplay go back to the first. */
1039
+ loop: z.boolean().optional(),
1040
+ }),
1041
+ );
1042
+
1043
+ /** W-1018: one slide; holds any elements. `label` names it instead of "2 of 5". */
1044
+ export const CarouselSlideNode = parentNode(
1045
+ "carousel-slide",
1046
+ z.strictObject({
1047
+ label: z.string().max(80).optional(),
1048
+ }),
1049
+ );
1050
+
786
1051
  const knownTypeSet = new Set<string>(KNOWN_ELEMENT_TYPES);
787
1052
 
788
1053
  /**
@@ -800,7 +1065,7 @@ const UnknownNodeSchema = z.strictObject({
800
1065
  props: z.record(z.string(), z.unknown()),
801
1066
  ...sharedNodeFields,
802
1067
  get children(): z.ZodType<LayoutNode[] | undefined> {
803
- return z.array(LayoutNode).optional();
1068
+ return ChildList.optional();
804
1069
  },
805
1070
  });
806
1071
 
@@ -816,6 +1081,17 @@ const KnownLayoutNode = z.discriminatedUnion("type", [
816
1081
  HeadingNode,
817
1082
  TocNode,
818
1083
  LanguageSwitcherNode,
1084
+ RatingNode,
1085
+ AlertNode,
1086
+ IconBoxNode,
1087
+ ImageBoxNode,
1088
+ TestimonialNode,
1089
+ SocialIconsNodeSchema,
1090
+ SocialLinkNode,
1091
+ GalleryNodeSchema,
1092
+ GalleryImageNode,
1093
+ CarouselNodeSchema,
1094
+ CarouselSlideNode,
819
1095
  SpacerNode,
820
1096
  DividerNode,
821
1097
  TextNode,
@@ -856,6 +1132,13 @@ export const KNOWN_NODE_SCHEMAS = KnownLayoutNode.options;
856
1132
  export type HeadingNode = z.infer<typeof HeadingNode>;
857
1133
  export type TocNode = z.infer<typeof TocNode>;
858
1134
  export type LanguageSwitcherNode = z.infer<typeof LanguageSwitcherNode>;
1135
+ export type RatingNode = z.infer<typeof RatingNode>;
1136
+ export type AlertNode = z.infer<typeof AlertNode>;
1137
+ export type IconBoxNode = z.infer<typeof IconBoxNode>;
1138
+ export type ImageBoxNode = z.infer<typeof ImageBoxNode>;
1139
+ export type TestimonialNode = z.infer<typeof TestimonialNode>;
1140
+ export type SocialLinkNode = z.infer<typeof SocialLinkNode>;
1141
+ export type GalleryImageNode = z.infer<typeof GalleryImageNode>;
859
1142
  export type SpacerNode = z.infer<typeof SpacerNode>;
860
1143
  export type DividerNode = z.infer<typeof DividerNode>;
861
1144
  export type TextNode = z.infer<typeof TextNode>;
@@ -903,7 +1186,7 @@ export type NodeExtras = {
903
1186
  /** Identity, style and extras shared by every node type (W-352). */
904
1187
  type NodeEnvelope = {
905
1188
  id: IdOf;
906
- style?: StyleOf;
1189
+ style?: z.infer<typeof OwnStyle>;
907
1190
  states?: StatesOf;
908
1191
  devices?: DevicesOf;
909
1192
  hiddenOn?: HiddenOnOf;
@@ -1021,6 +1304,30 @@ export type AccordionNode = NodeEnvelope & {
1021
1304
  children: LayoutNode[];
1022
1305
  };
1023
1306
 
1307
+ export type SocialIconsNode = NodeEnvelope & {
1308
+ type: "social-icons";
1309
+ props: z.infer<typeof SocialIconsNodeSchema>["props"];
1310
+ children: LayoutNode[];
1311
+ };
1312
+
1313
+ export type CarouselNode = NodeEnvelope & {
1314
+ type: "carousel";
1315
+ props: z.infer<typeof CarouselNodeSchema>["props"];
1316
+ children: LayoutNode[];
1317
+ };
1318
+
1319
+ export type CarouselSlideNode = NodeEnvelope & {
1320
+ type: "carousel-slide";
1321
+ props: { label?: string };
1322
+ children: LayoutNode[];
1323
+ };
1324
+
1325
+ export type GalleryNode = NodeEnvelope & {
1326
+ type: "gallery";
1327
+ props: z.infer<typeof GalleryNodeSchema>["props"];
1328
+ children: LayoutNode[];
1329
+ };
1330
+
1024
1331
  export type MenuNode = NodeEnvelope & {
1025
1332
  type: "menu";
1026
1333
  props: { direction: "row" | "column"; label?: string };
@@ -1055,6 +1362,17 @@ export type LayoutNode =
1055
1362
  | HeadingNode
1056
1363
  | TocNode
1057
1364
  | LanguageSwitcherNode
1365
+ | RatingNode
1366
+ | AlertNode
1367
+ | IconBoxNode
1368
+ | ImageBoxNode
1369
+ | TestimonialNode
1370
+ | SocialIconsNode
1371
+ | SocialLinkNode
1372
+ | GalleryNode
1373
+ | GalleryImageNode
1374
+ | CarouselNode
1375
+ | CarouselSlideNode
1058
1376
  | SpacerNode
1059
1377
  | DividerNode
1060
1378
  | TextNode
@@ -1085,6 +1403,9 @@ export type LayoutNode =
1085
1403
  | MenuItemNode
1086
1404
  | UnknownNode;
1087
1405
 
1406
+ /** S-03: the issues one element reports before "…and N more". */
1407
+ const MAX_NODE_ISSUES = 10;
1408
+
1088
1409
  /**
1089
1410
  * Prefer the known-type schema when `type` is registered so path-specific Zod issues stay
1090
1411
  * intact; only fall through to UnknownNode for types EmVB does not implement (W-022 / R-033).
@@ -1106,7 +1427,8 @@ const LayoutNode: z.ZodType<LayoutNode> = z.lazy(() =>
1106
1427
  ? KnownLayoutNode.safeParse(input)
1107
1428
  : UnknownNodeSchema.safeParse(input);
1108
1429
  if (!result.success) {
1109
- for (const issue of result.error.issues) {
1430
+ const issues = result.error.issues;
1431
+ for (const issue of issues.slice(0, MAX_NODE_ISSUES)) {
1110
1432
  ctx.addIssue({
1111
1433
  code: "custom",
1112
1434
  path: issue.path,
@@ -1114,12 +1436,68 @@ const LayoutNode: z.ZodType<LayoutNode> = z.lazy(() =>
1114
1436
  params: { zodCode: issue.code },
1115
1437
  });
1116
1438
  }
1439
+ // S-03: a node re-emits a few issues, not one per bad item, so a parent's count stays small.
1440
+ if (issues.length > MAX_NODE_ISSUES) {
1441
+ ctx.addIssue({
1442
+ code: "custom",
1443
+ path: [],
1444
+ message: `…and ${issues.length - MAX_NODE_ISSUES} more problems in this element.`,
1445
+ params: { zodCode: "too_many_issues" },
1446
+ });
1447
+ }
1117
1448
  return z.NEVER;
1118
1449
  }
1119
1450
  return result.data as LayoutNode;
1120
1451
  }),
1121
1452
  );
1122
1453
 
1454
+ /** S-03: the issues a list of children reports before the rest of them is skipped. */
1455
+ const MAX_CHILD_ISSUES = 40;
1456
+
1457
+ /**
1458
+ * Children parse one at a time and stop once they have reported MAX_CHILD_ISSUES issues: a
1459
+ * page of a thousand bad elements cost one issue list per element (180 MB on a 512 KB page).
1460
+ */
1461
+ const ChildList: z.ZodType<LayoutNode[]> = z.lazy(() =>
1462
+ z.array(z.unknown()).transform((items, ctx) => {
1463
+ const nodes: LayoutNode[] = [];
1464
+ let reported = 0;
1465
+ for (const [index, item] of items.entries()) {
1466
+ if (reported >= MAX_CHILD_ISSUES) {
1467
+ ctx.addIssue({
1468
+ code: "custom",
1469
+ path: [index],
1470
+ message: "…and more problems in the elements after this one.",
1471
+ params: { zodCode: "too_many_issues" },
1472
+ });
1473
+ return z.NEVER;
1474
+ }
1475
+ const result = LayoutNode.safeParse(item);
1476
+ if (result.success) {
1477
+ nodes.push(result.data);
1478
+ continue;
1479
+ }
1480
+ for (const issue of result.error.issues) {
1481
+ const params =
1482
+ "params" in issue ? (issue.params as { zodCode?: unknown } | undefined) : undefined;
1483
+ ctx.addIssue({
1484
+ code: "custom",
1485
+ path: [index, ...issue.path],
1486
+ message: issue.message,
1487
+ params: {
1488
+ zodCode:
1489
+ issue.code === "custom" && typeof params?.zodCode === "string"
1490
+ ? params.zodCode
1491
+ : issue.code,
1492
+ },
1493
+ });
1494
+ reported++;
1495
+ }
1496
+ }
1497
+ return reported > 0 ? z.NEVER : nodes;
1498
+ }),
1499
+ );
1500
+
1123
1501
  export const Layout = z.strictObject({
1124
1502
  schemaVersion: z.literal(LAYOUT_SCHEMA_VERSION),
1125
1503
  root: ContainerNode,
@@ -1173,7 +1551,8 @@ export const isLayoutParentNode = (
1173
1551
  | SectionNode
1174
1552
  | LoopEmptyNode
1175
1553
  | AccordionItemNode
1176
- | MenuItemNode =>
1554
+ | MenuItemNode
1555
+ | CarouselSlideNode =>
1177
1556
  node.type === "container" ||
1178
1557
  node.type === "div-block" ||
1179
1558
  node.type === "layout-section" ||
@@ -1183,7 +1562,8 @@ export const isLayoutParentNode = (
1183
1562
  node.type === "part-ref" ||
1184
1563
  node.type === "loop-empty" ||
1185
1564
  node.type === "accordion-item" ||
1186
- node.type === "menu-item";
1565
+ node.type === "menu-item" ||
1566
+ node.type === "carousel-slide";
1187
1567
 
1188
1568
  /** Nodes that may hold children. */
1189
1569
  export const isParentNode = (
@@ -1203,7 +1583,11 @@ export const isParentNode = (
1203
1583
  | AccordionNode
1204
1584
  | AccordionItemNode
1205
1585
  | MenuNode
1206
- | MenuItemNode =>
1586
+ | MenuItemNode
1587
+ | SocialIconsNode
1588
+ | GalleryNode
1589
+ | CarouselNode
1590
+ | CarouselSlideNode =>
1207
1591
  node.type === "container" ||
1208
1592
  node.type === "div-block" ||
1209
1593
  node.type === "layout-section" ||
@@ -1218,7 +1602,11 @@ export const isParentNode = (
1218
1602
  node.type === "accordion" ||
1219
1603
  node.type === "accordion-item" ||
1220
1604
  node.type === "menu" ||
1221
- node.type === "menu-item";
1605
+ node.type === "menu-item" ||
1606
+ node.type === "social-icons" ||
1607
+ node.type === "gallery" ||
1608
+ node.type === "carousel" ||
1609
+ node.type === "carousel-slide";
1222
1610
 
1223
1611
  export const isFormFieldType = (type: string): boolean =>
1224
1612
  (FORM_FIELD_TYPES as readonly string[]).includes(type);
@@ -1,3 +1,4 @@
1
+ import { boundedArray } from "../bounded-array.ts";
1
2
  import { z } from "zod";
2
3
  import {
3
4
  ALIGN_ITEMS,
@@ -268,6 +269,32 @@ const Overlay = z.union([
268
269
  * Style properties for layout and text elements (W-017 / R-012). Unknown keys are refused here;
269
270
  * `validateLayout` and `validateDesign` keep a newer 1.x key aside and puts it back untouched (D-065, W-925).
270
271
  */
272
+ /** W-974: the length keys whose `vh` can be drawn as `dvh` or `svh`. */
273
+ const VIEWPORT_UNIT_KEYS = [
274
+ "width",
275
+ "minWidth",
276
+ "maxWidth",
277
+ "height",
278
+ "minHeight",
279
+ "maxHeight",
280
+ "flexBasis",
281
+ "gap",
282
+ "fontSize",
283
+ "paddingTop",
284
+ "paddingRight",
285
+ "paddingBottom",
286
+ "paddingLeft",
287
+ "marginTop",
288
+ "marginRight",
289
+ "marginBottom",
290
+ "marginLeft",
291
+ "top",
292
+ "right",
293
+ "bottom",
294
+ "left",
295
+ ] as const;
296
+ const VIEWPORT_UNITS = ["dvh", "svh"] as const;
297
+
271
298
  export const StyleProps = z.strictObject({
272
299
  flexDirection: z.enum(FLEX_DIRECTIONS).optional(),
273
300
  flexWrap: z.enum(FLEX_WRAPS).optional(),
@@ -438,11 +465,32 @@ export const StyleProps = z.strictObject({
438
465
  color: ColorValue.optional(),
439
466
  })
440
467
  .optional(),
468
+ /**
469
+ * W-974 (1.1): which `vh` lengths in this record are drawn in dynamic (`dvh`) or small (`svh`)
470
+ * viewport units, for full-height sections on phones. The length itself stays `vh`, so 1.0
471
+ * (which ignores this key) still draws it in `vh`.
472
+ */
473
+ viewportUnits: z.partialRecord(z.enum(VIEWPORT_UNIT_KEYS), z.enum(VIEWPORT_UNITS)).optional(),
441
474
  motion: Motion.optional(),
442
475
  });
443
476
 
444
477
  export type StyleProps = z.infer<typeof StyleProps>;
445
478
 
479
+ /**
480
+ * W-959 (1.1): Wide screen, 2400 px and up (Elementor's widescreen breakpoint). Its overrides sit
481
+ * in the element's or class's own `style` as `style.wide`, a key 1.0 keeps and ignores, so a 1.1
482
+ * page still opens in 1.0 and shows its Desktop look on wide screens. `hidden` overrides the
483
+ * Desktop hide on wide screens: true hides it there, false shows it; unset follows Desktop.
484
+ */
485
+ export const WideStyle = StyleProps.extend({ hidden: z.boolean().optional() });
486
+
487
+ export type WideStyle = z.infer<typeof WideStyle>;
488
+
489
+ /** An element's or class's own `style`: the Desktop values plus the Wide screen ones. */
490
+ export const OwnStyle = StyleProps.extend({ wide: WideStyle.optional() });
491
+
492
+ export type OwnStyle = z.infer<typeof OwnStyle>;
493
+
446
494
  /**
447
495
  * The pre-1.0 flat style shape: `motion`'s parts as the top-level keys `entrance`, `scrollMotion`,
448
496
  * `transition` and `iconAnimation` (W-925). The editor's style rows and the CSS sanitizer work on
@@ -505,6 +553,6 @@ export const DeviceStyles = z.strictObject({
505
553
  export type DeviceStyles = z.infer<typeof DeviceStyles>;
506
554
 
507
555
  /** Devices on which the element is `display: none`. Empty means shown everywhere. */
508
- export const HiddenOn = z.array(z.enum(DEVICES)).max(4);
556
+ export const HiddenOn = boundedArray(z.enum(DEVICES), 4);
509
557
 
510
558
  export type HiddenOn = z.infer<typeof HiddenOn>;