@charisol/plexo-sdk 1.3.0 → 1.4.1
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/dist/{compiler-nmaKKdLq.js → compiler-JKW4O9Mv.js} +9 -9
- package/dist/compiler.js +1 -1
- package/dist/compilerClient-CZG4B3cC.js +216 -0
- package/dist/compilerClient.js +1 -1
- package/dist/components/CodeViewer.d.ts +3 -0
- package/dist/components/ImportModal.d.ts +3 -0
- package/dist/components/properties/accordionSections/DividerPropertiesAccordion.d.ts +2 -0
- package/dist/index.js +13739 -13653
- package/dist/plexo-sdk.css +1 -1
- package/dist/utilities/dndCollision.d.ts +34 -0
- package/dist/utilities/instrumentation.d.ts +25 -7
- package/dist/utilities/playground.interfaces.d.ts +4 -0
- package/package.json +1 -1
- package/dist/compilerClient-DW7b0Ifk.js +0 -215
|
@@ -643,11 +643,11 @@ var k = {
|
|
|
643
643
|
scale: 1,
|
|
644
644
|
floorPx: 0
|
|
645
645
|
}
|
|
646
|
-
},
|
|
646
|
+
}, N = ["fontSize"], ee = [
|
|
647
647
|
"height",
|
|
648
648
|
"minHeight",
|
|
649
649
|
"maxHeight"
|
|
650
|
-
],
|
|
650
|
+
], te = [
|
|
651
651
|
"padding",
|
|
652
652
|
"paddingTop",
|
|
653
653
|
"paddingBottom",
|
|
@@ -671,19 +671,19 @@ function I(e, t) {
|
|
|
671
671
|
function L(e, t) {
|
|
672
672
|
if (!e || typeof e != "object") return {};
|
|
673
673
|
let n = {};
|
|
674
|
-
for (let r of
|
|
674
|
+
for (let r of N) {
|
|
675
675
|
let i = F(e[r]);
|
|
676
676
|
if (i === null) continue;
|
|
677
677
|
let a = I(i, k[t]);
|
|
678
678
|
a !== null && (n[r] = `${a}px`);
|
|
679
679
|
}
|
|
680
|
-
for (let r of
|
|
680
|
+
for (let r of ee) {
|
|
681
681
|
let i = F(e[r]);
|
|
682
682
|
if (i === null) continue;
|
|
683
683
|
let a = I(i, A[t]);
|
|
684
684
|
a !== null && (n[r] = `${a}px`);
|
|
685
685
|
}
|
|
686
|
-
for (let r of
|
|
686
|
+
for (let r of te) {
|
|
687
687
|
let i = F(e[r]);
|
|
688
688
|
if (i === null) continue;
|
|
689
689
|
let a = I(i, j[t]);
|
|
@@ -1105,11 +1105,11 @@ var ae = (g) => {
|
|
|
1105
1105
|
let _ = g.style || {}, v = g.type === "heading" || g.type === "paragraph" || g.type === "text", y = v ? c(g).autoWidth : !1, b = y ? Object.fromEntries(Object.entries(_).filter(([e]) => e !== "width")) : _, x = V(g.type === "form_container" ? {
|
|
1106
1106
|
...K(),
|
|
1107
1107
|
..._
|
|
1108
|
-
} : b), S = g.attributes || {}, C = ` data-plexo-id="${q(g.id)}"`, w = (e) =>
|
|
1108
|
+
} : b), S = g.attributes || {}, C = ` data-plexo-id="${q(g.id)}"`, w = String(S.boxAlign || "left"), T = v && (y || !!_.width), E = (e) => T ? `<div style="text-align: ${w};">${e}</div>` : e, D = `${T ? "display: inline-block; " : ""}${v && _.height ? "overflow: hidden; " : ""}`;
|
|
1109
1109
|
switch (g.type) {
|
|
1110
|
-
case "heading": return
|
|
1111
|
-
case "paragraph": return
|
|
1112
|
-
case "text": return
|
|
1110
|
+
case "heading": return E(`<h2${C} style="margin-top: 0; margin-bottom: 8px; ${D}${x}">${S.text || "Heading"}</h2>`);
|
|
1111
|
+
case "paragraph": return E(`<p${C} style="margin-top: 0; margin-bottom: 12px; ${D}${x}">${S.text || "Paragraph text content."}</p>`);
|
|
1112
|
+
case "text": return E(`<div${C} style="${D}${x}">${S.text || ""}</div>`);
|
|
1113
1113
|
case "button": {
|
|
1114
1114
|
let e = u(g), t = V({
|
|
1115
1115
|
..._,
|
package/dist/compiler.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./compiler-
|
|
1
|
+
import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./compiler-JKW4O9Mv.js";
|
|
2
2
|
export { l as DEFAULT_BODY_FONT_FAMILY, a as FORM_NON_CSS_STYLE_KEYS, s as collectResponsiveRule, r as compileToHTML, e as compileToHTMLWithStrataAuto, o as compileToPlainText, c as convertSectionRowToPlexoRow, t as getFormDefaultStyle, i as getInlineStylesImportant, u as htmlToPlainText, n as injectStrataBundle };
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { d as e, f as t, g as n, h as r, m as i, o as a, p as o, t as s, u as c, x as l, y as u } from "./iconSvgStatic-CGue7nyp.js";
|
|
2
|
+
//#region src/utilities/instrumentation.ts
|
|
3
|
+
var d = "plexo-node", f = "plexo-row", p = "plexo-col";
|
|
4
|
+
function m(e) {
|
|
5
|
+
return `plexo-node-${e}`;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/utilities/compilerClient.ts
|
|
9
|
+
var h = "https://cdn.jsdelivr.net/npm/@charisol/plexo-sdk@latest/dist/social-icons", g = /* @__PURE__ */ new Set([
|
|
10
|
+
"selectable",
|
|
11
|
+
"draggable",
|
|
12
|
+
"duplicatable",
|
|
13
|
+
"deletable",
|
|
14
|
+
"hideable",
|
|
15
|
+
"locked"
|
|
16
|
+
]), _ = (e) => String(e ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), v = (e = {}) => Object.entries(e).filter(([, e]) => e != null && String(e).trim() !== "").map(([e, t]) => `${e.replace(/([A-Z])/g, "-$1").toLowerCase()}:${String(t)};`).join(""), y = (...e) => e.map((e) => String(e ?? "").trim()).filter(Boolean).join(" "), b = (e, t, n, r) => n ? y(e, d, m(t), r) : e, x = (e, t, n) => {
|
|
17
|
+
let r = b("", e, t, n);
|
|
18
|
+
return r ? ` css-class="${_(r)}"` : "";
|
|
19
|
+
}, S = (e, t, n) => {
|
|
20
|
+
let r = b("", e, t, n);
|
|
21
|
+
return r ? ` class="${_(r)}"` : "";
|
|
22
|
+
}, C = (e, t) => {
|
|
23
|
+
let n = { ...e.attributes || {} };
|
|
24
|
+
if (t === "email") for (let e of g) delete n[e];
|
|
25
|
+
return n;
|
|
26
|
+
}, w = (e, t, n) => {
|
|
27
|
+
let r = C(e, t), i = v(e.style || {}), a = b(y(r.htmlClassNames, r.htmlClass, r.validationClass, r.validationClassName), e.id, t === "landing_page" && n), o = _(r.name || r.fieldName || "field"), s = _(r.placeholder || ""), c = r.required ? " required" : "";
|
|
28
|
+
if (t === "email") return `<mj-table${x(e.id, n)}><tr><td style="padding:10px 12px;border:1px solid #d1d5db;border-radius:6px;color:#64748b;${i}">${s || o}</td></tr></mj-table>`;
|
|
29
|
+
let l = _(r.inputType || r.type || (e.type === "input" ? r.kind || "text" : e.type)), u = r.htmlId ? ` id="${_(r.htmlId)}"` : "", d = a ? ` class="${_(a)}"` : "";
|
|
30
|
+
return e.type === "textarea" ? `<textarea${u}${d} name="${o}" placeholder="${s}" style="${i}"${c}>${_(r.value || "")}</textarea>` : e.type === "select" ? `<select${u}${d} name="${o}" style="${i}"${c}>${(r.options || []).map((e) => `<option value="${_(e.value)}">${_(e.label)}</option>`).join("")}</select>` : `<input${u}${d} type="${l}" name="${o}" placeholder="${s}" value="${_(r.value || "")}" style="${i}"${c} />`;
|
|
31
|
+
}, T = (e, t, n) => {
|
|
32
|
+
let r = C(e, t), i = v(e.style || {}), a = b(y(r.htmlClassNames, r.htmlClass), e.id, t === "landing_page" && n), o = r.htmlId ? ` id="${_(r.htmlId)}"` : "", s = a ? ` class="${_(a)}"` : "", c = _(r.actionUrl || r.action || "#"), l = _(r.method || "POST"), u = r.fields || [], d = _(r.submitLabel || "Submit");
|
|
33
|
+
return t === "email" ? `<mj-table${x(e.id, n)}><tr><td style="${i}"><table role="presentation" width="100%">${u.map((e) => `<tr><td style="padding:8px 0;font-family:Arial,sans-serif;color:#334155;"><strong>${_(e.label || e.name || "Field")}</strong><br/><span style="display:inline-block;margin-top:4px;padding:10px 12px;border:1px solid #d1d5db;border-radius:6px;color:#64748b;">${_(e.placeholder || "") || " "}</span></td></tr>`).join("")}<tr><td style="padding-top:12px;"><a href="${_(r.href || r.submitHref || "#")}" style="display:inline-block;padding:10px 16px;background:#0f172a;color:#ffffff;text-decoration:none;border-radius:6px;">${d}</a></td></tr></table></td></tr></mj-table>` : `<form${o}${s} action="${c}" method="${l}" style="${i}">${u.map((t) => w({
|
|
34
|
+
id: `${e.id}-${String(t.name || t.label || "field")}`,
|
|
35
|
+
type: t.kind === "textarea" || t.kind === "select" ? t.kind : "input",
|
|
36
|
+
style: {
|
|
37
|
+
...e.style || {},
|
|
38
|
+
...t.style || {}
|
|
39
|
+
},
|
|
40
|
+
attributes: t
|
|
41
|
+
}, "landing_page", n)).join("")}<button type="submit">${d}</button></form>`;
|
|
42
|
+
}, E = [], D = !1, O = 148, k = [
|
|
43
|
+
["borderRadius", "border-radius"],
|
|
44
|
+
["borderWidth", "border-width"],
|
|
45
|
+
["borderStyle", "border-style"],
|
|
46
|
+
["borderColor", "border-color"],
|
|
47
|
+
["boxShadow", "box-shadow"]
|
|
48
|
+
], A = (e, t, n = []) => {
|
|
49
|
+
let r = [...k.filter(([t]) => e[t]).map(([t, n]) => `${n}: ${_(String(e[t]))}`), ...n];
|
|
50
|
+
if (r.length === 0) return "";
|
|
51
|
+
let i = `plexo-extra-style-${t}`;
|
|
52
|
+
return E.push(`.${i} { ${r.join("; ")}; }`), i;
|
|
53
|
+
}, j = (e = {}, t = {}) => {
|
|
54
|
+
let n = ["padding=\"0\""], r = e.fontSize || t.fontSize, i = e.fontWeight || t.fontWeight;
|
|
55
|
+
return r && n.push(`font-size="${_(String(r))}"`), i && n.push(`font-weight="${_(String(i))}"`), e.color && n.push(`color="${_(String(e.color))}"`), e.fontFamily && n.push(`font-family="${_(String(e.fontFamily))}"`), e.lineHeight && n.push(`line-height="${_(String(e.lineHeight))}"`), e.letterSpacing && n.push(`letter-spacing="${_(String(e.letterSpacing))}"`), n.join(" ");
|
|
56
|
+
}, M = (e = {}) => {
|
|
57
|
+
let t = e.backgroundColor || e.background;
|
|
58
|
+
return t ? ` background-color="${_(String(t))}"` : "";
|
|
59
|
+
}, N = (e, t, n) => {
|
|
60
|
+
if (e[t]) return String(e[t]);
|
|
61
|
+
let [r, i, a, o] = n;
|
|
62
|
+
if (e[r] || e[i] || e[a] || e[o]) return `${e[r] || "0px"} ${e[i] || "0px"} ${e[a] || "0px"} ${e[o] || "0px"}`;
|
|
63
|
+
}, P = (e = {}) => {
|
|
64
|
+
let t = [];
|
|
65
|
+
e.backgroundColor && t.push(`background-color="${_(String(e.backgroundColor))}"`), e.color && t.push(`color="${_(String(e.color))}"`), e.fontSize && t.push(`font-size="${_(String(e.fontSize))}"`), e.fontWeight && t.push(`font-weight="${_(String(e.fontWeight))}"`), e.fontFamily && t.push(`font-family="${_(String(e.fontFamily))}"`), e.lineHeight && t.push(`line-height="${_(String(e.lineHeight))}"`), e.letterSpacing && t.push(`letter-spacing="${_(String(e.letterSpacing))}"`), e.textAlign && t.push(`align="${_(String(e.textAlign))}"`);
|
|
66
|
+
let n = N(e, "borderRadius", [
|
|
67
|
+
"borderTopLeftRadius",
|
|
68
|
+
"borderTopRightRadius",
|
|
69
|
+
"borderBottomRightRadius",
|
|
70
|
+
"borderBottomLeftRadius"
|
|
71
|
+
]);
|
|
72
|
+
return n && t.push(`border-radius="${_(n)}"`), t.join(" ");
|
|
73
|
+
}, F = (l, d, f) => {
|
|
74
|
+
let p = C(l, d), m = v(l.style || {}), g = p.htmlId ? ` id="${_(p.htmlId)}"` : "", D = y(p.htmlClassNames, p.htmlClass, d === "landing_page" && p.hideOnMobile ? "hidden md:block" : ""), O = d === "landing_page" ? b(D, l.id, f) : D, k = O ? ` class="${_(O)}"` : "", A = typeof p.customCss == "string" && p.customCss.trim() ? p.customCss.trim() : "", M = A && d === "landing_page" ? `<style>${A}</style>` : "";
|
|
75
|
+
if (l.type === "form_container") return `${M}${T(l, d, f)}`;
|
|
76
|
+
if (l.type === "input" || l.type === "select" || l.type === "textarea") return `${M}${w(l, d, f)}`;
|
|
77
|
+
if (d === "email") {
|
|
78
|
+
if (l.type === "button") {
|
|
79
|
+
let e = _(p.href || "#"), t = _(p.text || "Button"), n = a(l).width, r = n === "auto" ? "" : ` width="${_(n)}"`, i = l.style || {}, o = P(i), s = N(i, "padding", [
|
|
80
|
+
"paddingTop",
|
|
81
|
+
"paddingRight",
|
|
82
|
+
"paddingBottom",
|
|
83
|
+
"paddingLeft"
|
|
84
|
+
]) || "10px 16px";
|
|
85
|
+
return `<mj-button href="${e}" css-class="${b(p.hideOnDesktop ? "desktop-hide" : "", l.id, f)}" padding="0" inner-padding="${_(s)}"${r}${o ? ` ${o}` : ""}>${t}</mj-button>`;
|
|
86
|
+
}
|
|
87
|
+
if (l.type === "image") {
|
|
88
|
+
let e = c(l), t = e.width && e.width !== "100%" ? ` width="${_(e.width)}"` : "", n = e.height && e.height !== "auto" ? ` height="${_(e.height)}"` : "", r = x(l.id, f);
|
|
89
|
+
return `<mj-image src="${_(p.src || "")}" alt="${_(p.alt || "")}"${t}${n}${r} />`;
|
|
90
|
+
}
|
|
91
|
+
if (l.type === "social") {
|
|
92
|
+
let e = t(l);
|
|
93
|
+
if (!e.length) return "";
|
|
94
|
+
let n = l.style || {}, r = n.textAlign === "center" ? "center" : n.textAlign === "right" ? "flex-end" : "flex-start", i = n.iconSpacing || "8px", a = N(n, "padding", [
|
|
95
|
+
"paddingTop",
|
|
96
|
+
"paddingRight",
|
|
97
|
+
"paddingBottom",
|
|
98
|
+
"paddingLeft"
|
|
99
|
+
]) || "8px", o = N(n, "margin", [
|
|
100
|
+
"marginTop",
|
|
101
|
+
"marginRight",
|
|
102
|
+
"marginBottom",
|
|
103
|
+
"marginLeft"
|
|
104
|
+
]), s = (e) => e === "square" ? "14px" : "9999px", c = e.map((e) => {
|
|
105
|
+
let t = `<img src="${`${h}/${u[e.provider] ? e.provider : "fallback"}.png`}" alt="" width="${parseInt(e.size, 10) || 36}" style="display:block;width:60%;height:60%;border:0;" />`;
|
|
106
|
+
return `<a href="${_(e.url)}" style="display:inline-flex;align-items:center;justify-content:center;width:${_(e.size)};height:${_(e.size)};background-color:${_(e.backgroundColor)};border-radius:${s(e.iconType)};text-decoration:none;">${t}</a>`;
|
|
107
|
+
}).join(""), d = `display:flex;flex-wrap:wrap;justify-content:${r};gap:${_(String(i))};padding:${_(a)};${o ? `margin:${_(o)};` : ""}`;
|
|
108
|
+
return `<mj-raw><div${S(l.id, f)} style="${d}">${c}</div></mj-raw>`;
|
|
109
|
+
}
|
|
110
|
+
if (l.type === "menu") {
|
|
111
|
+
let t = e(l);
|
|
112
|
+
return `<mj-navbar hamburger="hamburger"${x(l.id, f)}>${t.map((e) => `<mj-navbar-link href="${_(e.href)}">${_(e.label)}</mj-navbar-link>`).join("")}</mj-navbar>`;
|
|
113
|
+
}
|
|
114
|
+
if (l.type === "table") {
|
|
115
|
+
let e = o(l), t = l.style || {}, n = `${t.borderWidth || "1px"} ${t.borderStyle || "solid"} ${t.borderColor || "#cbd5e1"}`, r = (r, i, a, o) => {
|
|
116
|
+
let s = o ? "th" : "td", c = o ? t.headerBgColor || "#f8fafc" : e.striped && i % 2 == 1 ? "#f8fafc" : t.contentBgColor || "#ffffff", u = o ? t.headerTextColor || "#1e293b" : t.contentTextColor || "#475569";
|
|
117
|
+
return `<tr>${r.map((e, r) => {
|
|
118
|
+
let i = f ? ` data-plexo-cell="${_(l.id)}|${a}-${r}"` : "";
|
|
119
|
+
return `<${s}${i} style="padding: ${t.cellPadding || "8px"}; border: ${n}; background-color: ${c}; color: ${u};">${_(e) || " "}</${s}>`;
|
|
120
|
+
}).join("")}</tr>`;
|
|
121
|
+
}, i = +!!e.enableHeader, a = e.enableFooter ? e.cells.length - 1 : e.cells.length, s = e.enableHeader && e.cells.length > 0 ? `<thead>${r(e.cells[0], 0, 0, !0)}</thead>` : "", c = e.cells.slice(i, Math.max(i, a)).map((e, t) => r(e, t, i + t, !1)).join(""), u = e.enableFooter && e.cells.length > i ? `<tfoot>${r(e.cells[e.cells.length - 1], e.cells.length - 1, e.cells.length - 1, !1)}</tfoot>` : "";
|
|
122
|
+
return `<mj-table${x(l.id, f)}><table role="presentation" style="border-collapse: collapse; width: 100%;">${s}<tbody>${c}</tbody>${u}</table></mj-table>`;
|
|
123
|
+
}
|
|
124
|
+
if (l.type === "video") {
|
|
125
|
+
let e = n(p.videoUrl), t = p.linkType === "email" ? `mailto:${p.href || ""}` : p.href || p.videoUrl || "#", r = x(l.id, f);
|
|
126
|
+
return `<mj-image src="${_(e.thumbnailUrl)}" href="${_(t)}" alt="${_(p.alt || "Video preview")}"${r} />`;
|
|
127
|
+
}
|
|
128
|
+
if (l.type === "timer") {
|
|
129
|
+
let e = r(p.targetDate, p.timezone), t = p.showLabels !== !1;
|
|
130
|
+
return `<mj-text align="center"${x(l.id, f)}><div style="font-size: 28px; font-weight: 800;">${e.days}d ${e.hours}h ${e.minutes}m ${e.seconds}s</div>${t ? `<div style="font-size: 12px; color: #64748b;">Countdown to ${_(p.targetDate || "")}</div>` : ""}</mj-text>`;
|
|
131
|
+
}
|
|
132
|
+
if (l.type === "carousel") {
|
|
133
|
+
let e = Array.isArray(p.images) ? p.images : [], t = x(l.id, f);
|
|
134
|
+
return e.length === 0 ? `<mj-text align="center"${t}>No images in carousel</mj-text>` : `<mj-carousel${t}>${e.map((e) => `<mj-carousel-image src="${_(e.src)}" alt="${_(e.alt || "")}" />`).join("")}</mj-carousel>`;
|
|
135
|
+
}
|
|
136
|
+
if (l.type === "icon") {
|
|
137
|
+
let e = parseInt(String(p.iconSize || 48), 10) || 48, t = l.style?.color || "#1e293b", n = s(p.iconName, e, t);
|
|
138
|
+
return `<mj-text align="center"${x(l.id, f)}>${n}</mj-text>`;
|
|
139
|
+
}
|
|
140
|
+
let d = b(p.hideOnDesktop ? "desktop-hide" : "", l.id, f);
|
|
141
|
+
if (l.type === "heading" || l.type === "paragraph" || l.type === "text") {
|
|
142
|
+
let e = l.type === "heading" ? {
|
|
143
|
+
fontSize: "24px",
|
|
144
|
+
fontWeight: "700"
|
|
145
|
+
} : { fontSize: "14px" }, t = l.style || {}, n = j(t, e), r = i(l).autoWidth, a = String(p.boxAlign || "left"), o = /* @__PURE__ */ new Set([
|
|
146
|
+
"fontSize",
|
|
147
|
+
"fontWeight",
|
|
148
|
+
"color",
|
|
149
|
+
"fontFamily",
|
|
150
|
+
"lineHeight",
|
|
151
|
+
"letterSpacing",
|
|
152
|
+
"textAlign"
|
|
153
|
+
]), s = Object.entries(t).filter(([e, t]) => !o.has(e) && e !== "width" && t != null && t !== "").map(([e, t]) => `${e.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${_(String(t))}`);
|
|
154
|
+
r ? s.push("display: inline-block") : t.width && s.push(`width: ${_(String(t.width))}`), t.height && s.push("overflow: hidden"), (t.textAlign || a !== "left") && s.push(`text-align: ${_(String(t.textAlign || "left"))} !important`);
|
|
155
|
+
let c = "";
|
|
156
|
+
s.length > 0 && (c = `plexo-textbox-${l.id}`, E.push(`.${c} > div { ${s.join("; ")}; }`));
|
|
157
|
+
let u = y(c, d);
|
|
158
|
+
return `<mj-text${n ? ` ${n}` : ""} align="${_(a)}" css-class="${u}">${p.text || ""}</mj-text>`;
|
|
159
|
+
}
|
|
160
|
+
if (l.type === "spacer") {
|
|
161
|
+
let e = l.style?.height || "24px", t = x(l.id, f);
|
|
162
|
+
return `<mj-spacer height="${_(String(e))}"${t} />`;
|
|
163
|
+
}
|
|
164
|
+
if (l.type === "divider") {
|
|
165
|
+
let e = l.style || {}, t = x(l.id, f);
|
|
166
|
+
return `<mj-divider border-width="${_(String(e.borderWidth || "1px"))}" border-style="${_(String(e.borderStyle || "solid"))}" border-color="${_(String(e.borderColor || "#334155"))}"${t} />`;
|
|
167
|
+
}
|
|
168
|
+
return l.type === "card" ? `<mj-text css-class="${d}"><strong style="display:block;margin-bottom:8px;">${_(p.title || "Card Title")}</strong><span style="font-size:14px;color:#64748b;">${_(p.description || "Card description.")}</span></mj-text>` : l.type === "html" ? `<mj-text css-class="${d}">${p.htmlContent || p.text || ""}</mj-text>` : `<mj-text${g}${k} css-class="${d}">${_(p.text || p.htmlContent || "")}</mj-text>`;
|
|
169
|
+
}
|
|
170
|
+
if (l.type === "heading" || l.type === "paragraph" || l.type === "text") {
|
|
171
|
+
let e = l.style || {}, t = i(l).autoWidth, n = String(p.boxAlign || "left"), r = v(t ? Object.fromEntries(Object.entries(e).filter(([e]) => e !== "width")) : e), a = t || !!e.width, o = a ? "display:inline-block;" : "", s = l.type === "heading" ? "h2" : "p", c = l.type === "heading" ? "Heading" : "", u = `${M}<${s}${g}${k} style="${o}${r}">${_(p.text || c)}</${s}>`;
|
|
172
|
+
return a ? `<div style="text-align:${_(n)};">${u}</div>` : u;
|
|
173
|
+
}
|
|
174
|
+
switch (l.type) {
|
|
175
|
+
case "button": return `${M}<a${g}${k} href="${_(p.href || "#")}" style="${m}">${_(p.text || "Button")}</a>`;
|
|
176
|
+
case "image": return `${M}<img${g}${k} src="${_(p.src || "")}" alt="${_(p.alt || "")}" style="${m}" />`;
|
|
177
|
+
case "html": return `${M}<div${g}${k} style="${m}">${String(p.htmlContent || "")}</div>`;
|
|
178
|
+
case "blog_title":
|
|
179
|
+
case "blog_content":
|
|
180
|
+
case "blog_featured_image":
|
|
181
|
+
case "blog_date":
|
|
182
|
+
case "blog_author":
|
|
183
|
+
case "blog_categories":
|
|
184
|
+
case "blog_comments":
|
|
185
|
+
case "blog_post_list": return `${M}<div${g}${k} data-plexo-blog-${l.type.replace(/^blog_/, "").replace(/_([a-z])/g, (e, t) => t.toUpperCase())}="true"${p.prefix ? ` data-plexo-blog-prefix="${_(p.prefix)}"` : ""} style="${m}"></div>`;
|
|
186
|
+
default: return `${M}<div${g}${k} style="${m}">${_(p.text || "")}</div>`;
|
|
187
|
+
}
|
|
188
|
+
}, I = (e, t, n) => {
|
|
189
|
+
if (t === "email") {
|
|
190
|
+
let r = new Map(e.elements.map((e) => [e.id, e])), i = new Map((Array.isArray(e.nestedRows) ? e.nestedRows : []).map((e) => [e.id, e])), a = l(e).map((e) => {
|
|
191
|
+
let a = r.get(e);
|
|
192
|
+
if (a) return F(a, t, n);
|
|
193
|
+
let o = i.get(e);
|
|
194
|
+
return o ? `<mj-raw><tr><td style="font-size:16px;">${L(o, "landing_page", n)}</td></tr></mj-raw>` : "";
|
|
195
|
+
}).join(""), o = M(e.styles || {}), s = e.elements.length === 0 && (!Array.isArray(e.nestedRows) || e.nestedRows.length === 0), c = y(D && s ? A({}, e.id, [`min-height: ${O}px`]) : "", b("", e.id, n, p)), u = c ? ` css-class="${_(c)}"` : "";
|
|
196
|
+
return `<mj-column width="${_(e.width || "100%")}"${o}${u}>${a}</mj-column>`;
|
|
197
|
+
}
|
|
198
|
+
let r = v(e.styles || {}), i = new Map(e.elements.map((e) => [e.id, e])), a = new Map((Array.isArray(e.nestedRows) ? e.nestedRows : []).map((e) => [e.id, e])), o = l(e).map((e) => {
|
|
199
|
+
let r = i.get(e);
|
|
200
|
+
if (r) return F(r, t, n);
|
|
201
|
+
let o = a.get(e);
|
|
202
|
+
return o ? L(o, t, n) : "";
|
|
203
|
+
}).join(""), s = S(e.id, n, p), c = e.elements.length === 0 && (!Array.isArray(e.nestedRows) || e.nestedRows.length === 0), u = D && c ? `min-height: ${O}px;` : "";
|
|
204
|
+
return `<div${s} style="width:${_(e.width || "100%")};${u}${r}">${o}</div>`;
|
|
205
|
+
}, L = (e, t, n) => {
|
|
206
|
+
if (t === "email") return `<mj-section css-class="${b(e.style?.hideOnDesktop ? "desktop-hide" : "", e.id, n, f)}"${M(e.style || {})}>${e.columns.map((e) => I(e, t, n)).join("")}</mj-section>`;
|
|
207
|
+
let r = v(e.style || {}), i = e.columns.map((e) => I(e, t, n)).join("");
|
|
208
|
+
return `<section${S(e.id, n, f)} style="display:flex;flex-wrap:wrap;${r}">${i}</section>`;
|
|
209
|
+
}, R = (e, t, n) => {
|
|
210
|
+
let r = n?.instrument ?? !1;
|
|
211
|
+
E = [], D = n?.canvasEditorPadding ?? !1;
|
|
212
|
+
let i = (e.body?.rows || []).map((e) => L(e, t, r)).join(""), a = v(e.body?.style || {});
|
|
213
|
+
return t === "email" ? `<mjml><mj-head><mj-style>.desktop-hide { display:none !important; max-height:0; overflow:hidden; }${E.length > 0 ? ` ${E.join(" ")}` : ""}</mj-style></mj-head><mj-body><mj-section><mj-column><mj-text css-class="preheader" padding="0" font-size="1px" color="#ffffff"> </mj-text></mj-column></mj-section>${i}</mj-body></mjml>`.replace(/<span[^>]*data-merge-val="([^"]*)"[^>]*>[\s\S]*?<\/span>/gi, "$1") : `<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /></head><body style="${a}"><main>${i}</main></body></html>`;
|
|
214
|
+
};
|
|
215
|
+
//#endregion
|
|
216
|
+
export { R as t };
|
package/dist/compilerClient.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./compilerClient-
|
|
1
|
+
import { t as e } from "./compilerClient-CZG4B3cC.js";
|
|
2
2
|
export { e as parseJsonToTargetFormat };
|