@react-email/editor 0.0.0-canary.49

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 (80) hide show
  1. package/dist/columns-D1gzbJr5.cjs +404 -0
  2. package/dist/columns-TFI4L-IC.mjs +277 -0
  3. package/dist/columns-TFI4L-IC.mjs.map +1 -0
  4. package/dist/core/index.cjs +9 -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-Dp3tVCOZ.mjs +156 -0
  9. package/dist/core-Dp3tVCOZ.mjs.map +1 -0
  10. package/dist/core-NV1Aun-R.cjs +173 -0
  11. package/dist/event-bus-BxVEXi1L.mjs +88 -0
  12. package/dist/event-bus-BxVEXi1L.mjs.map +1 -0
  13. package/dist/event-bus-WI0H5tIM.cjs +105 -0
  14. package/dist/extension-CfIsm0_p.cjs +1504 -0
  15. package/dist/extension-n2yYIR7e.mjs +1403 -0
  16. package/dist/extension-n2yYIR7e.mjs.map +1 -0
  17. package/dist/extensions/index.cjs +51 -0
  18. package/dist/extensions/index.d.cts +401 -0
  19. package/dist/extensions/index.d.cts.map +1 -0
  20. package/dist/extensions/index.d.mts +401 -0
  21. package/dist/extensions/index.d.mts.map +1 -0
  22. package/dist/extensions/index.mjs +5 -0
  23. package/dist/extensions-BsDsFFkk.mjs +1785 -0
  24. package/dist/extensions-BsDsFFkk.mjs.map +1 -0
  25. package/dist/extensions-D9BbHnEV.cjs +2029 -0
  26. package/dist/global-content-CaNsyaPw.mjs +78 -0
  27. package/dist/global-content-CaNsyaPw.mjs.map +1 -0
  28. package/dist/global-content-CxV8qpMp.cjs +89 -0
  29. package/dist/index-BMsf5s28.d.mts +194 -0
  30. package/dist/index-BMsf5s28.d.mts.map +1 -0
  31. package/dist/index-DNriNUPU.d.cts +194 -0
  32. package/dist/index-DNriNUPU.d.cts.map +1 -0
  33. package/dist/index.cjs +199 -0
  34. package/dist/index.css +1171 -0
  35. package/dist/index.css.map +1 -0
  36. package/dist/index.d.cts +43 -0
  37. package/dist/index.d.cts.map +1 -0
  38. package/dist/index.d.mts +43 -0
  39. package/dist/index.d.mts.map +1 -0
  40. package/dist/index.mjs +199 -0
  41. package/dist/index.mjs.map +1 -0
  42. package/dist/plugins/index.cjs +19 -0
  43. package/dist/plugins/index.d.cts +73 -0
  44. package/dist/plugins/index.d.cts.map +1 -0
  45. package/dist/plugins/index.d.mts +73 -0
  46. package/dist/plugins/index.d.mts.map +1 -0
  47. package/dist/plugins/index.mjs +3 -0
  48. package/dist/root-BWiLr5WO.mjs +2363 -0
  49. package/dist/root-BWiLr5WO.mjs.map +1 -0
  50. package/dist/root-Bm_YBU0n.cjs +2873 -0
  51. package/dist/set-text-alignment-BDkB4Vfh.mjs +19 -0
  52. package/dist/set-text-alignment-BDkB4Vfh.mjs.map +1 -0
  53. package/dist/set-text-alignment-BlyZq1GA.cjs +24 -0
  54. package/dist/styles-BBXVfEv-.mjs +223 -0
  55. package/dist/styles-BBXVfEv-.mjs.map +1 -0
  56. package/dist/styles-D5jB7Yx-.cjs +252 -0
  57. package/dist/types-B-hiUAR9.d.cts +47 -0
  58. package/dist/types-B-hiUAR9.d.cts.map +1 -0
  59. package/dist/types-J7sLqbPy.d.mts +47 -0
  60. package/dist/types-J7sLqbPy.d.mts.map +1 -0
  61. package/dist/ui/bubble-menu/bubble-menu.css +285 -0
  62. package/dist/ui/index.cjs +3052 -0
  63. package/dist/ui/index.d.cts +1220 -0
  64. package/dist/ui/index.d.cts.map +1 -0
  65. package/dist/ui/index.d.mts +1220 -0
  66. package/dist/ui/index.d.mts.map +1 -0
  67. package/dist/ui/index.mjs +2942 -0
  68. package/dist/ui/index.mjs.map +1 -0
  69. package/dist/ui/inspector/inspector.css +338 -0
  70. package/dist/ui/slash-command/slash-command.css +44 -0
  71. package/dist/ui/themes/default.css +1169 -0
  72. package/dist/utils/index.cjs +3 -0
  73. package/dist/utils/index.d.cts +7 -0
  74. package/dist/utils/index.d.cts.map +1 -0
  75. package/dist/utils/index.d.mts +7 -0
  76. package/dist/utils/index.d.mts.map +1 -0
  77. package/dist/utils/index.mjs +3 -0
  78. package/license.md +7 -0
  79. package/package.json +159 -0
  80. package/readme.md +69 -0
