@react-email/editor 0.0.0-experimental.7 → 1.0.0-canary.51

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