@react-email/editor 0.0.0-experimental.8 → 1.0.0
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/columns-BItFgD76.mjs +273 -0
- package/dist/columns-BItFgD76.mjs.map +1 -0
- package/dist/columns-DqFvXgmK.cjs +394 -0
- package/dist/core/index.cjs +10 -0
- package/dist/core/index.d.cts +2 -0
- package/dist/core/index.d.mts +2 -0
- package/dist/core/index.mjs +4 -0
- package/dist/core-CbSTyrV4.mjs +151 -0
- package/dist/core-CbSTyrV4.mjs.map +1 -0
- package/dist/core-D7AzzMLI.cjs +167 -0
- package/dist/email-node-B-_g4X-S.mjs +254 -0
- package/dist/email-node-B-_g4X-S.mjs.map +1 -0
- package/dist/email-node-hLU5bGnX.cjs +288 -0
- package/dist/event-bus-CIJ___tH.cjs +65 -0
- package/dist/event-bus-CqrIUE24.mjs +55 -0
- package/dist/event-bus-CqrIUE24.mjs.map +1 -0
- package/dist/extension-BbjpP9mF.cjs +1625 -0
- package/dist/extension-C5qNDPZL.mjs +154 -0
- package/dist/extension-C5qNDPZL.mjs.map +1 -0
- package/dist/extension-Cs4Yq2gF.cjs +158 -0
- package/dist/extension-DlWknmE5.mjs +1495 -0
- package/dist/extension-DlWknmE5.mjs.map +1 -0
- package/dist/extensions/index.cjs +50 -0
- package/dist/extensions/index.d.cts +392 -0
- package/dist/extensions/index.d.cts.map +1 -0
- package/dist/extensions/index.d.mts +392 -0
- package/dist/extensions/index.d.mts.map +1 -0
- package/dist/extensions/index.mjs +4 -0
- package/dist/extensions-CHIQO3d-.mjs +1745 -0
- package/dist/extensions-CHIQO3d-.mjs.map +1 -0
- package/dist/extensions-DCrDvZ42.cjs +1981 -0
- package/dist/global-content-0-J-Te3N.mjs +77 -0
- package/dist/global-content-0-J-Te3N.mjs.map +1 -0
- package/dist/global-content-8M2KyrOL.cjs +87 -0
- package/dist/image-KwEYzhji.cjs +41 -0
- package/dist/image-Oc789YjV.mjs +37 -0
- package/dist/image-Oc789YjV.mjs.map +1 -0
- package/dist/index-CHAPu71g.d.cts +193 -0
- package/dist/index-CHAPu71g.d.cts.map +1 -0
- package/dist/index-D4UEWmJX.d.mts +193 -0
- package/dist/index-D4UEWmJX.d.mts.map +1 -0
- package/dist/index.cjs +216 -0
- package/dist/index.d.cts +38 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +33 -623
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +189 -2349
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/index.cjs +56 -0
- package/dist/plugins/index.d.cts +114 -0
- package/dist/plugins/index.d.cts.map +1 -0
- package/dist/plugins/index.d.mts +114 -0
- package/dist/plugins/index.d.mts.map +1 -0
- package/dist/plugins/index.mjs +34 -0
- package/dist/plugins/index.mjs.map +1 -0
- package/dist/root-CT5d4CKj.cjs +2798 -0
- package/dist/root-uvdshbyT.mjs +2295 -0
- package/dist/root-uvdshbyT.mjs.map +1 -0
- package/dist/set-text-alignment-BCRnE5So.mjs +19 -0
- package/dist/set-text-alignment-BCRnE5So.mjs.map +1 -0
- package/dist/set-text-alignment-Twg1EG4-.cjs +22 -0
- package/dist/style.css +974 -0
- package/dist/types-BG5XsXt9.d.mts +37 -0
- package/dist/types-BG5XsXt9.d.mts.map +1 -0
- package/dist/types-DnOcnDoO.d.mts +56 -0
- package/dist/types-DnOcnDoO.d.mts.map +1 -0
- package/dist/types-DzPTbbDC.d.cts +56 -0
- package/dist/types-DzPTbbDC.d.cts.map +1 -0
- package/dist/types-hURXpEIO.d.cts +37 -0
- package/dist/types-hURXpEIO.d.cts.map +1 -0
- package/dist/ui/bubble-menu/bubble-menu.css +291 -0
- package/dist/ui/index.cjs +2899 -0
- package/dist/ui/index.d.cts +1155 -0
- package/dist/ui/index.d.cts.map +1 -0
- package/dist/ui/index.d.mts +1157 -0
- package/dist/ui/index.d.mts.map +1 -0
- package/dist/ui/index.mjs +2788 -0
- package/dist/ui/index.mjs.map +1 -0
- package/dist/ui/inspector/inspector.css +293 -0
- package/dist/ui/slash-command/slash-command.css +44 -0
- package/dist/ui/themes/default.css +1140 -0
- package/dist/utils/index.cjs +3 -0
- package/dist/utils/index.d.cts +7 -0
- package/dist/utils/index.d.cts.map +1 -0
- package/dist/utils/index.d.mts +7 -0
- package/dist/utils/index.d.mts.map +1 -0
- package/dist/utils/index.mjs +2 -0
- package/package.json +100 -16
- package/readme.md +69 -0
- package/dist/index.d.ts +0 -628
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2461
|
@@ -0,0 +1,1625 @@
|
|
|
1
|
+
require("./columns-DqFvXgmK.cjs");
|
|
2
|
+
const require_email_node = require("./email-node-hLU5bGnX.cjs");
|
|
3
|
+
const require_global_content = require("./global-content-8M2KyrOL.cjs");
|
|
4
|
+
let _tiptap_react = require("@tiptap/react");
|
|
5
|
+
let react_email = require("react-email");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _tiptap_core = require("@tiptap/core");
|
|
8
|
+
let _tiptap_pm_state = require("@tiptap/pm/state");
|
|
9
|
+
//#region src/plugins/email-theming/css-transforms.ts
|
|
10
|
+
function transformToCssJs(styleArray, baseFontSize) {
|
|
11
|
+
const cssJS = {};
|
|
12
|
+
if (!Array.isArray(styleArray)) return cssJS;
|
|
13
|
+
for (const style of styleArray) for (const input of style.inputs) {
|
|
14
|
+
let value = input.value;
|
|
15
|
+
if (input.unit && typeof value === "number") if (input.prop === "fontSize") value = `${value / baseFontSize}em`;
|
|
16
|
+
else value = `${value}${input.unit}`;
|
|
17
|
+
if (!input.classReference) continue;
|
|
18
|
+
if (!cssJS[input.classReference]) cssJS[input.classReference] = {};
|
|
19
|
+
if (input.prop === "h-padding") {
|
|
20
|
+
cssJS[input.classReference].paddingLeft = value;
|
|
21
|
+
cssJS[input.classReference].paddingRight = value;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
cssJS[input.classReference][input.prop] = value;
|
|
25
|
+
}
|
|
26
|
+
for (const key of Object.keys(cssJS)) require_email_node.ensureBorderStyleFallback(cssJS[key]);
|
|
27
|
+
return cssJS;
|
|
28
|
+
}
|
|
29
|
+
function mergeCssJs(original, newCssJs) {
|
|
30
|
+
const merged = { ...original };
|
|
31
|
+
for (const key in newCssJs) {
|
|
32
|
+
const keyType = key;
|
|
33
|
+
if (Object.hasOwn(merged, key) && typeof merged[keyType] === "object" && !Array.isArray(merged[keyType])) merged[keyType] = {
|
|
34
|
+
...merged[keyType],
|
|
35
|
+
...newCssJs[keyType]
|
|
36
|
+
};
|
|
37
|
+
else merged[keyType] = newCssJs[keyType];
|
|
38
|
+
}
|
|
39
|
+
return merged;
|
|
40
|
+
}
|
|
41
|
+
function injectThemeCss(styles, options = {}) {
|
|
42
|
+
const container = options.scopeSelector ?? ".tiptap-extended .tiptap.ProseMirror";
|
|
43
|
+
const prefix = ".node-";
|
|
44
|
+
const styleId = options.styleId ?? "tiptap-extended-theme-css";
|
|
45
|
+
const css = Object.entries(styles).reduce((acc, [key, value]) => {
|
|
46
|
+
return `${acc}${key === "body" ? container : `${container} ${prefix}${key}`}{${Object.entries(value).reduce((acc, [prop, val]) => {
|
|
47
|
+
const normalizeProp = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
48
|
+
if (val === void 0) return acc;
|
|
49
|
+
return `${acc}${normalizeProp}:${val};`;
|
|
50
|
+
}, "")}}`;
|
|
51
|
+
}, "");
|
|
52
|
+
let styleTag = document.getElementById(styleId);
|
|
53
|
+
if (!styleTag) {
|
|
54
|
+
styleTag = document.createElement("style");
|
|
55
|
+
styleTag.textContent = css;
|
|
56
|
+
styleTag.id = styleId;
|
|
57
|
+
document.head.appendChild(styleTag);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
styleTag.textContent = css;
|
|
61
|
+
}
|
|
62
|
+
function injectGlobalPlainCss(css, options = {}) {
|
|
63
|
+
if (!css) return;
|
|
64
|
+
const styleId = options.styleId ?? "global-editor-style";
|
|
65
|
+
const container = options.scopeSelector ?? ".tiptap-extended .ProseMirror";
|
|
66
|
+
let styleElement = document.getElementById(styleId);
|
|
67
|
+
if (!styleElement) {
|
|
68
|
+
styleElement = document.createElement("style");
|
|
69
|
+
styleElement.id = styleId;
|
|
70
|
+
document.head.appendChild(styleElement);
|
|
71
|
+
}
|
|
72
|
+
const cleanedCSS = css.replace(/@media\s?\(prefers-color-scheme:\s?dark\)\s?{([\s\S]+?})\s*}/g, "");
|
|
73
|
+
styleElement.textContent = `${container} { ${cleanedCSS} }`;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/plugins/email-theming/themes.ts
|
|
77
|
+
/**
|
|
78
|
+
* Single source of truth for panel section display titles.
|
|
79
|
+
* Titles are resolved from here at render time via `getPanelTitle`,
|
|
80
|
+
* so they never depend on what's persisted in the DB.
|
|
81
|
+
*/
|
|
82
|
+
const PANEL_SECTION_TITLES = {
|
|
83
|
+
body: "Background",
|
|
84
|
+
container: "Body",
|
|
85
|
+
typography: "Text",
|
|
86
|
+
h1: "Title",
|
|
87
|
+
h2: "Subtitle",
|
|
88
|
+
h3: "Heading",
|
|
89
|
+
link: "Link",
|
|
90
|
+
image: "Image",
|
|
91
|
+
button: "Button",
|
|
92
|
+
"code-block": "Code Block",
|
|
93
|
+
"inline-code": "Inline Code"
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Resolves the display title for a panel group.
|
|
97
|
+
* Uses the `id` lookup when available, falls back to the
|
|
98
|
+
* DB-persisted `title` for backwards compatibility.
|
|
99
|
+
*/
|
|
100
|
+
function getPanelTitle(group) {
|
|
101
|
+
if (group.id && group.id in PANEL_SECTION_TITLES) return PANEL_SECTION_TITLES[group.id];
|
|
102
|
+
return group.title;
|
|
103
|
+
}
|
|
104
|
+
const THEME_BASIC = [
|
|
105
|
+
{
|
|
106
|
+
id: "body",
|
|
107
|
+
title: "Background",
|
|
108
|
+
classReference: "body",
|
|
109
|
+
inputs: [
|
|
110
|
+
{
|
|
111
|
+
label: "Background",
|
|
112
|
+
type: "color",
|
|
113
|
+
value: "#ffffff",
|
|
114
|
+
prop: "backgroundColor",
|
|
115
|
+
classReference: "body"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
label: "Padding Top",
|
|
119
|
+
type: "number",
|
|
120
|
+
value: void 0,
|
|
121
|
+
unit: "px",
|
|
122
|
+
prop: "paddingTop",
|
|
123
|
+
classReference: "body"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
label: "Padding Right",
|
|
127
|
+
type: "number",
|
|
128
|
+
value: void 0,
|
|
129
|
+
unit: "px",
|
|
130
|
+
prop: "paddingRight",
|
|
131
|
+
classReference: "body"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
label: "Padding Bottom",
|
|
135
|
+
type: "number",
|
|
136
|
+
value: void 0,
|
|
137
|
+
unit: "px",
|
|
138
|
+
prop: "paddingBottom",
|
|
139
|
+
classReference: "body"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
label: "Padding Left",
|
|
143
|
+
type: "number",
|
|
144
|
+
value: void 0,
|
|
145
|
+
unit: "px",
|
|
146
|
+
prop: "paddingLeft",
|
|
147
|
+
classReference: "body"
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: "container",
|
|
153
|
+
title: "Content",
|
|
154
|
+
classReference: "container",
|
|
155
|
+
inputs: [
|
|
156
|
+
{
|
|
157
|
+
label: "Align",
|
|
158
|
+
type: "select",
|
|
159
|
+
value: "left",
|
|
160
|
+
options: {
|
|
161
|
+
left: "Left",
|
|
162
|
+
center: "Center",
|
|
163
|
+
right: "Right"
|
|
164
|
+
},
|
|
165
|
+
prop: "align",
|
|
166
|
+
classReference: "container"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
label: "Width",
|
|
170
|
+
type: "number",
|
|
171
|
+
value: 600,
|
|
172
|
+
unit: "px",
|
|
173
|
+
prop: "width",
|
|
174
|
+
classReference: "container"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
label: "Height",
|
|
178
|
+
type: "number",
|
|
179
|
+
unit: "px",
|
|
180
|
+
prop: "height",
|
|
181
|
+
classReference: "container"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
label: "Text",
|
|
185
|
+
type: "color",
|
|
186
|
+
value: "#000000",
|
|
187
|
+
prop: "color",
|
|
188
|
+
classReference: "container"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
label: "Background",
|
|
192
|
+
type: "color",
|
|
193
|
+
value: "#ffffff",
|
|
194
|
+
prop: "backgroundColor",
|
|
195
|
+
classReference: "container"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
label: "Padding Top",
|
|
199
|
+
type: "number",
|
|
200
|
+
value: 0,
|
|
201
|
+
unit: "px",
|
|
202
|
+
prop: "paddingTop",
|
|
203
|
+
classReference: "container"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
label: "Padding Right",
|
|
207
|
+
type: "number",
|
|
208
|
+
value: 0,
|
|
209
|
+
unit: "px",
|
|
210
|
+
prop: "paddingRight",
|
|
211
|
+
classReference: "container"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
label: "Padding Bottom",
|
|
215
|
+
type: "number",
|
|
216
|
+
value: 0,
|
|
217
|
+
unit: "px",
|
|
218
|
+
prop: "paddingBottom",
|
|
219
|
+
classReference: "container"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
label: "Padding Left",
|
|
223
|
+
type: "number",
|
|
224
|
+
value: 0,
|
|
225
|
+
unit: "px",
|
|
226
|
+
prop: "paddingLeft",
|
|
227
|
+
classReference: "container"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
label: "Corner radius",
|
|
231
|
+
type: "number",
|
|
232
|
+
value: 0,
|
|
233
|
+
unit: "px",
|
|
234
|
+
prop: "borderRadius",
|
|
235
|
+
classReference: "container"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
label: "Border color",
|
|
239
|
+
type: "color",
|
|
240
|
+
value: "#000000",
|
|
241
|
+
prop: "borderColor",
|
|
242
|
+
classReference: "container"
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
id: "typography",
|
|
248
|
+
title: "Text",
|
|
249
|
+
classReference: "body",
|
|
250
|
+
inputs: [{
|
|
251
|
+
label: "Font size",
|
|
252
|
+
type: "number",
|
|
253
|
+
value: 14,
|
|
254
|
+
unit: "px",
|
|
255
|
+
prop: "fontSize",
|
|
256
|
+
classReference: "body"
|
|
257
|
+
}, {
|
|
258
|
+
label: "Line Height",
|
|
259
|
+
type: "number",
|
|
260
|
+
value: 155,
|
|
261
|
+
unit: "%",
|
|
262
|
+
prop: "lineHeight",
|
|
263
|
+
classReference: "container"
|
|
264
|
+
}]
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
id: "h1",
|
|
268
|
+
title: "Title",
|
|
269
|
+
category: "Text",
|
|
270
|
+
classReference: "h1",
|
|
271
|
+
inputs: []
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
id: "h2",
|
|
275
|
+
title: "Subtitle",
|
|
276
|
+
category: "Text",
|
|
277
|
+
classReference: "h2",
|
|
278
|
+
inputs: []
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
id: "h3",
|
|
282
|
+
title: "Heading",
|
|
283
|
+
category: "Text",
|
|
284
|
+
classReference: "h3",
|
|
285
|
+
inputs: []
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
id: "link",
|
|
289
|
+
title: "Link",
|
|
290
|
+
classReference: "link",
|
|
291
|
+
inputs: [{
|
|
292
|
+
label: "Color",
|
|
293
|
+
type: "color",
|
|
294
|
+
value: "#0670DB",
|
|
295
|
+
prop: "color",
|
|
296
|
+
classReference: "link"
|
|
297
|
+
}, {
|
|
298
|
+
label: "Decoration",
|
|
299
|
+
type: "select",
|
|
300
|
+
value: "underline",
|
|
301
|
+
prop: "textDecoration",
|
|
302
|
+
options: {
|
|
303
|
+
underline: "Underline",
|
|
304
|
+
none: "None"
|
|
305
|
+
},
|
|
306
|
+
classReference: "link"
|
|
307
|
+
}]
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
id: "image",
|
|
311
|
+
title: "Image",
|
|
312
|
+
classReference: "image",
|
|
313
|
+
inputs: [{
|
|
314
|
+
label: "Border radius",
|
|
315
|
+
type: "number",
|
|
316
|
+
value: 8,
|
|
317
|
+
unit: "px",
|
|
318
|
+
prop: "borderRadius",
|
|
319
|
+
classReference: "image"
|
|
320
|
+
}]
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
id: "button",
|
|
324
|
+
title: "Button",
|
|
325
|
+
classReference: "button",
|
|
326
|
+
inputs: [
|
|
327
|
+
{
|
|
328
|
+
label: "Background",
|
|
329
|
+
type: "color",
|
|
330
|
+
value: "#000000",
|
|
331
|
+
prop: "backgroundColor",
|
|
332
|
+
classReference: "button"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
label: "Text color",
|
|
336
|
+
type: "color",
|
|
337
|
+
value: "#ffffff",
|
|
338
|
+
prop: "color",
|
|
339
|
+
classReference: "button"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
label: "Radius",
|
|
343
|
+
type: "number",
|
|
344
|
+
value: 4,
|
|
345
|
+
unit: "px",
|
|
346
|
+
prop: "borderRadius",
|
|
347
|
+
classReference: "button"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
label: "Padding Top",
|
|
351
|
+
type: "number",
|
|
352
|
+
value: 7,
|
|
353
|
+
unit: "px",
|
|
354
|
+
prop: "paddingTop",
|
|
355
|
+
classReference: "button"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
label: "Padding Right",
|
|
359
|
+
type: "number",
|
|
360
|
+
value: 12,
|
|
361
|
+
unit: "px",
|
|
362
|
+
prop: "paddingRight",
|
|
363
|
+
classReference: "button"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
label: "Padding Bottom",
|
|
367
|
+
type: "number",
|
|
368
|
+
value: 7,
|
|
369
|
+
unit: "px",
|
|
370
|
+
prop: "paddingBottom",
|
|
371
|
+
classReference: "button"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
label: "Padding Left",
|
|
375
|
+
type: "number",
|
|
376
|
+
value: 12,
|
|
377
|
+
unit: "px",
|
|
378
|
+
prop: "paddingLeft",
|
|
379
|
+
classReference: "button"
|
|
380
|
+
}
|
|
381
|
+
]
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
id: "code-block",
|
|
385
|
+
title: "Code Block",
|
|
386
|
+
classReference: "codeBlock",
|
|
387
|
+
inputs: [
|
|
388
|
+
{
|
|
389
|
+
label: "Border Radius",
|
|
390
|
+
type: "number",
|
|
391
|
+
value: 4,
|
|
392
|
+
unit: "px",
|
|
393
|
+
prop: "borderRadius",
|
|
394
|
+
classReference: "codeBlock"
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
label: "Padding Top",
|
|
398
|
+
type: "number",
|
|
399
|
+
value: 12,
|
|
400
|
+
unit: "px",
|
|
401
|
+
prop: "paddingTop",
|
|
402
|
+
classReference: "codeBlock"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
label: "Padding Bottom",
|
|
406
|
+
type: "number",
|
|
407
|
+
value: 12,
|
|
408
|
+
unit: "px",
|
|
409
|
+
prop: "paddingBottom",
|
|
410
|
+
classReference: "codeBlock"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
label: "Padding Left",
|
|
414
|
+
type: "number",
|
|
415
|
+
value: 16,
|
|
416
|
+
unit: "px",
|
|
417
|
+
prop: "paddingLeft",
|
|
418
|
+
classReference: "codeBlock"
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
label: "Padding Right",
|
|
422
|
+
type: "number",
|
|
423
|
+
value: 16,
|
|
424
|
+
unit: "px",
|
|
425
|
+
prop: "paddingRight",
|
|
426
|
+
classReference: "codeBlock"
|
|
427
|
+
}
|
|
428
|
+
]
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
id: "inline-code",
|
|
432
|
+
title: "Inline Code",
|
|
433
|
+
classReference: "inlineCode",
|
|
434
|
+
inputs: [
|
|
435
|
+
{
|
|
436
|
+
label: "Background",
|
|
437
|
+
type: "color",
|
|
438
|
+
value: "#e5e7eb",
|
|
439
|
+
prop: "backgroundColor",
|
|
440
|
+
classReference: "inlineCode"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
label: "Text color",
|
|
444
|
+
type: "color",
|
|
445
|
+
value: "#1e293b",
|
|
446
|
+
prop: "color",
|
|
447
|
+
classReference: "inlineCode"
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
label: "Radius",
|
|
451
|
+
type: "number",
|
|
452
|
+
value: 4,
|
|
453
|
+
unit: "px",
|
|
454
|
+
prop: "borderRadius",
|
|
455
|
+
classReference: "inlineCode"
|
|
456
|
+
}
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
];
|
|
460
|
+
const THEME_MINIMAL = [
|
|
461
|
+
{
|
|
462
|
+
id: "body",
|
|
463
|
+
title: "Background",
|
|
464
|
+
classReference: "body",
|
|
465
|
+
inputs: [
|
|
466
|
+
{
|
|
467
|
+
label: "Background",
|
|
468
|
+
type: "color",
|
|
469
|
+
value: "#ffffff",
|
|
470
|
+
prop: "backgroundColor",
|
|
471
|
+
classReference: "body"
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
label: "Padding Top",
|
|
475
|
+
type: "number",
|
|
476
|
+
value: void 0,
|
|
477
|
+
unit: "px",
|
|
478
|
+
prop: "paddingTop",
|
|
479
|
+
classReference: "body"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
label: "Padding Right",
|
|
483
|
+
type: "number",
|
|
484
|
+
value: void 0,
|
|
485
|
+
unit: "px",
|
|
486
|
+
prop: "paddingRight",
|
|
487
|
+
classReference: "body"
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
label: "Padding Bottom",
|
|
491
|
+
type: "number",
|
|
492
|
+
value: void 0,
|
|
493
|
+
unit: "px",
|
|
494
|
+
prop: "paddingBottom",
|
|
495
|
+
classReference: "body"
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
label: "Padding Left",
|
|
499
|
+
type: "number",
|
|
500
|
+
value: void 0,
|
|
501
|
+
unit: "px",
|
|
502
|
+
prop: "paddingLeft",
|
|
503
|
+
classReference: "body"
|
|
504
|
+
}
|
|
505
|
+
]
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
id: "container",
|
|
509
|
+
title: "Content",
|
|
510
|
+
classReference: "container",
|
|
511
|
+
inputs: [
|
|
512
|
+
{
|
|
513
|
+
label: "Align",
|
|
514
|
+
type: "select",
|
|
515
|
+
value: "left",
|
|
516
|
+
options: {
|
|
517
|
+
left: "Left",
|
|
518
|
+
center: "Center",
|
|
519
|
+
right: "Right"
|
|
520
|
+
},
|
|
521
|
+
prop: "align",
|
|
522
|
+
classReference: "container"
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
label: "Width",
|
|
526
|
+
type: "number",
|
|
527
|
+
value: 600,
|
|
528
|
+
unit: "px",
|
|
529
|
+
prop: "width",
|
|
530
|
+
classReference: "container"
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
label: "Height",
|
|
534
|
+
type: "number",
|
|
535
|
+
unit: "px",
|
|
536
|
+
prop: "height",
|
|
537
|
+
classReference: "container"
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
label: "Text",
|
|
541
|
+
type: "color",
|
|
542
|
+
value: "#000000",
|
|
543
|
+
prop: "color",
|
|
544
|
+
classReference: "container"
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
label: "Background",
|
|
548
|
+
type: "color",
|
|
549
|
+
value: "#ffffff",
|
|
550
|
+
prop: "backgroundColor",
|
|
551
|
+
classReference: "container"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
label: "Padding Top",
|
|
555
|
+
type: "number",
|
|
556
|
+
value: 0,
|
|
557
|
+
unit: "px",
|
|
558
|
+
prop: "paddingTop",
|
|
559
|
+
classReference: "container"
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
label: "Padding Right",
|
|
563
|
+
type: "number",
|
|
564
|
+
value: 0,
|
|
565
|
+
unit: "px",
|
|
566
|
+
prop: "paddingRight",
|
|
567
|
+
classReference: "container"
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
label: "Padding Bottom",
|
|
571
|
+
type: "number",
|
|
572
|
+
value: 0,
|
|
573
|
+
unit: "px",
|
|
574
|
+
prop: "paddingBottom",
|
|
575
|
+
classReference: "container"
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
label: "Padding Left",
|
|
579
|
+
type: "number",
|
|
580
|
+
value: 0,
|
|
581
|
+
unit: "px",
|
|
582
|
+
prop: "paddingLeft",
|
|
583
|
+
classReference: "container"
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
label: "Corner radius",
|
|
587
|
+
type: "number",
|
|
588
|
+
value: 0,
|
|
589
|
+
unit: "px",
|
|
590
|
+
prop: "borderRadius",
|
|
591
|
+
classReference: "container"
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
label: "Border color",
|
|
595
|
+
type: "color",
|
|
596
|
+
value: "#000000",
|
|
597
|
+
prop: "borderColor",
|
|
598
|
+
classReference: "container"
|
|
599
|
+
}
|
|
600
|
+
]
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
id: "typography",
|
|
604
|
+
title: "Text",
|
|
605
|
+
classReference: "body",
|
|
606
|
+
inputs: []
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
id: "h1",
|
|
610
|
+
title: "Title",
|
|
611
|
+
category: "Text",
|
|
612
|
+
classReference: "h1",
|
|
613
|
+
inputs: []
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
id: "h2",
|
|
617
|
+
title: "Subtitle",
|
|
618
|
+
category: "Text",
|
|
619
|
+
classReference: "h2",
|
|
620
|
+
inputs: []
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
id: "h3",
|
|
624
|
+
title: "Heading",
|
|
625
|
+
category: "Text",
|
|
626
|
+
classReference: "h3",
|
|
627
|
+
inputs: []
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
id: "link",
|
|
631
|
+
title: "Link",
|
|
632
|
+
classReference: "link",
|
|
633
|
+
inputs: []
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
id: "image",
|
|
637
|
+
title: "Image",
|
|
638
|
+
classReference: "image",
|
|
639
|
+
inputs: []
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
id: "button",
|
|
643
|
+
title: "Button",
|
|
644
|
+
classReference: "button",
|
|
645
|
+
inputs: []
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
id: "code-block",
|
|
649
|
+
title: "Code Block",
|
|
650
|
+
classReference: "codeBlock",
|
|
651
|
+
inputs: []
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
id: "inline-code",
|
|
655
|
+
title: "Inline Code",
|
|
656
|
+
classReference: "inlineCode",
|
|
657
|
+
inputs: []
|
|
658
|
+
}
|
|
659
|
+
];
|
|
660
|
+
const RESET_BASIC = {
|
|
661
|
+
reset: {
|
|
662
|
+
margin: "0",
|
|
663
|
+
padding: "0"
|
|
664
|
+
},
|
|
665
|
+
body: {
|
|
666
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif",
|
|
667
|
+
fontSize: "14px",
|
|
668
|
+
minHeight: "100%",
|
|
669
|
+
lineHeight: "155%"
|
|
670
|
+
},
|
|
671
|
+
container: {},
|
|
672
|
+
h1: {
|
|
673
|
+
fontSize: "2.25em",
|
|
674
|
+
lineHeight: "1.44em",
|
|
675
|
+
paddingTop: "0.389em",
|
|
676
|
+
fontWeight: 600
|
|
677
|
+
},
|
|
678
|
+
h2: {
|
|
679
|
+
fontSize: "1.8em",
|
|
680
|
+
lineHeight: "1.44em",
|
|
681
|
+
paddingTop: "0.389em",
|
|
682
|
+
fontWeight: 600
|
|
683
|
+
},
|
|
684
|
+
h3: {
|
|
685
|
+
fontSize: "1.4em",
|
|
686
|
+
lineHeight: "1.08em",
|
|
687
|
+
paddingTop: "0.389em",
|
|
688
|
+
fontWeight: 600
|
|
689
|
+
},
|
|
690
|
+
paragraph: {
|
|
691
|
+
fontSize: "1em",
|
|
692
|
+
paddingTop: "0.5em",
|
|
693
|
+
paddingBottom: "0.5em"
|
|
694
|
+
},
|
|
695
|
+
list: {
|
|
696
|
+
paddingLeft: "1.1em",
|
|
697
|
+
paddingBottom: "1em"
|
|
698
|
+
},
|
|
699
|
+
nestedList: {
|
|
700
|
+
paddingLeft: "1.1em",
|
|
701
|
+
paddingBottom: "0"
|
|
702
|
+
},
|
|
703
|
+
listItem: {
|
|
704
|
+
marginLeft: "1em",
|
|
705
|
+
marginBottom: "0.3em",
|
|
706
|
+
marginTop: "0.3em"
|
|
707
|
+
},
|
|
708
|
+
listParagraph: {
|
|
709
|
+
padding: "0",
|
|
710
|
+
margin: "0"
|
|
711
|
+
},
|
|
712
|
+
blockquote: {
|
|
713
|
+
borderLeft: "3px solid #acb3be",
|
|
714
|
+
color: "#7e8a9a",
|
|
715
|
+
marginLeft: 0,
|
|
716
|
+
paddingLeft: "0.8em",
|
|
717
|
+
fontSize: "1.1em",
|
|
718
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif"
|
|
719
|
+
},
|
|
720
|
+
link: { textDecoration: "underline" },
|
|
721
|
+
footer: { fontSize: "0.8em" },
|
|
722
|
+
hr: {
|
|
723
|
+
paddingBottom: "1em",
|
|
724
|
+
borderWidth: "2px"
|
|
725
|
+
},
|
|
726
|
+
image: { maxWidth: "100%" },
|
|
727
|
+
button: {
|
|
728
|
+
lineHeight: "100%",
|
|
729
|
+
display: "inline-block"
|
|
730
|
+
},
|
|
731
|
+
inlineCode: {
|
|
732
|
+
paddingTop: "0.25em",
|
|
733
|
+
paddingBottom: "0.25em",
|
|
734
|
+
paddingLeft: "0.4em",
|
|
735
|
+
paddingRight: "0.4em",
|
|
736
|
+
background: "#e5e7eb",
|
|
737
|
+
color: "#1e293b",
|
|
738
|
+
borderRadius: "4px"
|
|
739
|
+
},
|
|
740
|
+
codeBlock: {
|
|
741
|
+
fontFamily: "monospace",
|
|
742
|
+
fontWeight: "500",
|
|
743
|
+
fontSize: ".92em"
|
|
744
|
+
},
|
|
745
|
+
codeTag: {
|
|
746
|
+
lineHeight: "130%",
|
|
747
|
+
fontFamily: "monospace",
|
|
748
|
+
fontSize: ".92em"
|
|
749
|
+
},
|
|
750
|
+
section: {
|
|
751
|
+
padding: "10px 20px 10px 20px",
|
|
752
|
+
boxSizing: "border-box"
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
const RESET_THEMES = {
|
|
756
|
+
basic: RESET_BASIC,
|
|
757
|
+
minimal: {
|
|
758
|
+
...Object.keys(RESET_BASIC).reduce((acc, key) => {
|
|
759
|
+
acc[key] = {};
|
|
760
|
+
return acc;
|
|
761
|
+
}, {}),
|
|
762
|
+
reset: RESET_BASIC.reset,
|
|
763
|
+
button: RESET_BASIC.button,
|
|
764
|
+
image: RESET_BASIC.image,
|
|
765
|
+
list: RESET_BASIC.list,
|
|
766
|
+
nestedList: RESET_BASIC.nestedList,
|
|
767
|
+
listItem: RESET_BASIC.listItem,
|
|
768
|
+
listParagraph: RESET_BASIC.listParagraph
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
function resolveResetValue(value, targetUnit, bodyFontSizePx) {
|
|
772
|
+
if (value === void 0) return;
|
|
773
|
+
const str = String(value);
|
|
774
|
+
const num = Number.parseFloat(str);
|
|
775
|
+
if (Number.isNaN(num)) return;
|
|
776
|
+
if (str.endsWith("em")) return targetUnit === "px" ? Math.floor(num * bodyFontSizePx) : num * 100;
|
|
777
|
+
return num;
|
|
778
|
+
}
|
|
779
|
+
const EDITOR_THEMES = {
|
|
780
|
+
minimal: THEME_MINIMAL,
|
|
781
|
+
basic: THEME_BASIC
|
|
782
|
+
};
|
|
783
|
+
function getThemeBodyFontSizePx(theme) {
|
|
784
|
+
for (const group of EDITOR_THEMES[theme]) {
|
|
785
|
+
if (group.classReference !== "body") continue;
|
|
786
|
+
for (const input of group.inputs) if (input.prop === "fontSize" && typeof input.value === "number") return input.value;
|
|
787
|
+
}
|
|
788
|
+
return 14;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Use to make the preview nicer once the theme might miss some
|
|
792
|
+
* important properties to make layout accurate
|
|
793
|
+
*/
|
|
794
|
+
const DEFAULT_INBOX_FONT_SIZE_PX = 14;
|
|
795
|
+
const INBOX_EMAIL_DEFAULTS = {
|
|
796
|
+
body: {
|
|
797
|
+
color: "#000000",
|
|
798
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif",
|
|
799
|
+
fontSize: `14px`
|
|
800
|
+
},
|
|
801
|
+
container: { width: 600 }
|
|
802
|
+
};
|
|
803
|
+
const SUPPORTED_CSS_PROPERTIES = {
|
|
804
|
+
align: {
|
|
805
|
+
label: "Align",
|
|
806
|
+
type: "select",
|
|
807
|
+
options: {
|
|
808
|
+
left: "Left",
|
|
809
|
+
center: "Center",
|
|
810
|
+
right: "Right"
|
|
811
|
+
},
|
|
812
|
+
defaultValue: "left",
|
|
813
|
+
category: "layout"
|
|
814
|
+
},
|
|
815
|
+
backgroundColor: {
|
|
816
|
+
label: "Background",
|
|
817
|
+
type: "color",
|
|
818
|
+
excludeNodes: ["image", "youtube"],
|
|
819
|
+
defaultValue: "#ffffff",
|
|
820
|
+
category: "appearance"
|
|
821
|
+
},
|
|
822
|
+
color: {
|
|
823
|
+
label: "Text color",
|
|
824
|
+
type: "color",
|
|
825
|
+
excludeNodes: ["image", "youtube"],
|
|
826
|
+
defaultValue: "#000000",
|
|
827
|
+
category: "typography"
|
|
828
|
+
},
|
|
829
|
+
fontSize: {
|
|
830
|
+
label: "Font size",
|
|
831
|
+
type: "number",
|
|
832
|
+
unit: "px",
|
|
833
|
+
excludeNodes: ["image", "youtube"],
|
|
834
|
+
defaultValue: 14,
|
|
835
|
+
category: "typography"
|
|
836
|
+
},
|
|
837
|
+
fontWeight: {
|
|
838
|
+
label: "Font weight",
|
|
839
|
+
type: "select",
|
|
840
|
+
options: {
|
|
841
|
+
300: "Light",
|
|
842
|
+
400: "Normal",
|
|
843
|
+
600: "Semi Bold",
|
|
844
|
+
700: "Bold",
|
|
845
|
+
800: "Extra Bold"
|
|
846
|
+
},
|
|
847
|
+
excludeNodes: ["image", "youtube"],
|
|
848
|
+
defaultValue: 400,
|
|
849
|
+
category: "typography"
|
|
850
|
+
},
|
|
851
|
+
letterSpacing: {
|
|
852
|
+
label: "Letter spacing",
|
|
853
|
+
type: "number",
|
|
854
|
+
unit: "px",
|
|
855
|
+
excludeNodes: ["image", "youtube"],
|
|
856
|
+
defaultValue: 0,
|
|
857
|
+
category: "typography"
|
|
858
|
+
},
|
|
859
|
+
lineHeight: {
|
|
860
|
+
label: "Line height",
|
|
861
|
+
type: "number",
|
|
862
|
+
unit: "%",
|
|
863
|
+
defaultValue: 155,
|
|
864
|
+
category: "typography"
|
|
865
|
+
},
|
|
866
|
+
textDecoration: {
|
|
867
|
+
label: "Text decoration",
|
|
868
|
+
type: "select",
|
|
869
|
+
options: {
|
|
870
|
+
none: "None",
|
|
871
|
+
underline: "Underline",
|
|
872
|
+
"line-through": "Line-through"
|
|
873
|
+
},
|
|
874
|
+
defaultValue: "none",
|
|
875
|
+
category: "typography"
|
|
876
|
+
},
|
|
877
|
+
borderRadius: {
|
|
878
|
+
label: "Border Radius",
|
|
879
|
+
type: "number",
|
|
880
|
+
unit: "px",
|
|
881
|
+
defaultValue: 8,
|
|
882
|
+
category: "appearance"
|
|
883
|
+
},
|
|
884
|
+
borderTopLeftRadius: {
|
|
885
|
+
label: "Border Radius (Top-Left)",
|
|
886
|
+
type: "number",
|
|
887
|
+
unit: "px",
|
|
888
|
+
defaultValue: 8,
|
|
889
|
+
category: "appearance"
|
|
890
|
+
},
|
|
891
|
+
borderTopRightRadius: {
|
|
892
|
+
label: "Border Radius (Top-Right)",
|
|
893
|
+
type: "number",
|
|
894
|
+
unit: "px",
|
|
895
|
+
defaultValue: 8,
|
|
896
|
+
category: "appearance"
|
|
897
|
+
},
|
|
898
|
+
borderBottomLeftRadius: {
|
|
899
|
+
label: "Border Radius (Bottom-Left)",
|
|
900
|
+
type: "number",
|
|
901
|
+
unit: "px",
|
|
902
|
+
defaultValue: 8,
|
|
903
|
+
category: "appearance"
|
|
904
|
+
},
|
|
905
|
+
borderBottomRightRadius: {
|
|
906
|
+
label: "Border Radius (Bottom-Right)",
|
|
907
|
+
type: "number",
|
|
908
|
+
unit: "px",
|
|
909
|
+
defaultValue: 8,
|
|
910
|
+
category: "appearance"
|
|
911
|
+
},
|
|
912
|
+
borderWidth: {
|
|
913
|
+
label: "Border Width",
|
|
914
|
+
type: "number",
|
|
915
|
+
unit: "px",
|
|
916
|
+
defaultValue: 1,
|
|
917
|
+
category: "appearance"
|
|
918
|
+
},
|
|
919
|
+
borderTopWidth: {
|
|
920
|
+
label: "Border Top Width",
|
|
921
|
+
type: "number",
|
|
922
|
+
unit: "px",
|
|
923
|
+
defaultValue: 1,
|
|
924
|
+
category: "appearance"
|
|
925
|
+
},
|
|
926
|
+
borderRightWidth: {
|
|
927
|
+
label: "Border Right Width",
|
|
928
|
+
type: "number",
|
|
929
|
+
unit: "px",
|
|
930
|
+
defaultValue: 1,
|
|
931
|
+
category: "appearance"
|
|
932
|
+
},
|
|
933
|
+
borderBottomWidth: {
|
|
934
|
+
label: "Border Bottom Width",
|
|
935
|
+
type: "number",
|
|
936
|
+
unit: "px",
|
|
937
|
+
defaultValue: 1,
|
|
938
|
+
category: "appearance"
|
|
939
|
+
},
|
|
940
|
+
borderLeftWidth: {
|
|
941
|
+
label: "Border Left Width",
|
|
942
|
+
type: "number",
|
|
943
|
+
unit: "px",
|
|
944
|
+
defaultValue: 1,
|
|
945
|
+
category: "appearance"
|
|
946
|
+
},
|
|
947
|
+
borderStyle: {
|
|
948
|
+
label: "Border Style",
|
|
949
|
+
type: "select",
|
|
950
|
+
options: {
|
|
951
|
+
solid: "Solid",
|
|
952
|
+
dashed: "Dashed",
|
|
953
|
+
dotted: "Dotted"
|
|
954
|
+
},
|
|
955
|
+
defaultValue: "solid",
|
|
956
|
+
category: "appearance"
|
|
957
|
+
},
|
|
958
|
+
borderTopStyle: {
|
|
959
|
+
label: "Border Top Style",
|
|
960
|
+
type: "select",
|
|
961
|
+
options: {
|
|
962
|
+
solid: "Solid",
|
|
963
|
+
dashed: "Dashed",
|
|
964
|
+
dotted: "Dotted"
|
|
965
|
+
},
|
|
966
|
+
defaultValue: "solid",
|
|
967
|
+
category: "appearance"
|
|
968
|
+
},
|
|
969
|
+
borderRightStyle: {
|
|
970
|
+
label: "Border Right Style",
|
|
971
|
+
type: "select",
|
|
972
|
+
options: {
|
|
973
|
+
solid: "Solid",
|
|
974
|
+
dashed: "Dashed",
|
|
975
|
+
dotted: "Dotted"
|
|
976
|
+
},
|
|
977
|
+
defaultValue: "solid",
|
|
978
|
+
category: "appearance"
|
|
979
|
+
},
|
|
980
|
+
borderBottomStyle: {
|
|
981
|
+
label: "Border Bottom Style",
|
|
982
|
+
type: "select",
|
|
983
|
+
options: {
|
|
984
|
+
solid: "Solid",
|
|
985
|
+
dashed: "Dashed",
|
|
986
|
+
dotted: "Dotted"
|
|
987
|
+
},
|
|
988
|
+
defaultValue: "solid",
|
|
989
|
+
category: "appearance"
|
|
990
|
+
},
|
|
991
|
+
borderLeftStyle: {
|
|
992
|
+
label: "Border Left Style",
|
|
993
|
+
type: "select",
|
|
994
|
+
options: {
|
|
995
|
+
solid: "Solid",
|
|
996
|
+
dashed: "Dashed",
|
|
997
|
+
dotted: "Dotted"
|
|
998
|
+
},
|
|
999
|
+
defaultValue: "solid",
|
|
1000
|
+
category: "appearance"
|
|
1001
|
+
},
|
|
1002
|
+
borderColor: {
|
|
1003
|
+
label: "Border Color",
|
|
1004
|
+
type: "color",
|
|
1005
|
+
defaultValue: "#000000",
|
|
1006
|
+
category: "appearance"
|
|
1007
|
+
},
|
|
1008
|
+
borderTopColor: {
|
|
1009
|
+
label: "Border Top Color",
|
|
1010
|
+
type: "color",
|
|
1011
|
+
defaultValue: "#000000",
|
|
1012
|
+
category: "appearance"
|
|
1013
|
+
},
|
|
1014
|
+
borderRightColor: {
|
|
1015
|
+
label: "Border Right Color",
|
|
1016
|
+
type: "color",
|
|
1017
|
+
defaultValue: "#000000",
|
|
1018
|
+
category: "appearance"
|
|
1019
|
+
},
|
|
1020
|
+
borderBottomColor: {
|
|
1021
|
+
label: "Border Bottom Color",
|
|
1022
|
+
type: "color",
|
|
1023
|
+
defaultValue: "#000000",
|
|
1024
|
+
category: "appearance"
|
|
1025
|
+
},
|
|
1026
|
+
borderLeftColor: {
|
|
1027
|
+
label: "Border Left Color",
|
|
1028
|
+
type: "color",
|
|
1029
|
+
defaultValue: "#000000",
|
|
1030
|
+
category: "appearance"
|
|
1031
|
+
},
|
|
1032
|
+
padding: {
|
|
1033
|
+
label: "Padding",
|
|
1034
|
+
type: "number",
|
|
1035
|
+
unit: "px",
|
|
1036
|
+
defaultValue: 8,
|
|
1037
|
+
category: "layout"
|
|
1038
|
+
},
|
|
1039
|
+
paddingTop: {
|
|
1040
|
+
label: "Padding Top",
|
|
1041
|
+
type: "number",
|
|
1042
|
+
unit: "px",
|
|
1043
|
+
defaultValue: 8,
|
|
1044
|
+
category: "layout"
|
|
1045
|
+
},
|
|
1046
|
+
paddingLeft: {
|
|
1047
|
+
label: "Padding Left",
|
|
1048
|
+
type: "number",
|
|
1049
|
+
unit: "px",
|
|
1050
|
+
defaultValue: 8,
|
|
1051
|
+
category: "layout"
|
|
1052
|
+
},
|
|
1053
|
+
paddingBottom: {
|
|
1054
|
+
label: "Padding Bottom",
|
|
1055
|
+
type: "number",
|
|
1056
|
+
unit: "px",
|
|
1057
|
+
defaultValue: 8,
|
|
1058
|
+
category: "layout"
|
|
1059
|
+
},
|
|
1060
|
+
paddingRight: {
|
|
1061
|
+
label: "Padding Right",
|
|
1062
|
+
type: "number",
|
|
1063
|
+
unit: "px",
|
|
1064
|
+
defaultValue: 8,
|
|
1065
|
+
category: "layout"
|
|
1066
|
+
},
|
|
1067
|
+
width: {
|
|
1068
|
+
label: "Width",
|
|
1069
|
+
type: "number",
|
|
1070
|
+
unit: "px",
|
|
1071
|
+
defaultValue: 600,
|
|
1072
|
+
category: "layout"
|
|
1073
|
+
},
|
|
1074
|
+
height: {
|
|
1075
|
+
label: "Height",
|
|
1076
|
+
type: "number",
|
|
1077
|
+
unit: "px",
|
|
1078
|
+
defaultValue: 400,
|
|
1079
|
+
category: "layout"
|
|
1080
|
+
}
|
|
1081
|
+
};
|
|
1082
|
+
//#endregion
|
|
1083
|
+
//#region src/plugins/email-theming/normalization.ts
|
|
1084
|
+
const PANEL_SECTION_IDS = new Set([
|
|
1085
|
+
"body",
|
|
1086
|
+
"container",
|
|
1087
|
+
"typography",
|
|
1088
|
+
"link",
|
|
1089
|
+
"image",
|
|
1090
|
+
"button",
|
|
1091
|
+
"code-block",
|
|
1092
|
+
"inline-code"
|
|
1093
|
+
]);
|
|
1094
|
+
const PANEL_SECTION_IDS_BY_TITLE = {
|
|
1095
|
+
background: "body",
|
|
1096
|
+
body: "body",
|
|
1097
|
+
content: "container",
|
|
1098
|
+
container: "container",
|
|
1099
|
+
typography: "typography",
|
|
1100
|
+
link: "link",
|
|
1101
|
+
image: "image",
|
|
1102
|
+
button: "button",
|
|
1103
|
+
"code block": "code-block",
|
|
1104
|
+
"inline code": "inline-code"
|
|
1105
|
+
};
|
|
1106
|
+
const PANEL_SECTION_IDS_BY_CLASS_REFERENCE = {
|
|
1107
|
+
container: "container",
|
|
1108
|
+
link: "link",
|
|
1109
|
+
image: "image",
|
|
1110
|
+
button: "button",
|
|
1111
|
+
codeBlock: "code-block",
|
|
1112
|
+
inlineCode: "inline-code"
|
|
1113
|
+
};
|
|
1114
|
+
function isPanelSectionId(value) {
|
|
1115
|
+
return typeof value === "string" && PANEL_SECTION_IDS.has(value);
|
|
1116
|
+
}
|
|
1117
|
+
function normalizeTitle(title) {
|
|
1118
|
+
return title?.trim().toLowerCase().replace(/\s+/g, " ") ?? "";
|
|
1119
|
+
}
|
|
1120
|
+
function resolvePanelSectionId(group) {
|
|
1121
|
+
if (isPanelSectionId(group.id)) return group.id;
|
|
1122
|
+
const normalizedTitle = normalizeTitle(group.title);
|
|
1123
|
+
if (group.classReference === "body") {
|
|
1124
|
+
if (normalizedTitle === "typography") return "typography";
|
|
1125
|
+
return "body";
|
|
1126
|
+
}
|
|
1127
|
+
if (group.classReference && PANEL_SECTION_IDS_BY_CLASS_REFERENCE[group.classReference]) return PANEL_SECTION_IDS_BY_CLASS_REFERENCE[group.classReference] ?? null;
|
|
1128
|
+
return PANEL_SECTION_IDS_BY_TITLE[normalizedTitle] ?? null;
|
|
1129
|
+
}
|
|
1130
|
+
function normalizePanelInputs(inputs, defaultInputs, fallbackClassReference) {
|
|
1131
|
+
if (!Array.isArray(inputs)) return [];
|
|
1132
|
+
return inputs.map((input) => {
|
|
1133
|
+
const defaultInput = defaultInputs.find((candidate) => candidate.prop === input.prop);
|
|
1134
|
+
return {
|
|
1135
|
+
...defaultInput,
|
|
1136
|
+
...input,
|
|
1137
|
+
classReference: input.classReference ?? defaultInput?.classReference ?? fallbackClassReference
|
|
1138
|
+
};
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
function inferThemeFromPanelStyles(panelStyles) {
|
|
1142
|
+
if (!Array.isArray(panelStyles) || panelStyles.length === 0) return null;
|
|
1143
|
+
let finalTheme = null;
|
|
1144
|
+
for (const group of panelStyles) {
|
|
1145
|
+
if (!Array.isArray(group?.inputs)) {
|
|
1146
|
+
finalTheme = null;
|
|
1147
|
+
break;
|
|
1148
|
+
}
|
|
1149
|
+
if (group.inputs.length !== 0) {
|
|
1150
|
+
finalTheme = "basic";
|
|
1151
|
+
break;
|
|
1152
|
+
}
|
|
1153
|
+
finalTheme = "minimal";
|
|
1154
|
+
}
|
|
1155
|
+
return finalTheme;
|
|
1156
|
+
}
|
|
1157
|
+
function normalizeThemePanelStyles(theme, panelStyles) {
|
|
1158
|
+
if (!Array.isArray(panelStyles)) return null;
|
|
1159
|
+
return panelStyles.map((group) => {
|
|
1160
|
+
const panelId = resolvePanelSectionId(group);
|
|
1161
|
+
if (!panelId) return group;
|
|
1162
|
+
const defaultGroup = EDITOR_THEMES[theme].find((candidate) => candidate.id === panelId);
|
|
1163
|
+
if (!defaultGroup) return group;
|
|
1164
|
+
return {
|
|
1165
|
+
...group,
|
|
1166
|
+
id: panelId,
|
|
1167
|
+
title: defaultGroup.title,
|
|
1168
|
+
classReference: defaultGroup.classReference,
|
|
1169
|
+
inputs: normalizePanelInputs(group.inputs, defaultGroup.inputs, defaultGroup.classReference)
|
|
1170
|
+
};
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
//#endregion
|
|
1174
|
+
//#region src/plugins/email-theming/theme-config.ts
|
|
1175
|
+
const CLASS_REFERENCE_TO_PANEL_ID = {
|
|
1176
|
+
body: "body",
|
|
1177
|
+
container: "container",
|
|
1178
|
+
h1: "h1",
|
|
1179
|
+
h2: "h2",
|
|
1180
|
+
h3: "h3",
|
|
1181
|
+
link: "link",
|
|
1182
|
+
image: "image",
|
|
1183
|
+
button: "button",
|
|
1184
|
+
codeBlock: "code-block",
|
|
1185
|
+
inlineCode: "inline-code"
|
|
1186
|
+
};
|
|
1187
|
+
function parseCssValue(value) {
|
|
1188
|
+
if (typeof value === "number") return { value };
|
|
1189
|
+
const pxMatch = /^(-?\d+(?:\.\d+)?)px$/.exec(value);
|
|
1190
|
+
if (pxMatch) return {
|
|
1191
|
+
value: Number.parseFloat(pxMatch[1]),
|
|
1192
|
+
unit: "px"
|
|
1193
|
+
};
|
|
1194
|
+
const percentMatch = /^(-?\d+(?:\.\d+)?)%$/.exec(value);
|
|
1195
|
+
if (percentMatch) return {
|
|
1196
|
+
value: Number.parseFloat(percentMatch[1]),
|
|
1197
|
+
unit: "%"
|
|
1198
|
+
};
|
|
1199
|
+
return { value };
|
|
1200
|
+
}
|
|
1201
|
+
function isThemeConfig(theme) {
|
|
1202
|
+
return typeof theme === "object" && theme !== null && "styles" in theme;
|
|
1203
|
+
}
|
|
1204
|
+
function themeStylesToPanelOverrides(styles, basePanels) {
|
|
1205
|
+
const result = basePanels.map((group) => ({
|
|
1206
|
+
...group,
|
|
1207
|
+
inputs: group.inputs.map((input) => ({ ...input }))
|
|
1208
|
+
}));
|
|
1209
|
+
for (const [component, cssProps] of Object.entries(styles)) {
|
|
1210
|
+
if (!cssProps) continue;
|
|
1211
|
+
const panelId = CLASS_REFERENCE_TO_PANEL_ID[component];
|
|
1212
|
+
const group = result.find((g) => g.id === panelId);
|
|
1213
|
+
if (!group) continue;
|
|
1214
|
+
for (const [cssProp, cssValue] of Object.entries(cssProps)) {
|
|
1215
|
+
if (cssValue === void 0) continue;
|
|
1216
|
+
const existingInput = group.inputs.find((i) => i.prop === cssProp && i.classReference === component);
|
|
1217
|
+
const parsed = parseCssValue(cssValue);
|
|
1218
|
+
if (existingInput) {
|
|
1219
|
+
existingInput.value = parsed.value;
|
|
1220
|
+
if (parsed.unit !== void 0) existingInput.unit = parsed.unit;
|
|
1221
|
+
} else {
|
|
1222
|
+
const propMeta = SUPPORTED_CSS_PROPERTIES[cssProp];
|
|
1223
|
+
group.inputs.push({
|
|
1224
|
+
label: propMeta?.label ?? cssProp,
|
|
1225
|
+
type: propMeta?.type ?? "text",
|
|
1226
|
+
prop: cssProp,
|
|
1227
|
+
classReference: component,
|
|
1228
|
+
value: parsed.value,
|
|
1229
|
+
unit: parsed.unit ?? propMeta?.unit,
|
|
1230
|
+
options: propMeta?.options
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
return result;
|
|
1236
|
+
}
|
|
1237
|
+
function createTheme(styles) {
|
|
1238
|
+
return { styles };
|
|
1239
|
+
}
|
|
1240
|
+
function extendTheme(base, overrides) {
|
|
1241
|
+
return {
|
|
1242
|
+
extends: base,
|
|
1243
|
+
styles: overrides
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
//#endregion
|
|
1247
|
+
//#region src/plugins/email-theming/extension.tsx
|
|
1248
|
+
/**
|
|
1249
|
+
* Maps a document node (type + attrs) to the theme component key used for style lookup.
|
|
1250
|
+
* Centralizes all node-type → theme-component knowledge.
|
|
1251
|
+
*/
|
|
1252
|
+
function getThemeComponentKey(nodeType, depth, attrs = {}) {
|
|
1253
|
+
switch (nodeType) {
|
|
1254
|
+
case "paragraph":
|
|
1255
|
+
if (depth > 0) return "listParagraph";
|
|
1256
|
+
return "paragraph";
|
|
1257
|
+
case "heading": return `h${attrs.level ?? 1}`;
|
|
1258
|
+
case "blockquote": return "blockquote";
|
|
1259
|
+
case "button": return "button";
|
|
1260
|
+
case "container": return "container";
|
|
1261
|
+
case "section": return "section";
|
|
1262
|
+
case "footer": return "footer";
|
|
1263
|
+
case "image": return "image";
|
|
1264
|
+
case "youtube":
|
|
1265
|
+
case "twitter": return "image";
|
|
1266
|
+
case "orderedList":
|
|
1267
|
+
case "bulletList":
|
|
1268
|
+
if (depth > 0) return "nestedList";
|
|
1269
|
+
return "list";
|
|
1270
|
+
case "listItem": return "listItem";
|
|
1271
|
+
case "codeBlock": return "codeBlock";
|
|
1272
|
+
case "code": return "inlineCode";
|
|
1273
|
+
case "link": return "link";
|
|
1274
|
+
case "horizontalRule": return "hr";
|
|
1275
|
+
default: return null;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Returns merged theme styles (reset + panel styles) for the given editor.
|
|
1280
|
+
* Use when you have editor access and need the full CssJs map.
|
|
1281
|
+
*/
|
|
1282
|
+
function getMergedCssJs(theme, panelStyles) {
|
|
1283
|
+
const parsed = transformToCssJs(normalizeThemePanelStyles(theme, panelStyles) ?? EDITOR_THEMES[theme], 14);
|
|
1284
|
+
return mergeCssJs(RESET_THEMES[theme], parsed);
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Returns resolved React.CSSProperties for a node when you already have merged CssJs
|
|
1288
|
+
* (e.g. in the serializer where there is no editor). Centralizes which theme keys
|
|
1289
|
+
* apply to which node type.
|
|
1290
|
+
*/
|
|
1291
|
+
const RESET_NODE_TYPES = new Set([
|
|
1292
|
+
"body",
|
|
1293
|
+
"bulletList",
|
|
1294
|
+
"button",
|
|
1295
|
+
"columns",
|
|
1296
|
+
"div",
|
|
1297
|
+
"h1",
|
|
1298
|
+
"h2",
|
|
1299
|
+
"h3",
|
|
1300
|
+
"list",
|
|
1301
|
+
"listItem",
|
|
1302
|
+
"listParagraph",
|
|
1303
|
+
"nestedList",
|
|
1304
|
+
"orderedList",
|
|
1305
|
+
"table",
|
|
1306
|
+
"paragraph",
|
|
1307
|
+
"tableCell",
|
|
1308
|
+
"tableHeader",
|
|
1309
|
+
"tableRow",
|
|
1310
|
+
"youtube"
|
|
1311
|
+
]);
|
|
1312
|
+
function getResolvedNodeStyles(node, depth, mergedCssJs) {
|
|
1313
|
+
const key = getThemeComponentKey(node.type ?? "", depth, node.attrs ?? {});
|
|
1314
|
+
if (!key) {
|
|
1315
|
+
if (RESET_NODE_TYPES.has(node.type ?? "")) return mergedCssJs.reset ?? {};
|
|
1316
|
+
return {};
|
|
1317
|
+
}
|
|
1318
|
+
const component = mergedCssJs[key] ?? {};
|
|
1319
|
+
if (RESET_NODE_TYPES.has(key) || RESET_NODE_TYPES.has(node.type ?? "")) return {
|
|
1320
|
+
...mergedCssJs.reset ?? {},
|
|
1321
|
+
...component
|
|
1322
|
+
};
|
|
1323
|
+
return { ...component };
|
|
1324
|
+
}
|
|
1325
|
+
function stylesToCss(styles, theme) {
|
|
1326
|
+
const parsed = transformToCssJs(normalizeThemePanelStyles(theme, styles) ?? EDITOR_THEMES[theme], 14);
|
|
1327
|
+
return mergeCssJs(RESET_THEMES[theme], parsed);
|
|
1328
|
+
}
|
|
1329
|
+
function resolveThemeConfig(config) {
|
|
1330
|
+
if (!isThemeConfig(config)) return {
|
|
1331
|
+
baseTheme: config,
|
|
1332
|
+
panels: void 0
|
|
1333
|
+
};
|
|
1334
|
+
const baseTheme = config.extends ?? "minimal";
|
|
1335
|
+
const basePanels = EDITOR_THEMES[baseTheme];
|
|
1336
|
+
return {
|
|
1337
|
+
baseTheme,
|
|
1338
|
+
panels: themeStylesToPanelOverrides(config.styles, basePanels)
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
function getEmailTheming(editor) {
|
|
1342
|
+
const theme = getEmailTheme(editor);
|
|
1343
|
+
return {
|
|
1344
|
+
styles: normalizeThemePanelStyles(theme, getEmailStyles(editor)) ?? EDITOR_THEMES[theme],
|
|
1345
|
+
theme,
|
|
1346
|
+
css: getEmailCss(editor)
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
function useEmailTheming(editor) {
|
|
1350
|
+
return (0, _tiptap_react.useEditorState)({
|
|
1351
|
+
editor,
|
|
1352
|
+
selector({ editor: ed }) {
|
|
1353
|
+
if (!ed) return null;
|
|
1354
|
+
return getEmailTheming(ed);
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
function getEmailStyles(editor) {
|
|
1359
|
+
return require_global_content.getGlobalContent("styles", editor);
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Sets the global panel styles on the editor document.
|
|
1363
|
+
* Persists into the `GlobalContent` node under the `'styles'` key.
|
|
1364
|
+
*/
|
|
1365
|
+
function setGlobalStyles(editor, styles) {
|
|
1366
|
+
return editor.commands.setGlobalContent("styles", styles);
|
|
1367
|
+
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Sets the current email theme on the editor document.
|
|
1370
|
+
* Persists into the `GlobalContent` node under the `'theme'` key.
|
|
1371
|
+
*/
|
|
1372
|
+
function setCurrentTheme(editor, theme) {
|
|
1373
|
+
return editor.commands.setGlobalContent("theme", theme);
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Sets the global CSS string injected into the email `<head>`.
|
|
1377
|
+
* Persists into the `GlobalContent` node under the `'css'` key.
|
|
1378
|
+
*/
|
|
1379
|
+
function setGlobalCssInjected(editor, css) {
|
|
1380
|
+
return editor.commands.setGlobalContent("css", css);
|
|
1381
|
+
}
|
|
1382
|
+
function getEmailTheme(editor) {
|
|
1383
|
+
const extensionOptions = editor.extensionManager.extensions.find((extension) => extension.name === "theming")?.options?.theme;
|
|
1384
|
+
if (isThemeConfig(extensionOptions)) return extensionOptions.extends ?? "minimal";
|
|
1385
|
+
if (extensionOptions === "basic" || extensionOptions === "minimal") return extensionOptions;
|
|
1386
|
+
const globalTheme = require_global_content.getGlobalContent("theme", editor);
|
|
1387
|
+
if (globalTheme === "basic" || globalTheme === "minimal") return globalTheme;
|
|
1388
|
+
const inferredTheme = inferThemeFromPanelStyles(getEmailStyles(editor));
|
|
1389
|
+
if (inferredTheme) return inferredTheme;
|
|
1390
|
+
return "basic";
|
|
1391
|
+
}
|
|
1392
|
+
function getEmailCss(editor) {
|
|
1393
|
+
return require_global_content.getGlobalContent("css", editor);
|
|
1394
|
+
}
|
|
1395
|
+
const EmailTheming = _tiptap_core.Extension.create({
|
|
1396
|
+
name: "theming",
|
|
1397
|
+
addOptions() {
|
|
1398
|
+
return {
|
|
1399
|
+
theme: void 0,
|
|
1400
|
+
serializerPlugin: {
|
|
1401
|
+
getNodeStyles(node, depth, editor) {
|
|
1402
|
+
const theming = getEmailTheming(editor);
|
|
1403
|
+
return getResolvedNodeStyles(node, depth, getMergedCssJs(theming.theme, theming.styles));
|
|
1404
|
+
},
|
|
1405
|
+
BaseTemplate({ previewText, children, editor }) {
|
|
1406
|
+
const { css: globalCss, styles, theme } = getEmailTheming(editor);
|
|
1407
|
+
const mergedStyles = getMergedCssJs(theme, styles);
|
|
1408
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_email.Html, { children: [
|
|
1409
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_email.Head, { children: [
|
|
1410
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
|
|
1411
|
+
content: "width=device-width",
|
|
1412
|
+
name: "viewport"
|
|
1413
|
+
}),
|
|
1414
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
|
|
1415
|
+
content: "IE=edge",
|
|
1416
|
+
httpEquiv: "X-UA-Compatible"
|
|
1417
|
+
}),
|
|
1418
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", { name: "x-apple-disable-message-reformatting" }),
|
|
1419
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
|
|
1420
|
+
content: "telephone=no,address=no,email=no,date=no,url=no",
|
|
1421
|
+
name: "format-detection"
|
|
1422
|
+
}),
|
|
1423
|
+
globalCss && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: globalCss })
|
|
1424
|
+
] }),
|
|
1425
|
+
previewText && previewText !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_email.Preview, { children: previewText }),
|
|
1426
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_email.Body, {
|
|
1427
|
+
style: mergedStyles.body,
|
|
1428
|
+
children
|
|
1429
|
+
})
|
|
1430
|
+
] });
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
},
|
|
1435
|
+
addProseMirrorPlugins() {
|
|
1436
|
+
const { editor } = this;
|
|
1437
|
+
const scopeId = `tiptap-theme-${Math.random().toString(36).slice(2, 10)}`;
|
|
1438
|
+
const scopeAttribute = "data-editor-theme-scope";
|
|
1439
|
+
const scopeSelector = `.tiptap.ProseMirror[${scopeAttribute}="${scopeId}"]`;
|
|
1440
|
+
const themeStyleId = `${scopeId}-theme`;
|
|
1441
|
+
const globalStyleId = `${scopeId}-global`;
|
|
1442
|
+
return [new _tiptap_pm_state.Plugin({
|
|
1443
|
+
key: new _tiptap_pm_state.PluginKey("themingStyleInjector"),
|
|
1444
|
+
view(view) {
|
|
1445
|
+
let prevStyles = null;
|
|
1446
|
+
let prevTheme = null;
|
|
1447
|
+
let prevCss = null;
|
|
1448
|
+
let seededFromConfig = false;
|
|
1449
|
+
view.dom.setAttribute(scopeAttribute, scopeId);
|
|
1450
|
+
const sync = () => {
|
|
1451
|
+
if (!seededFromConfig) {
|
|
1452
|
+
seededFromConfig = true;
|
|
1453
|
+
const extensionTheme = editor.extensionManager.extensions.find((ext) => ext.name === "theming")?.options?.theme;
|
|
1454
|
+
if (isThemeConfig(extensionTheme)) {
|
|
1455
|
+
const { baseTheme, panels } = resolveThemeConfig(extensionTheme);
|
|
1456
|
+
if (panels && !require_global_content.getGlobalContent("styles", editor)) editor.commands.setGlobalContent("styles", panels);
|
|
1457
|
+
if (!require_global_content.getGlobalContent("theme", editor)) editor.commands.setGlobalContent("theme", baseTheme);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
const theme = getEmailTheme(editor);
|
|
1461
|
+
const styles = getEmailStyles(editor);
|
|
1462
|
+
const resolvedStyles = styles ?? EDITOR_THEMES[theme];
|
|
1463
|
+
const css = getEmailCss(editor);
|
|
1464
|
+
if (styles !== prevStyles || theme !== prevTheme) {
|
|
1465
|
+
prevStyles = styles;
|
|
1466
|
+
prevTheme = theme;
|
|
1467
|
+
injectThemeCss(getMergedCssJs(theme, resolvedStyles), {
|
|
1468
|
+
scopeSelector,
|
|
1469
|
+
styleId: themeStyleId
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
if (css !== prevCss) {
|
|
1473
|
+
prevCss = css;
|
|
1474
|
+
injectGlobalPlainCss(css, {
|
|
1475
|
+
scopeSelector,
|
|
1476
|
+
styleId: globalStyleId
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
};
|
|
1480
|
+
sync();
|
|
1481
|
+
return {
|
|
1482
|
+
update: sync,
|
|
1483
|
+
destroy() {
|
|
1484
|
+
document.getElementById(themeStyleId)?.remove();
|
|
1485
|
+
document.getElementById(globalStyleId)?.remove();
|
|
1486
|
+
view.dom.removeAttribute(scopeAttribute);
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
})];
|
|
1491
|
+
}
|
|
1492
|
+
});
|
|
1493
|
+
//#endregion
|
|
1494
|
+
Object.defineProperty(exports, "DEFAULT_INBOX_FONT_SIZE_PX", {
|
|
1495
|
+
enumerable: true,
|
|
1496
|
+
get: function() {
|
|
1497
|
+
return DEFAULT_INBOX_FONT_SIZE_PX;
|
|
1498
|
+
}
|
|
1499
|
+
});
|
|
1500
|
+
Object.defineProperty(exports, "EDITOR_THEMES", {
|
|
1501
|
+
enumerable: true,
|
|
1502
|
+
get: function() {
|
|
1503
|
+
return EDITOR_THEMES;
|
|
1504
|
+
}
|
|
1505
|
+
});
|
|
1506
|
+
Object.defineProperty(exports, "EmailTheming", {
|
|
1507
|
+
enumerable: true,
|
|
1508
|
+
get: function() {
|
|
1509
|
+
return EmailTheming;
|
|
1510
|
+
}
|
|
1511
|
+
});
|
|
1512
|
+
Object.defineProperty(exports, "INBOX_EMAIL_DEFAULTS", {
|
|
1513
|
+
enumerable: true,
|
|
1514
|
+
get: function() {
|
|
1515
|
+
return INBOX_EMAIL_DEFAULTS;
|
|
1516
|
+
}
|
|
1517
|
+
});
|
|
1518
|
+
Object.defineProperty(exports, "RESET_THEMES", {
|
|
1519
|
+
enumerable: true,
|
|
1520
|
+
get: function() {
|
|
1521
|
+
return RESET_THEMES;
|
|
1522
|
+
}
|
|
1523
|
+
});
|
|
1524
|
+
Object.defineProperty(exports, "SUPPORTED_CSS_PROPERTIES", {
|
|
1525
|
+
enumerable: true,
|
|
1526
|
+
get: function() {
|
|
1527
|
+
return SUPPORTED_CSS_PROPERTIES;
|
|
1528
|
+
}
|
|
1529
|
+
});
|
|
1530
|
+
Object.defineProperty(exports, "createTheme", {
|
|
1531
|
+
enumerable: true,
|
|
1532
|
+
get: function() {
|
|
1533
|
+
return createTheme;
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
Object.defineProperty(exports, "extendTheme", {
|
|
1537
|
+
enumerable: true,
|
|
1538
|
+
get: function() {
|
|
1539
|
+
return extendTheme;
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
Object.defineProperty(exports, "getMergedCssJs", {
|
|
1543
|
+
enumerable: true,
|
|
1544
|
+
get: function() {
|
|
1545
|
+
return getMergedCssJs;
|
|
1546
|
+
}
|
|
1547
|
+
});
|
|
1548
|
+
Object.defineProperty(exports, "getPanelTitle", {
|
|
1549
|
+
enumerable: true,
|
|
1550
|
+
get: function() {
|
|
1551
|
+
return getPanelTitle;
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1554
|
+
Object.defineProperty(exports, "getResolvedNodeStyles", {
|
|
1555
|
+
enumerable: true,
|
|
1556
|
+
get: function() {
|
|
1557
|
+
return getResolvedNodeStyles;
|
|
1558
|
+
}
|
|
1559
|
+
});
|
|
1560
|
+
Object.defineProperty(exports, "getThemeBodyFontSizePx", {
|
|
1561
|
+
enumerable: true,
|
|
1562
|
+
get: function() {
|
|
1563
|
+
return getThemeBodyFontSizePx;
|
|
1564
|
+
}
|
|
1565
|
+
});
|
|
1566
|
+
Object.defineProperty(exports, "getThemeComponentKey", {
|
|
1567
|
+
enumerable: true,
|
|
1568
|
+
get: function() {
|
|
1569
|
+
return getThemeComponentKey;
|
|
1570
|
+
}
|
|
1571
|
+
});
|
|
1572
|
+
Object.defineProperty(exports, "isThemeConfig", {
|
|
1573
|
+
enumerable: true,
|
|
1574
|
+
get: function() {
|
|
1575
|
+
return isThemeConfig;
|
|
1576
|
+
}
|
|
1577
|
+
});
|
|
1578
|
+
Object.defineProperty(exports, "parseCssValue", {
|
|
1579
|
+
enumerable: true,
|
|
1580
|
+
get: function() {
|
|
1581
|
+
return parseCssValue;
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1584
|
+
Object.defineProperty(exports, "resolveResetValue", {
|
|
1585
|
+
enumerable: true,
|
|
1586
|
+
get: function() {
|
|
1587
|
+
return resolveResetValue;
|
|
1588
|
+
}
|
|
1589
|
+
});
|
|
1590
|
+
Object.defineProperty(exports, "setCurrentTheme", {
|
|
1591
|
+
enumerable: true,
|
|
1592
|
+
get: function() {
|
|
1593
|
+
return setCurrentTheme;
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1596
|
+
Object.defineProperty(exports, "setGlobalCssInjected", {
|
|
1597
|
+
enumerable: true,
|
|
1598
|
+
get: function() {
|
|
1599
|
+
return setGlobalCssInjected;
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
Object.defineProperty(exports, "setGlobalStyles", {
|
|
1603
|
+
enumerable: true,
|
|
1604
|
+
get: function() {
|
|
1605
|
+
return setGlobalStyles;
|
|
1606
|
+
}
|
|
1607
|
+
});
|
|
1608
|
+
Object.defineProperty(exports, "stylesToCss", {
|
|
1609
|
+
enumerable: true,
|
|
1610
|
+
get: function() {
|
|
1611
|
+
return stylesToCss;
|
|
1612
|
+
}
|
|
1613
|
+
});
|
|
1614
|
+
Object.defineProperty(exports, "themeStylesToPanelOverrides", {
|
|
1615
|
+
enumerable: true,
|
|
1616
|
+
get: function() {
|
|
1617
|
+
return themeStylesToPanelOverrides;
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
Object.defineProperty(exports, "useEmailTheming", {
|
|
1621
|
+
enumerable: true,
|
|
1622
|
+
get: function() {
|
|
1623
|
+
return useEmailTheming;
|
|
1624
|
+
}
|
|
1625
|
+
});
|