@@ -0,0 +1,404 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+ const require_styles = require('./styles-D5jB7Yx-.cjs');
29
+ const require_event_bus = require('./event-bus-WI0H5tIM.cjs');
30
+ let react_email = require("react-email");
31
+ let react_jsx_runtime = require("react/jsx-runtime");
32
+ let _tiptap_core = require("@tiptap/core");
33
+ let _tiptap_pm_state = require("@tiptap/pm/state");
34
+
35
+ //#region src/utils/attribute-helpers.ts
36
+ /**
37
+ * Creates TipTap attribute definitions for a list of HTML attributes.
38
+ * Each attribute will have the same pattern:
39
+ * - default: null
40
+ * - parseHTML: extracts the attribute from the element
41
+ * - renderHTML: conditionally renders the attribute if it has a value
42
+ *
43
+ * @param attributeNames - Array of HTML attribute names to create definitions for
44
+ * @returns Object with TipTap attribute definitions
45
+ *
46
+ * @example
47
+ * const attrs = createStandardAttributes(['class', 'id', 'title']);
48
+ * // Returns:
49
+ * // {
50
+ * // class: {
51
+ * // default: null,
52
+ * // parseHTML: (element) => element.getAttribute('class'),
53
+ * // renderHTML: (attributes) => attributes.class ? { class: attributes.class } : {}
54
+ * // },
55
+ * // ...
56
+ * // }
57
+ */
58
+ function createStandardAttributes(attributeNames) {
59
+ return Object.fromEntries(attributeNames.map((attr) => [attr, {
60
+ default: null,
61
+ parseHTML: (element) => element.getAttribute(attr),
62
+ renderHTML: (attributes) => {
63
+ if (!attributes[attr]) return {};
64
+ return { [attr]: attributes[attr] };
65
+ }
66
+ }]));
67
+ }
68
+ /**
69
+ * Common HTML attributes used across multiple extensions.
70
+ * These preserve attributes during HTML import and editing for better
71
+ * fidelity when importing existing email templates.
72
+ */
73
+ const COMMON_HTML_ATTRIBUTES = [
74
+ "id",
75
+ "class",
76
+ "title",
77
+ "lang",
78
+ "dir",
79
+ "data-id"
80
+ ];
81
+ /**
82
+ * Layout-specific HTML attributes used for positioning and sizing.
83
+ */
84
+ const LAYOUT_ATTRIBUTES = [
85
+ "align",
86
+ "width",
87
+ "height"
88
+ ];
89
+ /**
90
+ * Table-specific HTML attributes used for table layout and styling.
91
+ */
92
+ const TABLE_ATTRIBUTES = [
93
+ "border",
94
+ "cellpadding",
95
+ "cellspacing"
96
+ ];
97
+ /**
98
+ * Table cell-specific HTML attributes.
99
+ */
100
+ const TABLE_CELL_ATTRIBUTES = [
101
+ "valign",
102
+ "bgcolor",
103
+ "colspan",
104
+ "rowspan"
105
+ ];
106
+ /**
107
+ * Table header cell-specific HTML attributes.
108
+ * These are additional attributes that only apply to <th> elements.
109
+ */
110
+ const TABLE_HEADER_ATTRIBUTES = [...TABLE_CELL_ATTRIBUTES, "scope"];
111
+
112
+ //#endregion
113
+ //#region src/utils/prism-utils.ts
114
+ const publicURL = "/styles/prism";
115
+ function loadPrismTheme(theme) {
116
+ const link = document.createElement("link");
117
+ link.rel = "stylesheet";
118
+ link.href = `${publicURL}/prism-${theme}.css`;
119
+ link.setAttribute("data-prism-theme", "");
120
+ document.head.appendChild(link);
121
+ }
122
+ function removePrismTheme() {
123
+ const existingTheme = document.querySelectorAll("link[rel=\"stylesheet\"][data-prism-theme]");
124
+ if (existingTheme.length > 0) existingTheme.forEach((cssLinkTag) => {
125
+ cssLinkTag.remove();
126
+ });
127
+ }
128
+ function hasPrismThemeLoaded(theme) {
129
+ return !!document.querySelector(`link[rel="stylesheet"][data-prism-theme][href="${publicURL}/prism-${theme}.css"]`);
130
+ }
131
+
132
+ //#endregion
133
+ //#region src/extensions/columns.tsx
134
+ const COLUMN_PARENT_TYPES = [
135
+ "twoColumns",
136
+ "threeColumns",
137
+ "fourColumns"
138
+ ];
139
+ const COLUMN_PARENT_SET = new Set(COLUMN_PARENT_TYPES);
140
+ const MAX_COLUMNS_DEPTH = 3;
141
+ function getColumnsDepth(doc, from) {
142
+ const $from = doc.resolve(from);
143
+ let depth = 0;
144
+ for (let d = $from.depth; d > 0; d--) if (COLUMN_PARENT_SET.has($from.node(d).type.name)) depth++;
145
+ return depth;
146
+ }
147
+ const VARIANTS = [
148
+ {
149
+ name: "twoColumns",
150
+ columnCount: 2,
151
+ content: "columnsColumn columnsColumn",
152
+ dataType: "two-columns"
153
+ },
154
+ {
155
+ name: "threeColumns",
156
+ columnCount: 3,
157
+ content: "columnsColumn columnsColumn columnsColumn",
158
+ dataType: "three-columns"
159
+ },
160
+ {
161
+ name: "fourColumns",
162
+ columnCount: 4,
163
+ content: "columnsColumn{4}",
164
+ dataType: "four-columns"
165
+ }
166
+ ];
167
+ const NODE_TYPE_MAP = {
168
+ 2: "twoColumns",
169
+ 3: "threeColumns",
170
+ 4: "fourColumns"
171
+ };
172
+ function createColumnsNode(config, includeCommands) {
173
+ return require_event_bus.EmailNode.create({
174
+ name: config.name,
175
+ group: "block",
176
+ content: config.content,
177
+ isolating: true,
178
+ defining: true,
179
+ addAttributes() {
180
+ return createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]);
181
+ },
182
+ parseHTML() {
183
+ return [{ tag: `div[data-type="${config.dataType}"]` }];
184
+ },
185
+ renderHTML({ HTMLAttributes }) {
186
+ return [
187
+ "div",
188
+ (0, _tiptap_core.mergeAttributes)({
189
+ "data-type": config.dataType,
190
+ class: "node-columns"
191
+ }, HTMLAttributes),
192
+ 0
193
+ ];
194
+ },
195
+ ...includeCommands && { addCommands() {
196
+ return { insertColumns: (count) => ({ commands, state }) => {
197
+ if (getColumnsDepth(state.doc, state.selection.from) >= MAX_COLUMNS_DEPTH) return false;
198
+ const nodeType = NODE_TYPE_MAP[count];
199
+ const children = Array.from({ length: count }, () => ({
200
+ type: "columnsColumn",
201
+ content: [{
202
+ type: "paragraph",
203
+ content: []
204
+ }]
205
+ }));
206
+ return commands.insertContent({
207
+ type: nodeType,
208
+ content: children
209
+ });
210
+ } };
211
+ } },
212
+ renderToReactEmail({ children, node, style }) {
213
+ const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
214
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_email.Row, {
215
+ className: node.attrs?.class || void 0,
216
+ style: {
217
+ ...style,
218
+ ...inlineStyles
219
+ },
220
+ children
221
+ });
222
+ }
223
+ });
224
+ }
225
+ const TwoColumns = createColumnsNode(VARIANTS[0], true);
226
+ const ThreeColumns = createColumnsNode(VARIANTS[1], false);
227
+ const FourColumns = createColumnsNode(VARIANTS[2], false);
228
+ const ColumnsColumn = require_event_bus.EmailNode.create({
229
+ name: "columnsColumn",
230
+ group: "columnsColumn",
231
+ content: "block+",
232
+ isolating: true,
233
+ addAttributes() {
234
+ return { ...createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]) };
235
+ },
236
+ parseHTML() {
237
+ return [{ tag: "div[data-type=\"column\"]" }];
238
+ },
239
+ renderHTML({ HTMLAttributes }) {
240
+ return [
241
+ "div",
242
+ (0, _tiptap_core.mergeAttributes)({
243
+ "data-type": "column",
244
+ class: "node-column"
245
+ }, HTMLAttributes),
246
+ 0
247
+ ];
248
+ },
249
+ addKeyboardShortcuts() {
250
+ return {
251
+ Backspace: ({ editor }) => {
252
+ const { state } = editor;
253
+ const { selection } = state;
254
+ const { empty, $from } = selection;
255
+ if (!empty) return false;
256
+ for (let depth = $from.depth; depth >= 1; depth--) {
257
+ if ($from.pos !== $from.start(depth)) break;
258
+ const indexInParent = $from.index(depth - 1);
259
+ if (indexInParent === 0) continue;
260
+ const prevNode = $from.node(depth - 1).child(indexInParent - 1);
261
+ if (COLUMN_PARENT_SET.has(prevNode.type.name)) {
262
+ const deleteFrom = $from.before(depth) - prevNode.nodeSize;
263
+ const deleteTo = $from.before(depth);
264
+ editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));
265
+ return true;
266
+ }
267
+ break;
268
+ }
269
+ return false;
270
+ },
271
+ "Mod-a": ({ editor }) => {
272
+ const { state } = editor;
273
+ const { $from } = state.selection;
274
+ for (let d = $from.depth; d > 0; d--) {
275
+ if ($from.node(d).type.name !== "columnsColumn") continue;
276
+ const columnStart = $from.start(d);
277
+ const columnEnd = $from.end(d);
278
+ const { from, to } = state.selection;
279
+ if (from === columnStart && to === columnEnd) return false;
280
+ editor.view.dispatch(state.tr.setSelection(_tiptap_pm_state.TextSelection.create(state.doc, columnStart, columnEnd)));
281
+ return true;
282
+ }
283
+ return false;
284
+ }
285
+ };
286
+ },
287
+ renderToReactEmail({ children, node, style }) {
288
+ const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
289
+ const width = node.attrs?.width;
290
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_email.Column, {
291
+ className: node.attrs?.class || void 0,
292
+ style: {
293
+ ...style,
294
+ ...inlineStyles,
295
+ ...width ? { width } : {}
296
+ },
297
+ children
298
+ });
299
+ }
300
+ });
301
+
302
+ //#endregion
303
+ Object.defineProperty(exports, 'COLUMN_PARENT_TYPES', {
304
+ enumerable: true,
305
+ get: function () {
306
+ return COLUMN_PARENT_TYPES;
307
+ }
308
+ });
309
+ Object.defineProperty(exports, 'COMMON_HTML_ATTRIBUTES', {
310
+ enumerable: true,
311
+ get: function () {
312
+ return COMMON_HTML_ATTRIBUTES;
313
+ }
314
+ });
315
+ Object.defineProperty(exports, 'ColumnsColumn', {
316
+ enumerable: true,
317
+ get: function () {
318
+ return ColumnsColumn;
319
+ }
320
+ });
321
+ Object.defineProperty(exports, 'FourColumns', {
322
+ enumerable: true,
323
+ get: function () {
324
+ return FourColumns;
325
+ }
326
+ });
327
+ Object.defineProperty(exports, 'LAYOUT_ATTRIBUTES', {
328
+ enumerable: true,
329
+ get: function () {
330
+ return LAYOUT_ATTRIBUTES;
331
+ }
332
+ });
333
+ Object.defineProperty(exports, 'MAX_COLUMNS_DEPTH', {
334
+ enumerable: true,
335
+ get: function () {
336
+ return MAX_COLUMNS_DEPTH;
337
+ }
338
+ });
339
+ Object.defineProperty(exports, 'TABLE_ATTRIBUTES', {
340
+ enumerable: true,
341
+ get: function () {
342
+ return TABLE_ATTRIBUTES;
343
+ }
344
+ });
345
+ Object.defineProperty(exports, 'TABLE_CELL_ATTRIBUTES', {
346
+ enumerable: true,
347
+ get: function () {
348
+ return TABLE_CELL_ATTRIBUTES;
349
+ }
350
+ });
351
+ Object.defineProperty(exports, 'TABLE_HEADER_ATTRIBUTES', {
352
+ enumerable: true,
353
+ get: function () {
354
+ return TABLE_HEADER_ATTRIBUTES;
355
+ }
356
+ });
357
+ Object.defineProperty(exports, 'ThreeColumns', {
358
+ enumerable: true,
359
+ get: function () {
360
+ return ThreeColumns;
361
+ }
362
+ });
363
+ Object.defineProperty(exports, 'TwoColumns', {
364
+ enumerable: true,
365
+ get: function () {
366
+ return TwoColumns;
367
+ }
368
+ });
369
+ Object.defineProperty(exports, '__toESM', {
370
+ enumerable: true,
371
+ get: function () {
372
+ return __toESM;
373
+ }
374
+ });
375
+ Object.defineProperty(exports, 'createStandardAttributes', {
376
+ enumerable: true,
377
+ get: function () {
378
+ return createStandardAttributes;
379
+ }
380
+ });
381
+ Object.defineProperty(exports, 'getColumnsDepth', {
382
+ enumerable: true,
383
+ get: function () {
384
+ return getColumnsDepth;
385
+ }
386
+ });
387
+ Object.defineProperty(exports, 'hasPrismThemeLoaded', {
388
+ enumerable: true,
389
+ get: function () {
390
+ return hasPrismThemeLoaded;
391
+ }
392
+ });
393
+ Object.defineProperty(exports, 'loadPrismTheme', {
394
+ enumerable: true,
395
+ get: function () {
396
+ return loadPrismTheme;
397
+ }
398
+ });
399
+ Object.defineProperty(exports, 'removePrismTheme', {
400
+ enumerable: true,
401
+ get: function () {
402
+ return removePrismTheme;
403
+ }
404
+ });
@@ -0,0 +1,277 @@
1
+ import { r as inlineCssToJs } from "./styles-BBXVfEv-.mjs";
2
+ import { r as EmailNode } from "./event-bus-BxVEXi1L.mjs";
3
+ import { Column, Row } from "react-email";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { mergeAttributes } from "@tiptap/core";
6
+ import { TextSelection } from "@tiptap/pm/state";
7
+
8
+ //#region src/utils/attribute-helpers.ts
9
+ /**
10
+ * Creates TipTap attribute definitions for a list of HTML attributes.
11
+ * Each attribute will have the same pattern:
12
+ * - default: null
13
+ * - parseHTML: extracts the attribute from the element
14
+ * - renderHTML: conditionally renders the attribute if it has a value
15
+ *
16
+ * @param attributeNames - Array of HTML attribute names to create definitions for
17
+ * @returns Object with TipTap attribute definitions
18
+ *
19
+ * @example
20
+ * const attrs = createStandardAttributes(['class', 'id', 'title']);
21
+ * // Returns:
22
+ * // {
23
+ * // class: {
24
+ * // default: null,
25
+ * // parseHTML: (element) => element.getAttribute('class'),
26
+ * // renderHTML: (attributes) => attributes.class ? { class: attributes.class } : {}
27
+ * // },
28
+ * // ...
29
+ * // }
30
+ */
31
+ function createStandardAttributes(attributeNames) {
32
+ return Object.fromEntries(attributeNames.map((attr) => [attr, {
33
+ default: null,
34
+ parseHTML: (element) => element.getAttribute(attr),
35
+ renderHTML: (attributes) => {
36
+ if (!attributes[attr]) return {};
37
+ return { [attr]: attributes[attr] };
38
+ }
39
+ }]));
40
+ }
41
+ /**
42
+ * Common HTML attributes used across multiple extensions.
43
+ * These preserve attributes during HTML import and editing for better
44
+ * fidelity when importing existing email templates.
45
+ */
46
+ const COMMON_HTML_ATTRIBUTES = [
47
+ "id",
48
+ "class",
49
+ "title",
50
+ "lang",
51
+ "dir",
52
+ "data-id"
53
+ ];
54
+ /**
55
+ * Layout-specific HTML attributes used for positioning and sizing.
56
+ */
57
+ const LAYOUT_ATTRIBUTES = [
58
+ "align",
59
+ "width",
60
+ "height"
61
+ ];
62
+ /**
63
+ * Table-specific HTML attributes used for table layout and styling.
64
+ */
65
+ const TABLE_ATTRIBUTES = [
66
+ "border",
67
+ "cellpadding",
68
+ "cellspacing"
69
+ ];
70
+ /**
71
+ * Table cell-specific HTML attributes.
72
+ */
73
+ const TABLE_CELL_ATTRIBUTES = [
74
+ "valign",
75
+ "bgcolor",
76
+ "colspan",
77
+ "rowspan"
78
+ ];
79
+ /**
80
+ * Table header cell-specific HTML attributes.
81
+ * These are additional attributes that only apply to <th> elements.
82
+ */
83
+ const TABLE_HEADER_ATTRIBUTES = [...TABLE_CELL_ATTRIBUTES, "scope"];
84
+
85
+ //#endregion
86
+ //#region src/utils/prism-utils.ts
87
+ const publicURL = "/styles/prism";
88
+ function loadPrismTheme(theme) {
89
+ const link = document.createElement("link");
90
+ link.rel = "stylesheet";
91
+ link.href = `${publicURL}/prism-${theme}.css`;
92
+ link.setAttribute("data-prism-theme", "");
93
+ document.head.appendChild(link);
94
+ }
95
+ function removePrismTheme() {
96
+ const existingTheme = document.querySelectorAll("link[rel=\"stylesheet\"][data-prism-theme]");
97
+ if (existingTheme.length > 0) existingTheme.forEach((cssLinkTag) => {
98
+ cssLinkTag.remove();
99
+ });
100
+ }
101
+ function hasPrismThemeLoaded(theme) {
102
+ return !!document.querySelector(`link[rel="stylesheet"][data-prism-theme][href="${publicURL}/prism-${theme}.css"]`);
103
+ }
104
+
105
+ //#endregion
106
+ //#region src/extensions/columns.tsx
107
+ const COLUMN_PARENT_TYPES = [
108
+ "twoColumns",
109
+ "threeColumns",
110
+ "fourColumns"
111
+ ];
112
+ const COLUMN_PARENT_SET = new Set(COLUMN_PARENT_TYPES);
113
+ const MAX_COLUMNS_DEPTH = 3;
114
+ function getColumnsDepth(doc, from) {
115
+ const $from = doc.resolve(from);
116
+ let depth = 0;
117
+ for (let d = $from.depth; d > 0; d--) if (COLUMN_PARENT_SET.has($from.node(d).type.name)) depth++;
118
+ return depth;
119
+ }
120
+ const VARIANTS = [
121
+ {
122
+ name: "twoColumns",
123
+ columnCount: 2,
124
+ content: "columnsColumn columnsColumn",
125
+ dataType: "two-columns"
126
+ },
127
+ {
128
+ name: "threeColumns",
129
+ columnCount: 3,
130
+ content: "columnsColumn columnsColumn columnsColumn",
131
+ dataType: "three-columns"
132
+ },
133
+ {
134
+ name: "fourColumns",
135
+ columnCount: 4,
136
+ content: "columnsColumn{4}",
137
+ dataType: "four-columns"
138
+ }
139
+ ];
140
+ const NODE_TYPE_MAP = {
141
+ 2: "twoColumns",
142
+ 3: "threeColumns",
143
+ 4: "fourColumns"
144
+ };
145
+ function createColumnsNode(config, includeCommands) {
146
+ return EmailNode.create({
147
+ name: config.name,
148
+ group: "block",
149
+ content: config.content,
150
+ isolating: true,
151
+ defining: true,
152
+ addAttributes() {
153
+ return createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]);
154
+ },
155
+ parseHTML() {
156
+ return [{ tag: `div[data-type="${config.dataType}"]` }];
157
+ },
158
+ renderHTML({ HTMLAttributes }) {
159
+ return [
160
+ "div",
161
+ mergeAttributes({
162
+ "data-type": config.dataType,
163
+ class: "node-columns"
164
+ }, HTMLAttributes),
165
+ 0
166
+ ];
167
+ },
168
+ ...includeCommands && { addCommands() {
169
+ return { insertColumns: (count) => ({ commands, state }) => {
170
+ if (getColumnsDepth(state.doc, state.selection.from) >= MAX_COLUMNS_DEPTH) return false;
171
+ const nodeType = NODE_TYPE_MAP[count];
172
+ const children = Array.from({ length: count }, () => ({
173
+ type: "columnsColumn",
174
+ content: [{
175
+ type: "paragraph",
176
+ content: []
177
+ }]
178
+ }));
179
+ return commands.insertContent({
180
+ type: nodeType,
181
+ content: children
182
+ });
183
+ } };
184
+ } },
185
+ renderToReactEmail({ children, node, style }) {
186
+ const inlineStyles = inlineCssToJs(node.attrs?.style);
187
+ return /* @__PURE__ */ jsx(Row, {
188
+ className: node.attrs?.class || void 0,
189
+ style: {
190
+ ...style,
191
+ ...inlineStyles
192
+ },
193
+ children
194
+ });
195
+ }
196
+ });
197
+ }
198
+ const TwoColumns = createColumnsNode(VARIANTS[0], true);
199
+ const ThreeColumns = createColumnsNode(VARIANTS[1], false);
200
+ const FourColumns = createColumnsNode(VARIANTS[2], false);
201
+ const ColumnsColumn = EmailNode.create({
202
+ name: "columnsColumn",
203
+ group: "columnsColumn",
204
+ content: "block+",
205
+ isolating: true,
206
+ addAttributes() {
207
+ return { ...createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]) };
208
+ },
209
+ parseHTML() {
210
+ return [{ tag: "div[data-type=\"column\"]" }];
211
+ },
212
+ renderHTML({ HTMLAttributes }) {
213
+ return [
214
+ "div",
215
+ mergeAttributes({
216
+ "data-type": "column",
217
+ class: "node-column"
218
+ }, HTMLAttributes),
219
+ 0
220
+ ];
221
+ },
222
+ addKeyboardShortcuts() {
223
+ return {
224
+ Backspace: ({ editor }) => {
225
+ const { state } = editor;
226
+ const { selection } = state;
227
+ const { empty, $from } = selection;
228
+ if (!empty) return false;
229
+ for (let depth = $from.depth; depth >= 1; depth--) {
230
+ if ($from.pos !== $from.start(depth)) break;
231
+ const indexInParent = $from.index(depth - 1);
232
+ if (indexInParent === 0) continue;
233
+ const prevNode = $from.node(depth - 1).child(indexInParent - 1);
234
+ if (COLUMN_PARENT_SET.has(prevNode.type.name)) {
235
+ const deleteFrom = $from.before(depth) - prevNode.nodeSize;
236
+ const deleteTo = $from.before(depth);
237
+ editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));
238
+ return true;
239
+ }
240
+ break;
241
+ }
242
+ return false;
243
+ },
244
+ "Mod-a": ({ editor }) => {
245
+ const { state } = editor;
246
+ const { $from } = state.selection;
247
+ for (let d = $from.depth; d > 0; d--) {
248
+ if ($from.node(d).type.name !== "columnsColumn") continue;
249
+ const columnStart = $from.start(d);
250
+ const columnEnd = $from.end(d);
251
+ const { from, to } = state.selection;
252
+ if (from === columnStart && to === columnEnd) return false;
253
+ editor.view.dispatch(state.tr.setSelection(TextSelection.create(state.doc, columnStart, columnEnd)));
254
+ return true;
255
+ }
256
+ return false;
257
+ }
258
+ };
259
+ },
260
+ renderToReactEmail({ children, node, style }) {
261
+ const inlineStyles = inlineCssToJs(node.attrs?.style);
262
+ const width = node.attrs?.width;
263
+ return /* @__PURE__ */ jsx(Column, {
264
+ className: node.attrs?.class || void 0,
265
+ style: {
266
+ ...style,
267
+ ...inlineStyles,
268
+ ...width ? { width } : {}
269
+ },
270
+ children
271
+ });
272
+ }
273
+ });
274
+
275
+ //#endregion
276
+ export { ThreeColumns as a, hasPrismThemeLoaded as c, COMMON_HTML_ATTRIBUTES as d, LAYOUT_ATTRIBUTES as f, createStandardAttributes as g, TABLE_HEADER_ATTRIBUTES as h, MAX_COLUMNS_DEPTH as i, loadPrismTheme as l, TABLE_CELL_ATTRIBUTES as m, ColumnsColumn as n, TwoColumns as o, TABLE_ATTRIBUTES as p, FourColumns as r, getColumnsDepth as s, COLUMN_PARENT_TYPES as t, removePrismTheme as u };
277
+ //# sourceMappingURL=columns-TFI4L-IC.mjs.map