@lit-pigeon/parser-mjml 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +538 -311
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,36 +1,42 @@
|
|
|
1
|
-
import { Parser as
|
|
2
|
-
import { generateId as m } from "@lit-pigeon/core";
|
|
3
|
-
function
|
|
4
|
-
const e = { attributeDefaults: { all: {}, tags: {}, classes: {} } },
|
|
5
|
-
for (const
|
|
6
|
-
switch (
|
|
1
|
+
import { Parser as R } from "htmlparser2";
|
|
2
|
+
import { generatedStyleName as U, LINK_STYLE_NAME as H, cssToLinkStyle as Y, generateId as m } from "@lit-pigeon/core";
|
|
3
|
+
function q(t, n) {
|
|
4
|
+
const e = { attributeDefaults: { all: {}, tags: {}, classes: {} } }, o = [];
|
|
5
|
+
for (const i of t)
|
|
6
|
+
switch (i.tag) {
|
|
7
7
|
case "mj-preview":
|
|
8
|
-
e.previewText =
|
|
8
|
+
e.previewText = i.text;
|
|
9
|
+
break;
|
|
10
|
+
case "mj-title":
|
|
11
|
+
e.title = i.text;
|
|
9
12
|
break;
|
|
10
13
|
case "mj-attributes":
|
|
11
|
-
for (const
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
Object.assign(
|
|
15
|
-
else if (
|
|
16
|
-
const { name:
|
|
17
|
-
|
|
14
|
+
for (const r of i.children) {
|
|
15
|
+
const s = e.attributeDefaults;
|
|
16
|
+
if (r.tag === "mj-all")
|
|
17
|
+
Object.assign(s.all, r.attrs);
|
|
18
|
+
else if (r.tag === "mj-class") {
|
|
19
|
+
const { name: c, ...d } = r.attrs;
|
|
20
|
+
c && (s.classes[c] = { ...s.classes[c], ...d });
|
|
18
21
|
} else
|
|
19
|
-
|
|
22
|
+
s.tags[r.tag] = { ...s.tags[r.tag], ...r.attrs };
|
|
20
23
|
}
|
|
21
24
|
e.attributeDefaults.all["font-family"] && (e.fontFamily = e.attributeDefaults.all["font-family"]);
|
|
22
25
|
break;
|
|
23
|
-
case "mj-style":
|
|
24
|
-
|
|
26
|
+
case "mj-style": {
|
|
27
|
+
if (i.attrs.inline === "inline" || !i.text.trim()) break;
|
|
28
|
+
const r = U(i.text);
|
|
29
|
+
r === H ? e.linkStyle = Y(i.text) : r || o.push(i.text.trim());
|
|
25
30
|
break;
|
|
31
|
+
}
|
|
26
32
|
}
|
|
27
|
-
return
|
|
33
|
+
return o.length > 0 && (e.css = o.join(`
|
|
28
34
|
`)), e;
|
|
29
35
|
}
|
|
30
|
-
function
|
|
36
|
+
function h(t, n = 0) {
|
|
31
37
|
if (!t)
|
|
32
38
|
return { top: n, right: n, bottom: n, left: n };
|
|
33
|
-
const e = t.trim().split(/\s+/).map(
|
|
39
|
+
const e = t.trim().split(/\s+/).map(G);
|
|
34
40
|
switch (e.length) {
|
|
35
41
|
case 1:
|
|
36
42
|
return { top: e[0], right: e[0], bottom: e[0], left: e[0] };
|
|
@@ -44,84 +50,109 @@ function f(t, n = 0) {
|
|
|
44
50
|
return { top: n, right: n, bottom: n, left: n };
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
|
-
function
|
|
53
|
+
function G(t) {
|
|
48
54
|
const n = parseFloat(t);
|
|
49
55
|
return isNaN(n) ? 0 : n;
|
|
50
56
|
}
|
|
51
|
-
function
|
|
57
|
+
function a(t, n, e = "") {
|
|
52
58
|
return t[n] ?? e;
|
|
53
59
|
}
|
|
54
60
|
function b(t, n, e = 0) {
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
return isNaN(
|
|
59
|
-
}
|
|
60
|
-
function O(t
|
|
61
|
+
const o = t[n];
|
|
62
|
+
if (o === void 0 || o === "") return e;
|
|
63
|
+
const i = parseFloat(o);
|
|
64
|
+
return isNaN(i) ? e : i;
|
|
65
|
+
}
|
|
66
|
+
function O(t) {
|
|
67
|
+
const n = {}, e = t["css-class"];
|
|
68
|
+
if (!e) return n;
|
|
69
|
+
const o = e.replace(/(^|\s)pigeon-hide-(mobile|desktop)(?=\s|$)/g, (i, r, s) => (n[s === "mobile" ? "hideOnMobile" : "hideOnDesktop"] = !0, "")).trim();
|
|
70
|
+
return o ? t["css-class"] = o : delete t["css-class"], n;
|
|
71
|
+
}
|
|
72
|
+
function X(t, n) {
|
|
61
73
|
return {
|
|
62
74
|
id: m(),
|
|
63
75
|
type: "text",
|
|
64
76
|
values: {
|
|
65
77
|
content: n,
|
|
66
|
-
padding:
|
|
67
|
-
lineHeight:
|
|
68
|
-
textAlign:
|
|
69
|
-
cssClass:
|
|
78
|
+
padding: h(a(t, "padding"), 10),
|
|
79
|
+
lineHeight: a(t, "line-height", "1.5"),
|
|
80
|
+
textAlign: a(t, "align", "left"),
|
|
81
|
+
cssClass: a(t, "css-class") || void 0
|
|
70
82
|
}
|
|
71
83
|
};
|
|
72
84
|
}
|
|
73
|
-
function
|
|
74
|
-
const n =
|
|
85
|
+
function K(t) {
|
|
86
|
+
const n = a(t, "width"), e = n && parseInt(n, 10) || "auto";
|
|
75
87
|
return {
|
|
76
88
|
id: m(),
|
|
77
89
|
type: "image",
|
|
78
90
|
values: {
|
|
79
|
-
src:
|
|
80
|
-
alt:
|
|
91
|
+
src: a(t, "src"),
|
|
92
|
+
alt: a(t, "alt"),
|
|
81
93
|
width: e,
|
|
82
|
-
href:
|
|
83
|
-
padding:
|
|
84
|
-
alignment:
|
|
94
|
+
href: a(t, "href") || void 0,
|
|
95
|
+
padding: h(a(t, "padding"), 10),
|
|
96
|
+
alignment: a(t, "align", "center"),
|
|
85
97
|
borderRadius: b(t, "border-radius", 0),
|
|
86
|
-
cssClass:
|
|
98
|
+
cssClass: a(t, "css-class") || void 0
|
|
87
99
|
}
|
|
88
100
|
};
|
|
89
101
|
}
|
|
90
|
-
|
|
91
|
-
|
|
102
|
+
const V = /^(solid|dashed|dotted|double|groove|ridge|inset|outset)$/;
|
|
103
|
+
function J(t) {
|
|
104
|
+
const n = t.trim().split(/\s+/).filter(Boolean);
|
|
105
|
+
if (!n.length) return;
|
|
106
|
+
let e, o;
|
|
107
|
+
const i = [];
|
|
108
|
+
for (const r of n) {
|
|
109
|
+
const s = r.toLowerCase();
|
|
110
|
+
if (s === "none" || s === "hidden") return;
|
|
111
|
+
e === void 0 && /^\d*\.?\d+(px)?$/.test(s) ? e = parseFloat(s) : o === void 0 && V.test(s) ? o = s === "dashed" || s === "dotted" ? s : "solid" : i.push(r);
|
|
112
|
+
}
|
|
113
|
+
if (e !== 0)
|
|
114
|
+
return {
|
|
115
|
+
width: e ?? 1,
|
|
116
|
+
style: o ?? "solid",
|
|
117
|
+
color: i.join(" ") || "#000000"
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function Z(t, n) {
|
|
121
|
+
const e = n.trim(), o = /^<p[\s>]/i.test(e) ? e : `<p>${e}</p>`, i = J(a(t, "border"));
|
|
92
122
|
return {
|
|
93
123
|
id: m(),
|
|
94
124
|
type: "button",
|
|
95
125
|
values: {
|
|
96
|
-
content:
|
|
97
|
-
href:
|
|
98
|
-
backgroundColor:
|
|
99
|
-
textColor:
|
|
126
|
+
content: o,
|
|
127
|
+
href: a(t, "href", "#"),
|
|
128
|
+
backgroundColor: a(t, "background-color", "#3b82f6"),
|
|
129
|
+
textColor: a(t, "color", "#ffffff"),
|
|
100
130
|
borderRadius: b(t, "border-radius", 4),
|
|
101
|
-
|
|
102
|
-
|
|
131
|
+
...i ? { border: i } : {},
|
|
132
|
+
padding: h(a(t, "padding"), 10),
|
|
133
|
+
innerPadding: h(a(t, "inner-padding"), 12),
|
|
103
134
|
fontSize: b(t, "font-size", 16),
|
|
104
|
-
fontWeight:
|
|
105
|
-
alignment:
|
|
106
|
-
fullWidth:
|
|
107
|
-
cssClass:
|
|
135
|
+
fontWeight: a(t, "font-weight", "600"),
|
|
136
|
+
alignment: a(t, "align", "center"),
|
|
137
|
+
fullWidth: a(t, "width") === "100%",
|
|
138
|
+
cssClass: a(t, "css-class") || void 0
|
|
108
139
|
}
|
|
109
140
|
};
|
|
110
141
|
}
|
|
111
|
-
function
|
|
142
|
+
function Q(t) {
|
|
112
143
|
return {
|
|
113
144
|
id: m(),
|
|
114
145
|
type: "divider",
|
|
115
146
|
values: {
|
|
116
|
-
borderColor:
|
|
147
|
+
borderColor: a(t, "border-color", "#e2e8f0"),
|
|
117
148
|
borderWidth: b(t, "border-width", 1),
|
|
118
|
-
borderStyle:
|
|
119
|
-
padding:
|
|
120
|
-
width:
|
|
149
|
+
borderStyle: a(t, "border-style", "solid"),
|
|
150
|
+
padding: h(a(t, "padding"), 10),
|
|
151
|
+
width: a(t, "width", "100%")
|
|
121
152
|
}
|
|
122
153
|
};
|
|
123
154
|
}
|
|
124
|
-
function
|
|
155
|
+
function tt(t) {
|
|
125
156
|
return {
|
|
126
157
|
id: m(),
|
|
127
158
|
type: "spacer",
|
|
@@ -130,21 +161,21 @@ function q(t) {
|
|
|
130
161
|
}
|
|
131
162
|
};
|
|
132
163
|
}
|
|
133
|
-
const
|
|
134
|
-
function
|
|
164
|
+
const et = ["facebook", "twitter", "instagram", "linkedin", "youtube", "tiktok"];
|
|
165
|
+
function nt(t) {
|
|
135
166
|
const n = t.toLowerCase();
|
|
136
|
-
for (const e of
|
|
167
|
+
for (const e of et)
|
|
137
168
|
if (n.includes(e)) return e;
|
|
138
169
|
return "custom";
|
|
139
170
|
}
|
|
140
|
-
function
|
|
141
|
-
const e = n.map((
|
|
142
|
-
const
|
|
143
|
-
type:
|
|
144
|
-
href:
|
|
145
|
-
label:
|
|
146
|
-
},
|
|
147
|
-
return
|
|
171
|
+
function ot(t, n) {
|
|
172
|
+
const e = n.map((o) => {
|
|
173
|
+
const r = {
|
|
174
|
+
type: nt(a(o.attrs, "name", "custom")),
|
|
175
|
+
href: a(o.attrs, "href", "#"),
|
|
176
|
+
label: o.innerText.trim() || void 0
|
|
177
|
+
}, s = a(o.attrs, "src");
|
|
178
|
+
return s && (r.iconUrl = s), r;
|
|
148
179
|
});
|
|
149
180
|
return {
|
|
150
181
|
id: m(),
|
|
@@ -152,31 +183,34 @@ function M(t, n) {
|
|
|
152
183
|
values: {
|
|
153
184
|
icons: e,
|
|
154
185
|
iconSize: b(t, "icon-size", 32),
|
|
155
|
-
spacing: b(t, "icon-padding",
|
|
156
|
-
alignment:
|
|
157
|
-
padding:
|
|
186
|
+
spacing: b(t, "icon-padding", 0),
|
|
187
|
+
alignment: a(t, "align", "center"),
|
|
188
|
+
padding: h(a(t, "padding"), 10)
|
|
158
189
|
}
|
|
159
190
|
};
|
|
160
191
|
}
|
|
161
|
-
function
|
|
162
|
-
const n = t.match(
|
|
192
|
+
function it(t) {
|
|
193
|
+
const n = t.match(
|
|
194
|
+
/^<div(?:\s+class="lp-html((?:\s+pigeon-hide-(?:mobile|desktop))*)")?\s+style="padding:\s*([^"]*)">([\s\S]*)<\/div>$/
|
|
195
|
+
);
|
|
163
196
|
return n ? {
|
|
164
197
|
id: m(),
|
|
165
198
|
type: "html",
|
|
166
199
|
values: {
|
|
167
|
-
content: n[
|
|
168
|
-
padding:
|
|
200
|
+
content: n[3],
|
|
201
|
+
padding: h(n[2], 0),
|
|
202
|
+
...O({ "css-class": n[1] ?? "" })
|
|
169
203
|
}
|
|
170
204
|
} : {
|
|
171
205
|
id: m(),
|
|
172
206
|
type: "html",
|
|
173
207
|
values: {
|
|
174
208
|
content: t,
|
|
175
|
-
padding:
|
|
209
|
+
padding: h(void 0, 0)
|
|
176
210
|
}
|
|
177
211
|
};
|
|
178
212
|
}
|
|
179
|
-
const
|
|
213
|
+
const rt = {
|
|
180
214
|
align: "left",
|
|
181
215
|
border: "none",
|
|
182
216
|
cellpadding: "0",
|
|
@@ -189,8 +223,8 @@ const V = {
|
|
|
189
223
|
"table-layout": "auto",
|
|
190
224
|
width: "100%"
|
|
191
225
|
};
|
|
192
|
-
function
|
|
193
|
-
const e = { ...
|
|
226
|
+
function at(t, n) {
|
|
227
|
+
const e = { ...rt, ...t }, o = e.width.endsWith("%") || e.width === "auto" ? e.width : String(parseInt(e.width, 10)), i = parseFloat(e.cellspacing.replace(/[^\d.]/g, "")), r = [
|
|
194
228
|
`color:${e.color}`,
|
|
195
229
|
`font-family:${e["font-family"]}`,
|
|
196
230
|
`font-size:${e["font-size"]}`,
|
|
@@ -198,90 +232,107 @@ function Y(t, n) {
|
|
|
198
232
|
`table-layout:${e["table-layout"]}`,
|
|
199
233
|
`width:${e.width}`,
|
|
200
234
|
`border:${e.border}`,
|
|
201
|
-
...
|
|
202
|
-
].map((
|
|
203
|
-
return e.align !== "left" &&
|
|
235
|
+
...i > 0 ? ["border-collapse:separate"] : []
|
|
236
|
+
].map((c) => `${c};`).join(""), s = [];
|
|
237
|
+
return e.align !== "left" && s.push(`align="${y(e.align)}"`), s.push(`cellpadding="${y(e.cellpadding)}"`, `cellspacing="${y(e.cellspacing)}"`), t.role && s.push(`role="${y(t.role)}"`), s.push(`width="${y(o)}"`, 'border="0"', `style="${y(r)}"`), {
|
|
204
238
|
id: m(),
|
|
205
239
|
type: "html",
|
|
206
240
|
values: {
|
|
207
|
-
content: `<table ${
|
|
208
|
-
padding:
|
|
241
|
+
content: `<table ${s.join(" ")}>${n.trim()}</table>`,
|
|
242
|
+
padding: h(a(e, "padding"), 0)
|
|
209
243
|
}
|
|
210
244
|
};
|
|
211
245
|
}
|
|
212
|
-
function
|
|
246
|
+
function y(t) {
|
|
213
247
|
return t.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
214
248
|
}
|
|
215
|
-
function
|
|
216
|
-
const e =
|
|
217
|
-
const
|
|
218
|
-
href: e + i
|
|
219
|
-
text:
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
return
|
|
249
|
+
function st(t, n) {
|
|
250
|
+
const e = a(t, "base-url"), o = n.map((i) => {
|
|
251
|
+
const r = {
|
|
252
|
+
href: e + a(i.attrs, "href", "#"),
|
|
253
|
+
text: i.innerText.trim() || "Link"
|
|
254
|
+
}, s = a(i.attrs, "color");
|
|
255
|
+
s && (r.color = s);
|
|
256
|
+
const c = a(i.attrs, "font-weight");
|
|
257
|
+
c && (r.fontWeight = c);
|
|
258
|
+
const d = a(i.attrs, "text-decoration");
|
|
259
|
+
d && (r.textDecoration = d);
|
|
260
|
+
const l = a(i.attrs, "padding");
|
|
261
|
+
return l && (r.padding = l), r;
|
|
228
262
|
});
|
|
229
263
|
return {
|
|
230
264
|
id: m(),
|
|
231
265
|
type: "navbar",
|
|
232
266
|
values: {
|
|
233
|
-
links:
|
|
234
|
-
hamburger:
|
|
235
|
-
alignment:
|
|
236
|
-
padding:
|
|
237
|
-
linkColor:
|
|
267
|
+
links: o,
|
|
268
|
+
hamburger: a(t, "hamburger", "none"),
|
|
269
|
+
alignment: a(t, "align", "center"),
|
|
270
|
+
padding: h(a(t, "padding"), 0),
|
|
271
|
+
linkColor: a(t, "ico-color", "#000000"),
|
|
238
272
|
linkFontSize: b(t, "font-size", 14),
|
|
239
|
-
linkPadding:
|
|
273
|
+
linkPadding: a(t, "link-padding", "10px 15px")
|
|
240
274
|
}
|
|
241
275
|
};
|
|
242
276
|
}
|
|
243
|
-
function
|
|
244
|
-
const e = t.attrs,
|
|
245
|
-
for (
|
|
246
|
-
const
|
|
247
|
-
|
|
277
|
+
function z(t, n) {
|
|
278
|
+
const e = t.attrs, o = [], i = t.children;
|
|
279
|
+
for (let r = 0; r < i.length; r++) {
|
|
280
|
+
const s = lt(i[r]);
|
|
281
|
+
if (s && ct(i[r + 2])) {
|
|
282
|
+
const d = E(i[r + 1], n);
|
|
283
|
+
if (d) {
|
|
284
|
+
Object.assign(d.values, i[r + 1].visibility), d.values.condition = s, o.push(d), r += 2;
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const c = E(i[r], n);
|
|
289
|
+
c && (Object.assign(c.values, i[r].visibility), o.push(c));
|
|
248
290
|
}
|
|
249
291
|
return {
|
|
250
292
|
id: m(),
|
|
251
293
|
type: "column",
|
|
252
294
|
attributes: {
|
|
253
|
-
backgroundColor:
|
|
254
|
-
padding:
|
|
295
|
+
backgroundColor: a(e, "background-color") || void 0,
|
|
296
|
+
padding: h(a(e, "padding"), 0),
|
|
255
297
|
borderRadius: b(e, "border-radius", 0) || void 0,
|
|
256
|
-
verticalAlign:
|
|
257
|
-
cssClass:
|
|
298
|
+
verticalAlign: a(e, "vertical-align", "top"),
|
|
299
|
+
cssClass: a(e, "css-class") || void 0,
|
|
300
|
+
...t.visibility
|
|
258
301
|
},
|
|
259
|
-
blocks:
|
|
302
|
+
blocks: o
|
|
260
303
|
};
|
|
261
304
|
}
|
|
262
|
-
function
|
|
305
|
+
function lt(t) {
|
|
306
|
+
var n;
|
|
307
|
+
if (t.tag === "mj-raw")
|
|
308
|
+
return (n = /^\s*\{\{#if\s+([^}]+?)\s*\}\}\s*$/.exec(t.text ?? "")) == null ? void 0 : n[1];
|
|
309
|
+
}
|
|
310
|
+
function ct(t) {
|
|
311
|
+
return (t == null ? void 0 : t.tag) === "mj-raw" && /^\s*\{\{\/if\}\}\s*$/.test(t.text ?? "");
|
|
312
|
+
}
|
|
313
|
+
function E(t, n) {
|
|
263
314
|
switch (t.tag) {
|
|
264
315
|
case "mj-text":
|
|
265
|
-
return
|
|
316
|
+
return X(t.attrs, t.text);
|
|
266
317
|
case "mj-image":
|
|
267
|
-
return
|
|
318
|
+
return K(t.attrs);
|
|
268
319
|
case "mj-button":
|
|
269
|
-
return
|
|
320
|
+
return Z(t.attrs, t.text);
|
|
270
321
|
case "mj-divider":
|
|
271
|
-
return
|
|
322
|
+
return Q(t.attrs);
|
|
272
323
|
case "mj-spacer":
|
|
273
|
-
return
|
|
324
|
+
return tt(t.attrs);
|
|
274
325
|
case "mj-social": {
|
|
275
|
-
const e = t.children.filter((
|
|
276
|
-
return
|
|
326
|
+
const e = t.children.filter((o) => o.tag === "mj-social-element").map((o) => ({ attrs: o.attrs, innerText: o.text }));
|
|
327
|
+
return ot(t.attrs, e);
|
|
277
328
|
}
|
|
278
329
|
case "mj-raw":
|
|
279
|
-
return
|
|
330
|
+
return it(t.text);
|
|
280
331
|
case "mj-table":
|
|
281
|
-
return
|
|
332
|
+
return at(t.attrs, t.text);
|
|
282
333
|
case "mj-navbar": {
|
|
283
|
-
const e = t.children.filter((
|
|
284
|
-
return
|
|
334
|
+
const e = t.children.filter((o) => o.tag === "mj-navbar-link").map((o) => ({ attrs: o.attrs, innerText: o.text }));
|
|
335
|
+
return st(t.attrs, e);
|
|
285
336
|
}
|
|
286
337
|
default:
|
|
287
338
|
return n.push({
|
|
@@ -290,67 +341,245 @@ function J(t, n) {
|
|
|
290
341
|
}), null;
|
|
291
342
|
}
|
|
292
343
|
}
|
|
293
|
-
function
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
344
|
+
function _(t, n, e) {
|
|
345
|
+
const o = t.attrs, i = [], r = [];
|
|
346
|
+
let s = 0, c = 0;
|
|
347
|
+
for (const g of t.children)
|
|
348
|
+
if (g.tag === "mj-column")
|
|
349
|
+
i.push(z(g, n)), r.push(g), c++;
|
|
350
|
+
else if (g.tag === "mj-group") {
|
|
351
|
+
s++;
|
|
352
|
+
for (const x of g.children)
|
|
353
|
+
x.tag === "mj-column" && (i.push(z(x, n)), r.push(x));
|
|
354
|
+
} else
|
|
302
355
|
n.push({
|
|
303
|
-
message: `Unexpected section child: ${
|
|
304
|
-
tag:
|
|
356
|
+
message: `Unexpected section child: ${g.tag}`,
|
|
357
|
+
tag: g.tag
|
|
305
358
|
});
|
|
306
|
-
|
|
359
|
+
i.length === 0 && i.push({
|
|
307
360
|
id: m(),
|
|
308
361
|
type: "column",
|
|
309
362
|
attributes: {
|
|
310
|
-
padding:
|
|
363
|
+
padding: h(void 0, 0),
|
|
311
364
|
verticalAlign: "top"
|
|
312
365
|
},
|
|
313
366
|
blocks: []
|
|
314
367
|
});
|
|
315
|
-
const
|
|
368
|
+
const d = r.length ? ut(r, e, n) : [12], l = s === 1 && c === 0;
|
|
369
|
+
s > 0 && !l && n.push({
|
|
370
|
+
message: "A section mixing mj-group with other columns was flattened: its columns will stack on mobile",
|
|
371
|
+
tag: "mj-group"
|
|
372
|
+
});
|
|
373
|
+
const u = a(o, "full-width") === "full-width";
|
|
316
374
|
return {
|
|
317
375
|
id: m(),
|
|
318
376
|
type: "row",
|
|
319
377
|
attributes: {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
378
|
+
...t.visibility,
|
|
379
|
+
backgroundColor: a(o, "background-color") || void 0,
|
|
380
|
+
...dt(o, n),
|
|
381
|
+
padding: h(a(o, "padding"), 0),
|
|
382
|
+
fullWidth: u,
|
|
383
|
+
cssClass: a(o, "css-class") || void 0,
|
|
384
|
+
...l ? { noStackOnMobile: !0 } : {}
|
|
325
385
|
},
|
|
326
|
-
columns:
|
|
327
|
-
columnRatios:
|
|
386
|
+
columns: i,
|
|
387
|
+
columnRatios: d,
|
|
328
388
|
locked: !1
|
|
329
389
|
};
|
|
330
390
|
}
|
|
331
|
-
function
|
|
332
|
-
const e = t
|
|
333
|
-
|
|
391
|
+
function dt(t, n) {
|
|
392
|
+
const e = a(t, "background-url");
|
|
393
|
+
if (!e) return {};
|
|
394
|
+
const o = a(t, "background-repeat");
|
|
395
|
+
return (o === "repeat-x" || o === "repeat-y") && n.push({
|
|
396
|
+
message: `background-repeat="${o}" became "repeat" — a row cannot repeat on one axis`,
|
|
397
|
+
tag: "mj-section"
|
|
398
|
+
}), {
|
|
399
|
+
backgroundImage: e,
|
|
400
|
+
backgroundRepeat: o === "no-repeat" ? "no-repeat" : "repeat",
|
|
401
|
+
backgroundSize: a(t, "background-size") || void 0,
|
|
402
|
+
backgroundPosition: a(t, "background-position") || void 0
|
|
403
|
+
};
|
|
334
404
|
}
|
|
335
|
-
function
|
|
405
|
+
function pt(t, n) {
|
|
406
|
+
var i;
|
|
407
|
+
const e = (i = t.attrs.width) == null ? void 0 : i.trim();
|
|
408
|
+
if (!e) return;
|
|
409
|
+
const o = parseFloat(e);
|
|
410
|
+
if (!(isNaN(o) || o <= 0))
|
|
411
|
+
return e.endsWith("%") ? o : o / n * 100;
|
|
412
|
+
}
|
|
413
|
+
function ut(t, n, e) {
|
|
414
|
+
const o = t.map((l) => pt(l, n));
|
|
415
|
+
if (o.every((l) => l === void 0)) {
|
|
416
|
+
const l = Math.floor(12 / o.length);
|
|
417
|
+
return o.map(() => l);
|
|
418
|
+
}
|
|
419
|
+
const i = o.reduce((l, p) => l + (p ?? 0), 0);
|
|
420
|
+
i > 101 && e.push({
|
|
421
|
+
message: `Column widths total ${Math.round(i)}% of the body width; they were scaled to fit`,
|
|
422
|
+
tag: "mj-section"
|
|
423
|
+
});
|
|
424
|
+
const r = o.filter((l) => l === void 0).length, s = Math.max(0, 100 - i), c = o.map((l) => l ?? s / r), d = c.reduce((l, p) => l + p, 0);
|
|
425
|
+
return c.map((l) => Math.max(1, Math.round(l * 12 / d)));
|
|
426
|
+
}
|
|
427
|
+
const v = "Ubuntu, Helvetica, Arial, sans-serif", N = {
|
|
428
|
+
"mj-body": { width: "600px" },
|
|
429
|
+
"mj-section": {
|
|
430
|
+
"background-repeat": "repeat",
|
|
431
|
+
"background-size": "auto",
|
|
432
|
+
"background-position": "top center",
|
|
433
|
+
direction: "ltr",
|
|
434
|
+
padding: "20px 0",
|
|
435
|
+
"text-align": "center",
|
|
436
|
+
"text-padding": "4px 4px 4px 0"
|
|
437
|
+
},
|
|
438
|
+
"mj-wrapper": {
|
|
439
|
+
"background-repeat": "repeat",
|
|
440
|
+
"background-size": "auto",
|
|
441
|
+
"background-position": "top center",
|
|
442
|
+
direction: "ltr",
|
|
443
|
+
padding: "20px 0",
|
|
444
|
+
"text-align": "center",
|
|
445
|
+
"text-padding": "4px 4px 4px 0"
|
|
446
|
+
},
|
|
447
|
+
"mj-column": { direction: "ltr", "vertical-align": "top" },
|
|
448
|
+
"mj-text": {
|
|
449
|
+
align: "left",
|
|
450
|
+
color: "#000000",
|
|
451
|
+
"font-family": v,
|
|
452
|
+
"font-size": "13px",
|
|
453
|
+
"line-height": "1",
|
|
454
|
+
padding: "10px 25px"
|
|
455
|
+
},
|
|
456
|
+
"mj-button": {
|
|
457
|
+
align: "center",
|
|
458
|
+
"background-color": "#414141",
|
|
459
|
+
border: "none",
|
|
460
|
+
"border-radius": "3px",
|
|
461
|
+
color: "#ffffff",
|
|
462
|
+
"font-family": v,
|
|
463
|
+
"font-size": "13px",
|
|
464
|
+
"font-weight": "normal",
|
|
465
|
+
"inner-padding": "10px 25px",
|
|
466
|
+
"line-height": "120%",
|
|
467
|
+
padding: "10px 25px",
|
|
468
|
+
target: "_blank",
|
|
469
|
+
"text-decoration": "none",
|
|
470
|
+
"text-transform": "none",
|
|
471
|
+
"vertical-align": "middle"
|
|
472
|
+
},
|
|
473
|
+
"mj-image": {
|
|
474
|
+
alt: "",
|
|
475
|
+
align: "center",
|
|
476
|
+
border: "0",
|
|
477
|
+
height: "auto",
|
|
478
|
+
padding: "10px 25px",
|
|
479
|
+
target: "_blank",
|
|
480
|
+
"font-size": "13px"
|
|
481
|
+
},
|
|
482
|
+
"mj-divider": {
|
|
483
|
+
"border-color": "#000000",
|
|
484
|
+
"border-style": "solid",
|
|
485
|
+
"border-width": "4px",
|
|
486
|
+
padding: "10px 25px",
|
|
487
|
+
width: "100%",
|
|
488
|
+
align: "center"
|
|
489
|
+
},
|
|
490
|
+
"mj-spacer": { height: "20px" },
|
|
491
|
+
"mj-social": {
|
|
492
|
+
align: "center",
|
|
493
|
+
"border-radius": "3px",
|
|
494
|
+
color: "#333333",
|
|
495
|
+
"font-family": v,
|
|
496
|
+
"font-size": "13px",
|
|
497
|
+
"icon-size": "20px",
|
|
498
|
+
"line-height": "22px",
|
|
499
|
+
mode: "horizontal",
|
|
500
|
+
padding: "10px 25px",
|
|
501
|
+
"text-decoration": "none"
|
|
502
|
+
},
|
|
503
|
+
"mj-social-element": {
|
|
504
|
+
alt: "",
|
|
505
|
+
align: "left",
|
|
506
|
+
"icon-position": "left",
|
|
507
|
+
color: "#000",
|
|
508
|
+
"border-radius": "3px",
|
|
509
|
+
"font-family": v,
|
|
510
|
+
"font-size": "13px",
|
|
511
|
+
"line-height": "1",
|
|
512
|
+
padding: "4px",
|
|
513
|
+
"text-padding": "4px 4px 4px 0",
|
|
514
|
+
target: "_blank",
|
|
515
|
+
"text-decoration": "none",
|
|
516
|
+
"vertical-align": "middle"
|
|
517
|
+
},
|
|
518
|
+
"mj-hero": {
|
|
519
|
+
mode: "fixed-height",
|
|
520
|
+
height: "0px",
|
|
521
|
+
"background-position": "center center",
|
|
522
|
+
padding: "0px",
|
|
523
|
+
"background-color": "#ffffff",
|
|
524
|
+
"vertical-align": "top"
|
|
525
|
+
},
|
|
526
|
+
"mj-navbar": {
|
|
527
|
+
align: "center",
|
|
528
|
+
"ico-align": "center",
|
|
529
|
+
"ico-open": "☰",
|
|
530
|
+
"ico-close": "⊗",
|
|
531
|
+
"ico-color": "#000000",
|
|
532
|
+
"ico-font-size": "30px",
|
|
533
|
+
"ico-font-family": v,
|
|
534
|
+
"ico-text-transform": "uppercase",
|
|
535
|
+
"ico-padding": "10px",
|
|
536
|
+
"ico-text-decoration": "none",
|
|
537
|
+
"ico-line-height": "30px"
|
|
538
|
+
},
|
|
539
|
+
"mj-navbar-link": {
|
|
540
|
+
color: "#000000",
|
|
541
|
+
"font-family": v,
|
|
542
|
+
"font-size": "13px",
|
|
543
|
+
"font-weight": "normal",
|
|
544
|
+
"line-height": "22px",
|
|
545
|
+
padding: "15px 10px",
|
|
546
|
+
target: "_blank",
|
|
547
|
+
"text-decoration": "none",
|
|
548
|
+
"text-transform": "uppercase"
|
|
549
|
+
},
|
|
550
|
+
"mj-table": {
|
|
551
|
+
align: "left",
|
|
552
|
+
border: "none",
|
|
553
|
+
cellpadding: "0",
|
|
554
|
+
cellspacing: "0",
|
|
555
|
+
color: "#000000",
|
|
556
|
+
"font-family": v,
|
|
557
|
+
"font-size": "13px",
|
|
558
|
+
"line-height": "22px",
|
|
559
|
+
padding: "10px 25px",
|
|
560
|
+
"table-layout": "auto",
|
|
561
|
+
width: "100%"
|
|
562
|
+
}
|
|
563
|
+
}, gt = v;
|
|
564
|
+
function ft(t, n, e) {
|
|
336
565
|
return {
|
|
337
566
|
id: m(),
|
|
338
567
|
type: "hero",
|
|
339
568
|
values: {
|
|
340
|
-
backgroundUrl:
|
|
341
|
-
backgroundPosition:
|
|
342
|
-
mode:
|
|
569
|
+
backgroundUrl: a(t, "background-url"),
|
|
570
|
+
backgroundPosition: a(t, "background-position", "center center"),
|
|
571
|
+
mode: a(t, "mode", "fluid-height"),
|
|
343
572
|
width: b(t, "width", 600),
|
|
344
573
|
height: b(t, "height", 400),
|
|
345
|
-
verticalAlign:
|
|
346
|
-
padding:
|
|
347
|
-
innerPadding:
|
|
348
|
-
backgroundColor:
|
|
574
|
+
verticalAlign: a(t, "vertical-align", "middle"),
|
|
575
|
+
padding: h(a(t, "padding"), 0),
|
|
576
|
+
innerPadding: h(e, 20),
|
|
577
|
+
backgroundColor: a(t, "background-color", "#ffffff"),
|
|
349
578
|
content: n
|
|
350
579
|
}
|
|
351
580
|
};
|
|
352
581
|
}
|
|
353
|
-
const
|
|
582
|
+
const ht = [
|
|
354
583
|
["font-style", "font-style"],
|
|
355
584
|
["font-weight", "font-weight"],
|
|
356
585
|
["letter-spacing", "letter-spacing"],
|
|
@@ -359,70 +588,63 @@ const et = [
|
|
|
359
588
|
["text-decoration", "text-decoration"],
|
|
360
589
|
["text-transform", "text-transform"],
|
|
361
590
|
["height", "height"]
|
|
362
|
-
],
|
|
363
|
-
function
|
|
364
|
-
const
|
|
365
|
-
return
|
|
591
|
+
], mt = { "line-height": "1.5", align: "left" };
|
|
592
|
+
function D(t, n, e) {
|
|
593
|
+
const o = ht.filter(([, i]) => t[i] && t[i] !== mt[i]).concat(!e && t.padding ? [["padding", "padding"]] : []).map(([i, r]) => `${i}:${t[r]};`).join("");
|
|
594
|
+
return o ? `<div style="${w(o)}">${n}</div>` : e ? n : `<div>${n}</div>`;
|
|
366
595
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
"
|
|
370
|
-
border: "none",
|
|
371
|
-
"border-radius": "3px",
|
|
372
|
-
color: "#ffffff",
|
|
373
|
-
"font-family": "Ubuntu, Helvetica, Arial, sans-serif",
|
|
374
|
-
"font-size": "13px",
|
|
375
|
-
"font-weight": "normal",
|
|
376
|
-
"inner-padding": "10px 25px",
|
|
377
|
-
"line-height": "120%",
|
|
378
|
-
padding: "10px 25px",
|
|
379
|
-
target: "_blank",
|
|
380
|
-
"text-decoration": "none",
|
|
381
|
-
"text-transform": "none",
|
|
382
|
-
"vertical-align": "middle"
|
|
383
|
-
};
|
|
384
|
-
function ot(t, n) {
|
|
385
|
-
const e = { ...rt, ...t }, r = e["background-color"], o = `border:${e.border};border-radius:${e["border-radius"]};cursor:auto;mso-padding-alt:${e["inner-padding"]};background:${r};`, a = `display:inline-block;background:${r};color:${e.color};font-family:${e["font-family"]};font-size:${e["font-size"]};font-weight:${e["font-weight"]};line-height:${e["line-height"]};margin:0;text-decoration:${e["text-decoration"]};text-transform:${e["text-transform"]};padding:${e["inner-padding"]};mso-padding-alt:0px;border-radius:${e["border-radius"]};`, l = e.href ? `<a href="${w(e.href)}" target="${w(e.target)}" style="${w(a)}">${n.trim()}</a>` : `<p style="${w(a)}">${n.trim()}</p>`;
|
|
386
|
-
return `<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tr><td align="${w(e.align)}" style="padding:${w(e.padding)};"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;"><tr><td align="center"${r === "none" ? "" : ` bgcolor="${w(r)}"`} role="presentation" valign="${w(e["vertical-align"])}" style="${w(o)}">${l}</td></tr></table></td></tr></table>`;
|
|
596
|
+
function bt(t, n) {
|
|
597
|
+
const e = { ...N["mj-button"], ...t }, o = e["background-color"], i = `border:${e.border};border-radius:${e["border-radius"]};cursor:auto;mso-padding-alt:${e["inner-padding"]};background:${o};`, r = `display:inline-block;background:${o};color:${e.color};font-family:${e["font-family"]};font-size:${e["font-size"]};font-weight:${e["font-weight"]};line-height:${e["line-height"]};margin:0;text-decoration:${e["text-decoration"]};text-transform:${e["text-transform"]};padding:${e["inner-padding"]};mso-padding-alt:0px;border-radius:${e["border-radius"]};`, s = e.href ? `<a href="${w(e.href)}" target="${w(e.target)}" style="${w(r)}">${n.trim()}</a>` : `<p style="${w(r)}">${n.trim()}</p>`;
|
|
598
|
+
return `<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tr><td align="${w(e.align)}" style="padding:${w(e.padding)};"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;"><tr><td align="center"${o === "none" ? "" : ` bgcolor="${w(o)}"`} role="presentation" valign="${w(e["vertical-align"])}" style="${w(i)}">${s}</td></tr></table></td></tr></table>`;
|
|
387
599
|
}
|
|
388
600
|
function w(t) {
|
|
389
601
|
return t.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
390
602
|
}
|
|
391
|
-
function
|
|
392
|
-
const e = b(t.attrs, "width", 600),
|
|
393
|
-
let
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
603
|
+
function xt(t, n) {
|
|
604
|
+
const e = b(t.attrs, "width", 600), o = a(t.attrs, "background-color"), i = [];
|
|
605
|
+
let r = [], s;
|
|
606
|
+
const c = (d) => {
|
|
607
|
+
var g;
|
|
608
|
+
const [l, p] = r;
|
|
609
|
+
l && (d.attributes.condition = l);
|
|
610
|
+
const [u] = ((g = d.columns[0]) == null ? void 0 : g.blocks) ?? [];
|
|
611
|
+
return p && (u == null ? void 0 : u.type) === "hero" && (u.values.condition = p), r = [], s && (d.attributes.repeat = s, s = void 0), d;
|
|
612
|
+
};
|
|
613
|
+
for (const d of t.children)
|
|
614
|
+
switch (d.tag) {
|
|
397
615
|
case "mj-raw": {
|
|
398
|
-
const
|
|
399
|
-
|
|
616
|
+
const l = /\{\{#if\s+([^}]+?)\s*\}\}/.exec(d.text ?? "");
|
|
617
|
+
l && r.push(l[1].trim());
|
|
618
|
+
const p = /^\s*\{\{#each\s+([^}]+?)\s*\}\}\s*$/.exec(d.text ?? "");
|
|
619
|
+
p && (s = p[1].trim(), r = [r[0]]);
|
|
400
620
|
break;
|
|
401
621
|
}
|
|
402
622
|
case "mj-section":
|
|
403
|
-
|
|
623
|
+
i.push(c(_(d, n, e)));
|
|
404
624
|
break;
|
|
405
625
|
case "mj-hero": {
|
|
406
|
-
const
|
|
626
|
+
const l = kt(d, n), p = ft(d.attrs, l.content, l.innerPadding);
|
|
627
|
+
Object.assign(p.values, d.visibility);
|
|
628
|
+
const u = {
|
|
407
629
|
id: m(),
|
|
408
630
|
type: "column",
|
|
409
631
|
attributes: {
|
|
410
|
-
padding:
|
|
632
|
+
padding: h(void 0, 0),
|
|
411
633
|
verticalAlign: "top"
|
|
412
634
|
},
|
|
413
|
-
blocks: [
|
|
414
|
-
},
|
|
635
|
+
blocks: [p]
|
|
636
|
+
}, g = {
|
|
415
637
|
id: m(),
|
|
416
638
|
type: "row",
|
|
417
639
|
attributes: {
|
|
418
|
-
padding:
|
|
640
|
+
padding: h(void 0, 0),
|
|
419
641
|
fullWidth: !1
|
|
420
642
|
},
|
|
421
|
-
columns: [
|
|
643
|
+
columns: [u],
|
|
422
644
|
columnRatios: [12],
|
|
423
645
|
locked: !1
|
|
424
646
|
};
|
|
425
|
-
|
|
647
|
+
i.push(c(g));
|
|
426
648
|
break;
|
|
427
649
|
}
|
|
428
650
|
case "mj-wrapper":
|
|
@@ -430,40 +652,40 @@ function it(t, n) {
|
|
|
430
652
|
message: "mj-wrapper styling (padding, background-color) was dropped: the document model has no wrapper; its sections were imported unwrapped",
|
|
431
653
|
tag: "mj-wrapper"
|
|
432
654
|
});
|
|
433
|
-
for (const
|
|
434
|
-
|
|
655
|
+
for (const l of d.children)
|
|
656
|
+
l.tag === "mj-section" && i.push(c(_(l, n, e)));
|
|
435
657
|
break;
|
|
436
658
|
default:
|
|
437
659
|
n.push({
|
|
438
|
-
message: `Unknown body child element: ${
|
|
439
|
-
tag:
|
|
660
|
+
message: `Unknown body child element: ${d.tag}`,
|
|
661
|
+
tag: d.tag
|
|
440
662
|
});
|
|
441
663
|
break;
|
|
442
664
|
}
|
|
443
|
-
return { width: e, backgroundColor:
|
|
665
|
+
return { width: e, backgroundColor: o, rows: i };
|
|
444
666
|
}
|
|
445
|
-
function
|
|
667
|
+
function kt(t, n) {
|
|
446
668
|
const [e] = t.children;
|
|
447
669
|
if (t.children.length === 1 && e.tag === "mj-text")
|
|
448
|
-
return { content:
|
|
449
|
-
const
|
|
450
|
-
for (const
|
|
451
|
-
|
|
452
|
-
return { content:
|
|
453
|
-
}
|
|
454
|
-
const
|
|
455
|
-
function
|
|
456
|
-
const { "mj-class":
|
|
457
|
-
const
|
|
458
|
-
return { ...
|
|
670
|
+
return { content: D(e.attrs, e.text, !0), innerPadding: e.attrs.padding };
|
|
671
|
+
const o = [];
|
|
672
|
+
for (const i of t.children)
|
|
673
|
+
i.tag === "mj-text" ? o.push(D(i.attrs, i.text, !1)) : i.tag === "mj-button" ? o.push(bt(i.attrs, i.text)) : n.push({ message: `Unsupported mj-hero child element: ${i.tag}`, tag: i.tag });
|
|
674
|
+
return { content: o.join("") || "<p>Hero Content</p>" };
|
|
675
|
+
}
|
|
676
|
+
const wt = /* @__PURE__ */ new Set(["mj-section", "mj-column", "mj-text", "mj-button", "mj-image"]);
|
|
677
|
+
function F(t, n, e) {
|
|
678
|
+
const { "mj-class": o = "", ...i } = t.attrs, r = o.split(/\s+/).filter(Boolean).reduce((c, d) => {
|
|
679
|
+
const l = n.classes[d] ?? {}, p = c["css-class"] && l["css-class"] ? { "css-class": `${c["css-class"]} ${l["css-class"]}` } : {};
|
|
680
|
+
return { ...c, ...l, ...p };
|
|
459
681
|
}, {});
|
|
460
|
-
t.attrs = { ...n.all, ...n.tags[t.tag], ...
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
for (const
|
|
464
|
-
|
|
682
|
+
t.attrs = { ...N[t.tag], ...n.all, ...n.tags[t.tag], ...r, ...i }, t.visibility = O(t.attrs);
|
|
683
|
+
const s = t.attrs["css-class"];
|
|
684
|
+
s && !wt.has(t.tag) && e.push({ message: `css-class "${s}" on <${t.tag}> was dropped`, tag: t.tag });
|
|
685
|
+
for (const c of t.children)
|
|
686
|
+
F(c, n, e);
|
|
465
687
|
}
|
|
466
|
-
const
|
|
688
|
+
const I = /* @__PURE__ */ new Set([
|
|
467
689
|
"address",
|
|
468
690
|
"article",
|
|
469
691
|
"aside",
|
|
@@ -514,66 +736,67 @@ const D = /* @__PURE__ */ new Set([
|
|
|
514
736
|
"source",
|
|
515
737
|
"track",
|
|
516
738
|
"wbr"
|
|
517
|
-
]),
|
|
518
|
-
function
|
|
739
|
+
]), vt = "14px", jt = "#000000";
|
|
740
|
+
function M(t, n) {
|
|
519
741
|
if (t.tag === "mj-text") {
|
|
520
|
-
const { color: e, "font-size":
|
|
521
|
-
e && e.toLowerCase() !==
|
|
742
|
+
const { color: e, "font-size": o, "font-family": i } = t.attrs, r = [];
|
|
743
|
+
e && e.toLowerCase() !== jt && r.push(`color: ${e}`), o && o !== vt && r.push(`font-size: ${o}`), i && i !== n && r.push(`font-family: ${i}`), r.length > 0 && (t.text = yt(t.text, `<span style="${$t(r.join("; "))}">`));
|
|
522
744
|
return;
|
|
523
745
|
}
|
|
524
746
|
for (const e of t.children)
|
|
525
|
-
|
|
747
|
+
M(e, n);
|
|
526
748
|
}
|
|
527
|
-
function
|
|
749
|
+
function yt(t, n) {
|
|
528
750
|
const e = [];
|
|
529
|
-
let
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
},
|
|
533
|
-
|
|
534
|
-
},
|
|
535
|
-
onopentag(
|
|
536
|
-
if (
|
|
537
|
-
|
|
751
|
+
let o = -1, i = -1, r = !1, s = 0;
|
|
752
|
+
const c = () => {
|
|
753
|
+
o >= 0 && r && e.push([o, n], [i, "</span>"]), o = -1, r = !1;
|
|
754
|
+
}, d = (u, g) => {
|
|
755
|
+
o < 0 && (o = u), i = g;
|
|
756
|
+
}, l = new R({
|
|
757
|
+
onopentag(u) {
|
|
758
|
+
if (s === 0 && I.has(u)) {
|
|
759
|
+
c();
|
|
538
760
|
return;
|
|
539
761
|
}
|
|
540
|
-
|
|
762
|
+
d(l.startIndex, l.endIndex + 1), B.has(u) ? r = !0 : s++;
|
|
541
763
|
},
|
|
542
|
-
onclosetag(
|
|
543
|
-
if (!B.has(
|
|
544
|
-
if (
|
|
545
|
-
|
|
764
|
+
onclosetag(u, g) {
|
|
765
|
+
if (!B.has(u)) {
|
|
766
|
+
if (s === 0) {
|
|
767
|
+
I.has(u) && c();
|
|
546
768
|
return;
|
|
547
769
|
}
|
|
548
|
-
|
|
770
|
+
s--, g || (i = l.endIndex + 1);
|
|
549
771
|
}
|
|
550
772
|
},
|
|
551
|
-
ontext(
|
|
552
|
-
|
|
773
|
+
ontext(u) {
|
|
774
|
+
o < 0 && !u.trim() || (d(l.startIndex, l.endIndex + 1), u.trim() && (r = !0));
|
|
553
775
|
},
|
|
554
776
|
oncomment() {
|
|
555
|
-
|
|
777
|
+
o >= 0 && (i = l.endIndex + 1);
|
|
556
778
|
}
|
|
557
779
|
}, { recognizeSelfClosing: !0, lowerCaseTags: !0 });
|
|
558
|
-
|
|
780
|
+
l.write(t), l.end(), c();
|
|
559
781
|
let p = t;
|
|
560
|
-
for (const [
|
|
561
|
-
p = p.slice(0,
|
|
782
|
+
for (const [u, g] of e.reverse())
|
|
783
|
+
p = p.slice(0, u) + g + p.slice(u);
|
|
562
784
|
return p;
|
|
563
785
|
}
|
|
564
|
-
function
|
|
786
|
+
function $t(t) {
|
|
565
787
|
return t.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
566
788
|
}
|
|
567
|
-
function
|
|
568
|
-
const n = { tag: "root", attrs: {}, children: [], text: "" }, e = [n],
|
|
789
|
+
function St(t) {
|
|
790
|
+
const n = { tag: "root", attrs: {}, children: [], text: "" }, e = [n], o = /* @__PURE__ */ new Set([
|
|
569
791
|
"mj-text",
|
|
570
792
|
"mj-button",
|
|
571
793
|
"mj-raw",
|
|
572
794
|
"mj-preview",
|
|
795
|
+
"mj-title",
|
|
573
796
|
"mj-social-element",
|
|
574
797
|
"mj-navbar-link",
|
|
575
798
|
"mj-table"
|
|
576
|
-
]),
|
|
799
|
+
]), i = /* @__PURE__ */ new Set([
|
|
577
800
|
"mj-image",
|
|
578
801
|
"mj-divider",
|
|
579
802
|
"mj-spacer",
|
|
@@ -581,7 +804,7 @@ function gt(t) {
|
|
|
581
804
|
"mj-class",
|
|
582
805
|
"mj-font",
|
|
583
806
|
"mj-breakpoint"
|
|
584
|
-
]),
|
|
807
|
+
]), r = /* @__PURE__ */ new Set([
|
|
585
808
|
"area",
|
|
586
809
|
"base",
|
|
587
810
|
"br",
|
|
@@ -595,106 +818,110 @@ function gt(t) {
|
|
|
595
818
|
"source",
|
|
596
819
|
"track",
|
|
597
820
|
"wbr"
|
|
598
|
-
]),
|
|
599
|
-
let p = null,
|
|
600
|
-
const
|
|
601
|
-
onopentag(
|
|
821
|
+
]), s = /* @__PURE__ */ new Set(["mj-text", "mj-button", "mj-raw"]), c = /* @__PURE__ */ new Set(["style", "script"]), d = (f) => f.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), l = (f) => f.replace(/&/g, "&").replace(/"/g, """);
|
|
822
|
+
let p = null, u = "", g = 0, x = !1;
|
|
823
|
+
const $ = new R({
|
|
824
|
+
onopentag(f, j) {
|
|
602
825
|
if (p) {
|
|
603
|
-
const
|
|
604
|
-
|
|
826
|
+
const W = s.has(p.node.tag), T = Object.entries(j).map(([P, A]) => `${P}="${W ? l(A) : A}"`).join(" ");
|
|
827
|
+
u += T ? `<${f} ${T}>` : `<${f}>`, r.has(f) || g++, c.has(f) && (x = !0);
|
|
605
828
|
return;
|
|
606
829
|
}
|
|
607
|
-
const k = { tag:
|
|
608
|
-
e[e.length - 1].children.push(k), !
|
|
830
|
+
const k = { tag: f, attrs: j, children: [], text: "" };
|
|
831
|
+
e[e.length - 1].children.push(k), !i.has(f) && (e.push(k), o.has(f) && (p = { node: k, depth: 0 }, u = "", g = 0));
|
|
609
832
|
},
|
|
610
|
-
ontext(
|
|
833
|
+
ontext(f) {
|
|
611
834
|
if (p) {
|
|
612
|
-
const k =
|
|
613
|
-
|
|
835
|
+
const k = s.has(p.node.tag) && !x;
|
|
836
|
+
u += k ? d(f) : f;
|
|
614
837
|
return;
|
|
615
838
|
}
|
|
616
|
-
const
|
|
617
|
-
|
|
839
|
+
const j = e[e.length - 1];
|
|
840
|
+
j.text += f;
|
|
618
841
|
},
|
|
619
|
-
onclosetag(
|
|
842
|
+
onclosetag(f) {
|
|
620
843
|
if (p) {
|
|
621
|
-
if (
|
|
622
|
-
if (
|
|
623
|
-
|
|
844
|
+
if (r.has(f)) return;
|
|
845
|
+
if (g > 0) {
|
|
846
|
+
u += `</${f}>`, g--, c.has(f) && (x = !1);
|
|
624
847
|
return;
|
|
625
848
|
}
|
|
626
|
-
p.node.text =
|
|
849
|
+
p.node.text = u, p = null, u = "", g = 0, e.length > 1 && e[e.length - 1].tag === f && e.pop();
|
|
627
850
|
return;
|
|
628
851
|
}
|
|
629
|
-
|
|
852
|
+
i.has(f) || e.length > 1 && e[e.length - 1].tag === f && e.pop();
|
|
630
853
|
},
|
|
631
|
-
oncomment(
|
|
632
|
-
p && (
|
|
854
|
+
oncomment(f) {
|
|
855
|
+
p && (u += `<!--${f}-->`);
|
|
633
856
|
}
|
|
634
857
|
}, {
|
|
635
858
|
recognizeSelfClosing: !0,
|
|
636
859
|
lowerCaseTags: !0,
|
|
637
860
|
lowerCaseAttributeNames: !0
|
|
638
861
|
});
|
|
639
|
-
return
|
|
862
|
+
return $.write(t), $.end(), n;
|
|
640
863
|
}
|
|
641
|
-
function
|
|
864
|
+
function C(t, n) {
|
|
642
865
|
if (t.tag === n) return t;
|
|
643
866
|
for (const e of t.children) {
|
|
644
|
-
const
|
|
645
|
-
if (
|
|
867
|
+
const o = C(e, n);
|
|
868
|
+
if (o) return o;
|
|
646
869
|
}
|
|
647
870
|
}
|
|
648
|
-
function
|
|
649
|
-
|
|
650
|
-
|
|
871
|
+
function At(t, n) {
|
|
872
|
+
var j;
|
|
873
|
+
const e = [], o = St(t), i = C(o, "mjml");
|
|
874
|
+
if (!i)
|
|
651
875
|
return e.push({ message: "No <mjml> root element found" }), {
|
|
652
|
-
document:
|
|
876
|
+
document: L(),
|
|
653
877
|
warnings: e
|
|
654
878
|
};
|
|
655
|
-
const
|
|
656
|
-
let
|
|
657
|
-
if (
|
|
658
|
-
|
|
659
|
-
tag:
|
|
660
|
-
attrs:
|
|
661
|
-
children:
|
|
662
|
-
tag:
|
|
663
|
-
attrs:
|
|
879
|
+
const r = C(i, "mj-head"), s = C(i, "mj-body");
|
|
880
|
+
let c = { attributeDefaults: { all: {}, tags: {}, classes: {} } };
|
|
881
|
+
if (r && (c = q(
|
|
882
|
+
r.children.map((k) => ({
|
|
883
|
+
tag: k.tag,
|
|
884
|
+
attrs: k.attrs,
|
|
885
|
+
children: k.children.map((S) => ({
|
|
886
|
+
tag: S.tag,
|
|
887
|
+
attrs: S.attrs,
|
|
664
888
|
children: [],
|
|
665
|
-
text:
|
|
889
|
+
text: S.text
|
|
666
890
|
})),
|
|
667
|
-
text:
|
|
891
|
+
text: k.text
|
|
668
892
|
}))
|
|
669
|
-
)), !
|
|
893
|
+
)), !s)
|
|
670
894
|
return e.push({ message: "No <mj-body> element found" }), {
|
|
671
|
-
document:
|
|
895
|
+
document: L(),
|
|
672
896
|
warnings: e
|
|
673
897
|
};
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
const
|
|
898
|
+
const d = c.fontFamily ?? gt;
|
|
899
|
+
F(s, c.attributeDefaults, e), M(s, d);
|
|
900
|
+
const l = xt(s, e), p = i.attrs.lang, u = p && p !== "und" ? p : void 0, g = i.attrs.dir, x = g === "ltr" || g === "rtl" ? g : void 0, $ = (/* @__PURE__ */ new Date()).toISOString();
|
|
677
901
|
return { document: {
|
|
678
902
|
version: "1.0",
|
|
679
903
|
metadata: {
|
|
680
|
-
name: "Imported Template",
|
|
681
|
-
previewText:
|
|
682
|
-
createdAt:
|
|
683
|
-
updatedAt:
|
|
904
|
+
name: ((j = c.title) == null ? void 0 : j.trim()) || "Imported Template",
|
|
905
|
+
previewText: c.previewText,
|
|
906
|
+
createdAt: $,
|
|
907
|
+
updatedAt: $
|
|
684
908
|
},
|
|
685
909
|
body: {
|
|
686
910
|
attributes: {
|
|
687
|
-
width:
|
|
688
|
-
backgroundColor:
|
|
689
|
-
fontFamily:
|
|
911
|
+
width: l.width,
|
|
912
|
+
backgroundColor: l.backgroundColor,
|
|
913
|
+
fontFamily: d,
|
|
690
914
|
contentAlignment: "center",
|
|
691
|
-
|
|
915
|
+
...c.linkStyle ? { linkStyle: c.linkStyle } : {},
|
|
916
|
+
...u ? { language: u } : {},
|
|
917
|
+
...x ? { direction: x } : {},
|
|
918
|
+
css: c.css
|
|
692
919
|
},
|
|
693
|
-
rows:
|
|
920
|
+
rows: l.rows
|
|
694
921
|
}
|
|
695
922
|
}, warnings: e };
|
|
696
923
|
}
|
|
697
|
-
function
|
|
924
|
+
function L() {
|
|
698
925
|
const t = (/* @__PURE__ */ new Date()).toISOString();
|
|
699
926
|
return {
|
|
700
927
|
version: "1.0",
|
|
@@ -715,5 +942,5 @@ function I() {
|
|
|
715
942
|
};
|
|
716
943
|
}
|
|
717
944
|
export {
|
|
718
|
-
|
|
945
|
+
At as mjmlToDocument
|
|
719
946
|
};
|