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