mjml-blocks 4.6.0 → 4.7.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 (222) hide show
  1. package/dist/index.d.ts +144 -1200
  2. package/dist/index.js +76 -1934
  3. package/dist/models/CreateMjmlNodeSchemaOptions.d.ts +8 -0
  4. package/dist/models/CreateMjmlRegistryOptions.d.ts +11 -0
  5. package/dist/models/MjmlAccordionElementNode.d.ts +4 -0
  6. package/dist/models/MjmlAccordionElementProps.d.ts +18 -0
  7. package/dist/models/MjmlAccordionNode.d.ts +4 -0
  8. package/dist/models/MjmlAccordionProps.d.ts +22 -0
  9. package/dist/models/MjmlAccordionTextNode.d.ts +4 -0
  10. package/dist/models/MjmlAccordionTextProps.d.ts +17 -0
  11. package/dist/models/MjmlAccordionTitleNode.d.ts +4 -0
  12. package/dist/models/MjmlAccordionTitleProps.d.ts +14 -0
  13. package/dist/models/MjmlAttributeField.d.ts +6 -0
  14. package/dist/models/MjmlAttributeKind.d.ts +8 -0
  15. package/dist/models/MjmlAttributeKind.js +11 -0
  16. package/dist/models/MjmlAttributeSchema.d.ts +2 -0
  17. package/dist/models/MjmlAttributeType.d.ts +19 -0
  18. package/dist/models/MjmlBlockTypeDefinition.d.ts +26 -0
  19. package/dist/models/MjmlBuiltInNode.d.ts +23 -0
  20. package/dist/models/MjmlButtonNode.d.ts +4 -0
  21. package/dist/models/MjmlButtonProps.d.ts +37 -0
  22. package/dist/models/MjmlCarouselImageNode.d.ts +4 -0
  23. package/dist/models/MjmlCarouselImageProps.d.ts +14 -0
  24. package/dist/models/MjmlCarouselNode.d.ts +4 -0
  25. package/dist/models/MjmlCarouselProps.d.ts +22 -0
  26. package/dist/models/MjmlColumnNode.d.ts +4 -0
  27. package/dist/models/MjmlColumnProps.d.ts +28 -0
  28. package/dist/models/MjmlContentKind.d.ts +5 -0
  29. package/dist/models/MjmlContentKind.js +8 -0
  30. package/dist/models/MjmlDirection.d.ts +5 -0
  31. package/dist/models/MjmlDirection.js +8 -0
  32. package/dist/models/MjmlDividerNode.d.ts +4 -0
  33. package/dist/models/MjmlDividerProps.d.ts +14 -0
  34. package/dist/models/MjmlDocument.d.ts +4 -0
  35. package/dist/models/MjmlFlowNode.d.ts +12 -0
  36. package/dist/models/MjmlGroupNode.d.ts +4 -0
  37. package/dist/models/MjmlGroupProps.d.ts +10 -0
  38. package/dist/models/MjmlHeroNode.d.ts +4 -0
  39. package/dist/models/MjmlHeroProps.d.ts +26 -0
  40. package/dist/models/MjmlImageNode.d.ts +4 -0
  41. package/dist/models/MjmlImageProps.d.ts +32 -0
  42. package/dist/models/MjmlJson.d.ts +12 -0
  43. package/dist/models/MjmlLeafNode.d.ts +2 -0
  44. package/dist/models/MjmlLeafNodeSchema.d.ts +6 -0
  45. package/dist/models/MjmlLeafNodes.d.ts +1 -0
  46. package/dist/models/MjmlNavbarLinkNode.d.ts +4 -0
  47. package/dist/models/MjmlNavbarLinkProps.d.ts +22 -0
  48. package/dist/models/MjmlNavbarNode.d.ts +4 -0
  49. package/dist/models/MjmlNavbarProps.d.ts +28 -0
  50. package/dist/models/MjmlNode.d.ts +3 -0
  51. package/dist/models/MjmlNodeDefinition.d.ts +3 -0
  52. package/dist/models/MjmlNodeType.d.ts +24 -0
  53. package/dist/models/MjmlNodeType.js +27 -0
  54. package/dist/models/MjmlRawNode.d.ts +4 -0
  55. package/dist/models/MjmlRawProps.d.ts +5 -0
  56. package/dist/models/MjmlRegistry.d.ts +7 -0
  57. package/dist/models/MjmlRenderSpecification.d.ts +9 -0
  58. package/dist/models/MjmlRichText.d.ts +11 -0
  59. package/dist/models/MjmlRichTextAttributeValue.d.ts +3 -0
  60. package/dist/models/MjmlRichTextDefinition.d.ts +7 -0
  61. package/dist/models/MjmlRichTextTypeOptions.d.ts +10 -0
  62. package/dist/models/MjmlRootProps.d.ts +20 -0
  63. package/dist/models/MjmlSectionNode.d.ts +4 -0
  64. package/dist/models/MjmlSectionProps.d.ts +30 -0
  65. package/dist/models/MjmlSocialElementNode.d.ts +4 -0
  66. package/dist/models/MjmlSocialElementProps.d.ts +35 -0
  67. package/dist/models/MjmlSocialNode.d.ts +4 -0
  68. package/dist/models/MjmlSocialProps.d.ts +30 -0
  69. package/dist/models/MjmlSpacerNode.d.ts +4 -0
  70. package/dist/models/MjmlSpacerProps.d.ts +15 -0
  71. package/dist/models/MjmlTableNode.d.ts +4 -0
  72. package/dist/models/MjmlTableProps.d.ts +23 -0
  73. package/dist/models/MjmlTextNode.d.ts +4 -0
  74. package/dist/models/MjmlTextProps.d.ts +24 -0
  75. package/dist/models/MjmlWrapperNode.d.ts +4 -0
  76. package/dist/models/MjmlWrapperProps.d.ts +31 -0
  77. package/dist/models/RenderMjmlDocumentOptions.d.ts +4 -0
  78. package/dist/services/MjmlContentKindSchemaMap.d.ts +3 -0
  79. package/dist/services/MjmlContentKindSchemaMap.js +9 -0
  80. package/dist/services/allowedAddressSchema.d.ts +2 -0
  81. package/dist/services/allowedAddressSchema.js +6 -0
  82. package/dist/services/checkHasElement.d.ts +1 -0
  83. package/dist/services/checkHasElement.js +6 -0
  84. package/dist/services/checkIsMjmlAddressAttribute.d.ts +1 -0
  85. package/dist/services/checkIsMjmlAddressAttribute.js +7 -0
  86. package/dist/services/checkIsRepeatedMjmlTag.d.ts +1 -0
  87. package/dist/services/checkIsRepeatedMjmlTag.js +7 -0
  88. package/dist/services/checkMjmlAlternativeText.d.ts +5 -0
  89. package/dist/services/checkMjmlAlternativeText.js +9 -0
  90. package/dist/services/checkMjmlAttributeValues.d.ts +2 -0
  91. package/dist/services/checkMjmlAttributeValues.js +23 -0
  92. package/dist/services/components/createMjmlAccordionTextPropsSchema.d.ts +8 -0
  93. package/dist/services/components/createMjmlAccordionTextPropsSchema.js +6 -0
  94. package/dist/services/components/createMjmlAccordionTextType.d.ts +5 -0
  95. package/dist/services/components/createMjmlAccordionTextType.js +17 -0
  96. package/dist/services/components/createMjmlRichTextPropsSchema.d.ts +7 -0
  97. package/dist/services/components/createMjmlRichTextPropsSchema.js +7 -0
  98. package/dist/services/components/createMjmlRichTextType.d.ts +7 -0
  99. package/dist/services/components/createMjmlRichTextType.js +22 -0
  100. package/dist/services/components/createMjmlTextPropsSchema.d.ts +8 -0
  101. package/dist/services/components/createMjmlTextPropsSchema.js +6 -0
  102. package/dist/services/components/createMjmlTextType.d.ts +5 -0
  103. package/dist/services/components/createMjmlTextType.js +20 -0
  104. package/dist/services/components/mjAccordion.d.ts +23 -0
  105. package/dist/services/components/mjAccordion.js +52 -0
  106. package/dist/services/components/mjAccordionElement.d.ts +19 -0
  107. package/dist/services/components/mjAccordionElement.js +42 -0
  108. package/dist/services/components/mjAccordionText.d.ts +13 -0
  109. package/dist/services/components/mjAccordionText.js +13 -0
  110. package/dist/services/components/mjAccordionTitle.d.ts +19 -0
  111. package/dist/services/components/mjAccordionTitle.js +42 -0
  112. package/dist/services/components/mjButton.d.ts +42 -0
  113. package/dist/services/components/mjButton.js +78 -0
  114. package/dist/services/components/mjCarousel.d.ts +24 -0
  115. package/dist/services/components/mjCarousel.js +52 -0
  116. package/dist/services/components/mjCarouselImage.d.ts +20 -0
  117. package/dist/services/components/mjCarouselImage.js +44 -0
  118. package/dist/services/components/mjColumn.d.ts +30 -0
  119. package/dist/services/components/mjColumn.js +64 -0
  120. package/dist/services/components/mjDivider.d.ts +18 -0
  121. package/dist/services/components/mjDivider.js +42 -0
  122. package/dist/services/components/mjGroup.d.ts +12 -0
  123. package/dist/services/components/mjGroup.js +31 -0
  124. package/dist/services/components/mjHero.d.ts +28 -0
  125. package/dist/services/components/mjHero.js +66 -0
  126. package/dist/services/components/mjImage.d.ts +37 -0
  127. package/dist/services/components/mjImage.js +64 -0
  128. package/dist/services/components/mjNavbar.d.ts +29 -0
  129. package/dist/services/components/mjNavbar.js +58 -0
  130. package/dist/services/components/mjNavbarLink.d.ts +27 -0
  131. package/dist/services/components/mjNavbarLink.js +57 -0
  132. package/dist/services/components/mjRaw.d.ts +11 -0
  133. package/dist/services/components/mjRaw.js +31 -0
  134. package/dist/services/components/mjSection.d.ts +7 -0
  135. package/dist/services/components/mjSection.js +30 -0
  136. package/dist/services/components/mjSocial.d.ts +31 -0
  137. package/dist/services/components/mjSocial.js +59 -0
  138. package/dist/services/components/mjSocialElement.d.ts +40 -0
  139. package/dist/services/components/mjSocialElement.js +75 -0
  140. package/dist/services/components/mjSpacer.d.ts +19 -0
  141. package/dist/services/components/mjSpacer.js +36 -0
  142. package/dist/services/components/mjTable.d.ts +28 -0
  143. package/dist/services/components/mjTable.js +60 -0
  144. package/dist/services/components/mjText.d.ts +20 -0
  145. package/dist/services/components/mjText.js +20 -0
  146. package/dist/services/components/mjWrapper.d.ts +14 -0
  147. package/dist/services/components/mjWrapper.js +39 -0
  148. package/dist/services/components/sectionAttributes.d.ts +36 -0
  149. package/dist/services/components/sectionAttributes.js +40 -0
  150. package/dist/services/constants.d.ts +23 -0
  151. package/dist/services/constants.js +207 -0
  152. package/dist/services/createMjmlAttributeSchema.d.ts +2 -0
  153. package/dist/services/createMjmlAttributeSchema.js +10 -0
  154. package/dist/services/createMjmlAttributeShape.d.ts +2 -0
  155. package/dist/services/createMjmlAttributeShape.js +6 -0
  156. package/dist/services/createMjmlDocumentSchema.d.ts +6 -0
  157. package/dist/services/createMjmlDocumentSchema.js +4 -0
  158. package/dist/services/createMjmlNodeBranch.d.ts +7 -0
  159. package/dist/services/createMjmlNodeBranch.js +23 -0
  160. package/dist/services/createMjmlRawContentSchema.d.ts +2 -0
  161. package/dist/services/createMjmlRawContentSchema.js +6 -0
  162. package/dist/services/createMjmlRegistry.d.ts +4 -0
  163. package/dist/services/createMjmlRegistry.js +62 -0
  164. package/dist/services/createMjmlRootPropsSchema.d.ts +3 -0
  165. package/dist/services/createMjmlRootPropsSchema.js +49 -0
  166. package/dist/services/createMjmlSlotSchema.d.ts +6 -0
  167. package/dist/services/createMjmlSlotSchema.js +5 -0
  168. package/dist/services/createTypeSchema.d.ts +3 -0
  169. package/dist/services/createTypeSchema.js +19 -0
  170. package/dist/services/createUnitPattern.d.ts +1 -0
  171. package/dist/services/createUnitPattern.js +8 -0
  172. package/dist/services/escapeMjmlAttributes.d.ts +1 -0
  173. package/dist/services/escapeMjmlAttributes.js +4 -0
  174. package/dist/services/getMjmlAttributeFields.d.ts +3 -0
  175. package/dist/services/getMjmlAttributeFields.js +8 -0
  176. package/dist/services/getMjmlAttributeSchema.d.ts +2 -0
  177. package/dist/services/getMjmlAttributeSchema.js +7 -0
  178. package/dist/services/getMjmlRefusalKey.d.ts +1 -0
  179. package/dist/services/getMjmlRefusalKey.js +3 -0
  180. package/dist/services/labelContentSchema.d.ts +2 -0
  181. package/dist/services/labelContentSchema.js +5 -0
  182. package/dist/services/mjmlNodeChildren.d.ts +3 -0
  183. package/dist/services/mjmlNodeChildren.js +31 -0
  184. package/dist/services/mjmlNodeSchema.d.ts +8 -0
  185. package/dist/services/mjmlNodeSchema.js +113 -0
  186. package/dist/services/mjmlRootPropsSchema.d.ts +21 -0
  187. package/dist/services/mjmlRootPropsSchema.js +25 -0
  188. package/dist/services/parseMjmlAttributeType.d.ts +2 -0
  189. package/dist/services/parseMjmlAttributeType.js +31 -0
  190. package/dist/services/parseMjmlDocument.d.ts +7 -0
  191. package/dist/services/parseMjmlDocument.js +22 -0
  192. package/dist/services/readMjmlAttributeRefusal.d.ts +2 -0
  193. package/dist/services/readMjmlAttributeRefusal.js +4 -0
  194. package/dist/services/readMjmlContent.d.ts +5 -0
  195. package/dist/services/readMjmlContent.js +14 -0
  196. package/dist/services/readMjmlHead.d.ts +2 -0
  197. package/dist/services/readMjmlHead.js +53 -0
  198. package/dist/services/readMjmlHeadText.d.ts +2 -0
  199. package/dist/services/readMjmlHeadText.js +7 -0
  200. package/dist/services/readMjmlNode.d.ts +8 -0
  201. package/dist/services/readMjmlNode.js +32 -0
  202. package/dist/services/readMjmlNodes.d.ts +5 -0
  203. package/dist/services/readMjmlNodes.js +17 -0
  204. package/dist/services/readMjmlRoot.d.ts +10 -0
  205. package/dist/services/readMjmlRoot.js +39 -0
  206. package/dist/services/readMjmlStrayText.d.ts +2 -0
  207. package/dist/services/readMjmlStrayText.js +10 -0
  208. package/dist/services/readMjmlTopLevel.d.ts +2 -0
  209. package/dist/services/readMjmlTopLevel.js +11 -0
  210. package/dist/services/renderMjmlDocument.d.ts +5 -0
  211. package/dist/services/renderMjmlDocument.js +31 -0
  212. package/dist/services/renderMjmlHead.d.ts +3 -0
  213. package/dist/services/renderMjmlHead.js +43 -0
  214. package/dist/services/renderMjmlNode.d.ts +6 -0
  215. package/dist/services/renderMjmlNode.js +53 -0
  216. package/dist/services/serializeAttributes.d.ts +1 -0
  217. package/dist/services/serializeAttributes.js +3 -0
  218. package/dist/services/serializeMjml.d.ts +2 -0
  219. package/dist/services/serializeMjml.js +9 -0
  220. package/dist/services/stampNode.d.ts +3 -0
  221. package/dist/services/stampNode.js +15 -0
  222. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,1935 +1,77 @@
