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