@charisol/plexo-sdk 1.0.36 → 1.0.37
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-B23a0JeZ.js → compiler-BHUlR0D2.js} +256 -115
- package/dist/compiler.js +1 -1
- package/dist/compilerClient.js +87 -41
- package/dist/components/CodeViewer.d.ts +3 -0
- package/dist/components/ImportModal.d.ts +32 -0
- package/dist/components/properties/InternalLinkField.d.ts +28 -0
- package/dist/elementResolvers-qyNepC_f.js +39752 -0
- package/dist/index.js +16128 -54826
- package/dist/plexo-sdk.css +1 -1
- package/dist/store.d.ts +7 -0
- package/dist/utilities/elementResolvers.d.ts +121 -0
- package/dist/utilities/htmlToTemplate.d.ts +2 -0
- package/dist/utilities/playground.interfaces.d.ts +17 -0
- package/package.json +2 -1
package/dist/compiler.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./compiler-
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./compiler-BHUlR0D2.js";
|
|
2
2
|
export { c as DEFAULT_BODY_FONT_FAMILY, i as FORM_NON_CSS_STYLE_KEYS, o as collectResponsiveRule, n as compileToHTML, e as compileToHTMLWithStrataAuto, a as compileToPlainText, s as convertSectionRowToPlexoRow, t as getFormDefaultStyle, r as getInlineStylesImportant, l as injectStrataBundle };
|
package/dist/compilerClient.js
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, f as r, l as i, o as a, p as o, s, t as c, u as l } from "./elementResolvers-qyNepC_f.js";
|
|
2
|
+
import * as u from "react";
|
|
3
|
+
import { renderToStaticMarkup as d } from "react-dom/server";
|
|
1
4
|
//#region src/utilities/compilerClient.ts
|
|
2
|
-
var
|
|
5
|
+
var f = {
|
|
6
|
+
facebook: "facebook",
|
|
7
|
+
x: "twitter",
|
|
8
|
+
twitter: "twitter",
|
|
9
|
+
linkedin: "linkedin",
|
|
10
|
+
instagram: "instagram",
|
|
11
|
+
youtube: "youtube",
|
|
12
|
+
pinterest: "pinterest"
|
|
13
|
+
}, p = /* @__PURE__ */ new Set([
|
|
3
14
|
"selectable",
|
|
4
15
|
"draggable",
|
|
5
16
|
"duplicatable",
|
|
6
17
|
"deletable",
|
|
7
18
|
"hideable",
|
|
8
19
|
"locked"
|
|
9
|
-
]),
|
|
10
|
-
let
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
13
|
-
},
|
|
14
|
-
let
|
|
15
|
-
if (
|
|
16
|
-
let
|
|
17
|
-
return e.type === "textarea" ? `<textarea${
|
|
18
|
-
},
|
|
19
|
-
let
|
|
20
|
-
return
|
|
20
|
+
]), m = (e) => String(e ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), h = (e = {}) => Object.entries(e).filter(([, e]) => e != null && String(e).trim() !== "").map(([e, t]) => `${e.replace(/([A-Z])/g, "-$1").toLowerCase()}:${String(t)};`).join(""), g = (...e) => e.map((e) => String(e ?? "").trim()).filter(Boolean).join(" "), _ = (e, t) => {
|
|
21
|
+
let n = { ...e.attributes || {} };
|
|
22
|
+
if (t === "email") for (let e of p) delete n[e];
|
|
23
|
+
return n;
|
|
24
|
+
}, v = (e, t) => {
|
|
25
|
+
let n = _(e, t), r = h(e.style || {}), i = g(n.htmlClassNames, n.htmlClass, n.validationClass, n.validationClassName), a = m(n.name || n.fieldName || "field"), o = m(n.placeholder || ""), s = n.required ? " required" : "";
|
|
26
|
+
if (t === "email") return `<mj-table><tr><td style="padding:10px 12px;border:1px solid #d1d5db;border-radius:6px;color:#64748b;${r}">${o || a}</td></tr></mj-table>`;
|
|
27
|
+
let c = m(n.inputType || n.type || (e.type === "input" ? n.kind || "text" : e.type)), l = n.htmlId ? ` id="${m(n.htmlId)}"` : "", u = i ? ` class="${m(i)}"` : "";
|
|
28
|
+
return e.type === "textarea" ? `<textarea${l}${u} name="${a}" placeholder="${o}" style="${r}"${s}>${m(n.value || "")}</textarea>` : e.type === "select" ? `<select${l}${u} name="${a}" style="${r}"${s}>${(n.options || []).map((e) => `<option value="${m(e.value)}">${m(e.label)}</option>`).join("")}</select>` : `<input${l}${u} type="${c}" name="${a}" placeholder="${o}" value="${m(n.value || "")}" style="${r}"${s} />`;
|
|
29
|
+
}, y = (e, t) => {
|
|
30
|
+
let n = _(e, t), r = h(e.style || {}), i = g(n.htmlClassNames, n.htmlClass), a = n.htmlId ? ` id="${m(n.htmlId)}"` : "", o = i ? ` class="${m(i)}"` : "", s = m(n.actionUrl || n.action || "#"), c = m(n.method || "POST"), l = n.fields || [], u = m(n.submitLabel || "Submit");
|
|
31
|
+
return t === "email" ? `<mj-table><tr><td style="${r}"><table role="presentation" width="100%">${l.map((e) => `<tr><td style="padding:8px 0;font-family:Arial,sans-serif;color:#334155;"><strong>${m(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;">${m(e.placeholder || "") || " "}</span></td></tr>`).join("")}<tr><td style="padding-top:12px;"><a href="${m(n.href || n.submitHref || "#")}" style="display:inline-block;padding:10px 16px;background:#0f172a;color:#ffffff;text-decoration:none;border-radius:6px;">${u}</a></td></tr></table></td></tr></mj-table>` : `<form${a}${o} action="${s}" method="${c}" style="${r}">${l.map((t) => v({
|
|
21
32
|
id: `${e.id}-${String(t.name || t.label || "field")}`,
|
|
22
33
|
type: t.kind === "textarea" || t.kind === "select" ? t.kind : "input",
|
|
23
34
|
style: {
|
|
@@ -25,37 +36,72 @@ var e = /* @__PURE__ */ new Set([
|
|
|
25
36
|
...t.style || {}
|
|
26
37
|
},
|
|
27
38
|
attributes: t
|
|
28
|
-
}, "landing_page")).join("")}<button type="submit">${
|
|
29
|
-
},
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
if (
|
|
33
|
-
if (
|
|
34
|
-
if (
|
|
35
|
-
let e =
|
|
36
|
-
return `<mj-button href="${e}" css-class="${
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
+
}, "landing_page")).join("")}<button type="submit">${u}</button></form>`;
|
|
40
|
+
}, b = (p, b) => {
|
|
41
|
+
let x = _(p, b), S = h(p.style || {}), C = x.htmlId ? ` id="${m(x.htmlId)}"` : "", w = g(x.htmlClassNames, x.htmlClass, b === "landing_page" && x.hideOnMobile ? "hidden md:block" : ""), T = w ? ` class="${m(w)}"` : "", E = typeof x.customCss == "string" && x.customCss.trim() ? x.customCss.trim() : "", D = E && b === "landing_page" ? `<style>${E}</style>` : "";
|
|
42
|
+
if (p.type === "form_container") return `${D}${y(p, b)}`;
|
|
43
|
+
if (p.type === "input" || p.type === "select" || p.type === "textarea") return `${D}${v(p, b)}`;
|
|
44
|
+
if (b === "email") {
|
|
45
|
+
if (p.type === "button") {
|
|
46
|
+
let e = m(x.href || "#"), t = m(x.text || "Button"), n = c(p).width, r = n === "auto" ? "" : ` width="${m(n)}"`;
|
|
47
|
+
return `<mj-button href="${e}" css-class="${x.hideOnDesktop ? "desktop-hide" : ""}" padding="0" inner-padding="10px 16px"${r}>${t}</mj-button>`;
|
|
48
|
+
}
|
|
49
|
+
if (p.type === "image") {
|
|
50
|
+
let t = e(p), n = t.width && t.width !== "100%" ? ` width="${m(t.width)}"` : "", r = t.height && t.height !== "auto" ? ` height="${m(t.height)}"` : "";
|
|
51
|
+
return `<mj-image src="${m(x.src || "")}" alt="${m(x.alt || "")}"${n}${r} />`;
|
|
52
|
+
}
|
|
53
|
+
if (p.type === "social") {
|
|
54
|
+
let e = t(p), n = e.filter((e) => f[e.provider]), r = e.filter((e) => !f[e.provider]);
|
|
55
|
+
return `${n.length ? `<mj-social font-size="13px" icon-size="30px" mode="horizontal">${n.map((e) => `<mj-social-element name="${f[e.provider]}" href="${m(e.url)}" background-color="${m(e.backgroundColor)}" color="${m(e.color)}"></mj-social-element>`).join("")}</mj-social>` : ""}${r.length ? `<mj-text align="center">${r.map((e) => `<a href="${m(e.url)}" style="color: ${m(e.color)}; text-decoration: none; margin: 0 6px;">${m(e.provider)}</a>`).join("")}</mj-text>` : ""}`;
|
|
56
|
+
}
|
|
57
|
+
if (p.type === "menu") return `<mj-navbar hamburger="hamburger">${s(p).map((e) => `<mj-navbar-link href="${m(e.href)}">${m(e.label)}</mj-navbar-link>`).join("")}</mj-navbar>`;
|
|
58
|
+
if (p.type === "table") {
|
|
59
|
+
let e = i(p), t = p.style || {}, n = `${t.borderWidth || "1px"} ${t.borderStyle || "solid"} ${t.borderColor || "#cbd5e1"}`, r = (r, i, a) => {
|
|
60
|
+
let o = a ? "th" : "td", s = a ? t.headerBgColor || "#f8fafc" : e.striped && i % 2 == 1 ? "#f8fafc" : t.contentBgColor || "#ffffff", c = a ? t.headerTextColor || "#1e293b" : t.contentTextColor || "#475569";
|
|
61
|
+
return `<tr>${r.map((e) => `<${o} style="padding: ${t.cellPadding || "8px"}; border: ${n}; background-color: ${s}; color: ${c};">${m(e) || " "}</${o}>`).join("")}</tr>`;
|
|
62
|
+
}, a = +!!e.enableHeader, o = e.enableFooter ? e.cells.length - 1 : e.cells.length;
|
|
63
|
+
return `<mj-table><table role="presentation" style="border-collapse: collapse; width: 100%;">${e.enableHeader && e.cells.length > 0 ? `<thead>${r(e.cells[0], 0, !0)}</thead>` : ""}<tbody>${e.cells.slice(a, Math.max(a, o)).map((e, t) => r(e, t, !1)).join("")}</tbody>${e.enableFooter && e.cells.length > a ? `<tfoot>${r(e.cells[e.cells.length - 1], e.cells.length - 1, !1)}</tfoot>` : ""}</table></mj-table>`;
|
|
64
|
+
}
|
|
65
|
+
if (p.type === "video") {
|
|
66
|
+
let e = n(x.videoUrl), t = x.linkType === "email" ? `mailto:${x.href || ""}` : x.href || x.videoUrl || "#";
|
|
67
|
+
return `<mj-image src="${m(e.thumbnailUrl)}" href="${m(t)}" alt="${m(x.alt || "Video preview")}" />`;
|
|
68
|
+
}
|
|
69
|
+
if (p.type === "timer") {
|
|
70
|
+
let e = l(x.targetDate), t = x.showLabels !== !1;
|
|
71
|
+
return `<mj-text align="center"><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 ${m(x.targetDate || "")}</div>` : ""}</mj-text>`;
|
|
72
|
+
}
|
|
73
|
+
if (p.type === "carousel") {
|
|
74
|
+
let e = Array.isArray(x.images) ? x.images : [];
|
|
75
|
+
return e.length === 0 ? "<mj-text align=\"center\">No images in carousel</mj-text>" : `<mj-carousel>${e.map((e) => `<mj-carousel-image src="${m(e.src)}" alt="${m(e.alt || "")}" />`).join("")}</mj-carousel>`;
|
|
76
|
+
}
|
|
77
|
+
if (p.type === "icon") {
|
|
78
|
+
let e = r[a(x.iconName, Object.keys(r))] || o, t = parseInt(String(x.iconSize || 48), 10) || 48, n = p.style?.color || "#1e293b";
|
|
79
|
+
return `<mj-text align="center">${d(u.createElement(e, {
|
|
80
|
+
size: t,
|
|
81
|
+
color: n
|
|
82
|
+
}))}</mj-text>`;
|
|
83
|
+
}
|
|
84
|
+
return `<mj-text${C}${T} css-class="${x.hideOnDesktop ? "desktop-hide" : ""}">${m(x.text || x.htmlContent || "")}</mj-text>`;
|
|
39
85
|
}
|
|
40
|
-
switch (
|
|
41
|
-
case "heading": return `${
|
|
86
|
+
switch (p.type) {
|
|
87
|
+
case "heading": return `${D}<h2${C}${T} style="${S}">${m(x.text || "Heading")}</h2>`;
|
|
42
88
|
case "paragraph":
|
|
43
|
-
case "text": return `${
|
|
44
|
-
case "button": return `${
|
|
45
|
-
case "image": return `${
|
|
46
|
-
case "html": return `${
|
|
47
|
-
default: return `${
|
|
89
|
+
case "text": return `${D}<p${C}${T} style="${S}">${m(x.text || "")}</p>`;
|
|
90
|
+
case "button": return `${D}<a${C}${T} href="${m(x.href || "#")}" style="${S}">${m(x.text || "Button")}</a>`;
|
|
91
|
+
case "image": return `${D}<img${C}${T} src="${m(x.src || "")}" alt="${m(x.alt || "")}" style="${S}" />`;
|
|
92
|
+
case "html": return `${D}<div${C}${T} style="${S}">${String(x.htmlContent || "")}</div>`;
|
|
93
|
+
default: return `${D}<div${C}${T} style="${S}">${m(x.text || "")}</div>`;
|
|
48
94
|
}
|
|
49
|
-
},
|
|
50
|
-
if (
|
|
51
|
-
let n = e.elements.map((e) =>
|
|
52
|
-
return `<mj-column width="${
|
|
95
|
+
}, x = (e, t) => {
|
|
96
|
+
if (t === "email") {
|
|
97
|
+
let n = e.elements.map((e) => b(e, t)).join("");
|
|
98
|
+
return `<mj-column width="${m(e.width || "100%")}">${n}</mj-column>`;
|
|
53
99
|
}
|
|
54
|
-
let
|
|
55
|
-
return `<div style="width:${
|
|
56
|
-
},
|
|
57
|
-
let
|
|
58
|
-
return t === "email" ? `<mjml><mj-head><mj-style>.desktop-hide { display:none !important; max-height:0; overflow:hidden; }</mj-style></mj-head><mj-body><mj-section><mj-column><mj-wrapper css-class="email-root" padding="0"><mj-text css-class="preheader" padding="0" font-size="1px" color="#ffffff"> </mj-text></mj-wrapper></mj-column></mj-section>${
|
|
100
|
+
let n = h(e.styles || {}), r = e.elements.map((e) => b(e, t)).join(""), i = (Array.isArray(e.nestedRows) ? e.nestedRows : []).map((e) => S(e, t)).join("");
|
|
101
|
+
return `<div style="width:${m(e.width || "100%")};${n}">${r}${i}</div>`;
|
|
102
|
+
}, S = (e, t) => t === "email" ? `<mj-section css-class="${e.style?.hideOnDesktop ? "desktop-hide" : ""}">${e.columns.map((e) => x(e, t)).join("")}</mj-section>` : `<section style="display:flex;flex-wrap:wrap;${h(e.style || {})}">${e.columns.map((e) => x(e, t)).join("")}</section>`, C = (e, t) => {
|
|
103
|
+
let n = (e.body?.rows || []).map((e) => S(e, t)).join(""), r = h(e.body?.style || {});
|
|
104
|
+
return t === "email" ? `<mjml><mj-head><mj-style>.desktop-hide { display:none !important; max-height:0; overflow:hidden; }</mj-style></mj-head><mj-body><mj-section><mj-column><mj-wrapper css-class="email-root" padding="0"><mj-text css-class="preheader" padding="0" font-size="1px" color="#ffffff"> </mj-text></mj-wrapper></mj-column></mj-section>${n}</mj-body></mjml>` : `<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /></head><body style="${r}"><main>${n}</main></body></html>`;
|
|
59
105
|
};
|
|
60
106
|
//#endregion
|
|
61
|
-
export {
|
|
107
|
+
export { C as parseJsonToTargetFormat };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { TemplateJSON } from '../utilities/types';
|
|
3
|
+
import { type ImportResult } from './ImportModal';
|
|
3
4
|
interface CodeViewerProps {
|
|
4
5
|
activeTab: 'json' | 'html' | 'text';
|
|
5
6
|
template: TemplateJSON;
|
|
6
7
|
compiledHtml: string;
|
|
7
8
|
compiledText: string;
|
|
8
9
|
onNotify?: (message: string) => void;
|
|
10
|
+
onImportJson?: (jsonText: string) => ImportResult;
|
|
11
|
+
onImportHtml?: (htmlText: string) => ImportResult;
|
|
9
12
|
theme?: {
|
|
10
13
|
panelColor: string;
|
|
11
14
|
borderColor: string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ImportModalTheme {
|
|
3
|
+
panelColor?: string;
|
|
4
|
+
borderColor?: string;
|
|
5
|
+
textColor?: string;
|
|
6
|
+
themeBgColor?: string;
|
|
7
|
+
mutedTextColor?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ImportResult {
|
|
10
|
+
ok: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
interface ImportModalProps {
|
|
14
|
+
open: boolean;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
title: string;
|
|
17
|
+
description: string;
|
|
18
|
+
accept: string;
|
|
19
|
+
placeholder: string;
|
|
20
|
+
onImport: (content: string) => ImportResult;
|
|
21
|
+
theme?: ImportModalTheme;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Generic paste/drop/browse-file import modal, shared by the Json and Html tabs'
|
|
25
|
+
* "Import" buttons in CodeViewer.tsx. Themed via the same {panelColor, borderColor,
|
|
26
|
+
* textColor, themeBgColor, mutedTextColor} shape CodeViewer/TopHeader already receive
|
|
27
|
+
* from the host's PlexoBuilder theme props, rather than a hardcoded look — no dialog/modal
|
|
28
|
+
* primitive existed anywhere in this codebase to reuse, so this is built directly against
|
|
29
|
+
* plain div overlays + the browser's native drag/drop and File APIs.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ImportModal: React.FC<ImportModalProps>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SitePage } from '../../utilities/playground.interfaces';
|
|
3
|
+
export interface ResolvedSitePage {
|
|
4
|
+
id: string;
|
|
5
|
+
path: string;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Computes each page's full resolved path ("/blog/post-1") and a breadcrumb
|
|
10
|
+
* label ("Blog / Post 1") by walking its parent chain — shared by the Menu
|
|
11
|
+
* and Button internal-link pickers.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveSitePages(sitePages: SitePage[]): Map<string, ResolvedSitePage>;
|
|
14
|
+
interface InternalLinkFieldProps {
|
|
15
|
+
value: string;
|
|
16
|
+
onChange: (value: string) => void;
|
|
17
|
+
sitePages: SitePage[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Href field used by Menu items and the Button element: when the current
|
|
21
|
+
* landing page belongs to a multi-page site, offers a "Page on this site"
|
|
22
|
+
* picker (a dropdown of every page, resolved to a plain relative URL) next
|
|
23
|
+
* to the usual free-text "External URL" field. Falls back to a plain input
|
|
24
|
+
* when there's no site context (email templates, standalone pages, or
|
|
25
|
+
* sitePages hasn't loaded yet) so behavior is unchanged for those cases.
|
|
26
|
+
*/
|
|
27
|
+
export declare const InternalLinkField: React.FC<InternalLinkFieldProps>;
|
|
28
|
+
export {};
|