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