@charisol/plexo-sdk 1.4.1 → 1.4.2
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-JKW4O9Mv.js → compiler-Zh5KObm4.js} +151 -750
- package/dist/compiler.js +1 -1
- package/dist/compilerClient-iBNHz76w.js +220 -0
- package/dist/compilerClient.js +1 -1
- package/dist/components/editor/frame/CompiledCanvasEditorOverlay.d.ts +7 -4
- package/dist/components/editor/frame/DndOverlayNode.d.ts +1 -1
- package/dist/components/editor/frame/TableCellOverlay.d.ts +4 -1
- package/dist/components/editor/frame/useFrameTextEditing.d.ts +9 -2
- package/dist/{iconSvgStatic-CGue7nyp.js → iconSvgStatic-DEgDUD68.js} +660 -61
- package/dist/index.js +13842 -13768
- package/dist/{mjmlBrowser-DFgIYJ2a.js → mjmlBrowser-Cb23AZ33.js} +1 -1
- package/dist/sanitize.js +1 -1
- package/dist/{sanitizeCompiledHtml-C_sPjL3B.js → sanitizeCompiledHtml-BU82w6E-.js} +11 -11
- package/dist/utilities/sanitizePastedHtml.d.ts +1 -0
- package/package.json +1 -1
- package/dist/compilerClient-CZG4B3cC.js +0 -216
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-Zh5KObm4.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,220 @@
|
|
|
1
|
+
import { d as e, f as t, g as n, h as r, j as i, k as a, m as o, o as s, p as c, t as l, u, v as d, y as f } from "./iconSvgStatic-DEgDUD68.js";
|
|
2
|
+
//#region src/utilities/instrumentation.ts
|
|
3
|
+
var p = "plexo-node", m = "plexo-row", h = "plexo-col";
|
|
4
|
+
function g(e) {
|
|
5
|
+
return `plexo-node-${e}`;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/utilities/compilerClient.ts
|
|
9
|
+
var _ = "https://cdn.jsdelivr.net/npm/@charisol/plexo-sdk@latest/dist/social-icons", v = /* @__PURE__ */ new Set([
|
|
10
|
+
"selectable",
|
|
11
|
+
"draggable",
|
|
12
|
+
"duplicatable",
|
|
13
|
+
"deletable",
|
|
14
|
+
"hideable",
|
|
15
|
+
"locked"
|
|
16
|
+
]), y = (e) => String(e ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), b = (e = {}) => Object.entries(e).filter(([, e]) => e != null && String(e).trim() !== "").map(([e, t]) => `${e.replace(/([A-Z])/g, "-$1").toLowerCase()}:${String(t)};`).join(""), x = (...e) => e.map((e) => String(e ?? "").trim()).filter(Boolean).join(" "), S = (e, t, n, r) => n ? x(e, p, g(t), r) : e, C = (e, t, n) => {
|
|
17
|
+
let r = S("", e, t, n);
|
|
18
|
+
return r ? ` css-class="${y(r)}"` : "";
|
|
19
|
+
}, w = (e, t, n) => {
|
|
20
|
+
let r = S("", e, t, n);
|
|
21
|
+
return r ? ` class="${y(r)}"` : "";
|
|
22
|
+
}, T = (e, t) => {
|
|
23
|
+
let n = { ...e.attributes || {} };
|
|
24
|
+
if (t === "email") for (let e of v) delete n[e];
|
|
25
|
+
return n;
|
|
26
|
+
}, E = (e, t, n) => {
|
|
27
|
+
let r = T(e, t), i = b(e.style || {}), a = S(x(r.htmlClassNames, r.htmlClass, r.validationClass, r.validationClassName), e.id, t === "landing_page" && n), o = y(r.name || r.fieldName || "field"), s = y(r.placeholder || ""), c = r.required ? " required" : "";
|
|
28
|
+
if (t === "email") return `<mj-table${C(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 = y(r.inputType || r.type || (e.type === "input" ? r.kind || "text" : e.type)), u = r.htmlId ? ` id="${y(r.htmlId)}"` : "", d = a ? ` class="${y(a)}"` : "";
|
|
30
|
+
return e.type === "textarea" ? `<textarea${u}${d} name="${o}" placeholder="${s}" style="${i}"${c}>${y(r.value || "")}</textarea>` : e.type === "select" ? `<select${u}${d} name="${o}" style="${i}"${c}>${(r.options || []).map((e) => `<option value="${y(e.value)}">${y(e.label)}</option>`).join("")}</select>` : `<input${u}${d} type="${l}" name="${o}" placeholder="${s}" value="${y(r.value || "")}" style="${i}"${c} />`;
|
|
31
|
+
}, D = (e, t, n) => {
|
|
32
|
+
let r = T(e, t), i = b(e.style || {}), a = S(x(r.htmlClassNames, r.htmlClass), e.id, t === "landing_page" && n), o = r.htmlId ? ` id="${y(r.htmlId)}"` : "", s = a ? ` class="${y(a)}"` : "", c = y(r.actionUrl || r.action || "#"), l = y(r.method || "POST"), u = r.fields || [], d = y(r.submitLabel || "Submit");
|
|
33
|
+
return t === "email" ? `<mj-table${C(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>${y(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;">${y(e.placeholder || "") || " "}</span></td></tr>`).join("")}<tr><td style="padding-top:12px;"><a href="${y(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) => E({
|
|
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
|
+
}, O = [], k = !1, A = 148, j = [
|
|
43
|
+
["borderRadius", "border-radius"],
|
|
44
|
+
["borderWidth", "border-width"],
|
|
45
|
+
["borderStyle", "border-style"],
|
|
46
|
+
["borderColor", "border-color"],
|
|
47
|
+
["boxShadow", "box-shadow"]
|
|
48
|
+
], M = (e, t, n = []) => {
|
|
49
|
+
let r = [...j.filter(([t]) => e[t]).map(([t, n]) => `${n}: ${y(String(e[t]))}`), ...n];
|
|
50
|
+
if (r.length === 0) return "";
|
|
51
|
+
let i = `plexo-extra-style-${t}`;
|
|
52
|
+
return O.push(`.${i} { ${r.join("; ")}; }`), i;
|
|
53
|
+
}, N = (e = {}, t = {}) => {
|
|
54
|
+
let n = ["padding=\"0\""], r = e.fontSize || t.fontSize, i = e.fontWeight || t.fontWeight;
|
|
55
|
+
return r && n.push(`font-size="${y(String(r))}"`), i && n.push(`font-weight="${y(String(i))}"`), e.color && n.push(`color="${y(String(e.color))}"`), e.fontFamily && n.push(`font-family="${y(String(e.fontFamily))}"`), e.lineHeight && n.push(`line-height="${y(String(e.lineHeight))}"`), e.letterSpacing && n.push(`letter-spacing="${y(String(e.letterSpacing))}"`), n.join(" ");
|
|
56
|
+
}, P = (e = {}) => {
|
|
57
|
+
let t = e.backgroundColor || e.background;
|
|
58
|
+
return t ? ` background-color="${y(String(t))}"` : "";
|
|
59
|
+
}, F = (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
|
+
}, I = (e = {}) => {
|
|
64
|
+
let t = [];
|
|
65
|
+
e.backgroundColor && t.push(`background-color="${y(String(e.backgroundColor))}"`), e.color && t.push(`color="${y(String(e.color))}"`), e.fontSize && t.push(`font-size="${y(String(e.fontSize))}"`), e.fontWeight && t.push(`font-weight="${y(String(e.fontWeight))}"`), e.fontFamily && t.push(`font-family="${y(String(e.fontFamily))}"`), e.lineHeight && t.push(`line-height="${y(String(e.lineHeight))}"`), e.letterSpacing && t.push(`letter-spacing="${y(String(e.letterSpacing))}"`), e.textAlign && t.push(`align="${y(String(e.textAlign))}"`);
|
|
66
|
+
let n = F(e, "borderRadius", [
|
|
67
|
+
"borderTopLeftRadius",
|
|
68
|
+
"borderTopRightRadius",
|
|
69
|
+
"borderBottomRightRadius",
|
|
70
|
+
"borderBottomLeftRadius"
|
|
71
|
+
]);
|
|
72
|
+
return n && t.push(`border-radius="${y(n)}"`), t.join(" ");
|
|
73
|
+
}, L = (i, d, f) => {
|
|
74
|
+
let p = T(i, d), m = b(i.style || {}), h = p.htmlId ? ` id="${y(p.htmlId)}"` : "", g = x(p.htmlClassNames, p.htmlClass, d === "landing_page" && p.hideOnMobile ? "hidden md:block" : ""), v = d === "landing_page" ? S(g, i.id, f) : g, k = v ? ` class="${y(v)}"` : "", A = typeof p.customCss == "string" && p.customCss.trim() ? p.customCss.trim() : "", j = A && d === "landing_page" ? `<style>${A}</style>` : "";
|
|
75
|
+
if (i.type === "form_container") return `${j}${D(i, d, f)}`;
|
|
76
|
+
if (i.type === "input" || i.type === "select" || i.type === "textarea") return `${j}${E(i, d, f)}`;
|
|
77
|
+
if (d === "email") {
|
|
78
|
+
if (i.type === "button") {
|
|
79
|
+
let e = y(p.href || "#"), t = y(p.text || "Button"), n = s(i).width, r = n === "auto" ? "" : ` width="${y(n)}"`, a = i.style || {}, o = I(a), c = F(a, "padding", [
|
|
80
|
+
"paddingTop",
|
|
81
|
+
"paddingRight",
|
|
82
|
+
"paddingBottom",
|
|
83
|
+
"paddingLeft"
|
|
84
|
+
]) || "10px 16px";
|
|
85
|
+
return `<mj-button href="${e}" css-class="${S(p.hideOnDesktop ? "desktop-hide" : "", i.id, f)}" padding="0" inner-padding="${y(c)}"${r}${o ? ` ${o}` : ""}>${t}</mj-button>`;
|
|
86
|
+
}
|
|
87
|
+
if (i.type === "image") {
|
|
88
|
+
let e = u(i), t = e.width && e.width !== "100%" ? ` width="${y(e.width)}"` : "", n = e.height && e.height !== "auto" ? ` height="${y(e.height)}"` : "", r = C(i.id, f);
|
|
89
|
+
return `<mj-image src="${y(p.src || "")}" alt="${y(p.alt || "")}"${t}${n}${r} />`;
|
|
90
|
+
}
|
|
91
|
+
if (i.type === "social") {
|
|
92
|
+
let e = t(i);
|
|
93
|
+
if (!e.length) return "";
|
|
94
|
+
let n = i.style || {}, r = n.textAlign === "center" ? "center" : n.textAlign === "right" ? "flex-end" : "flex-start", o = n.iconSpacing || "8px", s = F(n, "padding", [
|
|
95
|
+
"paddingTop",
|
|
96
|
+
"paddingRight",
|
|
97
|
+
"paddingBottom",
|
|
98
|
+
"paddingLeft"
|
|
99
|
+
]) || "8px", c = F(n, "margin", [
|
|
100
|
+
"marginTop",
|
|
101
|
+
"marginRight",
|
|
102
|
+
"marginBottom",
|
|
103
|
+
"marginLeft"
|
|
104
|
+
]), l = (e) => e === "square" ? "14px" : "9999px", u = e.map((e) => {
|
|
105
|
+
let t = `<img src="${`${_}/${a[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="${y(e.url)}" style="display:inline-flex;align-items:center;justify-content:center;width:${y(e.size)};height:${y(e.size)};background-color:${y(e.backgroundColor)};border-radius:${l(e.iconType)};text-decoration:none;">${t}</a>`;
|
|
107
|
+
}).join(""), d = `display:flex;flex-wrap:wrap;justify-content:${r};gap:${y(String(o))};padding:${y(s)};${c ? `margin:${y(c)};` : ""}`;
|
|
108
|
+
return `<mj-raw><div${w(i.id, f)} style="${d}">${u}</div></mj-raw>`;
|
|
109
|
+
}
|
|
110
|
+
if (i.type === "menu") {
|
|
111
|
+
let t = e(i);
|
|
112
|
+
return `<mj-navbar hamburger="hamburger"${C(i.id, f)}>${t.map((e) => `<mj-navbar-link href="${y(e.href)}">${y(e.label)}</mj-navbar-link>`).join("")}</mj-navbar>`;
|
|
113
|
+
}
|
|
114
|
+
if (i.type === "table") {
|
|
115
|
+
let e = c(i), t = i.style || {}, n = `${t.borderWidth || "1px"} ${t.borderStyle || "solid"} ${t.borderColor || "#cbd5e1"}`, r = (r, a, o, s) => {
|
|
116
|
+
let c = s ? "th" : "td", l = s ? t.headerBgColor || "#f8fafc" : e.striped && a % 2 == 1 ? "#f8fafc" : t.contentBgColor || "#ffffff", u = s ? t.headerTextColor || "#1e293b" : t.contentTextColor || "#475569";
|
|
117
|
+
return `<tr>${r.map((e, r) => {
|
|
118
|
+
let a = f ? ` data-plexo-cell="${y(i.id)}|${o}-${r}"` : "";
|
|
119
|
+
return `<${c}${a} style="padding: ${t.cellPadding || "8px"}; border: ${n}; background-color: ${l}; color: ${u};">${y(e) || " "}</${c}>`;
|
|
120
|
+
}).join("")}</tr>`;
|
|
121
|
+
}, a = +!!e.enableHeader, o = 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>` : "", l = e.cells.slice(a, Math.max(a, o)).map((e, t) => r(e, t, a + t, !1)).join(""), u = e.enableFooter && e.cells.length > a ? `<tfoot>${r(e.cells[e.cells.length - 1], e.cells.length - 1, e.cells.length - 1, !1)}</tfoot>` : "";
|
|
122
|
+
return `<mj-table${C(i.id, f)}><table role="presentation" style="border-collapse: collapse; width: 100%;">${s}<tbody>${l}</tbody>${u}</table></mj-table>`;
|
|
123
|
+
}
|
|
124
|
+
if (i.type === "video") {
|
|
125
|
+
let e = n(p.videoUrl), t = p.linkType === "email" ? `mailto:${p.href || ""}` : p.href || p.videoUrl || "#", r = C(i.id, f);
|
|
126
|
+
return `<mj-image src="${y(e.thumbnailUrl)}" href="${y(t)}" alt="${y(p.alt || "Video preview")}"${r} />`;
|
|
127
|
+
}
|
|
128
|
+
if (i.type === "timer") {
|
|
129
|
+
let e = r(p.targetDate, p.timezone), t = p.showLabels !== !1;
|
|
130
|
+
return `<mj-text align="center"${C(i.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 ${y(p.targetDate || "")}</div>` : ""}</mj-text>`;
|
|
131
|
+
}
|
|
132
|
+
if (i.type === "carousel") {
|
|
133
|
+
let e = Array.isArray(p.images) ? p.images : [], t = C(i.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="${y(e.src)}" alt="${y(e.alt || "")}" />`).join("")}</mj-carousel>`;
|
|
135
|
+
}
|
|
136
|
+
if (i.type === "icon") {
|
|
137
|
+
let e = parseInt(String(p.iconSize || 48), 10) || 48, t = i.style?.color || "#1e293b", n = l(p.iconName, e, t);
|
|
138
|
+
return `<mj-text align="center"${C(i.id, f)}>${n}</mj-text>`;
|
|
139
|
+
}
|
|
140
|
+
let d = S(p.hideOnDesktop ? "desktop-hide" : "", i.id, f);
|
|
141
|
+
if (i.type === "heading" || i.type === "paragraph" || i.type === "text") {
|
|
142
|
+
let e = i.type === "heading" ? {
|
|
143
|
+
fontSize: "24px",
|
|
144
|
+
fontWeight: "700"
|
|
145
|
+
} : { fontSize: "14px" }, t = i.style || {}, n = N(t, e), r = o(i).autoWidth, a = String(p.boxAlign || "left"), s = /* @__PURE__ */ new Set([
|
|
146
|
+
"fontSize",
|
|
147
|
+
"fontWeight",
|
|
148
|
+
"color",
|
|
149
|
+
"fontFamily",
|
|
150
|
+
"lineHeight",
|
|
151
|
+
"letterSpacing",
|
|
152
|
+
"textAlign"
|
|
153
|
+
]), c = Object.entries(t).filter(([e, t]) => !s.has(e) && e !== "width" && t != null && t !== "").map(([e, t]) => `${e.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${y(String(t))}`);
|
|
154
|
+
r ? c.push("display: inline-block") : t.width && c.push(`width: ${y(String(t.width))}`), t.height && c.push("overflow: hidden"), (t.textAlign || a !== "left") && c.push(`text-align: ${y(String(t.textAlign || "left"))} !important`);
|
|
155
|
+
let l = "";
|
|
156
|
+
c.length > 0 && (l = `plexo-textbox-${i.id}`, O.push(`.${l} > div { ${c.join("; ")}; }`));
|
|
157
|
+
let u = x(l, d);
|
|
158
|
+
return `<mj-text${n ? ` ${n}` : ""} align="${y(a)}" css-class="${u}">${p.text || ""}</mj-text>`;
|
|
159
|
+
}
|
|
160
|
+
if (i.type === "spacer") {
|
|
161
|
+
let e = i.style?.height || "24px", t = C(i.id, f);
|
|
162
|
+
return `<mj-spacer height="${y(String(e))}"${t} />`;
|
|
163
|
+
}
|
|
164
|
+
if (i.type === "divider") {
|
|
165
|
+
let e = i.style || {}, t = C(i.id, f);
|
|
166
|
+
return `<mj-divider border-width="${y(String(e.borderWidth || "1px"))}" border-style="${y(String(e.borderStyle || "solid"))}" border-color="${y(String(e.borderColor || "#334155"))}"${t} />`;
|
|
167
|
+
}
|
|
168
|
+
return i.type === "card" ? `<mj-text css-class="${d}"><strong style="display:block;margin-bottom:8px;">${y(p.title || "Card Title")}</strong><span style="font-size:14px;color:#64748b;">${y(p.description || "Card description.")}</span></mj-text>` : i.type === "html" ? `<mj-text css-class="${d}">${p.htmlContent || p.text || ""}</mj-text>` : `<mj-text${h}${k} css-class="${d}">${y(p.text || p.htmlContent || "")}</mj-text>`;
|
|
169
|
+
}
|
|
170
|
+
if (i.type === "heading" || i.type === "paragraph" || i.type === "text") {
|
|
171
|
+
let e = i.style || {}, t = o(i).autoWidth, n = String(p.boxAlign || "left"), r = b(t ? Object.fromEntries(Object.entries(e).filter(([e]) => e !== "width")) : e), a = t || !!e.width, s = a ? "display:inline-block;" : "", c = i.type === "heading" ? "h2" : "p", l = i.type === "heading" ? "Heading" : "", u = `${j}<${c}${h}${k} style="${s}${r}">${y(p.text || l)}</${c}>`;
|
|
172
|
+
return a ? `<div style="text-align:${y(n)};">${u}</div>` : u;
|
|
173
|
+
}
|
|
174
|
+
switch (i.type) {
|
|
175
|
+
case "button": return `${j}<a${h}${k} href="${y(p.href || "#")}" style="${m}">${y(p.text || "Button")}</a>`;
|
|
176
|
+
case "image": return `${j}<img${h}${k} src="${y(p.src || "")}" alt="${y(p.alt || "")}" style="${m}" />`;
|
|
177
|
+
case "html": return `${j}<div${h}${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 `${j}<div${h}${k} data-plexo-blog-${i.type.replace(/^blog_/, "").replace(/_([a-z])/g, (e, t) => t.toUpperCase())}="true"${p.prefix ? ` data-plexo-blog-prefix="${y(p.prefix)}"` : ""} style="${m}"></div>`;
|
|
186
|
+
default: return `${j}<div${h}${k} style="${m}">${y(p.text || "")}</div>`;
|
|
187
|
+
}
|
|
188
|
+
}, R = (e, t, n) => {
|
|
189
|
+
if (t === "email") {
|
|
190
|
+
let r = new Map(e.elements.map((e) => [e.id, e])), a = new Map((Array.isArray(e.nestedRows) ? e.nestedRows : []).map((e) => [e.id, e])), o = i(e).map((e) => {
|
|
191
|
+
let i = r.get(e);
|
|
192
|
+
if (i) return L(i, t, n);
|
|
193
|
+
let o = a.get(e);
|
|
194
|
+
return o ? `<mj-raw><tr><td style="font-size:16px;">${z(o, "landing_page", n)}</td></tr></mj-raw>` : "";
|
|
195
|
+
}).join(""), s = P(e.styles || {}), c = e.elements.length === 0 && (!Array.isArray(e.nestedRows) || e.nestedRows.length === 0), l = x(k && c ? M({}, e.id, [`min-height: ${A}px`]) : "", S("", e.id, n, h)), u = l ? ` css-class="${y(l)}"` : "";
|
|
196
|
+
return `<mj-column width="${y(e.width || "100%")}" padding="0"${s}${u}>${o}</mj-column>`;
|
|
197
|
+
}
|
|
198
|
+
let r = b(e.styles || {}), a = new Map(e.elements.map((e) => [e.id, e])), o = new Map((Array.isArray(e.nestedRows) ? e.nestedRows : []).map((e) => [e.id, e])), s = i(e).map((e) => {
|
|
199
|
+
let r = a.get(e);
|
|
200
|
+
if (r) return L(r, t, n);
|
|
201
|
+
let i = o.get(e);
|
|
202
|
+
return i ? z(i, t, n) : "";
|
|
203
|
+
}).join(""), c = w(e.id, n, h), l = e.elements.length === 0 && (!Array.isArray(e.nestedRows) || e.nestedRows.length === 0), u = k && l ? `min-height: ${A}px;` : "";
|
|
204
|
+
return `<div${c} style="width:${y(e.width || "100%")};${u}${r}">${s}</div>`;
|
|
205
|
+
}, z = (e, t, n) => {
|
|
206
|
+
if (t === "email") return `<mj-section css-class="${S(e.style?.hideOnDesktop ? "desktop-hide" : "", e.id, n, m)}"${P(e.style || {})} padding="0">${e.columns.map((e) => R(e, t, n)).join("")}</mj-section>`;
|
|
207
|
+
let r = b(e.style || {}), i = e.columns.map((e) => R(e, t, n)).join("");
|
|
208
|
+
return `<section${w(e.id, n, m)} style="display:flex;flex-wrap:wrap;${r}">${i}</section>`;
|
|
209
|
+
}, B = (e, t, n) => {
|
|
210
|
+
let r = n?.instrument ?? !1;
|
|
211
|
+
O = [], k = n?.canvasEditorPadding ?? !1;
|
|
212
|
+
let i = (e.body?.rows || []).map((e) => z(e, t, r)).join(""), a = b(e.body?.style || {});
|
|
213
|
+
if (t === "email") {
|
|
214
|
+
let t = O.length > 0 ? ` ${O.join(" ")}` : "", n = d(f(e.body?.rows, [e.body?.style?.fontFamily]));
|
|
215
|
+
return `<mjml><mj-head>${n ? `<mj-font name="PlexoGoogleFonts" href="${y(n)}" />` : ""}<mj-style>.desktop-hide { display:none !important; max-height:0; overflow:hidden; }${t}</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");
|
|
216
|
+
}
|
|
217
|
+
return `<!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>`;
|
|
218
|
+
};
|
|
219
|
+
//#endregion
|
|
220
|
+
export { B 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-iBNHz76w.js";
|
|
2
2
|
export { e as parseJsonToTargetFormat };
|
|
@@ -11,10 +11,13 @@ export interface CompiledCanvasEditorOverlayProps {
|
|
|
11
11
|
* needs every pointer event itself (click-to-position-caret, drag-to-select-text), which an
|
|
12
12
|
* overlay hit-box sitting on top of it would otherwise intercept. */
|
|
13
13
|
editingId: string | null;
|
|
14
|
-
/** Fired on double-click of a text-editable element node
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
14
|
+
/** Fired on double-click of a text-editable element node, with the click's own viewport
|
|
15
|
+
* coordinates -- the real node lives inside the iframe and never sees this click itself,
|
|
16
|
+
* so this is the only way to place the caret where the user actually clicked (see
|
|
17
|
+
* useFrameTextEditing's beginEditing). Absent for row/column nodes and for element types
|
|
18
|
+
* not in TEXT_EDITABLE_TYPES (DndOverlayNode never wires the double-click handler at all
|
|
19
|
+
* in that case, rather than wiring it to a no-op). */
|
|
20
|
+
onEditRequest: (id: string, clientX: number, clientY: number) => void;
|
|
18
21
|
/** True in preview/read-only mode — hit-boxes render nothing interactive at all. */
|
|
19
22
|
disabled: boolean;
|
|
20
23
|
onSelect: (id: string, kind: FrameNodeKind, event: React.MouseEvent) => void;
|
|
@@ -33,7 +33,7 @@ export interface DndOverlayNodeProps {
|
|
|
33
33
|
* CompiledCanvasEditorOverlay's TEXT_EDITABLE_TYPES) -- wires a double-click to enter
|
|
34
34
|
* in-frame text editing. Absent (not just disabled) for every other node, so double-
|
|
35
35
|
* clicking a row/column/non-text element does nothing, matching the legacy canvas. */
|
|
36
|
-
onEditRequest?: (id: string) => void;
|
|
36
|
+
onEditRequest?: (id: string, clientX: number, clientY: number) => void;
|
|
37
37
|
/** Small tag shown above the hit-box when selected -- "Row"/"Nested Row"/"Column (60%)",
|
|
38
38
|
* matching SortableRow.tsx's/DroppableColumn.tsx's own selected-state label exactly.
|
|
39
39
|
* Absent for elements (their type already shows in the properties panel's own header). */
|
|
@@ -18,6 +18,9 @@ export interface TableCellOverlayProps {
|
|
|
18
18
|
editingKey: string | null;
|
|
19
19
|
disabled: boolean;
|
|
20
20
|
onCellClick: (event: React.MouseEvent) => void;
|
|
21
|
-
|
|
21
|
+
/** Fired on double-click, with the click's own viewport coordinates -- the real cell lives
|
|
22
|
+
* inside the iframe and never sees this click itself, so this is the only way to place the
|
|
23
|
+
* caret where the user actually clicked (see useFrameTextEditing's beginEditing). */
|
|
24
|
+
onCellEditRequest: (key: string, clientX: number, clientY: number) => void;
|
|
22
25
|
}
|
|
23
26
|
export declare const TableCellOverlay: React.FC<TableCellOverlayProps>;
|
|
@@ -24,8 +24,15 @@ export interface FrameTextEditingApi {
|
|
|
24
24
|
/** The node id currently in edit mode, or null. Only ever an 'element'-kind node. */
|
|
25
25
|
editingId: string | null;
|
|
26
26
|
/** Puts `id`'s real iframe DOM node into contentEditable mode and focuses it, committing
|
|
27
|
-
* whatever was previously being edited first (if anything, and if it's a different node).
|
|
28
|
-
|
|
27
|
+
* whatever was previously being edited first (if anything, and if it's a different node).
|
|
28
|
+
* `point` (iframe-local coordinates) places the caret exactly where the triggering click
|
|
29
|
+
* landed -- see beginEditing's own comment for why that has to be passed in explicitly
|
|
30
|
+
* rather than read off a live browser selection. Omit it (e.g. an edit entered some other
|
|
31
|
+
* way than a click) to fall back to a caret at the end of the content. */
|
|
32
|
+
beginEditing: (id: string, point?: {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
}) => void;
|
|
29
36
|
/** Commits and exits edit mode. Safe to call when nothing is being edited (no-op). */
|
|
30
37
|
endEditing: () => void;
|
|
31
38
|
/** Re-focuses the node being edited and restores its last known selection Range, for a
|