monto-email-builder 1.4.2 → 1.4.3
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/HtmlEditor/index.d.ts.map +1 -1
- package/dist/html-editor.js +274 -267
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/HtmlEditor/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6F,MAAM,OAAO,CAAC;AAmBlH,OAAO,EAaL,OAAO,EAIP,KAAK,EAKN,MAAM,eAAe,CAAC;AAWvB,OAAO,EAAE,QAAQ,EAAK,MAAM,SAAS,CAAC;AAKtC,OAAO,EASL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACxC,MAAM,aAAa,CAAC;AAYrB,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAC1D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,CAAC;AACpD,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,WAAW,CAAC;AACzD,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,GACnC,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,sBAAsB,EAAE,CAAC;IAC9C,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,EAAE,KAAK,IAAI,KAAK,sBAAsB,EAAE,CAAC;IACjG,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;IAC5D,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AA8DD,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,eAAe,CAAC,EAAE,kBAAkB,CAAC;IACrC;;OAEG;IACH,SAAS,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACtC;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,sBAAsB,EAAE,KAAK,IAAI,CAAC;IAClE;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/HtmlEditor/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6F,MAAM,OAAO,CAAC;AAmBlH,OAAO,EAaL,OAAO,EAIP,KAAK,EAKN,MAAM,eAAe,CAAC;AAWvB,OAAO,EAAE,QAAQ,EAAK,MAAM,SAAS,CAAC;AAKtC,OAAO,EASL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACxC,MAAM,aAAa,CAAC;AAYrB,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAC1D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,CAAC;AACpD,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,WAAW,CAAC;AACzD,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,kCAAkC,GACnC,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,sBAAsB,EAAE,CAAC;IAC9C,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,EAAE,KAAK,IAAI,KAAK,sBAAsB,EAAE,CAAC;IACjG,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;IAC5D,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AA8DD,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,eAAe,CAAC,EAAE,kBAAkB,CAAC;IACrC;;OAEG;IACH,SAAS,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACtC;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,sBAAsB,EAAE,KAAK,IAAI,CAAC;IAClE;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAi+BD,QAAA,MAAM,mBAAmB,uFAevB,CAAC;AAGH,eAAe,mBAAmB,CAAC"}
|
package/dist/html-editor.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as o, jsxs as f, Fragment as Nt } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as dt, useState as
|
|
2
|
+
import { forwardRef as dt, useState as V, useRef as $, useEffect as G, useCallback as L, useMemo as J, useImperativeHandle as zt } from "react";
|
|
3
3
|
import Ot from "@uiw/react-codemirror";
|
|
4
4
|
import { html as Pt } from "@codemirror/lang-html";
|
|
5
5
|
import { xcodeDark as _t, tomorrowNightBlue as Wt, dracula as ut, basicDark as jt, abcdef as Gt, bbedit as Ut, noctisLilac as qt, gruvboxLight as Yt, tokyoNightDay as Kt, vscodeLight as Xt, xcodeLight as Jt } from "@uiw/codemirror-themes-all";
|
|
6
6
|
import Q from "@mui/material/ToggleButton";
|
|
7
7
|
import et from "@mui/material/ToggleButtonGroup";
|
|
8
|
-
import { ThemeProvider as Qt, ScopedCssBaseline as Zt, useTheme as er, Box as
|
|
9
|
-
import { alpha as
|
|
8
|
+
import { ThemeProvider as Qt, ScopedCssBaseline as Zt, useTheme as er, Box as b, Tooltip as U, FormControl as tr, InputLabel as rr, Select as or, ListSubheader as tt, MenuItem as rt, Button as Ie, Tabs as nr, Tab as ot, Typography as A, Accordion as ar, AccordionSummary as ir, AccordionDetails as lr, TextField as Ee, Divider as sr } from "@mui/material";
|
|
9
|
+
import { alpha as de } from "@mui/material/styles";
|
|
10
10
|
import * as cr from "@mui/icons-material/AddOutlined";
|
|
11
11
|
import * as dr from "@mui/icons-material/Code";
|
|
12
12
|
import * as ur from "@mui/icons-material/DataObjectOutlined";
|
|
@@ -16,64 +16,64 @@ import * as br from "@mui/icons-material/Visibility";
|
|
|
16
16
|
import * as pr from "@mui/icons-material/ViewColumn";
|
|
17
17
|
import * as fr from "@mui/icons-material/MonitorOutlined";
|
|
18
18
|
import * as xr from "@mui/icons-material/PhoneIphoneOutlined";
|
|
19
|
-
import { B as gr, V as
|
|
20
|
-
const
|
|
21
|
-
function
|
|
22
|
-
return a
|
|
19
|
+
import { B as gr, V as F, r as k, T as vr, t as yr } from "./chunks/chunk-ZMWDxWGX.js";
|
|
20
|
+
const Ve = gr, nt = "unsubscribe_link", Te = /\{\{\s*([^{}]+?)\s*\}\}/g, at = /\{%\s*([^{}%]+?)\s*%\}/g;
|
|
21
|
+
function Ce(n, a, s, d, c) {
|
|
22
|
+
return n[a - 1] !== d && n[s] !== c;
|
|
23
23
|
}
|
|
24
|
-
function mt(
|
|
25
|
-
return
|
|
24
|
+
function mt(n, a = "user") {
|
|
25
|
+
return a === "builtin" || a === "system" ? `{%${n}%}` : `{{${n}}}`;
|
|
26
26
|
}
|
|
27
|
-
function Ir(
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
const s =
|
|
31
|
-
if (
|
|
27
|
+
function Ir(n) {
|
|
28
|
+
const a = typeof n == "string" ? n.trim() : "";
|
|
29
|
+
if (a.startsWith("{{") && a.endsWith("}}")) {
|
|
30
|
+
const s = a.slice(2, -2).trim();
|
|
31
|
+
if (F.test(s)) return { attribute: s, type: "user" };
|
|
32
32
|
}
|
|
33
|
-
if (
|
|
34
|
-
const s =
|
|
35
|
-
if (
|
|
33
|
+
if (a.startsWith("{%") && a.endsWith("%}")) {
|
|
34
|
+
const s = a.slice(2, -2).trim();
|
|
35
|
+
if (F.test(s)) return { attribute: s, type: "system" };
|
|
36
36
|
}
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
|
-
function Er(
|
|
40
|
-
const s =
|
|
41
|
-
return !
|
|
42
|
-
id: Number(
|
|
43
|
-
variableInstanceId:
|
|
44
|
-
variable: x === "system" ? `{%${
|
|
39
|
+
function Er(n, a) {
|
|
40
|
+
const s = n.variable ?? n.Variable ?? n.key ?? "", d = Ir(s), x = (n.type ?? n.Type ?? (d == null ? void 0 : d.type) ?? "user") === "system" ? "system" : "user", i = n.attribute ?? n.Attribute ?? (d == null ? void 0 : d.attribute) ?? "", h = String(i).trim();
|
|
41
|
+
return !h || !F.test(h) ? null : {
|
|
42
|
+
id: Number(n.id) || a + 1,
|
|
43
|
+
variableInstanceId: n.variableInstanceId ?? n.VariableInstanceId,
|
|
44
|
+
variable: x === "system" ? `{%${h}%}` : `{{${h}}}`,
|
|
45
45
|
type: x,
|
|
46
|
-
attribute:
|
|
47
|
-
default: String(
|
|
46
|
+
attribute: h,
|
|
47
|
+
default: String(n.default ?? n.Default ?? n.value ?? "")
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function it(
|
|
51
|
-
return Array.isArray(
|
|
52
|
-
...
|
|
50
|
+
function it(n) {
|
|
51
|
+
return Array.isArray(n) ? n.map((a, s) => Er(a, s)).filter((a) => !!a).map((a, s) => ({
|
|
52
|
+
...a,
|
|
53
53
|
id: s + 1,
|
|
54
|
-
variableInstanceId:
|
|
54
|
+
variableInstanceId: a.variableInstanceId || He(a.type, a.attribute, s)
|
|
55
55
|
})) : [];
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
s.push({ attribute: i, type:
|
|
57
|
+
function Z(n) {
|
|
58
|
+
const a = n || "", s = [], d = (i, h, p) => {
|
|
59
|
+
s.push({ attribute: i, type: h, start: p });
|
|
60
60
|
};
|
|
61
61
|
let c;
|
|
62
|
-
for (
|
|
63
|
-
const i = c.index,
|
|
64
|
-
if (!
|
|
62
|
+
for (Te.lastIndex = 0; c = Te.exec(a); ) {
|
|
63
|
+
const i = c.index, h = i + c[0].length;
|
|
64
|
+
if (!Ce(a, i, h, "{", "}")) continue;
|
|
65
65
|
const p = c[1].trim();
|
|
66
|
-
!p || !
|
|
66
|
+
!p || !F.test(p) || d(p, "user", i);
|
|
67
67
|
}
|
|
68
68
|
let x;
|
|
69
|
-
for (
|
|
70
|
-
const i = x.index,
|
|
71
|
-
if (!
|
|
69
|
+
for (at.lastIndex = 0; x = at.exec(a); ) {
|
|
70
|
+
const i = x.index, h = i + x[0].length;
|
|
71
|
+
if (!Ce(a, i, h, "{", "}")) continue;
|
|
72
72
|
const p = x[1].trim();
|
|
73
|
-
!p || !
|
|
73
|
+
!p || !F.test(p) || d(p, "system", i);
|
|
74
74
|
}
|
|
75
|
-
return s.sort((i,
|
|
76
|
-
id:
|
|
75
|
+
return s.sort((i, h) => i.start - h.start), s.map((i, h) => ({
|
|
76
|
+
id: h + 1,
|
|
77
77
|
variableInstanceId: wr(i.type, i.attribute, i.start),
|
|
78
78
|
variable: i.type === "system" ? `{%${i.attribute}%}` : `{{${i.attribute}}}`,
|
|
79
79
|
type: i.type,
|
|
@@ -81,77 +81,77 @@ function de(a) {
|
|
|
81
81
|
default: ""
|
|
82
82
|
}));
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function ue(n, a) {
|
|
85
85
|
const s = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
|
|
86
|
-
return
|
|
86
|
+
return a.forEach((c) => {
|
|
87
87
|
const x = { item: c, consumed: !1 };
|
|
88
88
|
if (c.variableInstanceId) {
|
|
89
89
|
const p = s.get(c.variableInstanceId) ?? [];
|
|
90
90
|
p.push(x), s.set(c.variableInstanceId, p);
|
|
91
91
|
}
|
|
92
|
-
const i = `${c.type}:${c.attribute}`,
|
|
93
|
-
|
|
94
|
-
}),
|
|
92
|
+
const i = `${c.type}:${c.attribute}`, h = d.get(i) ?? [];
|
|
93
|
+
h.push(x), d.set(i, h);
|
|
94
|
+
}), n.map((c, x) => {
|
|
95
95
|
var N;
|
|
96
|
-
const i = `${c.type}:${c.attribute}`,
|
|
97
|
-
return
|
|
96
|
+
const i = `${c.type}:${c.attribute}`, h = c.variableInstanceId ? (N = s.get(c.variableInstanceId)) == null ? void 0 : N.find((g) => !g.consumed) : void 0, p = (d.get(i) ?? []).find((g) => !g.consumed), H = h ?? p;
|
|
97
|
+
return H && (H.consumed = !0), {
|
|
98
98
|
...c,
|
|
99
99
|
id: x + 1,
|
|
100
|
-
variableInstanceId: c.variableInstanceId ||
|
|
101
|
-
default: c.type === "system" ? "" : (
|
|
100
|
+
variableInstanceId: c.variableInstanceId || He(c.type, c.attribute, x),
|
|
101
|
+
default: c.type === "system" ? "" : (H == null ? void 0 : H.item.default) ?? c.default ?? ""
|
|
102
102
|
};
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
function Vr(
|
|
106
|
-
return
|
|
105
|
+
function Vr(n) {
|
|
106
|
+
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
107
107
|
}
|
|
108
|
-
function lt(
|
|
108
|
+
function lt(n, a) {
|
|
109
109
|
const s = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
|
|
110
|
-
|
|
110
|
+
a.forEach((i) => {
|
|
111
111
|
i.type === "user" && (i.variableInstanceId && s.set(i.variableInstanceId, i.default ?? ""), d.has(i.attribute) || d.set(i.attribute, i.default ?? ""));
|
|
112
112
|
});
|
|
113
|
-
const c =
|
|
113
|
+
const c = Z(n), x = /* @__PURE__ */ new Map();
|
|
114
114
|
return c.forEach((i) => {
|
|
115
|
-
const
|
|
116
|
-
Number.isFinite(
|
|
117
|
-
}), (
|
|
118
|
-
var
|
|
115
|
+
const h = Number(String(i.variableInstanceId ?? "").split("-at-")[1]);
|
|
116
|
+
Number.isFinite(h) && x.set(h, i);
|
|
117
|
+
}), (n || "").replace(Te, (i, h, p, H) => {
|
|
118
|
+
var ee;
|
|
119
119
|
const N = p + i.length;
|
|
120
|
-
if (!
|
|
121
|
-
const g = String(
|
|
122
|
-
if (!g || !
|
|
123
|
-
const
|
|
120
|
+
if (!Ce(H, p, N, "{", "}")) return i;
|
|
121
|
+
const g = String(h).trim();
|
|
122
|
+
if (!g || !F.test(g)) return i;
|
|
123
|
+
const R = (ee = x.get(p)) == null ? void 0 : ee.variableInstanceId, z = (R ? s.get(R) : void 0) ?? (a.filter((l) => l.type === "user" && l.attribute === g).length === 1 ? d.get(g) : void 0);
|
|
124
124
|
return z === void 0 || z === "" ? i : Vr(z);
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
function st(
|
|
128
|
-
const d =
|
|
129
|
-
if (!d || !
|
|
130
|
-
const c =
|
|
127
|
+
function st(n, a, s = "") {
|
|
128
|
+
const d = n.trim();
|
|
129
|
+
if (!d || !F.test(d)) return null;
|
|
130
|
+
const c = a === "builtin" ? "system" : "user";
|
|
131
131
|
return {
|
|
132
132
|
id: 1,
|
|
133
|
-
variableInstanceId:
|
|
134
|
-
variable: mt(d,
|
|
133
|
+
variableInstanceId: He(c, d, 0),
|
|
134
|
+
variable: mt(d, a),
|
|
135
135
|
type: c,
|
|
136
136
|
attribute: d,
|
|
137
137
|
default: c === "system" ? "" : s
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
function Tr(
|
|
141
|
-
const
|
|
142
|
-
return
|
|
140
|
+
function Tr(n) {
|
|
141
|
+
const a = n.trim();
|
|
142
|
+
return a ? Ve.some((s) => s.items.some((d) => d.name === a)) : !1;
|
|
143
143
|
}
|
|
144
|
-
function Cr(
|
|
145
|
-
const s =
|
|
146
|
-
return
|
|
144
|
+
function Cr(n, a) {
|
|
145
|
+
const s = n.trim();
|
|
146
|
+
return a === "user" && s === nt ? `<a href="{{${nt}}}">Unsubscribe Link</a>` : mt(s, a);
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
return `html-${
|
|
148
|
+
function He(n, a, s) {
|
|
149
|
+
return `html-${n}-${a}-${s + 1}`;
|
|
150
150
|
}
|
|
151
|
-
function wr(
|
|
152
|
-
return `html-${
|
|
151
|
+
function wr(n, a, s) {
|
|
152
|
+
return `html-${n}-${a}-at-${s}`;
|
|
153
153
|
}
|
|
154
|
-
const Hr =
|
|
154
|
+
const Hr = k(cr), Sr = k(dr), Mr = k(ur), Dr = k(mr), Lr = k(hr), kr = k(br), Br = k(pr), Ar = k(fr), Fr = k(xr), we = {
|
|
155
155
|
// 浅色主题
|
|
156
156
|
xcodeLight: Jt,
|
|
157
157
|
vscodeLight: Xt,
|
|
@@ -179,207 +179,214 @@ const Hr = L(cr), Sr = L(dr), Mr = L(ur), Dr = L(mr), Lr = L(hr), kr = L(br), Br
|
|
|
179
179
|
tomorrowNightBlue: "Tomorrow Night Blue (Dark)",
|
|
180
180
|
xcodeDark: "Xcode Dark (Dark)"
|
|
181
181
|
}, ht = "html-editor-theme", ct = "dracula";
|
|
182
|
-
function Nr(
|
|
183
|
-
const
|
|
184
|
-
if (typeof window > "u") return
|
|
182
|
+
function Nr(n = ct) {
|
|
183
|
+
const a = n && we[n] ? n : ct;
|
|
184
|
+
if (typeof window > "u") return a;
|
|
185
185
|
try {
|
|
186
186
|
const s = localStorage.getItem(ht);
|
|
187
|
-
if (s &&
|
|
187
|
+
if (s && we[s]) return s;
|
|
188
188
|
} catch {
|
|
189
189
|
console.error("Failed to get HTML Editor stored theme");
|
|
190
190
|
}
|
|
191
|
-
return
|
|
191
|
+
return a;
|
|
192
192
|
}
|
|
193
|
-
function zr(
|
|
193
|
+
function zr(n) {
|
|
194
194
|
try {
|
|
195
|
-
localStorage.setItem(ht,
|
|
195
|
+
localStorage.setItem(ht, n);
|
|
196
196
|
} catch {
|
|
197
|
-
console.error("Failed to set HTML Editor stored theme",
|
|
197
|
+
console.error("Failed to set HTML Editor stored theme", n);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
function Or({
|
|
201
|
-
value:
|
|
202
|
-
onChange:
|
|
201
|
+
value: n,
|
|
202
|
+
onChange: a,
|
|
203
203
|
language: s = "zh",
|
|
204
204
|
initialMode: d = "split",
|
|
205
205
|
initialDevice: c = "desktop",
|
|
206
206
|
codeEditorHeight: x = "100%",
|
|
207
207
|
previewHeight: i = "100%",
|
|
208
|
-
sx:
|
|
208
|
+
sx: h,
|
|
209
209
|
showToolbar: p = !0,
|
|
210
|
-
initialTheme:
|
|
210
|
+
initialTheme: H,
|
|
211
211
|
initialRightTab: N = "preview",
|
|
212
212
|
variables: g,
|
|
213
|
-
onVariablesChange:
|
|
213
|
+
onVariablesChange: R,
|
|
214
214
|
requireVariableDefaults: z = !0
|
|
215
|
-
},
|
|
215
|
+
}, ee) {
|
|
216
216
|
var Re, $e, Ne, ze, Oe, Pe, _e, We, je, Ge, Ue, qe, Ye, Ke, Xe, Je, Qe, Ze;
|
|
217
|
-
const l = (e, t) => yr(e, t, s), [
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}, [
|
|
217
|
+
const l = (e, t) => yr(e, t, s), [S, pt] = V(d), [O, ft] = V(c), [Se, xt] = V(() => Nr(H)), [E, me] = V(n), [te, P] = V(N), [w, he] = V(() => it(g)), [gt, vt] = V(!1), [yt, It] = V(null), [_, Me] = V(""), [W, De] = V(""), [be, re] = V(!1), [pe, oe] = V(!1), q = $(null), fe = $(null), T = $(w), Le = $(null), ke = $(null), xe = $(!1), ne = $(null);
|
|
218
|
+
G(() => {
|
|
219
|
+
n !== E && me(n);
|
|
220
|
+
}, [n]), G(() => {
|
|
221
221
|
if (g === void 0) return;
|
|
222
222
|
const e = it(g);
|
|
223
|
-
|
|
224
|
-
}, [g])
|
|
225
|
-
|
|
223
|
+
T.current = e, he(e);
|
|
224
|
+
}, [g]), G(() => {
|
|
225
|
+
if (g !== void 0) return;
|
|
226
|
+
const e = Z(E), t = ue(e, T.current);
|
|
227
|
+
(t.length !== T.current.length || t.some((u, v) => {
|
|
228
|
+
const m = T.current[v];
|
|
229
|
+
return !m || m.variableInstanceId !== u.variableInstanceId || m.attribute !== u.attribute || m.type !== u.type || m.default !== u.default;
|
|
230
|
+
})) && (T.current = t, he(t));
|
|
231
|
+
}, [E, g]);
|
|
232
|
+
const B = L(
|
|
226
233
|
(e) => {
|
|
227
|
-
const t = e.map((r,
|
|
234
|
+
const t = e.map((r, u) => ({
|
|
228
235
|
...r,
|
|
229
|
-
id:
|
|
236
|
+
id: u + 1,
|
|
230
237
|
default: r.type === "system" ? "" : r.default ?? ""
|
|
231
238
|
}));
|
|
232
|
-
return
|
|
239
|
+
return T.current = t, he(t), R == null || R(t), t;
|
|
233
240
|
},
|
|
234
|
-
[
|
|
235
|
-
),
|
|
241
|
+
[R]
|
|
242
|
+
), M = L(() => {
|
|
236
243
|
var t, r;
|
|
237
|
-
const e = (r = (t =
|
|
238
|
-
return e && typeof e.toString == "function" ? e.toString() :
|
|
239
|
-
}, [
|
|
240
|
-
|
|
241
|
-
|
|
244
|
+
const e = (r = (t = fe.current) == null ? void 0 : t.state) == null ? void 0 : r.doc;
|
|
245
|
+
return e && typeof e.toString == "function" ? e.toString() : E;
|
|
246
|
+
}, [E]), ge = (e) => {
|
|
247
|
+
me(e), q.current && clearTimeout(q.current), q.current = setTimeout(() => {
|
|
248
|
+
a == null || a(e);
|
|
242
249
|
}, 300);
|
|
243
|
-
},
|
|
250
|
+
}, Y = L(
|
|
244
251
|
(e) => {
|
|
245
|
-
const t =
|
|
246
|
-
return
|
|
252
|
+
const t = Z(e ?? M()), r = ue(t, T.current);
|
|
253
|
+
return B(r);
|
|
247
254
|
},
|
|
248
|
-
[
|
|
249
|
-
), ae =
|
|
250
|
-
const e =
|
|
251
|
-
e !==
|
|
252
|
-
const t =
|
|
255
|
+
[M, B]
|
|
256
|
+
), ae = L(() => {
|
|
257
|
+
const e = M();
|
|
258
|
+
e !== E && me(e);
|
|
259
|
+
const t = Y(e), r = z ? t.filter((u) => u.type === "user" && u.default.trim() === "") : [];
|
|
253
260
|
return vt(r.length > 0), r.length > 0 && P("variables"), {
|
|
254
261
|
valid: r.length === 0,
|
|
255
262
|
variables: t,
|
|
256
263
|
missing: r
|
|
257
264
|
};
|
|
258
|
-
}, [
|
|
259
|
-
|
|
265
|
+
}, [M, E, z, Y]), Et = L(() => {
|
|
266
|
+
xe.current = !0, ae(), P("variables");
|
|
260
267
|
}, [ae]);
|
|
261
|
-
|
|
262
|
-
if (
|
|
268
|
+
G(() => {
|
|
269
|
+
if (te !== "variables" || !xe.current) return;
|
|
263
270
|
const e = window.requestAnimationFrame(() => {
|
|
264
271
|
const t = Le.current, r = ke.current;
|
|
265
272
|
t && r && t.scrollTo({
|
|
266
273
|
top: Math.max(r.offsetTop - 8, 0),
|
|
267
274
|
behavior: "auto"
|
|
268
|
-
}),
|
|
275
|
+
}), xe.current = !1;
|
|
269
276
|
});
|
|
270
277
|
return () => window.cancelAnimationFrame(e);
|
|
271
|
-
}, [
|
|
272
|
-
|
|
278
|
+
}, [te, w.length]), G(() => () => {
|
|
279
|
+
q.current && clearTimeout(q.current);
|
|
273
280
|
}, []);
|
|
274
281
|
const Vt = (e) => {
|
|
275
|
-
var y, I,
|
|
282
|
+
var y, I, K;
|
|
276
283
|
const t = e || "";
|
|
277
284
|
let r = t;
|
|
278
285
|
if (!t.trim())
|
|
279
286
|
r = "<!DOCTYPE html><html><head></head><body></body></html>";
|
|
280
287
|
else {
|
|
281
|
-
const
|
|
282
|
-
if (!
|
|
283
|
-
const $t =
|
|
284
|
-
r = `<!DOCTYPE html><html><head>${
|
|
288
|
+
const D = new DOMParser().parseFromString(t, "text/html"), ye = ((y = D.documentElement) == null ? void 0 : y.tagName.toLowerCase()) === "html", Ft = ((I = D.head) == null ? void 0 : I.tagName.toLowerCase()) === "head", Rt = ((K = D.body) == null ? void 0 : K.tagName.toLowerCase()) === "body";
|
|
289
|
+
if (!ye || !Ft || !Rt) {
|
|
290
|
+
const $t = D.body ? D.body.innerHTML : t;
|
|
291
|
+
r = `<!DOCTYPE html><html><head>${D.head ? D.head.innerHTML : ""}</head><body>${$t}</body></html>`;
|
|
285
292
|
} else
|
|
286
|
-
r = `<!DOCTYPE html>${
|
|
293
|
+
r = `<!DOCTYPE html>${D.documentElement.outerHTML}`;
|
|
287
294
|
}
|
|
288
|
-
const
|
|
289
|
-
return
|
|
290
|
-
|
|
291
|
-
}), r = `<!DOCTYPE html>${
|
|
295
|
+
const u = ["script", "iframe", "object", "embed", "canvas"], m = new DOMParser().parseFromString(r, "text/html");
|
|
296
|
+
return u.forEach((X) => {
|
|
297
|
+
m.querySelectorAll(X).forEach((ye) => ye.remove());
|
|
298
|
+
}), r = `<!DOCTYPE html>${m.documentElement.outerHTML}`, r;
|
|
292
299
|
}, Be = J(
|
|
293
|
-
() => lt(
|
|
294
|
-
[
|
|
295
|
-
),
|
|
300
|
+
() => lt(E, w),
|
|
301
|
+
[w, E]
|
|
302
|
+
), ie = J(() => Vt(Be), [Be]);
|
|
296
303
|
zt(
|
|
297
|
-
|
|
304
|
+
ee,
|
|
298
305
|
() => ({
|
|
299
|
-
getValue: () =>
|
|
300
|
-
getPreviewHtml: () => lt(
|
|
301
|
-
scanVariables: () =>
|
|
306
|
+
getValue: () => M(),
|
|
307
|
+
getPreviewHtml: () => lt(M(), T.current),
|
|
308
|
+
scanVariables: () => Y(M()),
|
|
302
309
|
getVariables: (e) => {
|
|
303
|
-
const t =
|
|
310
|
+
const t = Y(M());
|
|
304
311
|
return e == null || e(t), t;
|
|
305
312
|
},
|
|
306
313
|
validateVariables: ae,
|
|
307
314
|
showVariables: () => P("variables")
|
|
308
315
|
}),
|
|
309
|
-
[
|
|
310
|
-
),
|
|
311
|
-
|
|
312
|
-
}, [
|
|
316
|
+
[M, Y, ae]
|
|
317
|
+
), G(() => {
|
|
318
|
+
ne.current && ne.current.srcdoc !== ie && (ne.current.srcdoc = ie);
|
|
319
|
+
}, [ie]);
|
|
313
320
|
const Tt = (e, t) => {
|
|
314
321
|
t !== null && pt(t);
|
|
315
322
|
}, Ct = (e, t) => {
|
|
316
323
|
(t === "desktop" || t === "mobile") && ft(t);
|
|
317
|
-
},
|
|
324
|
+
}, le = L(
|
|
318
325
|
(e) => {
|
|
319
|
-
var
|
|
320
|
-
const t =
|
|
326
|
+
var u, v;
|
|
327
|
+
const t = fe.current;
|
|
321
328
|
if (t != null && t.state && (t != null && t.dispatch)) {
|
|
322
|
-
const
|
|
329
|
+
const m = (u = t.state.selection) == null ? void 0 : u.main, y = t.state.doc.toString(), I = (m == null ? void 0 : m.from) ?? t.state.doc.length, K = (m == null ? void 0 : m.to) ?? I, X = `${y.slice(0, I)}${e}${y.slice(K)}`;
|
|
323
330
|
return t.dispatch({
|
|
324
|
-
changes: { from: I, to:
|
|
331
|
+
changes: { from: I, to: K, insert: e },
|
|
325
332
|
selection: { anchor: I + e.length }
|
|
326
|
-
}), (v = t.focus) == null || v.call(t),
|
|
333
|
+
}), (v = t.focus) == null || v.call(t), ge(X), X;
|
|
327
334
|
}
|
|
328
|
-
const r = `${
|
|
329
|
-
return
|
|
335
|
+
const r = `${E}${e}`;
|
|
336
|
+
return ge(r), r;
|
|
330
337
|
},
|
|
331
|
-
[
|
|
332
|
-
), wt =
|
|
338
|
+
[E]
|
|
339
|
+
), wt = L(
|
|
333
340
|
(e, t) => {
|
|
334
|
-
const r =
|
|
335
|
-
|
|
341
|
+
const r = T.current;
|
|
342
|
+
B(
|
|
336
343
|
r.map(
|
|
337
|
-
(
|
|
344
|
+
(u) => u.variableInstanceId === e ? { ...u, default: t } : u
|
|
338
345
|
)
|
|
339
346
|
);
|
|
340
347
|
},
|
|
341
|
-
[
|
|
342
|
-
), Ht =
|
|
348
|
+
[B]
|
|
349
|
+
), Ht = L(
|
|
343
350
|
(e, t) => {
|
|
344
351
|
if (!st(e, t)) return;
|
|
345
|
-
const
|
|
346
|
-
|
|
352
|
+
const u = le(Cr(e, t)), v = Z(u), m = ue(v, T.current);
|
|
353
|
+
B(m), P("variables");
|
|
347
354
|
},
|
|
348
|
-
[
|
|
349
|
-
),
|
|
355
|
+
[le, B]
|
|
356
|
+
), se = J(() => {
|
|
350
357
|
const e = _.trim();
|
|
351
|
-
return e ?
|
|
352
|
-
}, [_,
|
|
358
|
+
return e ? F.test(e) ? Tr(e) || w.some((t) => t.type === "user" && t.attribute === e) ? l("text.variables.customVariableNameDuplicate") : "" : l("text.variables.customVariableNameInvalid") : l("text.variables.customVariableNameRequired");
|
|
359
|
+
}, [_, w]), St = L(() => {
|
|
353
360
|
const e = W.trim();
|
|
354
|
-
if (
|
|
361
|
+
if (re(!0), oe(!0), se || e === "") return;
|
|
355
362
|
const t = st(_.trim(), "user", e);
|
|
356
363
|
if (!t) return;
|
|
357
|
-
const r =
|
|
358
|
-
let
|
|
364
|
+
const r = le(t.variable), u = Z(r), v = ue(u, T.current);
|
|
365
|
+
let m = -1;
|
|
359
366
|
for (let y = v.length - 1; y >= 0; y -= 1) {
|
|
360
367
|
const I = v[y];
|
|
361
368
|
if (I.type === t.type && I.attribute === t.attribute && I.default === "") {
|
|
362
|
-
|
|
369
|
+
m = y;
|
|
363
370
|
break;
|
|
364
371
|
}
|
|
365
372
|
}
|
|
366
|
-
|
|
373
|
+
B(
|
|
367
374
|
v.map(
|
|
368
|
-
(y, I) => I ===
|
|
375
|
+
(y, I) => I === m ? { ...y, default: t.default } : y
|
|
369
376
|
)
|
|
370
|
-
), Me(""), De(""),
|
|
371
|
-
}, [W, _,
|
|
377
|
+
), Me(""), De(""), re(!1), oe(!1), P("variables");
|
|
378
|
+
}, [W, _, se, le, B]), Mt = J(() => {
|
|
372
379
|
const e = /* @__PURE__ */ new Set();
|
|
373
|
-
return [{ id: "custom", items:
|
|
380
|
+
return [{ id: "custom", items: w.filter((r) => r.type === "user").filter((r) => !Ve.some((u) => u.items.some((v) => v.name === r.attribute))).filter((r) => e.has(r.attribute) ? !1 : (e.add(r.attribute), !0)).map((r) => ({
|
|
374
381
|
name: r.attribute,
|
|
375
382
|
labelKey: r.attribute,
|
|
376
383
|
kind: "user"
|
|
377
|
-
})) }, ...
|
|
378
|
-
}, [
|
|
379
|
-
() =>
|
|
380
|
-
[
|
|
381
|
-
), Dt = (e) => e === "custom" ? "text.variables.groupCustom" : e === "contacts" ? "text.variables.groupContacts" : e === "email" ? "text.variables.groupEmail" : e === "organization" ? "text.variables.groupOrganization" : e === "date" ? "text.variables.groupDate" : "text.variables.groupLinks",
|
|
382
|
-
($e = (Re =
|
|
384
|
+
})) }, ...Ve];
|
|
385
|
+
}, [w]), ce = J(
|
|
386
|
+
() => w.filter((e) => e.type !== "system"),
|
|
387
|
+
[w]
|
|
388
|
+
), Dt = (e) => e === "custom" ? "text.variables.groupCustom" : e === "contacts" ? "text.variables.groupContacts" : e === "email" ? "text.variables.groupEmail" : e === "organization" ? "text.variables.groupOrganization" : e === "date" ? "text.variables.groupDate" : "text.variables.groupLinks", C = er(), Lt = O === "desktop" || O === "mobile" ? O : "desktop", kt = S === "split" || S === "code" || S === "preview" ? S : "split";
|
|
389
|
+
($e = (Re = C.palette) == null ? void 0 : Re.action) == null || $e.selected, (ze = (Ne = C.palette) == null ? void 0 : Ne.primary) == null || ze.main, (Pe = (Oe = C.palette) == null ? void 0 : Oe.action) == null || Pe.selected, (We = (_e = C.palette) == null ? void 0 : _e.background) == null || We.paper, (Ge = (je = C.palette) == null ? void 0 : je.text) == null || Ge.primary, (qe = (Ue = C.palette) == null ? void 0 : Ue.action) == null || qe.hover;
|
|
383
390
|
const j = {
|
|
384
391
|
tooltip: {
|
|
385
392
|
sx: {
|
|
@@ -387,14 +394,14 @@ function Or({
|
|
|
387
394
|
fontWeight: 400,
|
|
388
395
|
lineHeight: 1.45,
|
|
389
396
|
maxWidth: 360,
|
|
390
|
-
backgroundColor:
|
|
391
|
-
color: ((Je = (Xe =
|
|
397
|
+
backgroundColor: de(((Ke = (Ye = C.palette) == null ? void 0 : Ye.text) == null ? void 0 : Ke.primary) ?? "#1F1F21", 0.9),
|
|
398
|
+
color: ((Je = (Xe = C.palette) == null ? void 0 : Xe.common) == null ? void 0 : Je.white) ?? "#fff"
|
|
392
399
|
}
|
|
393
400
|
},
|
|
394
401
|
arrow: {
|
|
395
|
-
sx: { color:
|
|
402
|
+
sx: { color: de(((Ze = (Qe = C.palette) == null ? void 0 : Qe.text) == null ? void 0 : Ze.primary) ?? "#1F1F21", 0.9) }
|
|
396
403
|
}
|
|
397
|
-
},
|
|
404
|
+
}, ve = {
|
|
398
405
|
component: "div",
|
|
399
406
|
sx: {
|
|
400
407
|
mt: 0.5,
|
|
@@ -403,7 +410,7 @@ function Or({
|
|
|
403
410
|
lineHeight: 1.5
|
|
404
411
|
}
|
|
405
412
|
}, Ae = () => /* @__PURE__ */ f(
|
|
406
|
-
|
|
413
|
+
b,
|
|
407
414
|
{
|
|
408
415
|
sx: {
|
|
409
416
|
height: x,
|
|
@@ -411,12 +418,12 @@ function Or({
|
|
|
411
418
|
display: "flex",
|
|
412
419
|
flexDirection: "column",
|
|
413
420
|
position: "relative",
|
|
414
|
-
borderRight:
|
|
421
|
+
borderRight: S === "split" ? "1px solid" : "none",
|
|
415
422
|
borderColor: "divider"
|
|
416
423
|
},
|
|
417
424
|
children: [
|
|
418
425
|
/* @__PURE__ */ o(
|
|
419
|
-
|
|
426
|
+
b,
|
|
420
427
|
{
|
|
421
428
|
sx: {
|
|
422
429
|
flex: 1,
|
|
@@ -449,13 +456,13 @@ function Or({
|
|
|
449
456
|
children: /* @__PURE__ */ o(
|
|
450
457
|
Ot,
|
|
451
458
|
{
|
|
452
|
-
value:
|
|
459
|
+
value: E,
|
|
453
460
|
height: "100%",
|
|
454
461
|
extensions: [Pt()],
|
|
455
|
-
theme:
|
|
456
|
-
onChange:
|
|
462
|
+
theme: we[Se] || ut,
|
|
463
|
+
onChange: ge,
|
|
457
464
|
onCreateEditor: (e) => {
|
|
458
|
-
|
|
465
|
+
fe.current = e;
|
|
459
466
|
},
|
|
460
467
|
basicSetup: {
|
|
461
468
|
lineNumbers: !0,
|
|
@@ -468,7 +475,7 @@ function Or({
|
|
|
468
475
|
}
|
|
469
476
|
),
|
|
470
477
|
/* @__PURE__ */ o(
|
|
471
|
-
|
|
478
|
+
Ie,
|
|
472
479
|
{
|
|
473
480
|
size: "small",
|
|
474
481
|
variant: "contained",
|
|
@@ -487,7 +494,7 @@ function Or({
|
|
|
487
494
|
)
|
|
488
495
|
]
|
|
489
496
|
}
|
|
490
|
-
), Bt = () => /* @__PURE__ */ o(
|
|
497
|
+
), Bt = () => /* @__PURE__ */ o(b, { sx: {
|
|
491
498
|
height: i,
|
|
492
499
|
overflow: "auto",
|
|
493
500
|
backgroundColor: "#F5F5F5",
|
|
@@ -495,7 +502,7 @@ function Or({
|
|
|
495
502
|
display: "flex",
|
|
496
503
|
justifyContent: "center"
|
|
497
504
|
}, children: /* @__PURE__ */ o(
|
|
498
|
-
|
|
505
|
+
b,
|
|
499
506
|
{
|
|
500
507
|
sx: {
|
|
501
508
|
width: "100%",
|
|
@@ -507,8 +514,8 @@ function Or({
|
|
|
507
514
|
children: /* @__PURE__ */ o(
|
|
508
515
|
"iframe",
|
|
509
516
|
{
|
|
510
|
-
ref:
|
|
511
|
-
srcDoc:
|
|
517
|
+
ref: ne,
|
|
518
|
+
srcDoc: ie,
|
|
512
519
|
style: {
|
|
513
520
|
width: "100%",
|
|
514
521
|
height: "100%",
|
|
@@ -521,7 +528,7 @@ function Or({
|
|
|
521
528
|
)
|
|
522
529
|
}
|
|
523
530
|
) }), At = () => /* @__PURE__ */ f(
|
|
524
|
-
|
|
531
|
+
b,
|
|
525
532
|
{
|
|
526
533
|
ref: Le,
|
|
527
534
|
sx: {
|
|
@@ -535,23 +542,23 @@ function Or({
|
|
|
535
542
|
pb: 6
|
|
536
543
|
},
|
|
537
544
|
children: [
|
|
538
|
-
/* @__PURE__ */ o(
|
|
539
|
-
/* @__PURE__ */ f(
|
|
540
|
-
/* @__PURE__ */ o(
|
|
541
|
-
/* @__PURE__ */ o(
|
|
545
|
+
/* @__PURE__ */ o(b, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 1, mb: 1.5 }, children: /* @__PURE__ */ f(b, { sx: { minWidth: 0 }, children: [
|
|
546
|
+
/* @__PURE__ */ f(b, { sx: { display: "flex", alignItems: "center", gap: 0.75 }, children: [
|
|
547
|
+
/* @__PURE__ */ o(A, { variant: "subtitle1", sx: { fontWeight: 700 }, children: l("htmlEditor.variables.title") }),
|
|
548
|
+
/* @__PURE__ */ o(U, { title: l("htmlEditor.variables.help"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(b, { component: "span", sx: { display: "inline-flex", color: "text.secondary", cursor: "help" }, children: /* @__PURE__ */ o(Lr, { fontSize: "small" }) }) })
|
|
542
549
|
] }),
|
|
543
|
-
/* @__PURE__ */ o(
|
|
550
|
+
/* @__PURE__ */ o(A, { component: "div", variant: "body2", color: "text.secondary", children: l("htmlEditor.variables.scanHint") })
|
|
544
551
|
] }) }),
|
|
545
|
-
/* @__PURE__ */ o(
|
|
552
|
+
/* @__PURE__ */ o(b, { sx: { mb: 2 }, children: Mt.map((e) => {
|
|
546
553
|
const t = yt === e.id;
|
|
547
554
|
return /* @__PURE__ */ f(
|
|
548
|
-
|
|
555
|
+
ar,
|
|
549
556
|
{
|
|
550
557
|
disableGutters: !0,
|
|
551
558
|
square: !0,
|
|
552
559
|
elevation: 0,
|
|
553
560
|
expanded: t,
|
|
554
|
-
onChange: (r,
|
|
561
|
+
onChange: (r, u) => It(u ? e.id : null),
|
|
555
562
|
sx: {
|
|
556
563
|
"&:before": { display: "none" },
|
|
557
564
|
border: 1,
|
|
@@ -569,13 +576,13 @@ function Or({
|
|
|
569
576
|
minHeight: 44,
|
|
570
577
|
"& .MuiAccordionSummary-content": { my: 1 }
|
|
571
578
|
},
|
|
572
|
-
children: /* @__PURE__ */ o(
|
|
579
|
+
children: /* @__PURE__ */ o(A, { component: "div", variant: "body2", color: "text.primary", children: l(Dt(e.id)) })
|
|
573
580
|
}
|
|
574
581
|
),
|
|
575
582
|
/* @__PURE__ */ f(lr, { sx: { pt: 0, pb: 1.25 }, children: [
|
|
576
|
-
e.id === "custom" && /* @__PURE__ */ f(
|
|
583
|
+
e.id === "custom" && /* @__PURE__ */ f(b, { sx: { mb: 1 }, children: [
|
|
577
584
|
/* @__PURE__ */ o(
|
|
578
|
-
|
|
585
|
+
Ee,
|
|
579
586
|
{
|
|
580
587
|
size: "small",
|
|
581
588
|
fullWidth: !0,
|
|
@@ -583,19 +590,19 @@ function Or({
|
|
|
583
590
|
value: _,
|
|
584
591
|
placeholder: "e.g. order_id",
|
|
585
592
|
onChange: (r) => {
|
|
586
|
-
Me(r.target.value), !
|
|
593
|
+
Me(r.target.value), !be && r.target.value.trim() !== "" && re(!0);
|
|
587
594
|
},
|
|
588
595
|
onBlur: () => {
|
|
589
|
-
_.trim() !== "" &&
|
|
596
|
+
_.trim() !== "" && re(!0);
|
|
590
597
|
},
|
|
591
|
-
error:
|
|
592
|
-
helperText:
|
|
593
|
-
FormHelperTextProps:
|
|
598
|
+
error: be && !!se,
|
|
599
|
+
helperText: be && se || " ",
|
|
600
|
+
FormHelperTextProps: ve,
|
|
594
601
|
sx: { mb: 1 }
|
|
595
602
|
}
|
|
596
603
|
),
|
|
597
604
|
/* @__PURE__ */ o(
|
|
598
|
-
|
|
605
|
+
Ee,
|
|
599
606
|
{
|
|
600
607
|
size: "small",
|
|
601
608
|
fullWidth: !0,
|
|
@@ -603,18 +610,18 @@ function Or({
|
|
|
603
610
|
value: W,
|
|
604
611
|
placeholder: l("text.variables.defaultPlaceholder"),
|
|
605
612
|
onChange: (r) => {
|
|
606
|
-
De(r.target.value), !
|
|
613
|
+
De(r.target.value), !pe && r.target.value.trim() !== "" && oe(!0);
|
|
607
614
|
},
|
|
608
615
|
onBlur: () => {
|
|
609
|
-
W.trim() !== "" &&
|
|
616
|
+
W.trim() !== "" && oe(!0);
|
|
610
617
|
},
|
|
611
|
-
error:
|
|
612
|
-
helperText:
|
|
613
|
-
FormHelperTextProps:
|
|
618
|
+
error: pe && W.trim() === "",
|
|
619
|
+
helperText: pe && W.trim() === "" ? l("text.variables.defaultRequired") : " ",
|
|
620
|
+
FormHelperTextProps: ve
|
|
614
621
|
}
|
|
615
622
|
),
|
|
616
623
|
/* @__PURE__ */ o(
|
|
617
|
-
|
|
624
|
+
Ie,
|
|
618
625
|
{
|
|
619
626
|
fullWidth: !0,
|
|
620
627
|
size: "small",
|
|
@@ -632,8 +639,8 @@ function Or({
|
|
|
632
639
|
}
|
|
633
640
|
)
|
|
634
641
|
] }),
|
|
635
|
-
e.items.length > 0 && /* @__PURE__ */ o(
|
|
636
|
-
|
|
642
|
+
e.items.length > 0 && /* @__PURE__ */ o(b, { sx: { display: "grid", gap: 0.75 }, children: e.items.map((r) => /* @__PURE__ */ o(
|
|
643
|
+
Ie,
|
|
637
644
|
{
|
|
638
645
|
size: "small",
|
|
639
646
|
variant: "outlined",
|
|
@@ -644,10 +651,10 @@ function Or({
|
|
|
644
651
|
color: "text.secondary",
|
|
645
652
|
textTransform: "none"
|
|
646
653
|
},
|
|
647
|
-
children: /* @__PURE__ */ f(
|
|
648
|
-
/* @__PURE__ */ o(
|
|
654
|
+
children: /* @__PURE__ */ f(b, { sx: { textAlign: "left", minWidth: 0 }, children: [
|
|
655
|
+
/* @__PURE__ */ o(A, { component: "div", variant: "body2", color: "text.primary", children: e.id === "custom" ? r.name : l(r.labelKey) }),
|
|
649
656
|
/* @__PURE__ */ o(
|
|
650
|
-
|
|
657
|
+
A,
|
|
651
658
|
{
|
|
652
659
|
component: "div",
|
|
653
660
|
variant: "caption",
|
|
@@ -667,10 +674,10 @@ function Or({
|
|
|
667
674
|
);
|
|
668
675
|
}) }),
|
|
669
676
|
/* @__PURE__ */ o(sr, { sx: { my: 2 } }),
|
|
670
|
-
/* @__PURE__ */ o(
|
|
671
|
-
/* @__PURE__ */ o(
|
|
672
|
-
|
|
673
|
-
|
|
677
|
+
/* @__PURE__ */ o(A, { component: "div", ref: ke, variant: "subtitle2", sx: { mb: 0.5 }, children: l("htmlEditor.variables.detected") }),
|
|
678
|
+
/* @__PURE__ */ o(A, { component: "div", variant: "caption", color: "text.secondary", sx: { display: "block", mb: 1 }, children: l("htmlEditor.variables.defaultHelp") }),
|
|
679
|
+
ce.length === 0 ? /* @__PURE__ */ o(
|
|
680
|
+
b,
|
|
674
681
|
{
|
|
675
682
|
sx: {
|
|
676
683
|
border: "1px dashed",
|
|
@@ -683,10 +690,10 @@ function Or({
|
|
|
683
690
|
},
|
|
684
691
|
children: l("htmlEditor.variables.empty")
|
|
685
692
|
}
|
|
686
|
-
) : /* @__PURE__ */ o(
|
|
687
|
-
const r = gt && e.type === "user" && e.default.trim() === "",
|
|
693
|
+
) : /* @__PURE__ */ o(b, { sx: { display: "grid", gap: 0.25 }, children: ce.map((e, t) => {
|
|
694
|
+
const r = gt && e.type === "user" && e.default.trim() === "", u = ce.filter((m) => m.type === e.type && m.attribute === e.attribute).length, v = ce.slice(0, t + 1).filter((m) => m.type === e.type && m.attribute === e.attribute).length;
|
|
688
695
|
return /* @__PURE__ */ f(
|
|
689
|
-
|
|
696
|
+
b,
|
|
690
697
|
{
|
|
691
698
|
sx: {
|
|
692
699
|
display: "grid",
|
|
@@ -699,16 +706,16 @@ function Or({
|
|
|
699
706
|
borderColor: r ? "error.main" : "transparent",
|
|
700
707
|
borderRadius: 1,
|
|
701
708
|
borderBottomColor: r ? "error.main" : "divider",
|
|
702
|
-
backgroundColor: r ?
|
|
709
|
+
backgroundColor: r ? de(C.palette.error.main, 0.04) : "transparent",
|
|
703
710
|
transition: "background-color 120ms ease, border-color 120ms ease",
|
|
704
711
|
"&:hover": {
|
|
705
|
-
backgroundColor: r ?
|
|
712
|
+
backgroundColor: r ? de(C.palette.error.main, 0.04) : "action.hover",
|
|
706
713
|
borderColor: r ? "error.main" : "divider"
|
|
707
714
|
}
|
|
708
715
|
},
|
|
709
716
|
children: [
|
|
710
717
|
/* @__PURE__ */ o(
|
|
711
|
-
|
|
718
|
+
A,
|
|
712
719
|
{
|
|
713
720
|
component: "div",
|
|
714
721
|
variant: "body2",
|
|
@@ -719,11 +726,11 @@ function Or({
|
|
|
719
726
|
wordBreak: "break-all",
|
|
720
727
|
color: r ? "error.main" : "text.primary"
|
|
721
728
|
},
|
|
722
|
-
children:
|
|
729
|
+
children: u > 1 ? `${e.variable} (${v})` : e.variable
|
|
723
730
|
}
|
|
724
731
|
),
|
|
725
732
|
/* @__PURE__ */ o(
|
|
726
|
-
|
|
733
|
+
Ee,
|
|
727
734
|
{
|
|
728
735
|
size: "small",
|
|
729
736
|
fullWidth: !0,
|
|
@@ -733,8 +740,8 @@ function Or({
|
|
|
733
740
|
placeholder: e.type === "system" ? l("htmlEditor.variables.systemDefault") : l("text.variables.defaultPlaceholder"),
|
|
734
741
|
error: r,
|
|
735
742
|
helperText: r ? l("text.variables.defaultRequired") : void 0,
|
|
736
|
-
FormHelperTextProps:
|
|
737
|
-
onChange: (
|
|
743
|
+
FormHelperTextProps: ve,
|
|
744
|
+
onChange: (m) => wt(e.variableInstanceId, m.target.value),
|
|
738
745
|
sx: {
|
|
739
746
|
"& .MuiInputBase-input": {
|
|
740
747
|
py: 0.75,
|
|
@@ -750,11 +757,11 @@ function Or({
|
|
|
750
757
|
}) })
|
|
751
758
|
]
|
|
752
759
|
}
|
|
753
|
-
), Fe = () => /* @__PURE__ */ f(
|
|
760
|
+
), Fe = () => /* @__PURE__ */ f(b, { sx: { height: i, minHeight: 0, display: "flex", flexDirection: "column" }, children: [
|
|
754
761
|
/* @__PURE__ */ f(
|
|
755
|
-
|
|
762
|
+
nr,
|
|
756
763
|
{
|
|
757
|
-
value:
|
|
764
|
+
value: te,
|
|
758
765
|
onChange: (e, t) => P(t),
|
|
759
766
|
sx: {
|
|
760
767
|
minHeight: 40,
|
|
@@ -772,10 +779,10 @@ function Or({
|
|
|
772
779
|
]
|
|
773
780
|
}
|
|
774
781
|
),
|
|
775
|
-
/* @__PURE__ */ o(
|
|
782
|
+
/* @__PURE__ */ o(b, { sx: { flex: 1, minHeight: 0, overflow: "hidden", display: "flex", flexDirection: "column" }, children: te === "preview" ? Bt() : At() })
|
|
776
783
|
] });
|
|
777
784
|
return /* @__PURE__ */ f(
|
|
778
|
-
|
|
785
|
+
b,
|
|
779
786
|
{
|
|
780
787
|
sx: {
|
|
781
788
|
display: "flex",
|
|
@@ -784,11 +791,11 @@ function Or({
|
|
|
784
791
|
width: "100%",
|
|
785
792
|
minHeight: 0,
|
|
786
793
|
minWidth: 0,
|
|
787
|
-
...
|
|
794
|
+
...h
|
|
788
795
|
},
|
|
789
796
|
children: [
|
|
790
797
|
p && /* @__PURE__ */ f(
|
|
791
|
-
|
|
798
|
+
b,
|
|
792
799
|
{
|
|
793
800
|
sx: {
|
|
794
801
|
display: "flex",
|
|
@@ -800,7 +807,7 @@ function Or({
|
|
|
800
807
|
backgroundColor: "background.paper"
|
|
801
808
|
},
|
|
802
809
|
children: [
|
|
803
|
-
/* @__PURE__ */ f(
|
|
810
|
+
/* @__PURE__ */ f(b, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
804
811
|
/* @__PURE__ */ f(
|
|
805
812
|
et,
|
|
806
813
|
{
|
|
@@ -810,7 +817,7 @@ function Or({
|
|
|
810
817
|
size: "small",
|
|
811
818
|
"aria-label": l("htmlEditor.mode.split"),
|
|
812
819
|
children: [
|
|
813
|
-
/* @__PURE__ */ o(
|
|
820
|
+
/* @__PURE__ */ o(U, { title: l("htmlEditor.tooltips.splitView"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(
|
|
814
821
|
Q,
|
|
815
822
|
{
|
|
816
823
|
value: "split",
|
|
@@ -818,7 +825,7 @@ function Or({
|
|
|
818
825
|
children: /* @__PURE__ */ o(Br, { fontSize: "small" })
|
|
819
826
|
}
|
|
820
827
|
) }),
|
|
821
|
-
/* @__PURE__ */ o(
|
|
828
|
+
/* @__PURE__ */ o(U, { title: l("htmlEditor.tooltips.codeOnly"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(
|
|
822
829
|
Q,
|
|
823
830
|
{
|
|
824
831
|
value: "code",
|
|
@@ -826,7 +833,7 @@ function Or({
|
|
|
826
833
|
children: /* @__PURE__ */ o(Sr, { fontSize: "small" })
|
|
827
834
|
}
|
|
828
835
|
) }),
|
|
829
|
-
/* @__PURE__ */ o(
|
|
836
|
+
/* @__PURE__ */ o(U, { title: l("htmlEditor.tooltips.previewOnly"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(
|
|
830
837
|
Q,
|
|
831
838
|
{
|
|
832
839
|
value: "preview",
|
|
@@ -844,7 +851,7 @@ function Or({
|
|
|
844
851
|
{
|
|
845
852
|
labelId: "theme-select-label",
|
|
846
853
|
id: "theme-select",
|
|
847
|
-
value:
|
|
854
|
+
value: Se,
|
|
848
855
|
label: l("htmlEditor.theme"),
|
|
849
856
|
onChange: (e) => {
|
|
850
857
|
const t = e.target.value;
|
|
@@ -866,7 +873,7 @@ function Or({
|
|
|
866
873
|
)
|
|
867
874
|
] })
|
|
868
875
|
] }),
|
|
869
|
-
/* @__PURE__ */ o(
|
|
876
|
+
/* @__PURE__ */ o(b, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: S !== "code" && /* @__PURE__ */ f(
|
|
870
877
|
et,
|
|
871
878
|
{
|
|
872
879
|
value: Lt,
|
|
@@ -875,7 +882,7 @@ function Or({
|
|
|
875
882
|
size: "small",
|
|
876
883
|
"aria-label": l("htmlEditor.device.desktop"),
|
|
877
884
|
children: [
|
|
878
|
-
/* @__PURE__ */ o(
|
|
885
|
+
/* @__PURE__ */ o(U, { title: l("htmlEditor.tooltips.desktopView"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(
|
|
879
886
|
Q,
|
|
880
887
|
{
|
|
881
888
|
value: "desktop",
|
|
@@ -883,7 +890,7 @@ function Or({
|
|
|
883
890
|
children: /* @__PURE__ */ o(Ar, { fontSize: "small" })
|
|
884
891
|
}
|
|
885
892
|
) }),
|
|
886
|
-
/* @__PURE__ */ o(
|
|
893
|
+
/* @__PURE__ */ o(U, { title: l("htmlEditor.tooltips.mobileView"), arrow: !0, slotProps: j, children: /* @__PURE__ */ o(
|
|
887
894
|
Q,
|
|
888
895
|
{
|
|
889
896
|
value: "mobile",
|
|
@@ -898,7 +905,7 @@ function Or({
|
|
|
898
905
|
}
|
|
899
906
|
),
|
|
900
907
|
/* @__PURE__ */ f(
|
|
901
|
-
|
|
908
|
+
b,
|
|
902
909
|
{
|
|
903
910
|
sx: {
|
|
904
911
|
flex: 1,
|
|
@@ -908,12 +915,12 @@ function Or({
|
|
|
908
915
|
overflow: "hidden"
|
|
909
916
|
},
|
|
910
917
|
children: [
|
|
911
|
-
|
|
912
|
-
/* @__PURE__ */ o(
|
|
913
|
-
/* @__PURE__ */ o(
|
|
918
|
+
S === "split" && /* @__PURE__ */ f(Nt, { children: [
|
|
919
|
+
/* @__PURE__ */ o(b, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Ae() }),
|
|
920
|
+
/* @__PURE__ */ o(b, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Fe() })
|
|
914
921
|
] }),
|
|
915
|
-
|
|
916
|
-
|
|
922
|
+
S === "code" && /* @__PURE__ */ o(b, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Ae() }),
|
|
923
|
+
S === "preview" && /* @__PURE__ */ o(b, { sx: { flex: 1, minHeight: 0, minWidth: 0, overflow: "hidden" }, children: Fe() })
|
|
917
924
|
]
|
|
918
925
|
}
|
|
919
926
|
)
|
|
@@ -923,7 +930,7 @@ function Or({
|
|
|
923
930
|
}
|
|
924
931
|
const bt = dt(Or);
|
|
925
932
|
bt.displayName = "HtmlEditorContent";
|
|
926
|
-
const Pr = dt((
|
|
933
|
+
const Pr = dt((n, a) => /* @__PURE__ */ o(Qt, { theme: vr, children: /* @__PURE__ */ o(
|
|
927
934
|
Zt,
|
|
928
935
|
{
|
|
929
936
|
sx: {
|
|
@@ -934,7 +941,7 @@ const Pr = dt((a, n) => /* @__PURE__ */ o(Qt, { theme: vr, children: /* @__PURE_
|
|
|
934
941
|
display: "flex",
|
|
935
942
|
flexDirection: "column"
|
|
936
943
|
},
|
|
937
|
-
children: /* @__PURE__ */ o(bt, { ref:
|
|
944
|
+
children: /* @__PURE__ */ o(bt, { ref: a, ...n })
|
|
938
945
|
}
|
|
939
946
|
) }));
|
|
940
947
|
Pr.displayName = "HtmlEditor";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monto-email-builder",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "A powerful and customizable email template builder React component library with visual editing, internationalization, and image upload support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|