1
- import { InvalidOperationError, Operation, checkIsAllowedUrl, createRecordSchema, escapeAttribute, escapeText, exhaustiveGuard, normalizeString, sanitizeHtml } from "@esposter/shared";
2
- import { z } from "zod";
3
- import { createAcceptedTypesError, createBlockDocumentSchema, getBlockPropValue, getBlockTypeDefinition, renderBlockNodes } from "vue-block-editor-headless";
4
- import { HTMLElement, TextNode, parse } from "node-html-parser";
5
- // src/models/MjmlAttributeKind.ts
6
- let MjmlAttributeKind = /* @__PURE__ */ function(MjmlAttributeKind) {
7
- MjmlAttributeKind["Boolean"] = "boolean";
8
- MjmlAttributeKind["Color"] = "color";
9
- MjmlAttributeKind["Enum"] = "enum";
10
- MjmlAttributeKind["Integer"] = "integer";
11
- MjmlAttributeKind["String"] = "string";
12
- MjmlAttributeKind["Unit"] = "unit";
13
- return MjmlAttributeKind;
14
- }({});
15
- // src/models/MjmlContentKind.ts
16
- let MjmlContentKind = /* @__PURE__ */ function(MjmlContentKind) {
17
- MjmlContentKind["Label"] = "label";
18
- MjmlContentKind["Raw"] = "raw";
19
- MjmlContentKind["RichText"] = "richText";
20
- return MjmlContentKind;
21
- }({});
22
- // src/models/MjmlDirection.ts
23
- let MjmlDirection = /* @__PURE__ */ function(MjmlDirection) {
24
- MjmlDirection["Auto"] = "auto";
25
- MjmlDirection["Ltr"] = "ltr";
26
- MjmlDirection["Rtl"] = "rtl";
27
- return MjmlDirection;
28
- }({});
29
- // src/models/MjmlNodeType.ts
30
- let MjmlNodeType = /* @__PURE__ */ function(MjmlNodeType) {
31
- MjmlNodeType["Accordion"] = "mj-accordion";
32
- MjmlNodeType["AccordionElement"] = "mj-accordion-element";
33
- MjmlNodeType["AccordionText"] = "mj-accordion-text";
34
- MjmlNodeType["AccordionTitle"] = "mj-accordion-title";
35
- MjmlNodeType["Button"] = "mj-button";
36
- MjmlNodeType["Carousel"] = "mj-carousel";
37
- MjmlNodeType["CarouselImage"] = "mj-carousel-image";
38
- MjmlNodeType["Column"] = "mj-column";
39
- MjmlNodeType["Divider"] = "mj-divider";
40
- MjmlNodeType["Group"] = "mj-group";
41
- MjmlNodeType["Hero"] = "mj-hero";
42
- MjmlNodeType["Image"] = "mj-image";
43
- MjmlNodeType["Navbar"] = "mj-navbar";
44
- MjmlNodeType["NavbarLink"] = "mj-navbar-link";
45
- MjmlNodeType["Raw"] = "mj-raw";
46
- MjmlNodeType["Section"] = "mj-section";
47
- MjmlNodeType["Social"] = "mj-social";
48
- MjmlNodeType["SocialElement"] = "mj-social-element";
49
- MjmlNodeType["Spacer"] = "mj-spacer";
50
- MjmlNodeType["Table"] = "mj-table";
51
- MjmlNodeType["Text"] = "mj-text";
52
- MjmlNodeType["Wrapper"] = "mj-wrapper";
53
- return MjmlNodeType;
54
- }({});
55
- // src/services/constants.ts
56
- const ALL_ATTRIBUTES_KEY = "mj-all";
57
- const DIRECTION_ATTRIBUTE_KEY = "dir";
58
- const ALLOWED_URL_SCHEMES = [
59
- "http",
60
- "https",
61
- "mailto",
62
- "tel"
63
- ];
64
- const MJML_NAME_MAX_LENGTH = 64;
65
- const MJML_VALUE_MAX_LENGTH = 2048;
66
- const MJML_CONTENT_MAX_LENGTH = 1e5;
67
- const MJML_ROOT_LIST_MAX_LENGTH = 100;
68
- const EXCLUDED_MJML_TAGS = [
69
- "mj-include",
70
- "mj-html-attributes",
71
- "mj-class"
72
- ];
73
- const MJML_BODY_ATTRIBUTES = {
74
- "background-color": "color",
75
- id: "string",
76
- width: "unit(px)"
77
- };
78
- const MJML_BODY_CHILDREN = [
79
- "mj-raw",
80
- "mj-section",
81
- "mj-wrapper",
82
- "mj-hero"
83
- ];
84
- const MJML_BREAKPOINT_ATTRIBUTES = { width: "unit(px)" };
85
- const MJML_PADDING_ATTRIBUTES = {
86
- "padding-bottom": "unit(px,%)",
87
- "padding-left": "unit(px,%)",
88
- "padding-right": "unit(px,%)",
89
- "padding-top": "unit(px,%)"
90
- };
91
- const MJML_HEAD_SINGLE_TAGS = [
92
- "mj-breakpoint",
93
- "mj-preview",
94
- "mj-title"
95
- ];
96
- const MJML_COLOR_MATCHERS = [
97
- /^rgba\(\d{1,3},\s?\d{1,3},\s?\d{1,3},\s?\d(?:\.\d{1,3})?\)$/iu,
98
- /^rgb\(\d{1,3},\s?\d{1,3},\s?\d{1,3}\)$/iu,
99
- /^#(?:[0-9a-f]{3}){1,2}$/iu,
100
- new RegExp(`^(${[
101
- "aliceblue",
102
- "antiquewhite",
103
- "aqua",
104
- "aquamarine",
105
- "azure",
106
- "beige",
107
- "bisque",
108
- "black",
109
- "blanchedalmond",
110
- "blue",
111
- "blueviolet",
112
- "brown",
113
- "burlywood",
114
- "cadetblue",
115
- "chartreuse",
116
- "chocolate",
117
- "coral",
118
- "cornflowerblue",
119
- "cornsilk",
120
- "crimson",
121
- "cyan",
122
- "darkblue",
123
- "darkcyan",
124
- "darkgoldenrod",
125
- "darkgray",
126
- "darkgreen",
127
- "darkgrey",
128
- "darkkhaki",
129
- "darkmagenta",
130
- "darkolivegreen",
131
- "darkorange",
132
- "darkorchid",
133
- "darkred",
134
- "darksalmon",
135
- "darkseagreen",
136
- "darkslateblue",
137
- "darkslategray",
138
- "darkslategrey",
139
- "darkturquoise",
140
- "darkviolet",
141
- "deeppink",
142
- "deepskyblue",
143
- "dimgray",
144
- "dimgrey",
145
- "dodgerblue",
146
- "firebrick",
147
- "floralwhite",
148
- "forestgreen",
149
- "fuchsia",
150
- "gainsboro",
151
- "ghostwhite",
152
- "gold",
153
- "goldenrod",
154
- "gray",
155
- "green",
156
- "greenyellow",
157
- "grey",
158
- "honeydew",
159
- "hotpink",
160
- "indianred",
161
- "indigo",
162
- "inherit",
163
- "ivory",
164
- "khaki",
165
- "lavender",
166
- "lavenderblush",
167
- "lawngreen",
168
- "lemonchiffon",
169
- "lightblue",
170
- "lightcoral",
171
- "lightcyan",
172
- "lightgoldenrodyellow",
173
- "lightgray",
174
- "lightgreen",
175
- "lightgrey",
176
- "lightpink",
177
- "lightsalmon",
178
- "lightseagreen",
179
- "lightskyblue",
180
- "lightslategray",
181
- "lightslategrey",
182
- "lightsteelblue",
183
- "lightyellow",
184
- "lime",
185
- "limegreen",
186
- "linen",
187
- "magenta",
188
- "maroon",
189
- "mediumaquamarine",
190
- "mediumblue",
191
- "mediumorchid",
192
- "mediumpurple",
193
- "mediumseagreen",
194
- "mediumslateblue",
195
- "mediumspringgreen",
196
- "mediumturquoise",
197
- "mediumvioletred",
198
- "midnightblue",
199
- "mintcream",
200
- "mistyrose",
201
- "moccasin",
202
- "navajowhite",
203
- "navy",
204
- "oldlace",
205
- "olive",
206
- "olivedrab",
207
- "orange",
208
- "orangered",
209
- "orchid",
210
- "palegoldenrod",
211
- "palegreen",
212
- "paleturquoise",
213
- "palevioletred",
214
- "papayawhip",
215
- "peachpuff",
216
- "peru",
217
- "pink",
218
- "plum",
219
- "powderblue",
220
- "purple",
221
- "rebeccapurple",
222
- "red",
223
- "rosybrown",
224
- "royalblue",
225
- "saddlebrown",
226
- "salmon",
227
- "sandybrown",
228
- "seagreen",
229
- "seashell",
230
- "sienna",
231
- "silver",
232
- "skyblue",
233
- "slateblue",
234
- "slategray",
235
- "slategrey",
236
- "snow",
237
- "springgreen",
238
- "steelblue",
239
- "tan",
240
- "teal",
241
- "thistle",
242
- "tomato",
243
- "transparent",
244
- "turquoise",
245
- "violet",
246
- "wheat",
247
- "white",
248
- "whitesmoke",
249
- "yellow",
250
- "yellowgreen"
251
- ].join("|")})$`, "u")
252
- ];
253
- const MJML_HEAD_TEXT_TAGS = [
254
- "mj-preview",
255
- "mj-style",
256
- "mj-title"
257
- ];
258
- const STRAY_TEXT_TYPE = "#text";
259
- const STRAY_ID_ATTRIBUTE_KEY = "#id";
260
- // src/services/allowedAddressSchema.ts
261
- const allowedAddressSchema = z.string().max(MJML_VALUE_MAX_LENGTH).refine((address) => checkIsAllowedUrl(address, ALLOWED_URL_SCHEMES), { error: "has a scheme that is not allowed" });
262
- // src/services/checkHasElement.ts
263
- const checkHasElement = (html) => {
264
- const lastTagEnd = html.lastIndexOf(">");
265
- return lastTagEnd !== -1 && /<\/?[a-z]/iu.test(html.slice(0, lastTagEnd));
266
- };
267
- // src/services/checkIsMjmlAddressAttribute.ts
268
- const checkIsMjmlAddressAttribute = (name) => [
269
- "href",
270
- "src",
271
- "thumbnails-src"
272
- ].includes(name) || name.endsWith("-url") || name.endsWith("-icon");
273
- // src/services/checkIsRepeatedMjmlTag.ts
274
- const checkIsRepeatedMjmlTag = (tagName, readTagNames) => {
275
- const isRepeated = readTagNames.has(tagName);
276
- readTagNames.add(tagName);
277
- return isRepeated;
278
- };
279
- // src/services/checkMjmlAlternativeText.ts
280
- const checkMjmlAlternativeText = (props, context) => {
281
- if (!(props.alt || props.decorative)) context.addIssue({
282
- code: "custom",
283
- message: "needs an alternative text or to be decorative",
284
- path: ["alt"]
285
- });
286
- };
287
- // src/services/createUnitPattern.ts
288
- const createUnitPattern = (units, isNegativeAllowed, minCount, maxCount) => {
289
- const numeric = isNegativeAllowed ? String.raw`-|\d|\.` : String.raw`\d|\.`;
290
- const filteredUnits = units.filter((unit) => unit !== "auto").map((unit) => RegExp.escape(unit)).join("|");
291
- const autoAlternative = units.includes("auto") ? "|auto" : "";
292
- return new RegExp(`^(((${numeric}){1,}(${filteredUnits})|0${autoAlternative})( )?){${minCount},${maxCount}}$`, "u");
293
- };
294
- // src/services/createTypeSchema.ts
295
- const createTypeSchema = (type) => {
296
- const boundedString = z.string().max(MJML_VALUE_MAX_LENGTH);
297
- switch (type.kind) {
298
- case "boolean": return boundedString.refine((value) => ["false", "true"].includes(value));
299
- case "color": return boundedString.refine((value) => MJML_COLOR_MATCHERS.some((matcher) => matcher.test(value)));
300
- case "enum": return boundedString.refine((value) => type.options.includes(value));
301
- case "integer": return boundedString.regex(/^\d+$/u);
302
- case "string": return boundedString;
303
- case "unit": return boundedString.regex(createUnitPattern(type.units, type.isNegativeAllowed, type.minCount, type.maxCount));
304
- default: return exhaustiveGuard(type);
305
- }
306
- };
307
- // src/services/parseMjmlAttributeType.ts
308
- const ENUM_GRAMMAR_REGEX = /^enum\((?<options>[^)]*)\)$/u;
309
- const UNIT_GRAMMAR_REGEX = /^(?<kind>unit|unitWithNegative)\((?<units>[^)]*)\)(?:\{(?<minCount>\d+)(?:,(?<maxCount>\d+))?\})?$/u;
310
- const parseMjmlAttributeType = (grammar) => {
311
- switch (grammar) {
312
- case "boolean": return { kind: "boolean" };
313
- case "color": return { kind: "color" };
314
- case "integer": return { kind: "integer" };
315
- case "string": return { kind: "string" };
316
- }
317
- const options = ENUM_GRAMMAR_REGEX.exec(grammar)?.groups?.options;
318
- if (options !== void 0) return {
319
- kind: "enum",
320
- options: options.split(",")
321
- };
322
- const unit = UNIT_GRAMMAR_REGEX.exec(grammar)?.groups;
323
- if (unit) {
324
- const minCount = Number(unit.minCount ?? "1");
325
- return {
326
- isNegativeAllowed: unit.kind === "unitWithNegative",
327
- kind: "unit",
328
- maxCount: Number(unit.maxCount ?? unit.minCount ?? "1"),
329
- minCount,
330
- units: (unit.units ?? "").split(",")
331
- };
332
- }
333
- throw new InvalidOperationError(Operation.Read, grammar, "is not an MJML attribute type");
334
- };
335
- // src/services/createMjmlAttributeSchema.ts
336
- const createMjmlAttributeSchema = (grammar, name) => {
337
- const schema = createTypeSchema(parseMjmlAttributeType(grammar));
338
- return checkIsMjmlAddressAttribute(name) ? schema.and(allowedAddressSchema) : schema;
339
- };
340
- // src/services/getMjmlAttributeSchema.ts
341
- const getMjmlAttributeSchema = (allowedAttributes, name) => {
342
- const grammar = Object.hasOwn(allowedAttributes, name) ? allowedAttributes[name] : void 0;
343
- return grammar === void 0 ? void 0 : createMjmlAttributeSchema(grammar, name);
344
- };
345
- // src/services/checkMjmlAttributeValues.ts
346
- const checkMjmlAttributeValues = (values, allowedAttributes, segments, context) => {
347
- for (const [name, value] of Object.entries(values)) {
348
- const path = [...segments, name];
349
- const schema = getMjmlAttributeSchema(allowedAttributes, name);
350
- if (schema === void 0) {
351
- context.addIssue({
352
- code: "custom",
353
- message: `"${name}" is not an attribute it takes`,
354
- path
355
- });
356
- continue;
357
- }
358
- const result = schema.safeParse(value);
359
- if (!result.success) for (const issue of result.error.issues) context.addIssue({
360
- code: "custom",
361
- message: issue.message,
362
- path: [...path, ...issue.path]
363
- });
364
- }
365
- };
366
- // src/services/components/createMjmlRichTextPropsSchema.ts
367
- const createMjmlRichTextPropsSchema = (attributesSchema, richText) => z.strictObject({
368
- ...attributesSchema,
369
- content: richText.schema
370
- });
371
- const accordionTextAttributes = {
372
- "background-color": "color",
373
- color: "color",
374
- "font-family": "string",
375
- "font-size": "unit(px)",
376
- "font-weight": "string",
377
- "letter-spacing": "unitWithNegative(px,em)",
378
- "line-height": "unit(px,%,)",
379
- padding: "unit(px,%){1,4}",
380
- ...MJML_PADDING_ATTRIBUTES
381
- };
382
- // src/services/createMjmlAttributeShape.ts
383
- const createMjmlAttributeShape = (allowedAttributes) => {
384
- return Object.fromEntries(Object.entries(allowedAttributes).map(([name, grammar]) => [name, createMjmlAttributeSchema(grammar, name).optional()]));
385
- };
386
- // src/services/components/createMjmlAccordionTextPropsSchema.ts
387
- const createMjmlAccordionTextPropsSchema = (richText) => createMjmlRichTextPropsSchema({ ...createMjmlAttributeShape(accordionTextAttributes) }, richText);
388
- // src/services/createMjmlRawContentSchema.ts
389
- const createMjmlRawContentSchema = () => z.string().max(MJML_CONTENT_MAX_LENGTH).refine((html) => sanitizeHtml(html) === html, { error: "holds HTML the sanitiser would change" });
390
- // src/services/labelContentSchema.ts
391
- const labelContentSchema = z.string().max(MJML_CONTENT_MAX_LENGTH);
392
- // src/services/MjmlContentKindSchemaMap.ts
393
- const MjmlContentKindSchemaMap = {
394
- ["label"]: labelContentSchema,
395
- ["raw"]: createMjmlRawContentSchema()
396
- };
397
- // src/services/renderMjmlNode.ts
398
- const renderMjmlNode = (specification, richText) => {
399
- const attributeTypes = Object.entries(specification.allowedAttributes).map(([name, grammar]) => ({
400
- name,
401
- type: parseMjmlAttributeType(grammar)
402
- }));
403
- return (node, slots) => {
404
- const attributes = {};
405
- for (const { name, type } of attributeTypes) {
406
- const value = getBlockPropValue(node.props, name);
407
- if (typeof value === "string") attributes[name] = type.kind === "boolean" ? value === "true" : escapeAttribute(value);
408
- }
409
- if (specification.hasAlternativeText && getBlockPropValue(node.props, "decorative") === true) attributes.alt = "";
410
- const element = {
411
- attributes,
412
- tagName: specification.tagName
413
- };
414
- if (specification.hasChildren) return {
415
- ...element,
416
- children: slots.children ?? []
417
- };
418
- switch (specification.contentKind) {
419
- case "label": {
420
- const parsedLabel = MjmlContentKindSchemaMap["label"].parse(getBlockPropValue(node.props, "content"));
421
- return {
422
- ...element,
423
- content: escapeText(parsedLabel)
424
- };
425
- }
426
- case "raw": return {
427
- ...element,
428
- content: MjmlContentKindSchemaMap["raw"].parse(getBlockPropValue(node.props, "content"))
429
- };
430
- case "richText": {
431
- if (richText === void 0) throw new InvalidOperationError(Operation.Read, specification.tagName, "needs a rich text definition to render");
432
- const parsedRichText = richText.schema.parse(getBlockPropValue(node.props, "content"));
433
- return {
434
- ...element,
435
- content: richText.renderHtml(parsedRichText)
436
- };
437
- }
438
- case void 0: return element;
439
- default: return exhaustiveGuard(specification.contentKind);
440
- }
441
- };
442
- };
443
- // src/services/components/createMjmlRichTextType.ts
444
- const createMjmlRichTextType = ({ allowedAttributes, defaultAttributes, propsSchema, slots, type }, richText) => ({
445
- allowedAttributes,
446
- contentKind: "richText",
447
- defaultAttributes,
448
- formSchema: z.strictObject({}),
449
- hasAlternativeText: false,
450
- propsSchema,
451
- render: renderMjmlNode({
452
- allowedAttributes,
453
- contentKind: "richText",
454
- hasAlternativeText: false,
455
- hasChildren: false,
456
- tagName: type
457
- }, richText),
458
- slots,
459
- type
460
- });
461
- // src/services/components/createMjmlAccordionTextType.ts
462
- const createMjmlAccordionTextType = (richText) => createMjmlRichTextType({
463
- allowedAttributes: accordionTextAttributes,
464
- defaultAttributes: {
465
- "font-size": "13px",
466
- "line-height": "1",
467
- padding: "16px"
468
- },
469
- propsSchema: createMjmlAccordionTextPropsSchema(richText),
470
- slots: {},
471
- type: "mj-accordion-text"
472
- }, richText);
473
- const textAttributes = {
474
- align: "enum(left,right,center,justify)",
475
- "background-color": "color",
476
- color: "color",
477
- "container-background-color": "color",
478
- "font-family": "string",
479
- "font-size": "unit(px)",
480
- "font-style": "string",
481
- "font-weight": "string",
482
- height: "unit(px,%)",
483
- "letter-spacing": "unitWithNegative(px,em)",
484
- "line-height": "unit(px,%,)",
485
- padding: "unit(px,%){1,4}",
486
- "text-decoration": "string",
487
- "text-transform": "string",
488
- "vertical-align": "enum(top,bottom,middle)",
489
- ...MJML_PADDING_ATTRIBUTES
490
- };
491
- // src/services/components/createMjmlTextPropsSchema.ts
492
- const createMjmlTextPropsSchema = (richText) => createMjmlRichTextPropsSchema({ ...createMjmlAttributeShape(textAttributes) }, richText);
493
- // src/services/components/createMjmlTextType.ts
494
- const createMjmlTextType = (richText) => createMjmlRichTextType({
495
- allowedAttributes: textAttributes,
496
- defaultAttributes: {
497
- align: "left",
498
- color: "#000000",
499
- "font-family": "Ubuntu, Helvetica, Arial, sans-serif",
500
- "font-size": "13px",
501
- "line-height": "1",
502
- padding: "10px 25px"
503
- },
504
- propsSchema: createMjmlTextPropsSchema(richText),
505
- slots: {},
506
- type: "mj-text"
507
- }, richText);
508
- const accordionAttributes = {
509
- border: "string",
510
- "container-background-color": "color",
511
- "font-family": "string",
512
- "icon-align": "enum(top,middle,bottom)",
513
- "icon-height": "unit(px,%)",
514
- "icon-position": "enum(left,right)",
515
- "icon-unwrapped-alt": "string",
516
- "icon-unwrapped-url": "string",
517
- "icon-width": "unit(px,%)",
518
- "icon-wrapped-alt": "string",
519
- "icon-wrapped-url": "string",
520
- padding: "unit(px,%){1,4}",
521
- ...MJML_PADDING_ATTRIBUTES
522
- };
523
- const accordionPropsSchema = z.strictObject({ ...createMjmlAttributeShape(accordionAttributes) });
524
- const mjmlAccordionTypeFields = {
525
- allowedAttributes: accordionAttributes,
526
- contentKind: void 0,
527
- defaultAttributes: {
528
- border: "2px solid black",
529
- "font-family": "Ubuntu, Helvetica, Arial, sans-serif",
530
- "icon-align": "middle",
531
- "icon-height": "32px",
532
- "icon-position": "right",
533
- "icon-unwrapped-alt": "-",
534
- "icon-unwrapped-url": "https://i.imgur.com/w4uTygT.png",
535
- "icon-width": "32px",
536
- "icon-wrapped-alt": "+",
537
- "icon-wrapped-url": "https://i.imgur.com/bIXv1bk.png",
538
- padding: "10px 25px"
539
- },
540
- formSchema: z.strictObject({}),
541
- hasAlternativeText: false,
542
- propsSchema: accordionPropsSchema,
543
- slots: { children: ["mj-accordion-element", "mj-raw"] },
544
- type: "mj-accordion"
545
- };
546
- const mjmlAccordionType = {
547
- ...mjmlAccordionTypeFields,
548
- render: renderMjmlNode({
549
- ...mjmlAccordionTypeFields,
550
- hasChildren: true,
551
- tagName: "mj-accordion"
552
- })
553
- };
554
- // src/services/components/mjAccordionElement.ts
555
- const accordionElementAttributes = {
556
- "background-color": "color",
557
- border: "string",
558
- "font-family": "string",
559
- "icon-align": "enum(top,middle,bottom)",
560
- "icon-height": "unit(px,%)",
561
- "icon-position": "enum(left,right)",
562
- "icon-unwrapped-alt": "string",
563
- "icon-unwrapped-url": "string",
564
- "icon-width": "unit(px,%)",
565
- "icon-wrapped-alt": "string",
566
- "icon-wrapped-url": "string"
567
- };
568
- const accordionElementPropsSchema = z.strictObject({ ...createMjmlAttributeShape(accordionElementAttributes) });
569
- const mjmlAccordionElementTypeFields = {
570
- allowedAttributes: accordionElementAttributes,
571
- contentKind: void 0,
572
- defaultAttributes: {},
573
- formSchema: z.strictObject({}),
574
- hasAlternativeText: false,
575
- propsSchema: accordionElementPropsSchema,
576
- slots: { children: [
577
- "mj-accordion-title",
578
- "mj-accordion-text",
579
- "mj-raw"
580
- ] },
581
- type: "mj-accordion-element"
582
- };
583
- const mjmlAccordionElementType = {
584
- ...mjmlAccordionElementTypeFields,
585
- render: renderMjmlNode({
586
- ...mjmlAccordionElementTypeFields,
587
- hasChildren: true,
588
- tagName: "mj-accordion-element"
589
- })
590
- };
591
- const accordionTitleAttributes = {
592
- "background-color": "color",
593
- color: "color",
594
- "font-family": "string",
595
- "font-size": "unit(px)",
596
- "font-weight": "string",
597
- padding: "unit(px,%){1,4}",
598
- ...MJML_PADDING_ATTRIBUTES
599
- };
600
- const accordionTitlePropsSchema = z.strictObject({
601
- ...createMjmlAttributeShape(accordionTitleAttributes),
602
- content: MjmlContentKindSchemaMap["label"]
603
- });
604
- const mjmlAccordionTitleTypeFields = {
605
- allowedAttributes: accordionTitleAttributes,
606
- contentKind: "label",
607
- defaultAttributes: {
608
- "font-size": "13px",
609
- padding: "16px"
610
- },
611
- formSchema: z.strictObject({ content: MjmlContentKindSchemaMap["label"] }),
612
- hasAlternativeText: false,
613
- propsSchema: accordionTitlePropsSchema,
614
- slots: {},
615
- type: "mj-accordion-title"
616
- };
617
- const mjmlAccordionTitleType = {
618
- ...mjmlAccordionTitleTypeFields,
619
- render: renderMjmlNode({
620
- ...mjmlAccordionTitleTypeFields,
621
- hasChildren: false,
622
- tagName: "mj-accordion-title"
623
- })
624
- };
625
- const buttonAttributes = {
626
- align: "enum(left,center,right)",
627
- "background-color": "color",
628
- border: "string",
629
- "border-bottom": "string",
630
- "border-left": "string",
631
- "border-radius": "string",
632
- "border-right": "string",
633
- "border-top": "string",
634
- color: "color",
635
- "container-background-color": "color",
636
- "font-family": "string",
637
- "font-size": "unit(px)",
638
- "font-style": "string",
639
- "font-weight": "string",
640
- height: "unit(px,%)",
641
- href: "string",
642
- "inner-padding": "unit(px,%){1,4}",
643
- "letter-spacing": "unitWithNegative(px,em)",
644
- "line-height": "unit(px,%,)",
645
- name: "string",
646
- padding: "unit(px,%){1,4}",
647
- rel: "string",
648
- target: "string",
649
- "text-align": "enum(left,right,center)",
650
- "text-decoration": "string",
651
- "text-transform": "string",
652
- title: "string",
653
- "vertical-align": "enum(top,bottom,middle)",
654
- width: "unit(px,%)",
655
- ...MJML_PADDING_ATTRIBUTES
656
- };
657
- const buttonPropsSchema = z.strictObject({
658
- ...createMjmlAttributeShape(buttonAttributes),
659
- content: MjmlContentKindSchemaMap["label"]
660
- });
661
- const mjmlButtonTypeFields = {
662
- allowedAttributes: buttonAttributes,
663
- contentKind: "label",
664
- defaultAttributes: {
665
- align: "center",
666
- "background-color": "#414141",
667
- border: "none",
668
- "border-radius": "3px",
669
- color: "#ffffff",
670
- "font-family": "Ubuntu, Helvetica, Arial, sans-serif",
671
- "font-size": "13px",
672
- "font-weight": "normal",
673
- "inner-padding": "10px 25px",
674
- "line-height": "120%",
675
- padding: "10px 25px",
676
- target: "_blank",
677
- "text-decoration": "none",
678
- "text-transform": "none",
679
- "vertical-align": "middle"
680
- },
681
- formSchema: z.strictObject({ content: MjmlContentKindSchemaMap["label"] }),
682
- hasAlternativeText: false,
683
- propsSchema: buttonPropsSchema,
684
- slots: {},
685
- type: "mj-button"
686
- };
687
- const mjmlButtonType = {
688
- ...mjmlButtonTypeFields,
689
- render: renderMjmlNode({
690
- ...mjmlButtonTypeFields,
691
- hasChildren: false,
692
- tagName: "mj-button"
693
- })
694
- };
695
- const carouselAttributes = {
696
- align: "enum(left,center,right)",
697
- "border-radius": "string",
698
- "container-background-color": "color",
699
- "icon-width": "unit(px,%)",
700
- "left-icon": "string",
701
- padding: "unit(px,%){1,4}",
702
- "right-icon": "string",
703
- "tb-border": "string",
704
- "tb-border-radius": "string",
705
- "tb-hover-border-color": "color",
706
- "tb-selected-border-color": "color",
707
- "tb-width": "unit(px,%)",
708
- thumbnails: "enum(visible,hidden,supported)",
709
- ...MJML_PADDING_ATTRIBUTES
710
- };
711
- const carouselPropsSchema = z.strictObject({ ...createMjmlAttributeShape(carouselAttributes) });
712
- const mjmlCarouselTypeFields = {
713
- allowedAttributes: carouselAttributes,
714
- contentKind: void 0,
715
- defaultAttributes: {
716
- align: "center",
717
- "border-radius": "6px",
718
- "icon-width": "44px",
719
- "left-icon": "https://i.imgur.com/xTh3hln.png",
720
- "right-icon": "https://i.imgur.com/os7o9kz.png",
721
- "tb-border": "2px solid transparent",
722
- "tb-border-radius": "6px",
723
- "tb-hover-border-color": "#fead0d",
724
- "tb-selected-border-color": "#ccc",
725
- thumbnails: "visible"
726
- },
727
- formSchema: z.strictObject({}),
728
- hasAlternativeText: false,
729
- propsSchema: carouselPropsSchema,
730
- slots: { children: ["mj-carousel-image"] },
731
- type: "mj-carousel"
732
- };
733
- const mjmlCarouselType = {
734
- ...mjmlCarouselTypeFields,
735
- render: renderMjmlNode({
736
- ...mjmlCarouselTypeFields,
737
- hasChildren: true,
738
- tagName: "mj-carousel"
739
- })
740
- };
741
- // src/services/components/mjCarouselImage.ts
742
- const carouselImageAttributes = {
743
- alt: "string",
744
- "border-radius": "string",
745
- href: "string",
746
- rel: "string",
747
- src: "string",
748
- target: "string",
749
- "tb-border": "string",
750
- "tb-border-radius": "string",
751
- "thumbnails-src": "string",
752
- title: "string"
753
- };
754
- const carouselImagePropsSchema = z.strictObject({
755
- ...createMjmlAttributeShape(carouselImageAttributes),
756
- decorative: z.boolean().optional()
757
- }).superRefine(checkMjmlAlternativeText);
758
- const mjmlCarouselImageTypeFields = {
759
- allowedAttributes: carouselImageAttributes,
760
- contentKind: void 0,
761
- defaultAttributes: {
762
- alt: "",
763
- target: "_blank"
764
- },
765
- formSchema: z.strictObject({}),
766
- hasAlternativeText: true,
767
- propsSchema: carouselImagePropsSchema,
768
- slots: {},
769
- type: "mj-carousel-image"
770
- };
771
- const mjmlCarouselImageType = {
772
- ...mjmlCarouselImageTypeFields,
773
- render: renderMjmlNode({
774
- ...mjmlCarouselImageTypeFields,
775
- hasChildren: false,
776
- tagName: "mj-carousel-image"
777
- })
778
- };
779
- const columnAttributes = {
780
- "background-color": "color",
781
- border: "string",
782
- "border-bottom": "string",
783
- "border-left": "string",
784
- "border-radius": "string",
785
- "border-right": "string",
786
- "border-top": "string",
787
- direction: "enum(ltr,rtl)",
788
- "inner-background-color": "color",
789
- "inner-border": "string",
790
- "inner-border-bottom": "string",
791
- "inner-border-left": "string",
792
- "inner-border-radius": "string",
793
- "inner-border-right": "string",
794
- "inner-border-top": "string",
795
- padding: "unit(px,%){1,4}",
796
- "vertical-align": "enum(top,bottom,middle)",
797
- width: "unit(px,%)",
798
- ...MJML_PADDING_ATTRIBUTES
799
- };
800
- const columnPropsSchema = z.strictObject({ ...createMjmlAttributeShape(columnAttributes) });
801
- const createMjmlColumnType = (leafTypes) => {
802
- const columnTypeFields = {
803
- allowedAttributes: columnAttributes,
804
- contentKind: void 0,
805
- defaultAttributes: {
806
- direction: "ltr",
807
- "vertical-align": "top"
808
- },
809
- formSchema: z.strictObject({}),
810
- hasAlternativeText: false,
811
- propsSchema: columnPropsSchema,
812
- slots: { children: [
813
- "mj-accordion",
814
- "mj-button",
815
- "mj-carousel",
816
- "mj-divider",
817
- "mj-image",
818
- "mj-raw",
819
- "mj-social",
820
- "mj-spacer",
821
- "mj-table",
822
- "mj-text",
823
- "mj-navbar",
824
- ...leafTypes
825
- ] },
826
- type: "mj-column"
827
- };
828
- return {
829
- ...columnTypeFields,
830
- render: renderMjmlNode({
831
- ...columnTypeFields,
832
- hasChildren: true,
833
- tagName: "mj-column"
834
- })
835
- };
836
- };
837
- const dividerAttributes = {
838
- align: "enum(left,center,right)",
839
- "border-color": "color",
840
- "border-style": "string",
841
- "border-width": "unit(px)",
842
- "container-background-color": "color",
843
- padding: "unit(px,%){1,4}",
844
- width: "unit(px,%)",
845
- ...MJML_PADDING_ATTRIBUTES
846
- };
847
- const dividerPropsSchema = z.strictObject({ ...createMjmlAttributeShape(dividerAttributes) });
848
- const mjmlDividerTypeFields = {
849
- allowedAttributes: dividerAttributes,
850
- contentKind: void 0,
851
- defaultAttributes: {
852
- align: "center",
853
- "border-color": "#000000",
854
- "border-style": "solid",
855
- "border-width": "4px",
856
- padding: "10px 25px",
857
- width: "100%"
858
- },
859
- formSchema: z.strictObject({}),
860
- hasAlternativeText: false,
861
- propsSchema: dividerPropsSchema,
862
- slots: {},
863
- type: "mj-divider"
864
- };
865
- const mjmlDividerType = {
866
- ...mjmlDividerTypeFields,
867
- render: renderMjmlNode({
868
- ...mjmlDividerTypeFields,
869
- hasChildren: false,
870
- tagName: "mj-divider"
871
- })
872
- };
873
- // src/services/components/mjGroup.ts
874
- const groupAttributes = {
875
- "background-color": "color",
876
- direction: "enum(ltr,rtl)",
877
- "vertical-align": "enum(top,bottom,middle)",
878
- width: "unit(px,%)"
879
- };
880
- const groupPropsSchema = z.strictObject({ ...createMjmlAttributeShape(groupAttributes) });
881
- const mjmlGroupTypeFields = {
882
- allowedAttributes: groupAttributes,
883
- contentKind: void 0,
884
- defaultAttributes: { direction: "ltr" },
885
- formSchema: z.strictObject({}),
886
- hasAlternativeText: false,
887
- propsSchema: groupPropsSchema,
888
- slots: { children: ["mj-column", "mj-raw"] },
889
- type: "mj-group"
890
- };
891
- const mjmlGroupType = {
892
- ...mjmlGroupTypeFields,
893
- render: renderMjmlNode({
894
- ...mjmlGroupTypeFields,
895
- hasChildren: true,
896
- tagName: "mj-group"
897
- })
898
- };
899
- const heroAttributes = {
900
- "background-color": "color",
901
- "background-height": "unit(px,%)",
902
- "background-position": "string",
903
- "background-url": "string",
904
- "background-width": "unit(px,%)",
905
- "border-radius": "string",
906
- height: "unit(px,%)",
907
- "inner-background-color": "color",
908
- "inner-padding": "unit(px,%){1,4}",
909
- "inner-padding-bottom": "unit(px,%)",
910
- "inner-padding-left": "unit(px,%)",
911
- "inner-padding-right": "unit(px,%)",
912
- "inner-padding-top": "unit(px,%)",
913
- mode: "string",
914
- padding: "unit(px,%){1,4}",
915
- "vertical-align": "enum(top,bottom,middle)",
916
- ...MJML_PADDING_ATTRIBUTES
917
- };
918
- const heroPropsSchema = z.strictObject({ ...createMjmlAttributeShape(heroAttributes) });
919
- const createMjmlHeroType = (leafTypes) => {
920
- const heroTypeFields = {
921
- allowedAttributes: heroAttributes,
922
- contentKind: void 0,
923
- defaultAttributes: {
924
- "background-color": "#ffffff",
925
- "background-position": "center center",
926
- height: "0px",
927
- mode: "fixed-height",
928
- padding: "0px",
929
- "vertical-align": "top"
930
- },
931
- formSchema: z.strictObject({}),
932
- hasAlternativeText: false,
933
- propsSchema: heroPropsSchema,
934
- slots: { children: [
935
- "mj-accordion",
936
- "mj-button",
937
- "mj-carousel",
938
- "mj-divider",
939
- "mj-image",
940
- "mj-social",
941
- "mj-spacer",
942
- "mj-table",
943
- "mj-text",
944
- "mj-navbar",
945
- "mj-raw",
946
- ...leafTypes
947
- ] },
948
- type: "mj-hero"
949
- };
950
- return {
951
- ...heroTypeFields,
952
- render: renderMjmlNode({
953
- ...heroTypeFields,
954
- hasChildren: true,
955
- tagName: "mj-hero"
956
- })
957
- };
958
- };
959
- const imageAttributes = {
960
- align: "enum(left,center,right)",
961
- alt: "string",
962
- border: "string",
963
- "border-bottom": "string",
964
- "border-left": "string",
965
- "border-radius": "string",
966
- "border-right": "string",
967
- "border-top": "string",
968
- "container-background-color": "color",
969
- "fluid-on-mobile": "boolean",
970
- "font-size": "unit(px)",
971
- height: "unit(px,auto)",
972
- href: "string",
973
- "max-height": "unit(px,%)",
974
- name: "string",
975
- padding: "unit(px,%){1,4}",
976
- rel: "string",
977
- sizes: "string",
978
- src: "string",
979
- srcset: "string",
980
- target: "string",
981
- title: "string",
982
- usemap: "string",
983
- width: "unit(px)",
984
- ...MJML_PADDING_ATTRIBUTES
985
- };
986
- const imagePropsSchema = z.strictObject({
987
- ...createMjmlAttributeShape(imageAttributes),
988
- decorative: z.boolean().optional()
989
- }).superRefine(checkMjmlAlternativeText);
990
- const mjmlImageTypeFields = {
991
- allowedAttributes: imageAttributes,
992
- contentKind: void 0,
993
- defaultAttributes: {
994
- align: "center",
995
- alt: "",
996
- border: "0",
997
- "font-size": "13px",
998
- height: "auto",
999
- padding: "10px 25px",
1000
- target: "_blank"
1001
- },
1002
- formSchema: z.strictObject({}),
1003
- hasAlternativeText: true,
1004
- propsSchema: imagePropsSchema,
1005
- slots: {},
1006
- type: "mj-image"
1007
- };
1008
- const mjmlImageType = {
1009
- ...mjmlImageTypeFields,
1010
- render: renderMjmlNode({
1011
- ...mjmlImageTypeFields,
1012
- hasChildren: false,
1013
- tagName: "mj-image"
1014
- })
1015
- };
1016
- const navbarAttributes = {
1017
- align: "enum(left,center,right)",
1018
- "base-url": "string",
1019
- hamburger: "string",
1020
- "ico-align": "enum(left,center,right)",
1021
- "ico-close": "string",
1022
- "ico-color": "color",
1023
- "ico-font-family": "string",
1024
- "ico-font-size": "unit(px,%)",
1025
- "ico-line-height": "unit(px,%,)",
1026
- "ico-open": "string",
1027
- "ico-padding": "unit(px,%){1,4}",
1028
- "ico-padding-bottom": "unit(px,%)",
1029
- "ico-padding-left": "unit(px,%)",
1030
- "ico-padding-right": "unit(px,%)",
1031
- "ico-padding-top": "unit(px,%)",
1032
- "ico-text-decoration": "string",
1033
- "ico-text-transform": "string",
1034
- padding: "unit(px,%){1,4}",
1035
- ...MJML_PADDING_ATTRIBUTES
1036
- };
1037
- const navbarPropsSchema = z.strictObject({ ...createMjmlAttributeShape(navbarAttributes) });
1038
- const mjmlNavbarTypeFields = {
1039
- allowedAttributes: navbarAttributes,
1040
- contentKind: void 0,
1041
- defaultAttributes: {
1042
- align: "center",
1043
- "ico-align": "center",
1044
- "ico-close": "⊗",
1045
- "ico-color": "#000000",
1046
- "ico-font-family": "Ubuntu, Helvetica, Arial, sans-serif",
1047
- "ico-font-size": "30px",
1048
- "ico-line-height": "30px",
1049
- "ico-open": "☰",
1050
- "ico-padding": "10px",
1051
- "ico-text-decoration": "none",
1052
- "ico-text-transform": "uppercase"
1053
- },
1054
- formSchema: z.strictObject({}),
1055
- hasAlternativeText: false,
1056
- propsSchema: navbarPropsSchema,
1057
- slots: { children: ["mj-navbar-link", "mj-raw"] },
1058
- type: "mj-navbar"
1059
- };
1060
- const mjmlNavbarType = {
1061
- ...mjmlNavbarTypeFields,
1062
- render: renderMjmlNode({
1063
- ...mjmlNavbarTypeFields,
1064
- hasChildren: true,
1065
- tagName: "mj-navbar"
1066
- })
1067
- };
1068
- const navbarLinkAttributes = {
1069
- color: "color",
1070
- "font-family": "string",
1071
- "font-size": "unit(px)",
1072
- "font-style": "string",
1073
- "font-weight": "string",
1074
- href: "string",
1075
- "letter-spacing": "unitWithNegative(px,em)",
1076
- "line-height": "unit(px,%,)",
1077
- name: "string",
1078
- padding: "unit(px,%){1,4}",
1079
- rel: "string",
1080
- target: "string",
1081
- "text-decoration": "string",
1082
- "text-transform": "string",
1083
- ...MJML_PADDING_ATTRIBUTES
1084
- };
1085
- const navbarLinkPropsSchema = z.strictObject({
1086
- ...createMjmlAttributeShape(navbarLinkAttributes),
1087
- content: MjmlContentKindSchemaMap["label"]
1088
- });
1089
- const mjmlNavbarLinkTypeFields = {
1090
- allowedAttributes: navbarLinkAttributes,
1091
- contentKind: "label",
1092
- defaultAttributes: {
1093
- color: "#000000",
1094
- "font-family": "Ubuntu, Helvetica, Arial, sans-serif",
1095
- "font-size": "13px",
1096
- "font-weight": "normal",
1097
- "line-height": "22px",
1098
- padding: "15px 10px",
1099
- target: "_blank",
1100
- "text-decoration": "none",
1101
- "text-transform": "uppercase"
1102
- },
1103
- formSchema: z.strictObject({ content: MjmlContentKindSchemaMap["label"] }),
1104
- hasAlternativeText: false,
1105
- propsSchema: navbarLinkPropsSchema,
1106
- slots: {},
1107
- type: "mj-navbar-link"
1108
- };
1109
- const mjmlNavbarLinkType = {
1110
- ...mjmlNavbarLinkTypeFields,
1111
- render: renderMjmlNode({
1112
- ...mjmlNavbarLinkTypeFields,
1113
- hasChildren: false,
1114
- tagName: "mj-navbar-link"
1115
- })
1116
- };
1117
- // src/services/components/mjRaw.ts
1118
- const rawAttributes = { position: "enum(file-start)" };
1119
- const rawPropsSchema = z.strictObject({
1120
- content: MjmlContentKindSchemaMap["raw"],
1121
- ...createMjmlAttributeShape(rawAttributes)
1122
- });
1123
- const mjmlRawTypeFields = {
1124
- allowedAttributes: rawAttributes,
1125
- contentKind: "raw",
1126
- defaultAttributes: {},
1127
- formSchema: z.strictObject({ content: MjmlContentKindSchemaMap["raw"] }),
1128
- hasAlternativeText: false,
1129
- propsSchema: rawPropsSchema,
1130
- slots: {},
1131
- type: "mj-raw"
1132
- };
1133
- const mjmlRawType = {
1134
- ...mjmlRawTypeFields,
1135
- render: renderMjmlNode({
1136
- ...mjmlRawTypeFields,
1137
- hasChildren: false,
1138
- tagName: "mj-raw"
1139
- })
1140
- };
1141
- // src/services/components/sectionAttributes.ts
1142
- const sectionBaseAllowedAttributes = {
1143
- "background-color": "color",
1144
- "background-position": "string",
1145
- "background-position-x": "string",
1146
- "background-position-y": "string",
1147
- "background-repeat": "enum(repeat,no-repeat)",
1148
- "background-size": "string",
1149
- "background-url": "string",
1150
- border: "string",
1151
- "border-bottom": "string",
1152
- "border-left": "string",
1153
- "border-radius": "string",
1154
- "border-right": "string",
1155
- "border-top": "string",
1156
- direction: "enum(ltr,rtl)",
1157
- "full-width": "enum(full-width,false,)",
1158
- gutter: "unit(px,%)",
1159
- padding: "unit(px,%){1,4}",
1160
- "text-align": "enum(left,center,right)",
1161
- "text-padding": "unit(px,%){1,4}"
1162
- };
1163
- const sectionDefaultAttributes = {
1164
- "background-position": "top center",
1165
- "background-repeat": "repeat",
1166
- "background-size": "auto",
1167
- direction: "ltr",
1168
- padding: "20px 0",
1169
- "text-align": "center",
1170
- "text-padding": "4px 4px 4px 0"
1171
- };
1172
- const sectionAttributes = {
1173
- allowedAttributes: {
1174
- ...sectionBaseAllowedAttributes,
1175
- ...MJML_PADDING_ATTRIBUTES
1176
- },
1177
- defaultAttributes: sectionDefaultAttributes
1178
- };
1179
- // src/services/components/mjSection.ts
1180
- const sectionPropsSchema = z.strictObject({ ...createMjmlAttributeShape(sectionAttributes.allowedAttributes) });
1181
- const mjmlSectionTypeFields = {
1182
- allowedAttributes: sectionAttributes.allowedAttributes,
1183
- contentKind: void 0,
1184
- defaultAttributes: sectionAttributes.defaultAttributes,
1185
- formSchema: z.strictObject({}),
1186
- hasAlternativeText: false,
1187
- propsSchema: sectionPropsSchema,
1188
- slots: { children: [
1189
- "mj-column",
1190
- "mj-group",
1191
- "mj-raw"
1192
- ] },
1193
- type: "mj-section"
1194
- };
1195
- const mjmlSectionType = {
1196
- ...mjmlSectionTypeFields,
1197
- render: renderMjmlNode({
1198
- ...mjmlSectionTypeFields,
1199
- hasChildren: true,
1200
- tagName: "mj-section"
1201
- })
1202
- };
1203
- const socialAttributes = {
1204
- align: "enum(left,right,center)",
1205
- border: "string",
1206
- "border-radius": "string",
1207
- color: "color",
1208
- "container-background-color": "color",
1209
- "font-family": "string",
1210
- "font-size": "unit(px)",
1211
- "font-style": "string",
1212
- "font-weight": "string",
1213
- "icon-height": "unit(px,%)",
1214
- "icon-padding": "unit(px,%){1,4}",
1215
- "icon-size": "unit(px,%)",
1216
- "inner-padding": "unit(px,%){1,4}",
1217
- "line-height": "unit(px,%,)",
1218
- mode: "enum(horizontal,vertical)",
1219
- padding: "unit(px,%){1,4}",
1220
- "table-layout": "enum(auto,fixed)",
1221
- "text-decoration": "string",
1222
- "text-padding": "unit(px,%){1,4}",
1223
- "vertical-align": "enum(top,bottom,middle)",
1224
- ...MJML_PADDING_ATTRIBUTES
1225
- };
1226
- const socialPropsSchema = z.strictObject({ ...createMjmlAttributeShape(socialAttributes) });
1227
- const mjmlSocialTypeFields = {
1228
- allowedAttributes: socialAttributes,
1229
- contentKind: void 0,
1230
- defaultAttributes: {
1231
- align: "center",
1232
- "border-radius": "3px",
1233
- color: "#333333",
1234
- "font-family": "Ubuntu, Helvetica, Arial, sans-serif",
1235
- "font-size": "13px",
1236
- "icon-size": "20px",
1237
- "line-height": "22px",
1238
- mode: "horizontal",
1239
- padding: "10px 25px",
1240
- "text-decoration": "none"
1241
- },
1242
- formSchema: z.strictObject({}),
1243
- hasAlternativeText: false,
1244
- propsSchema: socialPropsSchema,
1245
- slots: { children: ["mj-social-element", "mj-raw"] },
1246
- type: "mj-social"
1247
- };
1248
- const mjmlSocialType = {
1249
- ...mjmlSocialTypeFields,
1250
- render: renderMjmlNode({
1251
- ...mjmlSocialTypeFields,
1252
- hasChildren: true,
1253
- tagName: "mj-social"
1254
- })
1255
- };
1256
- const socialElementAttributes = {
1257
- align: "enum(left,center,right)",
1258
- alt: "string",
1259
- "background-color": "color",
1260
- border: "string",
1261
- "border-radius": "string",
1262
- color: "color",
1263
- "font-family": "string",
1264
- "font-size": "unit(px)",
1265
- "font-style": "string",
1266
- "font-weight": "string",
1267
- href: "string",
1268
- "icon-height": "unit(px,%)",
1269
- "icon-padding": "unit(px,%){1,4}",
1270
- "icon-position": "enum(left,right)",
1271
- "icon-size": "unit(px,%)",
1272
- "line-height": "unit(px,%,)",
1273
- name: "string",
1274
- padding: "unit(px,%){1,4}",
1275
- rel: "string",
1276
- sizes: "string",
1277
- src: "string",
1278
- srcset: "string",
1279
- target: "string",
1280
- "text-decoration": "string",
1281
- "text-padding": "unit(px,%){1,4}",
1282
- title: "string",
1283
- "vertical-align": "enum(top,middle,bottom)",
1284
- ...MJML_PADDING_ATTRIBUTES
1285
- };
1286
- const socialElementPropsSchema = z.strictObject({
1287
- ...createMjmlAttributeShape(socialElementAttributes),
1288
- content: MjmlContentKindSchemaMap["label"]
1289
- });
1290
- const mjmlSocialElementTypeFields = {
1291
- allowedAttributes: socialElementAttributes,
1292
- contentKind: "label",
1293
- defaultAttributes: {
1294
- align: "left",
1295
- alt: "",
1296
- border: "0",
1297
- "border-radius": "3px",
1298
- color: "#000",
1299
- "font-family": "Ubuntu, Helvetica, Arial, sans-serif",
1300
- "font-size": "13px",
1301
- "icon-position": "left",
1302
- "line-height": "1",
1303
- padding: "4px",
1304
- target: "_blank",
1305
- "text-decoration": "none",
1306
- "text-padding": "4px 4px 4px 0",
1307
- "vertical-align": "middle"
1308
- },
1309
- formSchema: z.strictObject({ content: MjmlContentKindSchemaMap["label"] }),
1310
- hasAlternativeText: false,
1311
- propsSchema: socialElementPropsSchema,
1312
- slots: {},
1313
- type: "mj-social-element"
1314
- };
1315
- const mjmlSocialElementType = {
1316
- ...mjmlSocialElementTypeFields,
1317
- render: renderMjmlNode({
1318
- ...mjmlSocialElementTypeFields,
1319
- hasChildren: false,
1320
- tagName: "mj-social-element"
1321
- })
1322
- };
1323
- const spacerAttributes = {
1324
- border: "string",
1325
- "border-bottom": "string",
1326
- "border-left": "string",
1327
- "border-right": "string",
1328
- "border-top": "string",
1329
- "container-background-color": "color",
1330
- height: "unit(px,%)",
1331
- padding: "unit(px,%){1,4}",
1332
- ...MJML_PADDING_ATTRIBUTES
1333
- };
1334
- const spacerPropsSchema = z.strictObject({ ...createMjmlAttributeShape(spacerAttributes) });
1335
- const mjmlSpacerTypeFields = {
1336
- allowedAttributes: spacerAttributes,
1337
- contentKind: void 0,
1338
- defaultAttributes: { height: "20px" },
1339
- formSchema: z.strictObject({}),
1340
- hasAlternativeText: false,
1341
- propsSchema: spacerPropsSchema,
1342
- slots: {},
1343
- type: "mj-spacer"
1344
- };
1345
- const mjmlSpacerType = {
1346
- ...mjmlSpacerTypeFields,
1347
- render: renderMjmlNode({
1348
- ...mjmlSpacerTypeFields,
1349
- hasChildren: false,
1350
- tagName: "mj-spacer"
1351
- })
1352
- };
1353
- const tableAttributes = {
1354
- align: "enum(left,right,center)",
1355
- border: "string",
1356
- cellpadding: "integer",
1357
- cellspacing: "integer",
1358
- color: "color",
1359
- "container-background-color": "color",
1360
- "font-family": "string",
1361
- "font-size": "unit(px)",
1362
- "font-weight": "string",
1363
- "line-height": "unit(px,%,)",
1364
- padding: "unit(px,%){1,4}",
1365
- role: "enum(none,presentation)",
1366
- "table-layout": "enum(auto,fixed,initial,inherit)",
1367
- "vertical-align": "enum(top,bottom,middle)",
1368
- width: "unit(px,%,auto)",
1369
- ...MJML_PADDING_ATTRIBUTES
1370
- };
1371
- const tablePropsSchema = z.strictObject({
1372
- ...createMjmlAttributeShape(tableAttributes),
1373
- content: MjmlContentKindSchemaMap["raw"]
1374
- });
1375
- const mjmlTableTypeFields = {
1376
- allowedAttributes: tableAttributes,
1377
- contentKind: "raw",
1378
- defaultAttributes: {
1379
- align: "left",
1380
- border: "none",
1381
- cellpadding: "0",
1382
- cellspacing: "0",
1383
- color: "#000000",
1384
- "font-family": "Ubuntu, Helvetica, Arial, sans-serif",
1385
- "font-size": "13px",
1386
- "line-height": "22px",
1387
- padding: "10px 25px",
1388
- "table-layout": "auto",
1389
- width: "100%"
1390
- },
1391
- formSchema: z.strictObject({ content: MjmlContentKindSchemaMap["raw"] }),
1392
- hasAlternativeText: false,
1393
- propsSchema: tablePropsSchema,
1394
- slots: {},
1395
- type: "mj-table"
1396
- };
1397
- const mjmlTableType = {
1398
- ...mjmlTableTypeFields,
1399
- render: renderMjmlNode({
1400
- ...mjmlTableTypeFields,
1401
- hasChildren: false,
1402
- tagName: "mj-table"
1403
- })
1404
- };
1405
- // src/services/components/mjWrapper.ts
1406
- const wrapperGapAttributes = { gap: "unit(px)" };
1407
- const wrapperAttributes = {
1408
- ...sectionAttributes.allowedAttributes,
1409
- ...wrapperGapAttributes
1410
- };
1411
- const wrapperPropsSchema = z.strictObject({
1412
- ...sectionPropsSchema.shape,
1413
- ...createMjmlAttributeShape(wrapperGapAttributes)
1414
- });
1415
- const mjmlWrapperTypeFields = {
1416
- allowedAttributes: wrapperAttributes,
1417
- contentKind: void 0,
1418
- defaultAttributes: sectionAttributes.defaultAttributes,
1419
- formSchema: z.strictObject({}),
1420
- hasAlternativeText: false,
1421
- propsSchema: wrapperPropsSchema,
1422
- slots: { children: [
1423
- "mj-hero",
1424
- "mj-raw",
1425
- "mj-section"
1426
- ] },
1427
- type: "mj-wrapper"
1428
- };
1429
- const mjmlWrapperType = {
1430
- ...mjmlWrapperTypeFields,
1431
- render: renderMjmlNode({
1432
- ...mjmlWrapperTypeFields,
1433
- hasChildren: true,
1434
- tagName: "mj-wrapper"
1435
- })
1436
- };
1437
- // src/services/createMjmlDocumentSchema.ts
1438
- const createMjmlDocumentSchema = (registry, bodyChildrenSchema, maxNodes) => createBlockDocumentSchema(bodyChildrenSchema, registry, registry.children, maxNodes);
1439
- // src/services/createMjmlNodeBranch.ts
1440
- const createMjmlNodeBranch = (type, propsSchema, slots) => {
1441
- const declaredKeys = Object.keys(propsSchema.shape);
1442
- const props = z.strictObject({
1443
- ...propsSchema.shape,
1444
- id: z.string().max(64),
1445
- ...slots
1446
- }).superRefine((value, context) => {
1447
- const declaredProps = Object.fromEntries(Object.entries(value).filter(([key]) => declaredKeys.includes(String(key))));
1448
- for (const { message, path } of propsSchema.safeParse(declaredProps).error?.issues ?? []) context.addIssue({
1449
- code: "custom",
1450
- message,
1451
- path
1452
- });
1453
- }, { when: ({ issues }) => issues.length === 0 });
1454
- return z.object({
1455
- props,
1456
- type: z.literal(type)
1457
- });
1458
- };
1459
- // src/services/mjmlRootPropsSchema.ts
1460
- const rootName = z.string().max(64);
1461
- const rootValue = z.string().max(MJML_VALUE_MAX_LENGTH);
1462
- const mjmlRootPropsSchema = z.strictObject({
1463
- attributes: createRecordSchema(rootName, createRecordSchema(rootName, rootValue, 100), 100).optional(),
1464
- body: createRecordSchema(rootName, rootValue, 100).optional(),
1465
- breakpoint: z.strictObject({ width: rootValue }).optional(),
1466
- direction: z.enum(MjmlDirection).optional(),
1467
- fonts: z.array(z.strictObject({
1468
- href: rootValue,
1469
- name: rootName
1470
- })).max(100).optional(),
1471
- lang: rootName.optional(),
1472
- preview: rootValue.optional(),
1473
- styles: z.array(z.strictObject({
1474
- css: z.string().max(MJML_CONTENT_MAX_LENGTH).refine((css) => !css.includes("<"), { error: "holds a < that could close its element" }),
1475
- inline: z.boolean()
1476
- })).max(100).optional(),
1477
- title: rootValue.optional()
1478
- });
1479
- // src/services/createMjmlRootPropsSchema.ts
1480
- const createMjmlRootPropsSchema = (definitions) => mjmlRootPropsSchema.superRefine((props, context) => {
1481
- checkMjmlAttributeValues(props.body ?? {}, MJML_BODY_ATTRIBUTES, ["body"], context);
1482
- if (props.breakpoint) checkMjmlAttributeValues(props.breakpoint, MJML_BREAKPOINT_ATTRIBUTES, ["breakpoint"], context);
1483
- for (const [index, font] of (props.fonts ?? []).entries()) {
1484
- const result = allowedAddressSchema.safeParse(font.href);
1485
- if (!result.success) for (const issue of result.error.issues) context.addIssue({
1486
- code: "custom",
1487
- message: issue.message,
1488
- path: [
1489
- "fonts",
1490
- index,
1491
- "href"
1492
- ]
1493
- });
1494
- }
1495
- for (const [type, values] of Object.entries(props.attributes ?? {})) {
1496
- const segments = ["attributes", type];
1497
- if (type === "mj-all") {
1498
- for (const [name, value] of Object.entries(values)) {
1499
- const schemas = definitions.map((definition) => getMjmlAttributeSchema(definition.allowedAttributes, name)).filter((schema) => schema !== void 0);
1500
- if (schemas.length === 0) context.addIssue({
1501
- code: "custom",
1502
- message: `"${name}" is not an attribute any type takes`,
1503
- path: [...segments, name]
1504
- });
1505
- else if (!schemas.every((schema) => schema.safeParse(value).success)) context.addIssue({
1506
- code: "custom",
1507
- message: `"${value}" is not a value every type that takes "${name}" accepts`,
1508
- path: [...segments, name]
1509
- });
1510
- }
1511
- continue;
1512
- }
1513
- const definition = definitions.find((candidate) => candidate.type === type);
1514
- if (definition) checkMjmlAttributeValues(values, definition.allowedAttributes, segments, context);
1515
- else context.addIssue({
1516
- code: "custom",
1517
- message: `"${type}" is not in the registry`,
1518
- path: segments
1519
- });
1520
- }
1521
- });
1522
- // src/services/createMjmlRegistry.ts
1523
- const createMjmlRegistry = (options) => {
1524
- const leafTypeNames = options.leafTypes.map((leafType) => leafType.type);
1525
- const types = [
1526
- mjmlAccordionType,
1527
- mjmlAccordionElementType,
1528
- createMjmlAccordionTextType(options.richText),
1529
- mjmlAccordionTitleType,
1530
- mjmlButtonType,
1531
- mjmlCarouselType,
1532
- mjmlCarouselImageType,
1533
- createMjmlColumnType(leafTypeNames),
1534
- mjmlDividerType,
1535
- mjmlGroupType,
1536
- createMjmlHeroType(leafTypeNames),
1537
- mjmlImageType,
1538
- mjmlNavbarType,
1539
- mjmlNavbarLinkType,
1540
- mjmlRawType,
1541
- mjmlSectionType,
1542
- mjmlSocialType,
1543
- mjmlSocialElementType,
1544
- mjmlSpacerType,
1545
- mjmlTableType,
1546
- createMjmlTextType(options.richText),
1547
- mjmlWrapperType,
1548
- ...options.leafTypes
1549
- ];
1550
- return {
1551
- children: options.children,
1552
- root: {
1553
- content: MJML_BODY_CHILDREN,
1554
- propsSchema: createMjmlRootPropsSchema(types)
1555
- },
1556
- types
1557
- };
1558
- };
1559
- // src/services/createMjmlSlotSchema.ts
1560
- const createMjmlSlotSchema = (branches) => z.discriminatedUnion("type", branches, createAcceptedTypesError(branches.flatMap((branch) => [...branch.shape.type.values]).toSorted()));
1561
- // src/services/escapeMjmlAttributes.ts
1562
- const escapeMjmlAttributes = (attributes) => Object.fromEntries(Object.entries(attributes).map(([name, value]) => [name, escapeAttribute(value)]));
1563
- // src/services/getMjmlAttributeFields.ts
1564
- const getMjmlAttributeFields = (definition) => Object.entries(definition.allowedAttributes).toSorted(([left], [right]) => left < right ? -1 : 1).map(([name, grammar]) => ({
1565
- defaultValue: definition.defaultAttributes[name],
1566
- name,
1567
- type: parseMjmlAttributeType(grammar)
1568
- }));
1569
- // src/services/getMjmlRefusalKey.ts
1570
- const getMjmlRefusalKey = (tagName) => `<${tagName}>`;
1571
- // src/services/mjmlNodeChildren.ts
1572
- const mjmlNodeChildren = (node) => {
1573
- switch (node.type) {
1574
- case "mj-accordion":
1575
- case "mj-accordion-element":
1576
- case "mj-carousel":
1577
- case "mj-column":
1578
- case "mj-group":
1579
- case "mj-hero":
1580
- case "mj-navbar":
1581
- case "mj-section":
1582
- case "mj-social":
1583
- case "mj-wrapper": return { children: node.props.children };
1584
- case "mj-accordion-text":
1585
- case "mj-accordion-title":
1586
- case "mj-button":
1587
- case "mj-carousel-image":
1588
- case "mj-divider":
1589
- case "mj-image":
1590
- case "mj-navbar-link":
1591
- case "mj-raw":
1592
- case "mj-social-element":
1593
- case "mj-spacer":
1594
- case "mj-table":
1595
- case "mj-text": return {};
1596
- default: return exhaustiveGuard(node);
1597
- }
1598
- };
1599
- // src/services/mjmlNodeSchema.ts
1600
- const createMjmlNodeSchema = ({ leafNodeSchema, maxChildren, richText }) => {
1601
- const childrenOf = (schema) => z.array(schema).max(maxChildren);
1602
- const textNode = createMjmlNodeBranch("mj-text", createMjmlTextPropsSchema(richText), {});
1603
- const rawNode = createMjmlNodeBranch("mj-raw", rawPropsSchema, {});
1604
- const accordionTitleNode = createMjmlNodeBranch("mj-accordion-title", accordionTitlePropsSchema, {});
1605
- const accordionTextNode = createMjmlNodeBranch("mj-accordion-text", createMjmlAccordionTextPropsSchema(richText), {});
1606
- const accordionElementNode = createMjmlNodeBranch("mj-accordion-element", accordionElementPropsSchema, { children: childrenOf(createMjmlSlotSchema([
1607
- accordionTitleNode,
1608
- accordionTextNode,
1609
- rawNode
1610
- ])) });
1611
- const accordionNode = createMjmlNodeBranch("mj-accordion", accordionPropsSchema, { children: childrenOf(createMjmlSlotSchema([accordionElementNode, rawNode])) });
1612
- const buttonNode = createMjmlNodeBranch("mj-button", buttonPropsSchema, {});
1613
- const carouselImageNode = createMjmlNodeBranch("mj-carousel-image", carouselImagePropsSchema, {});
1614
- const carouselNode = createMjmlNodeBranch("mj-carousel", carouselPropsSchema, { children: childrenOf(createMjmlSlotSchema([carouselImageNode])) });
1615
- const dividerNode = createMjmlNodeBranch("mj-divider", dividerPropsSchema, {});
1616
- const imageNode = createMjmlNodeBranch("mj-image", imagePropsSchema, {});
1617
- const navbarLinkNode = createMjmlNodeBranch("mj-navbar-link", navbarLinkPropsSchema, {});
1618
- const navbarNode = createMjmlNodeBranch("mj-navbar", navbarPropsSchema, { children: childrenOf(createMjmlSlotSchema([navbarLinkNode, rawNode])) });
1619
- const socialElementNode = createMjmlNodeBranch("mj-social-element", socialElementPropsSchema, {});
1620
- const socialNode = createMjmlNodeBranch("mj-social", socialPropsSchema, { children: childrenOf(createMjmlSlotSchema([socialElementNode, rawNode])) });
1621
- const spacerNode = createMjmlNodeBranch("mj-spacer", spacerPropsSchema, {});
1622
- const tableNode = createMjmlNodeBranch("mj-table", tablePropsSchema, {});
1623
- const flowChildrenSchema = createMjmlSlotSchema([
1624
- accordionNode,
1625
- buttonNode,
1626
- carouselNode,
1627
- dividerNode,
1628
- imageNode,
1629
- rawNode,
1630
- socialNode,
1631
- spacerNode,
1632
- tableNode,
1633
- textNode,
1634
- navbarNode,
1635
- leafNodeSchema
1636
- ]);
1637
- const columnNode = createMjmlNodeBranch("mj-column", columnPropsSchema, { children: childrenOf(flowChildrenSchema) });
1638
- const groupNode = createMjmlNodeBranch("mj-group", groupPropsSchema, { children: childrenOf(createMjmlSlotSchema([columnNode, rawNode])) });
1639
- const heroNode = createMjmlNodeBranch("mj-hero", heroPropsSchema, { children: childrenOf(flowChildrenSchema) });
1640
- const sectionNode = createMjmlNodeBranch("mj-section", sectionPropsSchema, { children: childrenOf(createMjmlSlotSchema([
1641
- columnNode,
1642
- groupNode,
1643
- rawNode
1644
- ])) });
1645
- const wrapperNode = createMjmlNodeBranch("mj-wrapper", wrapperPropsSchema, { children: childrenOf(createMjmlSlotSchema([
1646
- heroNode,
1647
- rawNode,
1648
- sectionNode
1649
- ])) });
1650
- const nodeSchema = z.discriminatedUnion("type", [
1651
- accordionElementNode,
1652
- accordionNode,
1653
- accordionTextNode,
1654
- accordionTitleNode,
1655
- buttonNode,
1656
- carouselImageNode,
1657
- carouselNode,
1658
- columnNode,
1659
- dividerNode,
1660
- groupNode,
1661
- heroNode,
1662
- imageNode,
1663
- navbarLinkNode,
1664
- navbarNode,
1665
- rawNode,
1666
- sectionNode,
1667
- socialElementNode,
1668
- socialNode,
1669
- spacerNode,
1670
- tableNode,
1671
- textNode,
1672
- wrapperNode,
1673
- leafNodeSchema
1674
- ]);
1675
- return {
1676
- bodyChildrenSchema: createMjmlSlotSchema([
1677
- rawNode,
1678
- sectionNode,
1679
- wrapperNode,
1680
- heroNode
1681
- ]),
1682
- nodeSchema
1683
- };
1684
- };
1685
- // src/services/readMjmlAttributeRefusal.ts
1686
- const readMjmlAttributeRefusal = (tag) => Object.keys(tag.attributes).length > 0 ? [[getMjmlRefusalKey(tag.rawTagName), tag.attributes]] : [];
1687
- // src/services/readMjmlHeadText.ts
1688
- const readMjmlHeadText = (tag, propName) => {
1689
- const refusal = readMjmlAttributeRefusal(tag);
1690
- return refusal.length > 0 ? refusal : [[propName, tag.text]];
1691
- };
1692
- // src/services/readMjmlStrayText.ts
1693
- const readMjmlStrayText = (element) => {
1694
- const strayText = {};
1695
- for (const text of element.childNodes) if (text instanceof TextNode && normalizeString(text.text) !== "") strayText[STRAY_TEXT_TYPE] = text.text;
1696
- return strayText;
1697
- };
1698
- // src/services/readMjmlHead.ts
1699
- const readMjmlHead = (head) => {
1700
- const entries = Object.entries(readMjmlStrayText(head));
1701
- entries.push(...readMjmlAttributeRefusal(head));
1702
- const readTagNames = /* @__PURE__ */ new Set();
1703
- const typeAttributesMap = /* @__PURE__ */ new Map();
1704
- const fonts = [];
1705
- const styles = [];
1706
- for (const child of head.children) {
1707
- if (MJML_HEAD_SINGLE_TAGS.includes(child.rawTagName) && checkIsRepeatedMjmlTag(child.rawTagName, readTagNames)) {
1708
- entries.push([getMjmlRefusalKey(child.rawTagName), child.attributes]);
1709
- continue;
1710
- }
1711
- switch (child.rawTagName) {
1712
- case "mj-attributes":
1713
- entries.push(...readMjmlAttributeRefusal(child));
1714
- for (const { attributes, rawTagName } of child.children) if (typeAttributesMap.has(rawTagName)) entries.push([getMjmlRefusalKey(rawTagName), attributes]);
1715
- else typeAttributesMap.set(rawTagName, attributes);
1716
- break;
1717
- case "mj-breakpoint":
1718
- entries.push(["breakpoint", child.attributes]);
1719
- break;
1720
- case "mj-font":
1721
- fonts.push(child.attributes);
1722
- break;
1723
- case "mj-preview":
1724
- entries.push(...readMjmlHeadText(child, "preview"));
1725
- break;
1726
- case "mj-style":
1727
- if (Object.entries(child.attributes).every(([name, value]) => name === "inline" && value === "inline")) styles.push({
1728
- css: child.rawText,
1729
- inline: child.attributes.inline === "inline"
1730
- });
1731
- else entries.push([getMjmlRefusalKey(child.rawTagName), child.attributes]);
1732
- break;
1733
- case "mj-title":
1734
- entries.push(...readMjmlHeadText(child, "title"));
1735
- break;
1736
- default: entries.push([getMjmlRefusalKey(child.rawTagName), child.attributes]);
1737
- }
1738
- }
1739
- if (typeAttributesMap.size > 0) entries.push(["attributes", Object.fromEntries(typeAttributesMap)]);
1740
- if (fonts.length > 0) entries.push(["fonts", fonts]);
1741
- if (styles.length > 0) entries.push(["styles", styles]);
1742
- return entries;
1743
- };
1744
- // src/services/readMjmlContent.ts
1745
- const readMjmlContent = (element, contentKind, richText) => {
1746
- const html = element.rawText;
1747
- switch (contentKind) {
1748
- case "label": return checkHasElement(html) ? { html } : element.text;
1749
- case "raw": return sanitizeHtml(html);
1750
- case "richText": return richText.parseHtml(html);
1751
- default: return exhaustiveGuard(contentKind);
1752
- }
1753
- };
1754
- // src/services/readMjmlNode.ts
1755
- const readMjmlNode = (element, registry, richText, readChildNodes) => {
1756
- const type = element.rawTagName;
1757
- const definition = getBlockTypeDefinition(registry, type);
1758
- const { alt, id: idAttribute, ...attributes } = element.attributes;
1759
- const isDecorative = definition?.hasAlternativeText === true && alt === "";
1760
- const slotNames = Object.keys(definition?.slots ?? {});
1761
- const reservedNames = /* @__PURE__ */ new Set([
1762
- ...slotNames,
1763
- ...definition?.contentKind === void 0 ? [] : ["content"],
1764
- ...definition?.hasAlternativeText === true ? ["decorative"] : []
1765
- ]);
1766
- const entries = [];
1767
- for (const name of Object.keys(attributes)) entries.push([reservedNames.has(name) ? getMjmlRefusalKey(name) : name, attributes[name]]);
1768
- if (isDecorative) entries.push(["decorative", true]);
1769
- else if (alt !== void 0) entries.push(["alt", alt]);
1770
- if (idAttribute !== void 0) entries.push(["#id", idAttribute]);
1771
- entries.push(["id", crypto.randomUUID()]);
1772
- if (definition?.contentKind === void 0) {
1773
- const children = readChildNodes(element.childNodes);
1774
- if (children.length > 0 || slotNames.length > 0) entries.push(["children", children]);
1775
- } else entries.push(["content", readMjmlContent(element, definition.contentKind, richText)]);
1776
- return {
1777
- props: Object.fromEntries(entries),
1778
- type
1779
- };
1780
- };
1781
- // src/services/readMjmlNodes.ts
1782
- const readMjmlNodes = (children, registry, richText) => children.flatMap((child) => {
1783
- if (child instanceof HTMLElement) return [readMjmlNode(child, registry, richText, (grandchildren) => readMjmlNodes(grandchildren, registry, richText))];
1784
- if (child instanceof TextNode && normalizeString(child.text) !== "") return [{
1785
- props: {
1786
- content: child.text,
1787
- id: crypto.randomUUID()
1788
- },
1789
- type: STRAY_TEXT_TYPE
1790
- }];
1791
- return [];
1792
- });
1793
- // src/services/readMjmlRoot.ts
1794
- const readMjmlRoot = (mjml, registry, richText) => {
1795
- const { ["dir"]: direction, lang, ...refusedAttributes } = mjml.attributes;
1796
- const entries = [
1797
- ...Object.entries(readMjmlStrayText(mjml)),
1798
- ...direction === void 0 ? [] : [["direction", direction]],
1799
- ...lang === void 0 ? [] : [["lang", lang]]
1800
- ];
1801
- if (Object.keys(refusedAttributes).length > 0) entries.push([getMjmlRefusalKey("mjml"), refusedAttributes]);
1802
- const readTagNames = /* @__PURE__ */ new Set();
1803
- let content = [];
1804
- for (const child of mjml.children) {
1805
- if (checkIsRepeatedMjmlTag(child.rawTagName, readTagNames)) {
1806
- entries.push([getMjmlRefusalKey(child.rawTagName), child.attributes]);
1807
- continue;
1808
- }
1809
- switch (child.rawTagName) {
1810
- case "mj-body":
1811
- entries.push(["body", child.attributes]);
1812
- content = readMjmlNodes(child.childNodes, registry, richText);
1813
- break;
1814
- case "mj-head":
1815
- entries.push(...readMjmlHead(child));
1816
- break;
1817
- default: entries.push([getMjmlRefusalKey(child.rawTagName), child.attributes]);
1818
- }
1819
- }
1820
- return {
1821
- content,
1822
- root: { props: Object.fromEntries(entries) }
1823
- };
1824
- };
1825
- // src/services/readMjmlTopLevel.ts
1826
- const readMjmlTopLevel = (root) => {
1827
- const [mjml, ...others] = root.children;
1828
- const strayText = Object.entries(readMjmlStrayText(root));
1829
- if (mjml?.rawTagName !== "mjml") return [...strayText, [mjml === void 0 ? "#document" : getMjmlRefusalKey(mjml.rawTagName), {}]];
1830
- if (others.length > 0) return [...strayText, ["#document", {}]];
1831
- return strayText;
1832
- };
1833
- // src/services/parseMjmlDocument.ts
1834
- const parseMjmlDocument = (source, registry, bodyChildrenSchema, richText, maxNodes) => {
1835
- const contentTagNames = [...registry.types.filter((type) => type.contentKind !== void 0).map((type) => type.type), ...MJML_HEAD_TEXT_TAGS];
1836
- const root = parse(source, {
1837
- blockTextElements: Object.fromEntries(contentTagNames.map((tagName) => [tagName, true])),
1838
- comment: false,
1839
- lowerCaseTagName: false
1840
- });
1841
- const [mjml] = root.children;
1842
- const topLevelEntries = readMjmlTopLevel(root);
1843
- const candidate = mjml?.rawTagName === "mjml" && topLevelEntries.length === 0 ? readMjmlRoot(mjml, registry, richText) : {
1844
- content: [],
1845
- root: { props: Object.fromEntries(topLevelEntries) }
1846
- };
1847
- return createMjmlDocumentSchema(registry, bodyChildrenSchema, maxNodes).safeParse(candidate);
1848
- };
1849
- // src/services/renderMjmlHead.ts
1850
- const renderMjmlHead = (rootProps) => {
1851
- const head = [];
1852
- if (rootProps.title !== void 0) head.push({
1853
- attributes: {},
1854
- content: escapeText(rootProps.title),
1855
- tagName: "mj-title"
1856
- });
1857
- if (rootProps.preview !== void 0) head.push({
1858
- attributes: {},
1859
- content: escapeText(rootProps.preview),
1860
- tagName: "mj-preview"
1861
- });
1862
- for (const font of rootProps.fonts ?? []) head.push({
1863
- attributes: escapeMjmlAttributes({
1864
- href: font.href,
1865
- name: font.name
1866
- }),
1867
- tagName: "mj-font"
1868
- });
1869
- if (rootProps.breakpoint) head.push({
1870
- attributes: escapeMjmlAttributes(rootProps.breakpoint),
1871
- tagName: "mj-breakpoint"
1872
- });
1873
- const attributesByType = Object.entries(rootProps.attributes ?? {});
1874
- if (attributesByType.length > 0) head.push({
1875
- attributes: {},
1876
- children: attributesByType.map(([type, attributes]) => ({
1877
- attributes: escapeMjmlAttributes(attributes),
1878
- tagName: type
1879
- })),
1880
- tagName: "mj-attributes"
1881
- });
1882
- for (const style of rootProps.styles ?? []) head.push({
1883
- attributes: style.inline ? { inline: "inline" } : {},
1884
- content: style.css,
1885
- tagName: "mj-style"
1886
- });
1887
- return head;
1888
- };
1889
- // src/services/stampNode.ts
1890
- const stampNode = (output, node, isStampingIds) => {
1891
- if (!isStampingIds) return output;
1892
- const id = z.string().parse(node.props.id);
1893
- return {
1894
- ...output,
1895
- attributes: {
1896
- ...output.attributes,
1897
- "css-class": escapeAttribute(id)
1898
- }
1899
- };
1900
- };
1901
- // src/services/renderMjmlDocument.ts
1902
- const renderMjmlDocument = (document, registry, options) => {
1903
- const rootProps = document.root.props;
1904
- const content = renderBlockNodes(document.content, registry, registry.children, (node, definition, slots) => {
1905
- const output = definition.render(node, slots, options.context);
1906
- return stampNode(output, node, options.isStampingIds);
1907
- });
1908
- const head = renderMjmlHead(rootProps);
1909
- const rootAttributes = {};
1910
- if (rootProps.lang !== void 0) rootAttributes.lang = rootProps.lang;
1911
- if (rootProps.direction !== void 0) rootAttributes["dir"] = rootProps.direction;
1912
- return {
1913
- attributes: escapeMjmlAttributes(rootAttributes),
1914
- children: [...head.length > 0 ? [{
1915
- attributes: {},
1916
- children: head,
1917
- tagName: "mj-head"
1918
- }] : [], {
1919
- attributes: escapeMjmlAttributes(rootProps.body ?? {}),
1920
- children: content,
1921
- tagName: "mj-body"
1922
- }],
1923
- tagName: "mjml"
1924
- };
1925
- };
1926
- // src/services/serializeAttributes.ts
1927
- const serializeAttributes = (attributes) => Object.entries(attributes).map(([name, value]) => ` ${name}="${String(value)}"`).join("");
1928
- // src/services/serializeMjml.ts
1929
- const serializeMjml = (json) => {
1930
- const attributes = serializeAttributes(json.attributes);
1931
- if ("children" in json) return `<${json.tagName}${attributes}>${json.children.map((child) => serializeMjml(child)).join("")}</${json.tagName}>`;
1932
- const content = "content" in json ? json.content : "";
1933
- return `<${json.tagName}${attributes}>${content}</${json.tagName}>`;
1934
- };
1
+ import { MjmlAttributeKind } from "./models/MjmlAttributeKind.js";
2
+ import { MjmlContentKind } from "./models/MjmlContentKind.js";
3
+ import { MjmlDirection } from "./models/MjmlDirection.js";
4
+ import { MjmlNodeType } from "./models/MjmlNodeType.js";
5
+ import { allowedAddressSchema } from "./services/allowedAddressSchema.js";
6
+ import { checkHasElement } from "./services/checkHasElement.js";
7
+ import { checkIsMjmlAddressAttribute } from "./services/checkIsMjmlAddressAttribute.js";
8
+ import { checkIsRepeatedMjmlTag } from "./services/checkIsRepeatedMjmlTag.js";
9
+ import { checkMjmlAlternativeText } from "./services/checkMjmlAlternativeText.js";
10
+ import { checkMjmlAttributeValues } from "./services/checkMjmlAttributeValues.js";
11
+ import { createMjmlAccordionTextPropsSchema } from "./services/components/createMjmlAccordionTextPropsSchema.js";
12
+ import { createMjmlAccordionTextType } from "./services/components/createMjmlAccordionTextType.js";
13
+ import { createMjmlRichTextPropsSchema } from "./services/components/createMjmlRichTextPropsSchema.js";
14
+ import { createMjmlRichTextType } from "./services/components/createMjmlRichTextType.js";
15
+ import { createMjmlTextPropsSchema } from "./services/components/createMjmlTextPropsSchema.js";
16
+ import { createMjmlTextType } from "./services/components/createMjmlTextType.js";
17
+ import { accordionAttributes, accordionPropsSchema, mjmlAccordionType } from "./services/components/mjAccordion.js";
18
+ import { accordionElementAttributes, accordionElementPropsSchema, mjmlAccordionElementType } from "./services/components/mjAccordionElement.js";
19
+ import { accordionTextAttributes } from "./services/components/mjAccordionText.js";
20
+ import { accordionTitleAttributes, accordionTitlePropsSchema, mjmlAccordionTitleType } from "./services/components/mjAccordionTitle.js";
21
+ import { buttonAttributes, buttonPropsSchema, mjmlButtonType } from "./services/components/mjButton.js";
22
+ import { carouselAttributes, carouselPropsSchema, mjmlCarouselType } from "./services/components/mjCarousel.js";
23
+ import { carouselImageAttributes, carouselImagePropsSchema, mjmlCarouselImageType } from "./services/components/mjCarouselImage.js";
24
+ import { columnAttributes, columnPropsSchema, createMjmlColumnType } from "./services/components/mjColumn.js";
25
+ import { dividerAttributes, dividerPropsSchema, mjmlDividerType } from "./services/components/mjDivider.js";
26
+ import { groupAttributes, groupPropsSchema, mjmlGroupType } from "./services/components/mjGroup.js";
27
+ import { createMjmlHeroType, heroAttributes, heroPropsSchema } from "./services/components/mjHero.js";
28
+ import { imageAttributes, imagePropsSchema, mjmlImageType } from "./services/components/mjImage.js";
29
+ import { mjmlNavbarType, navbarAttributes, navbarPropsSchema } from "./services/components/mjNavbar.js";
30
+ import { mjmlNavbarLinkType, navbarLinkAttributes, navbarLinkPropsSchema } from "./services/components/mjNavbarLink.js";
31
+ import { mjmlRawType, rawAttributes, rawPropsSchema } from "./services/components/mjRaw.js";
32
+ import { mjmlSectionType, sectionPropsSchema } from "./services/components/mjSection.js";
33
+ import { mjmlSocialType, socialAttributes, socialPropsSchema } from "./services/components/mjSocial.js";
34
+ import { mjmlSocialElementType, socialElementAttributes, socialElementPropsSchema } from "./services/components/mjSocialElement.js";
35
+ import { mjmlSpacerType, spacerAttributes, spacerPropsSchema } from "./services/components/mjSpacer.js";
36
+ import { mjmlTableType, tableAttributes, tablePropsSchema } from "./services/components/mjTable.js";
37
+ import { textAttributes } from "./services/components/mjText.js";
38
+ import { mjmlWrapperType, wrapperAttributes, wrapperGapAttributes, wrapperPropsSchema } from "./services/components/mjWrapper.js";
39
+ import { sectionAttributes } from "./services/components/sectionAttributes.js";
40
+ import { ALLOWED_URL_SCHEMES, ALL_ATTRIBUTES_KEY, DIRECTION_ATTRIBUTE_KEY, EXCLUDED_MJML_TAGS, MJML_BODY_ATTRIBUTES, MJML_BODY_CHILDREN, MJML_BREAKPOINT_ATTRIBUTES, MJML_COLOR_MATCHERS, MJML_CONTENT_MAX_LENGTH, MJML_HEAD_SINGLE_TAGS, MJML_HEAD_TEXT_TAGS, MJML_NAME_MAX_LENGTH, MJML_PADDING_ATTRIBUTES, MJML_ROOT_LIST_MAX_LENGTH, MJML_VALUE_MAX_LENGTH, STRAY_ID_ATTRIBUTE_KEY, STRAY_TEXT_TYPE } from "./services/constants.js";
41
+ import { createMjmlAttributeSchema } from "./services/createMjmlAttributeSchema.js";
42
+ import { createMjmlAttributeShape } from "./services/createMjmlAttributeShape.js";
43
+ import { createMjmlDocumentSchema } from "./services/createMjmlDocumentSchema.js";
44
+ import { createMjmlNodeBranch } from "./services/createMjmlNodeBranch.js";
45
+ import { createMjmlRawContentSchema } from "./services/createMjmlRawContentSchema.js";
46
+ import { createMjmlRegistry } from "./services/createMjmlRegistry.js";
47
+ import { createMjmlRootPropsSchema } from "./services/createMjmlRootPropsSchema.js";
48
+ import { createMjmlSlotSchema } from "./services/createMjmlSlotSchema.js";
49
+ import { createTypeSchema } from "./services/createTypeSchema.js";
50
+ import { createUnitPattern } from "./services/createUnitPattern.js";
51
+ import { escapeMjmlAttributes } from "./services/escapeMjmlAttributes.js";
52
+ import { getMjmlAttributeFields } from "./services/getMjmlAttributeFields.js";
53
+ import { getMjmlAttributeSchema } from "./services/getMjmlAttributeSchema.js";
54
+ import { getMjmlRefusalKey } from "./services/getMjmlRefusalKey.js";
55
+ import { labelContentSchema } from "./services/labelContentSchema.js";
56
+ import { MjmlContentKindSchemaMap } from "./services/MjmlContentKindSchemaMap.js";
57
+ import { mjmlNodeChildren } from "./services/mjmlNodeChildren.js";
58
+ import { createMjmlNodeSchema } from "./services/mjmlNodeSchema.js";
59
+ import { mjmlRootPropsSchema } from "./services/mjmlRootPropsSchema.js";
60
+ import { parseMjmlAttributeType } from "./services/parseMjmlAttributeType.js";
61
+ import { parseMjmlDocument } from "./services/parseMjmlDocument.js";
62
+ import { readMjmlAttributeRefusal } from "./services/readMjmlAttributeRefusal.js";
63
+ import { readMjmlContent } from "./services/readMjmlContent.js";
64
+ import { readMjmlHead } from "./services/readMjmlHead.js";
65
+ import { readMjmlHeadText } from "./services/readMjmlHeadText.js";
66
+ import { readMjmlNode } from "./services/readMjmlNode.js";
67
+ import { readMjmlNodes } from "./services/readMjmlNodes.js";
68
+ import { readMjmlRoot } from "./services/readMjmlRoot.js";
69
+ import { readMjmlStrayText } from "./services/readMjmlStrayText.js";
70
+ import { readMjmlTopLevel } from "./services/readMjmlTopLevel.js";
71
+ import { renderMjmlDocument } from "./services/renderMjmlDocument.js";
72
+ import { renderMjmlHead } from "./services/renderMjmlHead.js";
73
+ import { renderMjmlNode } from "./services/renderMjmlNode.js";
74
+ import { serializeAttributes } from "./services/serializeAttributes.js";
75
+ import { serializeMjml } from "./services/serializeMjml.js";
76
+ import { stampNode } from "./services/stampNode.js";
1935
77
  export { ALLOWED_URL_SCHEMES, ALL_ATTRIBUTES_KEY, DIRECTION_ATTRIBUTE_KEY, EXCLUDED_MJML_TAGS, MJML_BODY_ATTRIBUTES, MJML_BODY_CHILDREN, MJML_BREAKPOINT_ATTRIBUTES, MJML_COLOR_MATCHERS, MJML_CONTENT_MAX_LENGTH, MJML_HEAD_SINGLE_TAGS, MJML_HEAD_TEXT_TAGS, MJML_NAME_MAX_LENGTH, MJML_PADDING_ATTRIBUTES, MJML_ROOT_LIST_MAX_LENGTH, MJML_VALUE_MAX_LENGTH, MjmlAttributeKind, MjmlContentKind, MjmlContentKindSchemaMap, MjmlDirection, MjmlNodeType, STRAY_ID_ATTRIBUTE_KEY, STRAY_TEXT_TYPE, accordionAttributes, accordionElementAttributes, accordionElementPropsSchema, accordionPropsSchema, accordionTextAttributes, accordionTitleAttributes, accordionTitlePropsSchema, allowedAddressSchema, buttonAttributes, buttonPropsSchema, carouselAttributes, carouselImageAttributes, carouselImagePropsSchema, carouselPropsSchema, checkHasElement, checkIsMjmlAddressAttribute, checkIsRepeatedMjmlTag, checkMjmlAlternativeText, checkMjmlAttributeValues, columnAttributes, columnPropsSchema, createMjmlAccordionTextPropsSchema, createMjmlAccordionTextType, createMjmlAttributeSchema, createMjmlAttributeShape, createMjmlColumnType, createMjmlDocumentSchema, createMjmlHeroType, createMjmlNodeBranch, createMjmlNodeSchema, createMjmlRawContentSchema, createMjmlRegistry, createMjmlRichTextPropsSchema, createMjmlRichTextType, createMjmlRootPropsSchema, createMjmlSlotSchema, createMjmlTextPropsSchema, createMjmlTextType, createTypeSchema, createUnitPattern, dividerAttributes, dividerPropsSchema, escapeMjmlAttributes, getMjmlAttributeFields, getMjmlAttributeSchema, getMjmlRefusalKey, groupAttributes, groupPropsSchema, heroAttributes, heroPropsSchema, imageAttributes, imagePropsSchema, labelContentSchema, mjmlAccordionElementType, mjmlAccordionTitleType, mjmlAccordionType, mjmlButtonType, mjmlCarouselImageType, mjmlCarouselType, mjmlDividerType, mjmlGroupType, mjmlImageType, mjmlNavbarLinkType, mjmlNavbarType, mjmlNodeChildren, mjmlRawType, mjmlRootPropsSchema, mjmlSectionType, mjmlSocialElementType, mjmlSocialType, mjmlSpacerType, mjmlTableType, mjmlWrapperType, navbarAttributes, navbarLinkAttributes, navbarLinkPropsSchema, navbarPropsSchema, parseMjmlAttributeType, parseMjmlDocument, rawAttributes, rawPropsSchema, readMjmlAttributeRefusal, readMjmlContent, readMjmlHead, readMjmlHeadText, readMjmlNode, readMjmlNodes, readMjmlRoot, readMjmlStrayText, readMjmlTopLevel, renderMjmlDocument, renderMjmlHead, renderMjmlNode, sectionAttributes, sectionPropsSchema, serializeAttributes, serializeMjml, socialAttributes, socialElementAttributes, socialElementPropsSchema, socialPropsSchema, spacerAttributes, spacerPropsSchema, stampNode, tableAttributes, tablePropsSchema, textAttributes, wrapperAttributes, wrapperGapAttributes, wrapperPropsSchema };