@react-email/editor 0.0.0-experimental.3 → 0.0.0-experimental.30

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 (63) hide show
  1. package/dist/columns-BXN-NNd4.cjs +450 -0
  2. package/dist/columns-Cos2lqfu.mjs +329 -0
  3. package/dist/columns-Cos2lqfu.mjs.map +1 -0
  4. package/dist/core/index.cjs +8 -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-DVox_fis.cjs +2159 -0
  9. package/dist/core-mUMTkab3.mjs +1914 -0
  10. package/dist/core-mUMTkab3.mjs.map +1 -0
  11. package/dist/extensions/index.cjs +48 -0
  12. package/dist/extensions/index.d.cts +395 -0
  13. package/dist/extensions/index.d.cts.map +1 -0
  14. package/dist/extensions/index.d.mts +395 -0
  15. package/dist/extensions/index.d.mts.map +1 -0
  16. package/dist/extensions/index.mjs +5 -0
  17. package/dist/global-content-BRvA4PRG.cjs +89 -0
  18. package/dist/global-content-kdUzYcsA.mjs +78 -0
  19. package/dist/global-content-kdUzYcsA.mjs.map +1 -0
  20. package/dist/index-jGyVEd5q.d.cts +131 -0
  21. package/dist/index-jGyVEd5q.d.cts.map +1 -0
  22. package/dist/index-ozCcANmD.d.mts +131 -0
  23. package/dist/index-ozCcANmD.d.mts.map +1 -0
  24. package/dist/plugins/index.cjs +747 -0
  25. package/dist/plugins/index.d.cts +79 -0
  26. package/dist/plugins/index.d.cts.map +1 -0
  27. package/dist/plugins/index.d.mts +79 -0
  28. package/dist/plugins/index.d.mts.map +1 -0
  29. package/dist/plugins/index.mjs +742 -0
  30. package/dist/plugins/index.mjs.map +1 -0
  31. package/dist/set-text-alignment-BO24ieeE.mjs +19 -0
  32. package/dist/set-text-alignment-BO24ieeE.mjs.map +1 -0
  33. package/dist/set-text-alignment-CbECklB4.cjs +24 -0
  34. package/dist/styles-C-cCyJCn.cjs +211 -0
  35. package/dist/styles-DLviD0JK.mjs +194 -0
  36. package/dist/styles-DLviD0JK.mjs.map +1 -0
  37. package/dist/ui/bubble-menu/bubble-menu.css +146 -0
  38. package/dist/ui/button-bubble-menu/button-bubble-menu.css +29 -0
  39. package/dist/ui/image-bubble-menu/image-bubble-menu.css +29 -0
  40. package/dist/ui/index.cjs +1646 -0
  41. package/dist/ui/index.d.cts +668 -0
  42. package/dist/ui/index.d.cts.map +1 -0
  43. package/dist/ui/index.d.mts +668 -0
  44. package/dist/ui/index.d.mts.map +1 -0
  45. package/dist/ui/index.mjs +1584 -0
  46. package/dist/ui/index.mjs.map +1 -0
  47. package/dist/ui/link-bubble-menu/link-bubble-menu.css +66 -0
  48. package/dist/ui/slash-command/slash-command.css +44 -0
  49. package/dist/ui/themes/default.css +769 -0
  50. package/dist/utils/index.cjs +3 -0
  51. package/dist/utils/index.d.cts +7 -0
  52. package/dist/utils/index.d.cts.map +1 -0
  53. package/dist/utils/index.d.mts +7 -0
  54. package/dist/utils/index.d.mts.map +1 -0
  55. package/dist/utils/index.mjs +3 -0
  56. package/package.json +96 -23
  57. package/dist/index.d.mts +0 -273
  58. package/dist/index.d.mts.map +0 -1
  59. package/dist/index.d.ts +0 -273
  60. package/dist/index.d.ts.map +0 -1
  61. package/dist/index.js +0 -1394
  62. package/dist/index.mjs +0 -1346
  63. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,2159 @@
1
+ const require_columns = require('./columns-BXN-NNd4.cjs');
2
+ const require_styles = require('./styles-C-cCyJCn.cjs');
3
+ const require_global_content = require('./global-content-BRvA4PRG.cjs');
4
+ let _react_email_components = require("@react-email/components");
5
+ _react_email_components = require_columns.__toESM(_react_email_components);
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ let _tiptap_core = require("@tiptap/core");
8
+ let _tiptap_extensions = require("@tiptap/extensions");
9
+ let _tiptap_react = require("@tiptap/react");
10
+ let react = require("react");
11
+ react = require_columns.__toESM(react);
12
+ let _tiptap_starter_kit = require("@tiptap/starter-kit");
13
+ _tiptap_starter_kit = require_columns.__toESM(_tiptap_starter_kit);
14
+ let _tiptap_extension_blockquote = require("@tiptap/extension-blockquote");
15
+ _tiptap_extension_blockquote = require_columns.__toESM(_tiptap_extension_blockquote);
16
+ let _tiptap_extension_bold = require("@tiptap/extension-bold");
17
+ _tiptap_extension_bold = require_columns.__toESM(_tiptap_extension_bold);
18
+ let _tiptap_extension_bullet_list = require("@tiptap/extension-bullet-list");
19
+ _tiptap_extension_bullet_list = require_columns.__toESM(_tiptap_extension_bullet_list);
20
+ let _tiptap_extension_code = require("@tiptap/extension-code");
21
+ _tiptap_extension_code = require_columns.__toESM(_tiptap_extension_code);
22
+ let _tiptap_extension_code_block = require("@tiptap/extension-code-block");
23
+ _tiptap_extension_code_block = require_columns.__toESM(_tiptap_extension_code_block);
24
+ let _tiptap_pm_state = require("@tiptap/pm/state");
25
+ let _tiptap_pm_view = require("@tiptap/pm/view");
26
+ let hast_util_from_html = require("hast-util-from-html");
27
+ let prismjs = require("prismjs");
28
+ prismjs = require_columns.__toESM(prismjs);
29
+ let _tiptap_extension_horizontal_rule = require("@tiptap/extension-horizontal-rule");
30
+ _tiptap_extension_horizontal_rule = require_columns.__toESM(_tiptap_extension_horizontal_rule);
31
+ let _tiptap_extension_hard_break = require("@tiptap/extension-hard-break");
32
+ _tiptap_extension_hard_break = require_columns.__toESM(_tiptap_extension_hard_break);
33
+ let _tiptap_extension_heading = require("@tiptap/extension-heading");
34
+ let _tiptap_extension_italic = require("@tiptap/extension-italic");
35
+ _tiptap_extension_italic = require_columns.__toESM(_tiptap_extension_italic);
36
+ let _tiptap_extension_link = require("@tiptap/extension-link");
37
+ _tiptap_extension_link = require_columns.__toESM(_tiptap_extension_link);
38
+ let _tiptap_extension_list_item = require("@tiptap/extension-list-item");
39
+ _tiptap_extension_list_item = require_columns.__toESM(_tiptap_extension_list_item);
40
+ let _tiptap_extension_ordered_list = require("@tiptap/extension-ordered-list");
41
+ _tiptap_extension_ordered_list = require_columns.__toESM(_tiptap_extension_ordered_list);
42
+ let _tiptap_extension_paragraph = require("@tiptap/extension-paragraph");
43
+ _tiptap_extension_paragraph = require_columns.__toESM(_tiptap_extension_paragraph);
44
+ let _tiptap_extension_placeholder = require("@tiptap/extension-placeholder");
45
+ _tiptap_extension_placeholder = require_columns.__toESM(_tiptap_extension_placeholder);
46
+ let _tiptap_extension_strike = require("@tiptap/extension-strike");
47
+ _tiptap_extension_strike = require_columns.__toESM(_tiptap_extension_strike);
48
+ let _tiptap_extension_superscript = require("@tiptap/extension-superscript");
49
+ _tiptap_extension_superscript = require_columns.__toESM(_tiptap_extension_superscript);
50
+ let _tiptap_extension_text = require("@tiptap/extension-text");
51
+ let _tiptap_extension_underline = require("@tiptap/extension-underline");
52
+ _tiptap_extension_underline = require_columns.__toESM(_tiptap_extension_underline);
53
+ let _tiptap_html = require("@tiptap/html");
54
+
55
+ //#region src/core/is-document-visually-empty.ts
56
+ function isDocumentVisuallyEmpty(doc) {
57
+ let nonGlobalNodeCount = 0;
58
+ let firstNonGlobalNode = null;
59
+ for (let index = 0; index < doc.childCount; index += 1) {
60
+ const node = doc.child(index);
61
+ if (node.type.name === "globalContent") continue;
62
+ nonGlobalNodeCount += 1;
63
+ if (firstNonGlobalNode === null) firstNonGlobalNode = {
64
+ type: node.type,
65
+ textContent: node.textContent,
66
+ childCount: node.content.childCount
67
+ };
68
+ }
69
+ if (nonGlobalNodeCount === 0) return true;
70
+ if (nonGlobalNodeCount !== 1) return false;
71
+ return firstNonGlobalNode?.type.name === "paragraph" && firstNonGlobalNode.textContent.trim().length === 0 && firstNonGlobalNode.childCount === 0;
72
+ }
73
+
74
+ //#endregion
75
+ //#region src/core/serializer/default-base-template.tsx
76
+ function DefaultBaseTemplate({ children, previewText }) {
77
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_react_email_components.Html, { children: [
78
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_react_email_components.Head, { children: [
79
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
80
+ content: "width=device-width",
81
+ name: "viewport"
82
+ }),
83
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
84
+ content: "IE=edge",
85
+ httpEquiv: "X-UA-Compatible"
86
+ }),
87
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", { name: "x-apple-disable-message-reformatting" }),
88
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
89
+ content: "telephone=no,address=no,email=no,date=no,url=no",
90
+ name: "format-detection"
91
+ })
92
+ ] }),
93
+ previewText && previewText !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Preview, { children: previewText }),
94
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Body, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Section, {
95
+ width: "100%",
96
+ align: "center",
97
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Section, {
98
+ style: { width: "100%" },
99
+ children
100
+ })
101
+ }) })
102
+ ] });
103
+ }
104
+
105
+ //#endregion
106
+ //#region src/core/serializer/email-mark.ts
107
+ var EmailMark = class EmailMark extends _tiptap_core.Mark {
108
+ constructor(config) {
109
+ super(config);
110
+ }
111
+ /**
112
+ * Create a new Mark instance
113
+ * @param config - Mark configuration object or a function that returns a configuration object
114
+ */
115
+ static create(config) {
116
+ return new EmailMark(typeof config === "function" ? config() : config);
117
+ }
118
+ static from(mark, renderToReactEmail) {
119
+ const customMark = EmailMark.create({});
120
+ Object.assign(customMark, { ...mark });
121
+ customMark.config = {
122
+ ...mark.config,
123
+ renderToReactEmail
124
+ };
125
+ return customMark;
126
+ }
127
+ configure(options) {
128
+ return super.configure(options);
129
+ }
130
+ extend(extendedConfig) {
131
+ const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
132
+ return super.extend(resolvedConfig);
133
+ }
134
+ };
135
+
136
+ //#endregion
137
+ //#region src/core/serializer/compose-react-email.tsx
138
+ const NODES_WITH_INCREMENTED_CHILD_DEPTH = new Set(["bulletList", "orderedList"]);
139
+ const composeReactEmail = async ({ editor, preview }) => {
140
+ const data = editor.getJSON();
141
+ const extensions = editor.extensionManager.extensions;
142
+ const serializerPlugin = extensions.map((ext) => ext.options?.serializerPlugin).filter((p) => Boolean(p)).at(-1);
143
+ const typeToExtensionMap = Object.fromEntries(extensions.map((extension) => [extension.name, extension]));
144
+ function parseContent(content, depth = 0) {
145
+ if (!content) return;
146
+ return content.map((node, index) => {
147
+ const style = serializerPlugin?.getNodeStyles(node, depth, editor) ?? {};
148
+ const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
149
+ if (!node.type) return null;
150
+ const emailNode = typeToExtensionMap[node.type];
151
+ if (!emailNode || !(emailNode instanceof require_columns.EmailNode)) return null;
152
+ const NodeComponent = emailNode.config.renderToReactEmail;
153
+ const childDepth = NODES_WITH_INCREMENTED_CHILD_DEPTH.has(node.type) ? depth + 1 : depth;
154
+ let renderedNode = node.text ? node.text : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeComponent, {
155
+ node: node.type === "table" && inlineStyles.width && !node.attrs?.width ? {
156
+ ...node,
157
+ attrs: {
158
+ ...node.attrs,
159
+ width: inlineStyles.width
160
+ }
161
+ } : node,
162
+ style,
163
+ extension: emailNode,
164
+ children: parseContent(node.content, childDepth)
165
+ }, index);
166
+ if (node.marks) for (const mark of node.marks) {
167
+ const emailMark = typeToExtensionMap[mark.type];
168
+ if (emailMark instanceof EmailMark) {
169
+ const MarkComponent = emailMark.config.renderToReactEmail;
170
+ renderedNode = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkComponent, {
171
+ mark,
172
+ node,
173
+ style: serializerPlugin?.getNodeStyles({
174
+ type: mark.type,
175
+ attrs: mark.attrs ?? {}
176
+ }, depth, editor) ?? {},
177
+ extension: emailMark,
178
+ children: renderedNode
179
+ });
180
+ }
181
+ }
182
+ return renderedNode;
183
+ });
184
+ }
185
+ const unformattedHtml = await (0, _react_email_components.render)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(serializerPlugin?.BaseTemplate ?? DefaultBaseTemplate, {
186
+ previewText: preview,
187
+ editor,
188
+ children: parseContent(data.content)
189
+ }));
190
+ const [prettyHtml, text] = await Promise.all([(0, _react_email_components.pretty)(unformattedHtml), (0, _react_email_components.toPlainText)(unformattedHtml)]);
191
+ return {
192
+ html: prettyHtml,
193
+ text
194
+ };
195
+ };
196
+
197
+ //#endregion
198
+ //#region src/extensions/alignment-attribute.tsx
199
+ const AlignmentAttribute = _tiptap_core.Extension.create({
200
+ name: "alignmentAttribute",
201
+ addOptions() {
202
+ return {
203
+ types: [],
204
+ alignments: [
205
+ "left",
206
+ "center",
207
+ "right",
208
+ "justify"
209
+ ]
210
+ };
211
+ },
212
+ addGlobalAttributes() {
213
+ return [{
214
+ types: this.options.types,
215
+ attributes: { alignment: {
216
+ parseHTML: (element) => {
217
+ const explicitAlign = element.getAttribute("align") || element.getAttribute("alignment") || element.style.textAlign;
218
+ if (explicitAlign && this.options.alignments.includes(explicitAlign)) return explicitAlign;
219
+ return null;
220
+ },
221
+ renderHTML: (attributes) => {
222
+ if (attributes.alignment === "left") return {};
223
+ return { alignment: attributes.alignment };
224
+ }
225
+ } }
226
+ }];
227
+ },
228
+ addCommands() {
229
+ return { setAlignment: (alignment) => ({ commands }) => {
230
+ if (!this.options.alignments.includes(alignment)) return false;
231
+ return this.options.types.every((type) => commands.updateAttributes(type, { alignment }));
232
+ } };
233
+ },
234
+ addKeyboardShortcuts() {
235
+ return {
236
+ Enter: () => {
237
+ const { from } = this.editor.state.selection;
238
+ const currentAlignment = this.editor.state.doc.nodeAt(from)?.attrs?.alignment;
239
+ if (currentAlignment) requestAnimationFrame(() => {
240
+ this.editor.commands.setAlignment(currentAlignment);
241
+ });
242
+ return false;
243
+ },
244
+ "Mod-Shift-l": () => this.editor.commands.setAlignment("left"),
245
+ "Mod-Shift-e": () => this.editor.commands.setAlignment("center"),
246
+ "Mod-Shift-r": () => this.editor.commands.setAlignment("right"),
247
+ "Mod-Shift-j": () => this.editor.commands.setAlignment("justify")
248
+ };
249
+ }
250
+ });
251
+
252
+ //#endregion
253
+ //#region src/utils/get-text-alignment.ts
254
+ function getTextAlignment(alignment) {
255
+ switch (alignment) {
256
+ case "left": return { textAlign: "left" };
257
+ case "center": return { textAlign: "center" };
258
+ case "right": return { textAlign: "right" };
259
+ default: return {};
260
+ }
261
+ }
262
+
263
+ //#endregion
264
+ //#region src/extensions/blockquote.tsx
265
+ const Blockquote = require_columns.EmailNode.from(_tiptap_extension_blockquote.default, ({ children, node, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("blockquote", {
266
+ className: node.attrs?.class || void 0,
267
+ style: {
268
+ ...style,
269
+ ...require_styles.inlineCssToJs(node.attrs?.style),
270
+ ...getTextAlignment(node.attrs?.align || node.attrs?.alignment)
271
+ },
272
+ children
273
+ }));
274
+
275
+ //#endregion
276
+ //#region src/extensions/body.tsx
277
+ const Body = require_columns.EmailNode.create({
278
+ name: "body",
279
+ group: "block",
280
+ content: "block+",
281
+ defining: true,
282
+ isolating: true,
283
+ addAttributes() {
284
+ return { ...require_columns.createStandardAttributes([...require_columns.COMMON_HTML_ATTRIBUTES, ...require_columns.LAYOUT_ATTRIBUTES]) };
285
+ },
286
+ parseHTML() {
287
+ return [{
288
+ tag: "body",
289
+ getAttrs: (node) => {
290
+ if (typeof node === "string") return false;
291
+ const element = node;
292
+ const attrs = {};
293
+ Array.from(element.attributes).forEach((attr) => {
294
+ attrs[attr.name] = attr.value;
295
+ });
296
+ return attrs;
297
+ }
298
+ }];
299
+ },
300
+ renderHTML({ HTMLAttributes }) {
301
+ return [
302
+ "div",
303
+ (0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
304
+ 0
305
+ ];
306
+ },
307
+ renderToReactEmail({ children, node, style }) {
308
+ const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
309
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
310
+ className: node.attrs?.class || void 0,
311
+ style: {
312
+ ...style,
313
+ ...inlineStyles
314
+ },
315
+ children
316
+ });
317
+ }
318
+ });
319
+
320
+ //#endregion
321
+ //#region src/extensions/bold.tsx
322
+ const BoldWithoutFontWeightInference = _tiptap_extension_bold.default.extend({ parseHTML() {
323
+ return [
324
+ { tag: "strong" },
325
+ {
326
+ tag: "b",
327
+ getAttrs: (node) => node.style.fontWeight !== "normal" && null
328
+ },
329
+ {
330
+ style: "font-weight=400",
331
+ clearMark: (mark) => mark.type.name === this.name
332
+ }
333
+ ];
334
+ } });
335
+ const Bold = EmailMark.from(BoldWithoutFontWeightInference, ({ children, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
336
+ style,
337
+ children
338
+ }));
339
+
340
+ //#endregion
341
+ //#region src/extensions/bullet-list.tsx
342
+ const BulletList = require_columns.EmailNode.from(_tiptap_extension_bullet_list.default, ({ children, node, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
343
+ className: node.attrs?.class || void 0,
344
+ style: {
345
+ ...style,
346
+ ...require_styles.inlineCssToJs(node.attrs?.style)
347
+ },
348
+ children
349
+ }));
350
+
351
+ //#endregion
352
+ //#region src/extensions/button.tsx
353
+ const Button = require_columns.EmailNode.create({
354
+ name: "button",
355
+ group: "block",
356
+ content: "inline*",
357
+ defining: true,
358
+ draggable: true,
359
+ marks: "bold",
360
+ addAttributes() {
361
+ return {
362
+ class: { default: "button" },
363
+ href: { default: "#" },
364
+ alignment: { default: "left" }
365
+ };
366
+ },
367
+ parseHTML() {
368
+ return [{
369
+ tag: "a[data-id=\"react-email-button\"]",
370
+ getAttrs: (node) => {
371
+ if (typeof node === "string") return false;
372
+ const element = node;
373
+ const attrs = {};
374
+ Array.from(element.attributes).forEach((attr) => {
375
+ attrs[attr.name] = attr.value;
376
+ });
377
+ return attrs;
378
+ }
379
+ }];
380
+ },
381
+ renderHTML({ HTMLAttributes }) {
382
+ return [
383
+ "div",
384
+ (0, _tiptap_core.mergeAttributes)({ class: `align-${HTMLAttributes?.alignment}` }),
385
+ [
386
+ "a",
387
+ (0, _tiptap_core.mergeAttributes)({
388
+ class: `node-button ${HTMLAttributes?.class}`,
389
+ style: HTMLAttributes?.style,
390
+ "data-id": "react-email-button",
391
+ "data-href": HTMLAttributes?.href
392
+ }),
393
+ 0
394
+ ]
395
+ ];
396
+ },
397
+ addCommands() {
398
+ return {
399
+ updateButton: (attributes) => ({ commands }) => {
400
+ return commands.updateAttributes("button", attributes);
401
+ },
402
+ setButton: () => ({ commands }) => {
403
+ return commands.insertContent({
404
+ type: "button",
405
+ content: [{
406
+ type: "text",
407
+ text: "Button"
408
+ }]
409
+ });
410
+ }
411
+ };
412
+ },
413
+ renderToReactEmail({ children, node, style }) {
414
+ const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
415
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Row, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Column, {
416
+ align: node.attrs?.align || node.attrs?.alignment,
417
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Button, {
418
+ className: node.attrs?.class || void 0,
419
+ href: node.attrs?.href,
420
+ style: {
421
+ ...style,
422
+ ...inlineStyles
423
+ },
424
+ children
425
+ })
426
+ }) });
427
+ }
428
+ });
429
+
430
+ //#endregion
431
+ //#region src/extensions/class-attribute.tsx
432
+ const ClassAttribute = _tiptap_core.Extension.create({
433
+ name: "classAttribute",
434
+ addOptions() {
435
+ return {
436
+ types: [],
437
+ class: []
438
+ };
439
+ },
440
+ addGlobalAttributes() {
441
+ return [{
442
+ types: this.options.types,
443
+ attributes: { class: {
444
+ default: "",
445
+ parseHTML: (element) => element.className || "",
446
+ renderHTML: (attributes) => {
447
+ return attributes.class ? { class: attributes.class } : {};
448
+ }
449
+ } }
450
+ }];
451
+ },
452
+ addCommands() {
453
+ return {
454
+ unsetClass: () => ({ commands }) => {
455
+ return this.options.types.every((type) => commands.resetAttributes(type, "class"));
456
+ },
457
+ setClass: (classList) => ({ commands }) => {
458
+ return this.options.types.every((type) => commands.updateAttributes(type, { class: classList }));
459
+ }
460
+ };
461
+ },
462
+ addKeyboardShortcuts() {
463
+ return { Enter: ({ editor }) => {
464
+ requestAnimationFrame(() => {
465
+ editor.commands.resetAttributes("paragraph", "class");
466
+ });
467
+ return false;
468
+ } };
469
+ }
470
+ });
471
+
472
+ //#endregion
473
+ //#region src/extensions/code.tsx
474
+ const Code = EmailMark.from(_tiptap_extension_code.default, ({ children, node, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
475
+ style: {
476
+ ...style,
477
+ ...require_styles.inlineCssToJs(node.attrs?.style)
478
+ },
479
+ children
480
+ }));
481
+
482
+ //#endregion
483
+ //#region src/utils/prism-utils.ts
484
+ const publicURL = "/styles/prism";
485
+ function loadPrismTheme(theme) {
486
+ const link = document.createElement("link");
487
+ link.rel = "stylesheet";
488
+ link.href = `${publicURL}/prism-${theme}.css`;
489
+ link.setAttribute("data-prism-theme", "");
490
+ document.head.appendChild(link);
491
+ }
492
+ function removePrismTheme() {
493
+ const existingTheme = document.querySelectorAll("link[rel=\"stylesheet\"][data-prism-theme]");
494
+ if (existingTheme.length > 0) existingTheme.forEach((cssLinkTag) => {
495
+ cssLinkTag.remove();
496
+ });
497
+ }
498
+ function hasPrismThemeLoaded(theme) {
499
+ return !!document.querySelector(`link[rel="stylesheet"][data-prism-theme][href="${publicURL}/prism-${theme}.css"]`);
500
+ }
501
+
502
+ //#endregion
503
+ //#region src/extensions/prism-plugin.ts
504
+ const PRISM_LANGUAGE_LOADED_META = "prismLanguageLoaded";
505
+ function parseNodes(nodes, className = []) {
506
+ return nodes.flatMap((node) => {
507
+ const classes = [...className, ...node.properties ? node.properties.className : []];
508
+ if (node.children) return parseNodes(node.children, classes);
509
+ return {
510
+ text: node.value ?? "",
511
+ classes
512
+ };
513
+ });
514
+ }
515
+ function getHighlightNodes(html) {
516
+ return (0, hast_util_from_html.fromHtml)(html, { fragment: true }).children;
517
+ }
518
+ function registeredLang(aliasOrLanguage) {
519
+ const allSupportLang = Object.keys(prismjs.default.languages).filter((id) => typeof prismjs.default.languages[id] === "object");
520
+ return Boolean(allSupportLang.find((x) => x === aliasOrLanguage));
521
+ }
522
+ function getDecorations({ doc, name, defaultLanguage, defaultTheme, loadingLanguages, onLanguageLoaded }) {
523
+ const decorations = [];
524
+ (0, _tiptap_core.findChildren)(doc, (node) => node.type.name === name).forEach((block) => {
525
+ let from = block.pos + 1;
526
+ const language = block.node.attrs.language || defaultLanguage;
527
+ const theme = block.node.attrs.theme || defaultTheme;
528
+ let html = "";
529
+ try {
530
+ if (!registeredLang(language) && !loadingLanguages.has(language)) {
531
+ loadingLanguages.add(language);
532
+ import(`prismjs/components/prism-${language}`).then(() => {
533
+ loadingLanguages.delete(language);
534
+ onLanguageLoaded(language);
535
+ }).catch(() => {
536
+ loadingLanguages.delete(language);
537
+ });
538
+ }
539
+ if (!hasPrismThemeLoaded(theme)) loadPrismTheme(theme);
540
+ html = prismjs.default.highlight(block.node.textContent, prismjs.default.languages[language], language);
541
+ } catch {
542
+ html = prismjs.default.highlight(block.node.textContent, prismjs.default.languages.javascript, "js");
543
+ }
544
+ parseNodes(getHighlightNodes(html)).forEach((node) => {
545
+ const to = from + node.text.length;
546
+ if (node.classes.length) {
547
+ const decoration = _tiptap_pm_view.Decoration.inline(from, to, { class: node.classes.join(" ") });
548
+ decorations.push(decoration);
549
+ }
550
+ from = to;
551
+ });
552
+ });
553
+ return _tiptap_pm_view.DecorationSet.create(doc, decorations);
554
+ }
555
+ function PrismPlugin({ name, defaultLanguage, defaultTheme }) {
556
+ if (!defaultLanguage) throw Error("You must specify the defaultLanguage parameter");
557
+ const loadingLanguages = /* @__PURE__ */ new Set();
558
+ let pluginView = null;
559
+ const onLanguageLoaded = (language) => {
560
+ if (pluginView) pluginView.dispatch(pluginView.state.tr.setMeta(PRISM_LANGUAGE_LOADED_META, language));
561
+ };
562
+ const prismjsPlugin = new _tiptap_pm_state.Plugin({
563
+ key: new _tiptap_pm_state.PluginKey("prism"),
564
+ view(view) {
565
+ pluginView = view;
566
+ return { destroy() {
567
+ pluginView = null;
568
+ } };
569
+ },
570
+ state: {
571
+ init: (_, { doc }) => {
572
+ return getDecorations({
573
+ doc,
574
+ name,
575
+ defaultLanguage,
576
+ defaultTheme,
577
+ loadingLanguages,
578
+ onLanguageLoaded
579
+ });
580
+ },
581
+ apply: (transaction, decorationSet, oldState, newState) => {
582
+ const oldNodeName = oldState.selection.$head.parent.type.name;
583
+ const newNodeName = newState.selection.$head.parent.type.name;
584
+ const oldNodes = (0, _tiptap_core.findChildren)(oldState.doc, (node) => node.type.name === name);
585
+ const newNodes = (0, _tiptap_core.findChildren)(newState.doc, (node) => node.type.name === name);
586
+ if (transaction.getMeta(PRISM_LANGUAGE_LOADED_META) || transaction.docChanged && ([oldNodeName, newNodeName].includes(name) || newNodes.length !== oldNodes.length || transaction.steps.some((step) => {
587
+ const rangeStep = step;
588
+ return rangeStep.from !== void 0 && rangeStep.to !== void 0 && oldNodes.some((node) => {
589
+ return node.pos >= rangeStep.from && node.pos + node.node.nodeSize <= rangeStep.to;
590
+ });
591
+ }))) return getDecorations({
592
+ doc: transaction.doc,
593
+ name,
594
+ defaultLanguage,
595
+ defaultTheme,
596
+ loadingLanguages,
597
+ onLanguageLoaded
598
+ });
599
+ return decorationSet.map(transaction.mapping, transaction.doc);
600
+ }
601
+ },
602
+ props: { decorations(state) {
603
+ return prismjsPlugin.getState(state);
604
+ } },
605
+ destroy() {
606
+ pluginView = null;
607
+ removePrismTheme();
608
+ }
609
+ });
610
+ return prismjsPlugin;
611
+ }
612
+
613
+ //#endregion
614
+ //#region src/extensions/code-block.tsx
615
+ const CodeBlockPrism = require_columns.EmailNode.from(_tiptap_extension_code_block.default.extend({
616
+ addOptions() {
617
+ return {
618
+ languageClassPrefix: "language-",
619
+ exitOnTripleEnter: false,
620
+ exitOnArrowDown: false,
621
+ enableTabIndentation: true,
622
+ tabSize: 2,
623
+ defaultLanguage: "javascript",
624
+ defaultTheme: "default",
625
+ HTMLAttributes: {}
626
+ };
627
+ },
628
+ addAttributes() {
629
+ return {
630
+ ...this.parent?.(),
631
+ language: {
632
+ default: this.options.defaultLanguage,
633
+ parseHTML: (element) => {
634
+ if (!element) return null;
635
+ const { languageClassPrefix } = this.options;
636
+ if (!languageClassPrefix) return null;
637
+ const language = [...element.firstElementChild?.classList || []].filter((className) => className.startsWith(languageClassPrefix || "")).map((className) => className.replace(languageClassPrefix, ""))[0];
638
+ if (!language) return null;
639
+ return language;
640
+ },
641
+ rendered: false
642
+ },
643
+ theme: {
644
+ default: this.options.defaultTheme,
645
+ rendered: false
646
+ }
647
+ };
648
+ },
649
+ renderHTML({ node, HTMLAttributes }) {
650
+ return [
651
+ "pre",
652
+ (0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, { class: node.attrs.language ? `${this.options.languageClassPrefix}${node.attrs.language}` : null }, { "data-theme": node.attrs.theme }),
653
+ [
654
+ "code",
655
+ { class: node.attrs.language ? `${this.options.languageClassPrefix}${node.attrs.language} node-codeTag` : "node-codeTag" },
656
+ 0
657
+ ]
658
+ ];
659
+ },
660
+ addKeyboardShortcuts() {
661
+ return {
662
+ ...this.parent?.(),
663
+ "Mod-a": ({ editor }) => {
664
+ const { state } = editor;
665
+ const { selection } = state;
666
+ const { $from } = selection;
667
+ for (let depth = $from.depth; depth >= 1; depth--) if ($from.node(depth).type.name === this.name) {
668
+ const blockStart = $from.start(depth);
669
+ const blockEnd = $from.end(depth);
670
+ if (selection.from === blockStart && selection.to === blockEnd) return false;
671
+ const tr = state.tr.setSelection(_tiptap_pm_state.TextSelection.create(state.doc, blockStart, blockEnd));
672
+ editor.view.dispatch(tr);
673
+ return true;
674
+ }
675
+ return false;
676
+ }
677
+ };
678
+ },
679
+ addProseMirrorPlugins() {
680
+ return [...this.parent?.() || [], PrismPlugin({
681
+ name: this.name,
682
+ defaultLanguage: this.options.defaultLanguage,
683
+ defaultTheme: this.options.defaultTheme
684
+ })];
685
+ }
686
+ }), ({ node, style }) => {
687
+ const language = node.attrs?.language ? `${node.attrs.language}` : "javascript";
688
+ const userTheme = _react_email_components[node.attrs?.theme];
689
+ const theme = userTheme ? {
690
+ ...userTheme,
691
+ base: {
692
+ ...userTheme.base,
693
+ borderRadius: "0.125rem",
694
+ padding: "0.75rem 1rem"
695
+ }
696
+ } : { base: {
697
+ color: "#1e293b",
698
+ background: "#f1f5f9",
699
+ lineHeight: "1.5",
700
+ fontFamily: "\"Fira Code\", \"Fira Mono\", Menlo, Consolas, \"DejaVu Sans Mono\", monospace",
701
+ padding: "0.75rem 1rem",
702
+ borderRadius: "0.125rem"
703
+ } };
704
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.CodeBlock, {
705
+ code: node.content?.[0]?.text ?? "",
706
+ language,
707
+ theme,
708
+ style: {
709
+ width: "auto",
710
+ ...style
711
+ }
712
+ });
713
+ });
714
+
715
+ //#endregion
716
+ //#region src/extensions/div.tsx
717
+ const Div = require_columns.EmailNode.create({
718
+ name: "div",
719
+ group: "block",
720
+ content: "block+",
721
+ defining: true,
722
+ isolating: true,
723
+ parseHTML() {
724
+ return [{
725
+ tag: "div:not([data-type])",
726
+ getAttrs: (node) => {
727
+ if (typeof node === "string") return false;
728
+ const element = node;
729
+ const attrs = {};
730
+ Array.from(element.attributes).forEach((attr) => {
731
+ attrs[attr.name] = attr.value;
732
+ });
733
+ return attrs;
734
+ }
735
+ }];
736
+ },
737
+ renderHTML({ HTMLAttributes }) {
738
+ return [
739
+ "div",
740
+ (0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
741
+ 0
742
+ ];
743
+ },
744
+ addAttributes() {
745
+ return { ...require_columns.createStandardAttributes([...require_columns.COMMON_HTML_ATTRIBUTES, ...require_columns.LAYOUT_ATTRIBUTES]) };
746
+ },
747
+ renderToReactEmail({ children, node, style }) {
748
+ const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
749
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
750
+ className: node.attrs?.class || void 0,
751
+ style: {
752
+ ...style,
753
+ ...inlineStyles
754
+ },
755
+ children
756
+ });
757
+ }
758
+ });
759
+
760
+ //#endregion
761
+ //#region src/extensions/divider.tsx
762
+ const Divider = require_columns.EmailNode.from(_tiptap_extension_horizontal_rule.default.extend({
763
+ addAttributes() {
764
+ return { class: { default: "divider" } };
765
+ },
766
+ addInputRules() {
767
+ return [new _tiptap_core.InputRule({
768
+ find: /^(?:---|—-|___\s|\*\*\*\s)$/,
769
+ handler: ({ state, range }) => {
770
+ const attributes = {};
771
+ const { tr } = state;
772
+ const start = range.from;
773
+ const end = range.to;
774
+ tr.insert(start - 1, this.type.create(attributes)).delete(tr.mapping.map(start), tr.mapping.map(end));
775
+ }
776
+ })];
777
+ },
778
+ addNodeView() {
779
+ return (0, _tiptap_react.ReactNodeViewRenderer)((props) => {
780
+ const node = props.node;
781
+ const { class: className, ...rest } = node.attrs;
782
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Hr, {
783
+ ...rest,
784
+ className: "node-hr",
785
+ style: require_styles.inlineCssToJs(node.attrs.style)
786
+ }) });
787
+ });
788
+ }
789
+ }), ({ node, style }) => {
790
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Hr, {
791
+ className: node.attrs?.class || void 0,
792
+ style: {
793
+ ...style,
794
+ ...require_styles.inlineCssToJs(node.attrs?.style)
795
+ }
796
+ });
797
+ });
798
+
799
+ //#endregion
800
+ //#region src/extensions/hard-break.tsx
801
+ const HardBreak = require_columns.EmailNode.from(_tiptap_extension_hard_break.default, () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("br", {}));
802
+
803
+ //#endregion
804
+ //#region src/extensions/heading.tsx
805
+ const Heading = require_columns.EmailNode.from(_tiptap_extension_heading.Heading.extend({ addNodeView() {
806
+ return (0, _tiptap_react.ReactNodeViewRenderer)(({ node }) => {
807
+ const level = node.attrs.level ?? 1;
808
+ const { class: className, ...rest } = node.attrs;
809
+ const attrs = {
810
+ ...rest,
811
+ className: `node-h${level} ${className}`,
812
+ style: require_styles.inlineCssToJs(node.attrs.style)
813
+ };
814
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Heading, {
815
+ as: `h${level}`,
816
+ ...attrs,
817
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewContent, {})
818
+ }) });
819
+ });
820
+ } }), ({ children, node, style }) => {
821
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Heading, {
822
+ as: `h${node.attrs?.level ?? 1}`,
823
+ className: node.attrs?.class || void 0,
824
+ style: {
825
+ ...style,
826
+ ...require_styles.inlineCssToJs(node.attrs?.style),
827
+ ...getTextAlignment(node.attrs?.align ?? node.attrs?.alignment)
828
+ },
829
+ children
830
+ });
831
+ });
832
+
833
+ //#endregion
834
+ //#region src/extensions/italic.tsx
835
+ const Italic = EmailMark.from(_tiptap_extension_italic.default, ({ children, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("em", {
836
+ style,
837
+ children
838
+ }));
839
+
840
+ //#endregion
841
+ //#region src/extensions/preserved-style.tsx
842
+ const PreservedStyle = EmailMark.create({
843
+ name: "preservedStyle",
844
+ addAttributes() {
845
+ return { style: {
846
+ default: null,
847
+ parseHTML: (element) => element.getAttribute("style"),
848
+ renderHTML: (attributes) => {
849
+ if (!attributes.style) return {};
850
+ return { style: attributes.style };
851
+ }
852
+ } };
853
+ },
854
+ parseHTML() {
855
+ return [{
856
+ tag: "span[style]",
857
+ getAttrs: (element) => {
858
+ if (typeof element === "string") return false;
859
+ const style = element.getAttribute("style");
860
+ if (style && hasPreservableStyles(style)) return { style };
861
+ return false;
862
+ }
863
+ }];
864
+ },
865
+ renderHTML({ HTMLAttributes }) {
866
+ return [
867
+ "span",
868
+ (0, _tiptap_core.mergeAttributes)(HTMLAttributes),
869
+ 0
870
+ ];
871
+ },
872
+ renderToReactEmail({ children, mark }) {
873
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
874
+ style: mark.attrs?.style ? require_styles.inlineCssToJs(mark.attrs.style) : void 0,
875
+ children
876
+ });
877
+ }
878
+ });
879
+ const LINK_INDICATOR_STYLES = [
880
+ "color",
881
+ "text-decoration",
882
+ "text-decoration-line",
883
+ "text-decoration-color",
884
+ "text-decoration-style"
885
+ ];
886
+ function parseStyleString(styleString) {
887
+ const temp = document.createElement("div");
888
+ temp.style.cssText = styleString;
889
+ return temp.style;
890
+ }
891
+ function hasBackground(style) {
892
+ const bgColor = style.backgroundColor;
893
+ const bg = style.background;
894
+ if (bgColor && bgColor !== "transparent" && bgColor !== "rgba(0, 0, 0, 0)") return true;
895
+ if (bg && bg !== "transparent" && bg !== "none" && bg !== "rgba(0, 0, 0, 0)") return true;
896
+ return false;
897
+ }
898
+ function hasPreservableStyles(styleString) {
899
+ return processStylesForUnlink(styleString) !== null;
900
+ }
901
+ /**
902
+ * Processes styles when unlinking:
903
+ * - Has background (button-like): preserve all styles
904
+ * - No background: strip link-indicator styles (color, text-decoration), keep the rest
905
+ */
906
+ function processStylesForUnlink(styleString) {
907
+ if (!styleString) return null;
908
+ const style = parseStyleString(styleString);
909
+ if (hasBackground(style)) return styleString;
910
+ const filtered = [];
911
+ for (let i = 0; i < style.length; i++) {
912
+ const prop = style[i];
913
+ if (LINK_INDICATOR_STYLES.includes(prop)) continue;
914
+ const value = style.getPropertyValue(prop);
915
+ if (value) filtered.push(`${prop}: ${value}`);
916
+ }
917
+ return filtered.length > 0 ? filtered.join("; ") : null;
918
+ }
919
+
920
+ //#endregion
921
+ //#region src/extensions/link.tsx
922
+ const Link = EmailMark.from(_tiptap_extension_link.default, ({ children, mark, style }) => {
923
+ const linkMarkStyle = mark.attrs?.style ? require_styles.inlineCssToJs(mark.attrs.style) : {};
924
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Link, {
925
+ href: mark.attrs?.href ?? void 0,
926
+ rel: mark.attrs?.rel ?? void 0,
927
+ style: {
928
+ ...style,
929
+ ...linkMarkStyle
930
+ },
931
+ target: mark.attrs?.target ?? void 0,
932
+ ...mark.attrs?.["ses:no-track"] ? { "ses:no-track": mark.attrs["ses:no-track"] } : {},
933
+ children
934
+ });
935
+ }).extend({
936
+ parseHTML() {
937
+ return [{
938
+ tag: "a[target]:not([data-id=\"react-email-button\"])",
939
+ getAttrs: (node) => {
940
+ if (typeof node === "string") return false;
941
+ const element = node;
942
+ const attrs = {};
943
+ Array.from(element.attributes).forEach((attr) => {
944
+ attrs[attr.name] = attr.value;
945
+ });
946
+ return attrs;
947
+ }
948
+ }, {
949
+ tag: "a[href]:not([data-id=\"react-email-button\"])",
950
+ getAttrs: (node) => {
951
+ if (typeof node === "string") return false;
952
+ const element = node;
953
+ const attrs = {};
954
+ Array.from(element.attributes).forEach((attr) => {
955
+ attrs[attr.name] = attr.value;
956
+ });
957
+ return attrs;
958
+ }
959
+ }];
960
+ },
961
+ addAttributes() {
962
+ return {
963
+ ...this.parent?.(),
964
+ "ses:no-track": {
965
+ default: null,
966
+ parseHTML: (element) => element.getAttribute("ses:no-track")
967
+ }
968
+ };
969
+ },
970
+ addCommands() {
971
+ return {
972
+ ...this.parent?.(),
973
+ unsetLink: () => ({ state, chain }) => {
974
+ const { from } = state.selection;
975
+ const linkStyle = state.doc.resolve(from).marks().find((m) => m.type.name === "link")?.attrs?.style ?? null;
976
+ const preservedStyle = processStylesForUnlink(linkStyle);
977
+ const shouldRemoveUnderline = preservedStyle !== linkStyle;
978
+ if (preservedStyle) {
979
+ const cmd = chain().extendMarkRange("link").unsetMark("link").setMark("preservedStyle", { style: preservedStyle });
980
+ return shouldRemoveUnderline ? cmd.unsetMark("underline").run() : cmd.run();
981
+ }
982
+ return chain().extendMarkRange("link").unsetMark("link").unsetMark("underline").run();
983
+ }
984
+ };
985
+ },
986
+ addKeyboardShortcuts() {
987
+ return { "Mod-k": () => {
988
+ require_columns.editorEventBus.dispatch("bubble-menu:add-link", void 0);
989
+ return this.editor.chain().focus().toggleLink({ href: "" }).run();
990
+ } };
991
+ }
992
+ });
993
+
994
+ //#endregion
995
+ //#region src/extensions/list-item.tsx
996
+ const ListItem = require_columns.EmailNode.from(_tiptap_extension_list_item.default, ({ children, node, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
997
+ className: node.attrs?.class || void 0,
998
+ style: {
999
+ ...style,
1000
+ ...require_styles.inlineCssToJs(node.attrs?.style),
1001
+ ...getTextAlignment(node.attrs?.align || node.attrs?.alignment)
1002
+ },
1003
+ children
1004
+ }));
1005
+
1006
+ //#endregion
1007
+ //#region src/extensions/max-nesting.ts
1008
+ const MaxNesting = _tiptap_core.Extension.create({
1009
+ name: "maxNesting",
1010
+ addOptions() {
1011
+ return {
1012
+ maxDepth: 3,
1013
+ nodeTypes: void 0
1014
+ };
1015
+ },
1016
+ addProseMirrorPlugins() {
1017
+ const { maxDepth, nodeTypes } = this.options;
1018
+ if (typeof maxDepth !== "number" || maxDepth < 1) throw new Error("maxDepth must be a positive number");
1019
+ return [new _tiptap_pm_state.Plugin({
1020
+ key: new _tiptap_pm_state.PluginKey("maxNesting"),
1021
+ appendTransaction(transactions, _oldState, newState) {
1022
+ if (!transactions.some((tr$1) => tr$1.docChanged)) return null;
1023
+ const rangesToLift = [];
1024
+ newState.doc.descendants((node, pos) => {
1025
+ let depth = 0;
1026
+ let currentPos = pos;
1027
+ let currentNode = node;
1028
+ while (currentNode && depth <= maxDepth) {
1029
+ if (!nodeTypes || nodeTypes.includes(currentNode.type.name)) depth++;
1030
+ const $pos = newState.doc.resolve(currentPos);
1031
+ if ($pos.depth === 0) break;
1032
+ currentPos = $pos.before($pos.depth);
1033
+ currentNode = newState.doc.nodeAt(currentPos);
1034
+ }
1035
+ if (depth > maxDepth) {
1036
+ const $pos = newState.doc.resolve(pos);
1037
+ if ($pos.depth > 0) {
1038
+ const range = $pos.blockRange();
1039
+ if (range && "canReplace" in newState.schema.nodes.doc && typeof newState.schema.nodes.doc.canReplace === "function" && newState.schema.nodes.doc.canReplace(range.start - 1, range.end + 1, newState.doc.slice(range.start, range.end).content)) rangesToLift.push({
1040
+ range,
1041
+ target: range.start - 1
1042
+ });
1043
+ }
1044
+ }
1045
+ });
1046
+ if (rangesToLift.length === 0) return null;
1047
+ const tr = newState.tr;
1048
+ for (let i = rangesToLift.length - 1; i >= 0; i--) {
1049
+ const { range, target } = rangesToLift[i];
1050
+ tr.lift(range, target);
1051
+ }
1052
+ return tr;
1053
+ },
1054
+ filterTransaction(tr) {
1055
+ if (!tr.docChanged) return true;
1056
+ let wouldCreateDeepNesting = false;
1057
+ const newDoc = tr.doc;
1058
+ newDoc.descendants((node, pos) => {
1059
+ if (wouldCreateDeepNesting) return false;
1060
+ let depth = 0;
1061
+ let currentPos = pos;
1062
+ let currentNode = node;
1063
+ while (currentNode && depth <= maxDepth) {
1064
+ if (!nodeTypes || nodeTypes.includes(currentNode.type.name)) depth++;
1065
+ const $pos = newDoc.resolve(currentPos);
1066
+ if ($pos.depth === 0) break;
1067
+ currentPos = $pos.before($pos.depth);
1068
+ currentNode = newDoc.nodeAt(currentPos);
1069
+ }
1070
+ if (depth > maxDepth) {
1071
+ wouldCreateDeepNesting = true;
1072
+ return false;
1073
+ }
1074
+ });
1075
+ return !wouldCreateDeepNesting;
1076
+ }
1077
+ })];
1078
+ }
1079
+ });
1080
+
1081
+ //#endregion
1082
+ //#region src/extensions/ordered-list.tsx
1083
+ const OrderedList = require_columns.EmailNode.from(_tiptap_extension_ordered_list.default, ({ children, node, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
1084
+ className: node.attrs?.class || void 0,
1085
+ start: node.attrs?.start,
1086
+ style: {
1087
+ ...style,
1088
+ ...require_styles.inlineCssToJs(node.attrs?.style)
1089
+ },
1090
+ children
1091
+ }));
1092
+
1093
+ //#endregion
1094
+ //#region src/extensions/paragraph.tsx
1095
+ const Paragraph = require_columns.EmailNode.from(_tiptap_extension_paragraph.default, ({ children, node, style }) => {
1096
+ const isEmpty = !node.content || node.content.length === 0;
1097
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1098
+ className: node.attrs?.class || void 0,
1099
+ style: {
1100
+ ...style,
1101
+ ...require_styles.inlineCssToJs(node.attrs?.style),
1102
+ ...getTextAlignment(node.attrs?.align || node.attrs?.alignment)
1103
+ },
1104
+ children: isEmpty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("br", {}) : children
1105
+ });
1106
+ });
1107
+
1108
+ //#endregion
1109
+ //#region src/extensions/placeholder.ts
1110
+ const Placeholder = _tiptap_extension_placeholder.default.configure({
1111
+ placeholder: ({ node }) => {
1112
+ if (node.type.name === "heading") return `Heading ${node.attrs.level}`;
1113
+ return "Press '/' for commands";
1114
+ },
1115
+ includeChildren: true
1116
+ });
1117
+
1118
+ //#endregion
1119
+ //#region src/extensions/preview-text.ts
1120
+ const PreviewText = _tiptap_core.Node.create({
1121
+ name: "previewText",
1122
+ group: "block",
1123
+ selectable: false,
1124
+ draggable: false,
1125
+ atom: true,
1126
+ addOptions() {
1127
+ return { HTMLAttributes: {} };
1128
+ },
1129
+ addStorage() {
1130
+ return { previewText: null };
1131
+ },
1132
+ renderHTML() {
1133
+ return ["div", { style: "display: none" }];
1134
+ },
1135
+ parseHTML() {
1136
+ return [{
1137
+ tag: "div[data-skip-in-text=\"true\"]",
1138
+ getAttrs: (node) => {
1139
+ if (typeof node === "string") return false;
1140
+ const element = node;
1141
+ let directText = "";
1142
+ for (const child of element.childNodes) if (child.nodeType === 3) directText += child.textContent || "";
1143
+ const cleanText = directText.trim();
1144
+ if (cleanText) this.storage.previewText = cleanText;
1145
+ return false;
1146
+ }
1147
+ }, {
1148
+ tag: "span.preheader",
1149
+ getAttrs: (node) => {
1150
+ if (typeof node === "string") return false;
1151
+ const preheaderText = node.textContent?.trim();
1152
+ if (preheaderText) this.storage.previewText = preheaderText;
1153
+ return false;
1154
+ }
1155
+ }];
1156
+ }
1157
+ });
1158
+
1159
+ //#endregion
1160
+ //#region src/extensions/section.tsx
1161
+ const Section$1 = require_columns.EmailNode.create({
1162
+ name: "section",
1163
+ group: "block",
1164
+ content: "block+",
1165
+ isolating: true,
1166
+ defining: true,
1167
+ parseHTML() {
1168
+ return [{ tag: "section[data-type=\"section\"]" }];
1169
+ },
1170
+ renderHTML({ HTMLAttributes }) {
1171
+ return [
1172
+ "section",
1173
+ (0, _tiptap_core.mergeAttributes)({
1174
+ "data-type": "section",
1175
+ class: "node-section"
1176
+ }, HTMLAttributes),
1177
+ 0
1178
+ ];
1179
+ },
1180
+ addCommands() {
1181
+ return { insertSection: () => ({ commands }) => {
1182
+ return commands.insertContent({
1183
+ type: this.name,
1184
+ content: [{
1185
+ type: "paragraph",
1186
+ content: []
1187
+ }]
1188
+ });
1189
+ } };
1190
+ },
1191
+ renderToReactEmail({ children, node, style }) {
1192
+ const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
1193
+ const textAlign = node.attrs?.align || node.attrs?.alignment;
1194
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Section, {
1195
+ className: node.attrs?.class || void 0,
1196
+ align: textAlign,
1197
+ style: {
1198
+ ...style,
1199
+ ...inlineStyles,
1200
+ ...getTextAlignment(textAlign)
1201
+ },
1202
+ children
1203
+ });
1204
+ }
1205
+ });
1206
+
1207
+ //#endregion
1208
+ //#region src/extensions/strike.tsx
1209
+ const Strike = EmailMark.from(_tiptap_extension_strike.default, ({ children, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("s", {
1210
+ style,
1211
+ children
1212
+ }));
1213
+
1214
+ //#endregion
1215
+ //#region src/extensions/style-attribute.tsx
1216
+ const StyleAttribute = _tiptap_core.Extension.create({
1217
+ name: "styleAttribute",
1218
+ priority: 101,
1219
+ addOptions() {
1220
+ return {
1221
+ types: [],
1222
+ style: []
1223
+ };
1224
+ },
1225
+ addGlobalAttributes() {
1226
+ return [{
1227
+ types: this.options.types,
1228
+ attributes: { style: {
1229
+ default: "",
1230
+ parseHTML: (element) => element.getAttribute("style") || "",
1231
+ renderHTML: (attributes) => {
1232
+ return { style: attributes.style ?? "" };
1233
+ }
1234
+ } }
1235
+ }];
1236
+ },
1237
+ addCommands() {
1238
+ return {
1239
+ unsetStyle: () => ({ commands }) => {
1240
+ return this.options.types.every((type) => commands.resetAttributes(type, "style"));
1241
+ },
1242
+ setStyle: (style) => ({ commands }) => {
1243
+ return this.options.types.every((type) => commands.updateAttributes(type, { style }));
1244
+ }
1245
+ };
1246
+ },
1247
+ addKeyboardShortcuts() {
1248
+ return { Enter: ({ editor }) => {
1249
+ const { state } = editor.view;
1250
+ const { selection } = state;
1251
+ const { $from } = selection;
1252
+ const textBefore = $from.nodeBefore?.text || "";
1253
+ if (textBefore.includes("{{") || textBefore.includes("{{{")) return false;
1254
+ requestAnimationFrame(() => {
1255
+ editor.commands.resetAttributes("paragraph", "style");
1256
+ });
1257
+ return false;
1258
+ } };
1259
+ }
1260
+ });
1261
+
1262
+ //#endregion
1263
+ //#region src/extensions/sup.tsx
1264
+ const SupBase = _tiptap_extension_superscript.default.extend({
1265
+ name: "sup",
1266
+ addCommands() {
1267
+ return {
1268
+ ...this.parent?.(),
1269
+ setSup: () => ({ commands }) => {
1270
+ return commands.setMark(this.name);
1271
+ },
1272
+ toggleSup: () => ({ commands }) => {
1273
+ return commands.toggleMark(this.name);
1274
+ },
1275
+ unsetSup: () => ({ commands }) => {
1276
+ return commands.unsetMark(this.name);
1277
+ }
1278
+ };
1279
+ }
1280
+ });
1281
+ const Sup = EmailMark.from(SupBase, ({ children, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("sup", {
1282
+ style,
1283
+ children
1284
+ }));
1285
+
1286
+ //#endregion
1287
+ //#region src/extensions/table.tsx
1288
+ const Table = require_columns.EmailNode.create({
1289
+ name: "table",
1290
+ group: "block",
1291
+ content: "tableRow+",
1292
+ isolating: true,
1293
+ tableRole: "table",
1294
+ addAttributes() {
1295
+ return { ...require_columns.createStandardAttributes([
1296
+ ...require_columns.TABLE_ATTRIBUTES,
1297
+ ...require_columns.LAYOUT_ATTRIBUTES,
1298
+ ...require_columns.COMMON_HTML_ATTRIBUTES
1299
+ ]) };
1300
+ },
1301
+ parseHTML() {
1302
+ return [{
1303
+ tag: "table",
1304
+ getAttrs: (node) => {
1305
+ if (typeof node === "string") return false;
1306
+ const element = node;
1307
+ const attrs = {};
1308
+ Array.from(element.attributes).forEach((attr) => {
1309
+ attrs[attr.name] = attr.value;
1310
+ });
1311
+ return attrs;
1312
+ }
1313
+ }];
1314
+ },
1315
+ renderHTML({ HTMLAttributes }) {
1316
+ return [
1317
+ "table",
1318
+ (0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),
1319
+ [
1320
+ "tbody",
1321
+ {},
1322
+ 0
1323
+ ]
1324
+ ];
1325
+ },
1326
+ renderToReactEmail({ children, node, style }) {
1327
+ const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
1328
+ const alignment = node.attrs?.align || node.attrs?.alignment;
1329
+ const width = node.attrs?.width;
1330
+ const centeringStyles = alignment === "center" ? {
1331
+ marginLeft: "auto",
1332
+ marginRight: "auto"
1333
+ } : {};
1334
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Section, {
1335
+ className: node.attrs?.class || void 0,
1336
+ align: alignment,
1337
+ style: require_styles.resolveConflictingStyles(style, {
1338
+ ...inlineStyles,
1339
+ ...centeringStyles
1340
+ }),
1341
+ ...width !== void 0 ? { width } : {},
1342
+ children
1343
+ });
1344
+ }
1345
+ });
1346
+ const TableRow = require_columns.EmailNode.create({
1347
+ name: "tableRow",
1348
+ group: "tableRow",
1349
+ content: "(tableCell | tableHeader)+",
1350
+ addAttributes() {
1351
+ return { ...require_columns.createStandardAttributes([
1352
+ ...require_columns.TABLE_CELL_ATTRIBUTES,
1353
+ ...require_columns.LAYOUT_ATTRIBUTES,
1354
+ ...require_columns.COMMON_HTML_ATTRIBUTES
1355
+ ]) };
1356
+ },
1357
+ parseHTML() {
1358
+ return [{
1359
+ tag: "tr",
1360
+ getAttrs: (node) => {
1361
+ if (typeof node === "string") return false;
1362
+ const element = node;
1363
+ const attrs = {};
1364
+ Array.from(element.attributes).forEach((attr) => {
1365
+ attrs[attr.name] = attr.value;
1366
+ });
1367
+ return attrs;
1368
+ }
1369
+ }];
1370
+ },
1371
+ renderHTML({ HTMLAttributes }) {
1372
+ return [
1373
+ "tr",
1374
+ HTMLAttributes,
1375
+ 0
1376
+ ];
1377
+ },
1378
+ renderToReactEmail({ children, node, style }) {
1379
+ const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
1380
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
1381
+ className: node.attrs?.class || void 0,
1382
+ style: {
1383
+ ...style,
1384
+ ...inlineStyles
1385
+ },
1386
+ children
1387
+ });
1388
+ }
1389
+ });
1390
+ const TableCell = require_columns.EmailNode.create({
1391
+ name: "tableCell",
1392
+ group: "tableCell",
1393
+ content: "block+",
1394
+ isolating: true,
1395
+ addAttributes() {
1396
+ return { ...require_columns.createStandardAttributes([
1397
+ ...require_columns.TABLE_CELL_ATTRIBUTES,
1398
+ ...require_columns.LAYOUT_ATTRIBUTES,
1399
+ ...require_columns.COMMON_HTML_ATTRIBUTES
1400
+ ]) };
1401
+ },
1402
+ parseHTML() {
1403
+ return [{
1404
+ tag: "td",
1405
+ getAttrs: (node) => {
1406
+ if (typeof node === "string") return false;
1407
+ const element = node;
1408
+ const attrs = {};
1409
+ Array.from(element.attributes).forEach((attr) => {
1410
+ attrs[attr.name] = attr.value;
1411
+ });
1412
+ return attrs;
1413
+ }
1414
+ }];
1415
+ },
1416
+ renderHTML({ HTMLAttributes }) {
1417
+ return [
1418
+ "td",
1419
+ HTMLAttributes,
1420
+ 0
1421
+ ];
1422
+ },
1423
+ renderToReactEmail({ children, node, style }) {
1424
+ const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
1425
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Column, {
1426
+ className: node.attrs?.class || void 0,
1427
+ align: node.attrs?.align || node.attrs?.alignment,
1428
+ style: {
1429
+ ...style,
1430
+ ...inlineStyles
1431
+ },
1432
+ children
1433
+ });
1434
+ }
1435
+ });
1436
+ const TableHeader = _tiptap_core.Node.create({
1437
+ name: "tableHeader",
1438
+ group: "tableCell",
1439
+ content: "block+",
1440
+ isolating: true,
1441
+ addAttributes() {
1442
+ return { ...require_columns.createStandardAttributes([
1443
+ ...require_columns.TABLE_HEADER_ATTRIBUTES,
1444
+ ...require_columns.TABLE_CELL_ATTRIBUTES,
1445
+ ...require_columns.LAYOUT_ATTRIBUTES,
1446
+ ...require_columns.COMMON_HTML_ATTRIBUTES
1447
+ ]) };
1448
+ },
1449
+ parseHTML() {
1450
+ return [{
1451
+ tag: "th",
1452
+ getAttrs: (node) => {
1453
+ if (typeof node === "string") return false;
1454
+ const element = node;
1455
+ const attrs = {};
1456
+ Array.from(element.attributes).forEach((attr) => {
1457
+ attrs[attr.name] = attr.value;
1458
+ });
1459
+ return attrs;
1460
+ }
1461
+ }];
1462
+ },
1463
+ renderHTML({ HTMLAttributes }) {
1464
+ return [
1465
+ "th",
1466
+ HTMLAttributes,
1467
+ 0
1468
+ ];
1469
+ }
1470
+ });
1471
+
1472
+ //#endregion
1473
+ //#region src/extensions/text.tsx
1474
+ const Text = require_columns.EmailNode.from(_tiptap_extension_text.Text, ({ children }) => {
1475
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
1476
+ });
1477
+
1478
+ //#endregion
1479
+ //#region src/extensions/underline.tsx
1480
+ const Underline = EmailMark.from(_tiptap_extension_underline.default, ({ children, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("u", {
1481
+ style,
1482
+ children
1483
+ }));
1484
+
1485
+ //#endregion
1486
+ //#region src/extensions/uppercase.tsx
1487
+ const Uppercase = EmailMark.create({
1488
+ name: "uppercase",
1489
+ addOptions() {
1490
+ return { HTMLAttributes: {} };
1491
+ },
1492
+ parseHTML() {
1493
+ return [{
1494
+ tag: "span",
1495
+ getAttrs: (node) => {
1496
+ if (node.style.textTransform === "uppercase") return {};
1497
+ return false;
1498
+ }
1499
+ }];
1500
+ },
1501
+ renderHTML({ HTMLAttributes }) {
1502
+ return [
1503
+ "span",
1504
+ (0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, { style: "text-transform: uppercase" }),
1505
+ 0
1506
+ ];
1507
+ },
1508
+ renderToReactEmail({ children, style }) {
1509
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1510
+ style: {
1511
+ ...style,
1512
+ textTransform: "uppercase"
1513
+ },
1514
+ children
1515
+ });
1516
+ },
1517
+ addCommands() {
1518
+ return {
1519
+ setUppercase: () => ({ commands }) => {
1520
+ return commands.setMark(this.name);
1521
+ },
1522
+ toggleUppercase: () => ({ commands }) => {
1523
+ return commands.toggleMark(this.name);
1524
+ },
1525
+ unsetUppercase: () => ({ commands }) => {
1526
+ return commands.unsetMark(this.name);
1527
+ }
1528
+ };
1529
+ }
1530
+ });
1531
+
1532
+ //#endregion
1533
+ //#region src/extensions/index.ts
1534
+ const starterKitExtensions = {
1535
+ CodeBlockPrism,
1536
+ Code,
1537
+ TwoColumns: require_columns.TwoColumns,
1538
+ ThreeColumns: require_columns.ThreeColumns,
1539
+ FourColumns: require_columns.FourColumns,
1540
+ ColumnsColumn: require_columns.ColumnsColumn,
1541
+ Paragraph,
1542
+ BulletList,
1543
+ OrderedList,
1544
+ Blockquote,
1545
+ ListItem,
1546
+ HardBreak,
1547
+ Italic,
1548
+ Placeholder,
1549
+ PreviewText,
1550
+ Bold,
1551
+ Strike,
1552
+ Heading,
1553
+ Divider,
1554
+ Link,
1555
+ Sup,
1556
+ Underline,
1557
+ Uppercase,
1558
+ PreservedStyle,
1559
+ Table,
1560
+ TableRow,
1561
+ TableCell,
1562
+ TableHeader,
1563
+ Body,
1564
+ Div,
1565
+ Button,
1566
+ Section: Section$1,
1567
+ GlobalContent: require_global_content.GlobalContent,
1568
+ Text,
1569
+ AlignmentAttribute,
1570
+ StyleAttribute,
1571
+ ClassAttribute,
1572
+ MaxNesting
1573
+ };
1574
+ const StarterKit = _tiptap_core.Extension.create({
1575
+ name: "reactEmailStarterKit",
1576
+ addOptions() {
1577
+ return {
1578
+ TiptapStarterKit: {},
1579
+ CodeBlockPrism: {
1580
+ defaultLanguage: "javascript",
1581
+ HTMLAttributes: { class: "prism node-codeBlock" }
1582
+ },
1583
+ Code: { HTMLAttributes: {
1584
+ class: "node-inlineCode",
1585
+ spellcheck: "false"
1586
+ } },
1587
+ TwoColumns: {},
1588
+ ThreeColumns: {},
1589
+ FourColumns: {},
1590
+ ColumnsColumn: {},
1591
+ Paragraph: { HTMLAttributes: { class: "node-paragraph" } },
1592
+ BulletList: { HTMLAttributes: { class: "node-bulletList" } },
1593
+ OrderedList: { HTMLAttributes: { class: "node-orderedList" } },
1594
+ Blockquote: { HTMLAttributes: { class: "node-blockquote" } },
1595
+ ListItem: {},
1596
+ HardBreak: {},
1597
+ Italic: {},
1598
+ Placeholder: {},
1599
+ PreviewText: {},
1600
+ Bold: {},
1601
+ Strike: {},
1602
+ Heading: {},
1603
+ Divider: {},
1604
+ Link: {
1605
+ openOnClick: false,
1606
+ HTMLAttributes: { class: "node-link" }
1607
+ },
1608
+ Sup: {},
1609
+ Underline: {},
1610
+ Uppercase: {},
1611
+ PreservedStyle: {},
1612
+ Table: {},
1613
+ TableRow: {},
1614
+ TableCell: {},
1615
+ TableHeader: {},
1616
+ Body: {},
1617
+ Div: {},
1618
+ Button: {},
1619
+ Section: {},
1620
+ GlobalContent: {},
1621
+ AlignmentAttribute: { types: [
1622
+ "heading",
1623
+ "paragraph",
1624
+ "image",
1625
+ "blockquote",
1626
+ "codeBlock",
1627
+ "bulletList",
1628
+ "orderedList",
1629
+ "listItem",
1630
+ "button",
1631
+ "youtube",
1632
+ "twitter",
1633
+ "table",
1634
+ "tableRow",
1635
+ "tableCell",
1636
+ "tableHeader",
1637
+ "columnsColumn"
1638
+ ] },
1639
+ StyleAttribute: { types: [
1640
+ "heading",
1641
+ "paragraph",
1642
+ "image",
1643
+ "blockquote",
1644
+ "codeBlock",
1645
+ "bulletList",
1646
+ "orderedList",
1647
+ "listItem",
1648
+ "button",
1649
+ "youtube",
1650
+ "twitter",
1651
+ "horizontalRule",
1652
+ "footer",
1653
+ "section",
1654
+ "div",
1655
+ "body",
1656
+ "table",
1657
+ "tableRow",
1658
+ "tableCell",
1659
+ "tableHeader",
1660
+ "columnsColumn",
1661
+ "link"
1662
+ ] },
1663
+ Text: {},
1664
+ ClassAttribute: { types: [
1665
+ "heading",
1666
+ "paragraph",
1667
+ "image",
1668
+ "blockquote",
1669
+ "bulletList",
1670
+ "orderedList",
1671
+ "listItem",
1672
+ "button",
1673
+ "youtube",
1674
+ "twitter",
1675
+ "horizontalRule",
1676
+ "footer",
1677
+ "section",
1678
+ "div",
1679
+ "body",
1680
+ "table",
1681
+ "tableRow",
1682
+ "tableCell",
1683
+ "tableHeader",
1684
+ "columnsColumn",
1685
+ "link"
1686
+ ] },
1687
+ MaxNesting: {
1688
+ maxDepth: 50,
1689
+ nodeTypes: [
1690
+ "section",
1691
+ "bulletList",
1692
+ "orderedList"
1693
+ ]
1694
+ }
1695
+ };
1696
+ },
1697
+ addExtensions() {
1698
+ const extensions = [];
1699
+ if (this.options.TiptapStarterKit !== false) extensions.push(_tiptap_starter_kit.default.configure({
1700
+ undoRedo: false,
1701
+ heading: false,
1702
+ link: false,
1703
+ underline: false,
1704
+ trailingNode: false,
1705
+ bold: false,
1706
+ italic: false,
1707
+ strike: false,
1708
+ code: false,
1709
+ paragraph: false,
1710
+ bulletList: false,
1711
+ orderedList: false,
1712
+ listItem: false,
1713
+ blockquote: false,
1714
+ hardBreak: false,
1715
+ gapcursor: false,
1716
+ codeBlock: false,
1717
+ text: false,
1718
+ horizontalRule: false,
1719
+ dropcursor: {
1720
+ color: "#61a8f8",
1721
+ class: "rounded-full animate-[fade-in_300ms_ease-in-out] !z-40",
1722
+ width: 4
1723
+ },
1724
+ ...this.options.TiptapStarterKit
1725
+ }));
1726
+ for (const [name, extension] of Object.entries(starterKitExtensions)) {
1727
+ const key = name;
1728
+ const extensionOptions = this.options[key];
1729
+ if (extensionOptions !== false) extensions.push(extension.configure(extensionOptions));
1730
+ }
1731
+ return extensions;
1732
+ }
1733
+ });
1734
+
1735
+ //#endregion
1736
+ //#region src/core/create-drop-handler.ts
1737
+ function createDropHandler({ onPaste, onUploadImage }) {
1738
+ return (view, event, _slice, moved) => {
1739
+ if (!moved && event.dataTransfer && event.dataTransfer.files && event.dataTransfer.files[0]) {
1740
+ event.preventDefault();
1741
+ const file = event.dataTransfer.files[0];
1742
+ if (onPaste?.(file, view)) return true;
1743
+ if (file.type.includes("image/") && onUploadImage) {
1744
+ onUploadImage(file, view, (view.posAtCoords({
1745
+ left: event.clientX,
1746
+ top: event.clientY
1747
+ })?.pos || 0) - 1);
1748
+ return true;
1749
+ }
1750
+ }
1751
+ return false;
1752
+ };
1753
+ }
1754
+
1755
+ //#endregion
1756
+ //#region src/utils/paste-sanitizer.ts
1757
+ /**
1758
+ * Sanitizes pasted HTML.
1759
+ * - From editor (has node-* classes): pass through as-is
1760
+ * - From external: strip all styles/classes, keep only semantic HTML
1761
+ */
1762
+ /**
1763
+ * Detects content from the Resend editor by checking for node-* class names.
1764
+ */
1765
+ const EDITOR_CLASS_PATTERN = /class="[^"]*node-/;
1766
+ /**
1767
+ * Attributes to preserve on specific elements for EXTERNAL content.
1768
+ * Only functional attributes - NO style or class.
1769
+ */
1770
+ const PRESERVED_ATTRIBUTES = {
1771
+ a: [
1772
+ "href",
1773
+ "target",
1774
+ "rel"
1775
+ ],
1776
+ img: [
1777
+ "src",
1778
+ "alt",
1779
+ "width",
1780
+ "height"
1781
+ ],
1782
+ td: ["colspan", "rowspan"],
1783
+ th: [
1784
+ "colspan",
1785
+ "rowspan",
1786
+ "scope"
1787
+ ],
1788
+ table: [
1789
+ "border",
1790
+ "cellpadding",
1791
+ "cellspacing"
1792
+ ],
1793
+ "*": ["id"]
1794
+ };
1795
+ function isFromEditor(html) {
1796
+ return EDITOR_CLASS_PATTERN.test(html);
1797
+ }
1798
+ function sanitizePastedHtml(html) {
1799
+ if (isFromEditor(html)) return html;
1800
+ const doc = new DOMParser().parseFromString(html, "text/html");
1801
+ sanitizeNode(doc.body);
1802
+ return doc.body.innerHTML;
1803
+ }
1804
+ function sanitizeNode(node) {
1805
+ if (node.nodeType === Node.ELEMENT_NODE) sanitizeElement(node);
1806
+ for (const child of Array.from(node.childNodes)) sanitizeNode(child);
1807
+ }
1808
+ function sanitizeElement(el) {
1809
+ const allowedForTag = PRESERVED_ATTRIBUTES[el.tagName.toLowerCase()] || [];
1810
+ const allowedGlobal = PRESERVED_ATTRIBUTES["*"] || [];
1811
+ const allowed = new Set([...allowedForTag, ...allowedGlobal]);
1812
+ const attributesToRemove = [];
1813
+ for (const attr of Array.from(el.attributes)) {
1814
+ if (attr.name.startsWith("data-")) {
1815
+ attributesToRemove.push(attr.name);
1816
+ continue;
1817
+ }
1818
+ if (!allowed.has(attr.name)) attributesToRemove.push(attr.name);
1819
+ }
1820
+ for (const attr of attributesToRemove) el.removeAttribute(attr);
1821
+ }
1822
+
1823
+ //#endregion
1824
+ //#region src/core/create-paste-handler.ts
1825
+ function createPasteHandler({ onPaste, onUploadImage, extensions }) {
1826
+ return (view, event, slice) => {
1827
+ const text = event.clipboardData?.getData("text/plain");
1828
+ if (text && onPaste?.(text, view)) {
1829
+ event.preventDefault();
1830
+ return true;
1831
+ }
1832
+ if (event.clipboardData?.files?.[0]) {
1833
+ const file = event.clipboardData.files[0];
1834
+ if (onPaste?.(file, view)) {
1835
+ event.preventDefault();
1836
+ return true;
1837
+ }
1838
+ if (file.type.includes("image/") && onUploadImage) {
1839
+ const pos = view.state.selection.from;
1840
+ onUploadImage(file, view, pos);
1841
+ return true;
1842
+ }
1843
+ }
1844
+ /**
1845
+ * If the coming content has a single child, we can assume
1846
+ * it's a plain text and doesn't need to be parsed and
1847
+ * be introduced in a new line
1848
+ */
1849
+ if (slice.content.childCount === 1) return false;
1850
+ if (event.clipboardData?.getData?.("text/html")) {
1851
+ event.preventDefault();
1852
+ const jsonContent = (0, _tiptap_html.generateJSON)(sanitizePastedHtml(event.clipboardData.getData("text/html")), extensions);
1853
+ const node = view.state.schema.nodeFromJSON(jsonContent);
1854
+ const transaction = view.state.tr.replaceSelectionWith(node, false);
1855
+ view.dispatch(transaction);
1856
+ return true;
1857
+ }
1858
+ return false;
1859
+ };
1860
+ }
1861
+
1862
+ //#endregion
1863
+ //#region src/core/use-editor.ts
1864
+ const COLLABORATION_EXTENSION_NAMES = new Set(["liveblocksExtension", "collaboration"]);
1865
+ function hasCollaborationExtension(exts) {
1866
+ return exts.some((ext) => COLLABORATION_EXTENSION_NAMES.has(ext.name));
1867
+ }
1868
+ function useEditor({ content, extensions = [], onUpdate, onPaste, onUploadImage, onReady, editable = true, ...rest }) {
1869
+ const [contentError, setContentError] = react.useState(null);
1870
+ const isCollaborative = hasCollaborationExtension(extensions);
1871
+ const effectiveExtensions = react.useMemo(() => [
1872
+ StarterKit,
1873
+ ...isCollaborative ? [] : [_tiptap_extensions.UndoRedo],
1874
+ ...extensions
1875
+ ], [extensions, isCollaborative]);
1876
+ const editor = (0, _tiptap_react.useEditor)({
1877
+ content: isCollaborative ? void 0 : content,
1878
+ extensions: effectiveExtensions,
1879
+ editable,
1880
+ immediatelyRender: false,
1881
+ enableContentCheck: true,
1882
+ onContentError({ editor: editor$1, error, disableCollaboration }) {
1883
+ disableCollaboration();
1884
+ setContentError(error);
1885
+ console.error(error);
1886
+ editor$1.setEditable(false);
1887
+ },
1888
+ onCreate({ editor: editor$1 }) {
1889
+ onReady?.(editor$1);
1890
+ },
1891
+ onUpdate({ editor: editor$1, transaction }) {
1892
+ onUpdate?.(editor$1, transaction);
1893
+ },
1894
+ editorProps: {
1895
+ handleDOMEvents: { click: (view, event) => {
1896
+ if (!view.editable) {
1897
+ if (event.target.closest("a")) {
1898
+ event.preventDefault();
1899
+ return true;
1900
+ }
1901
+ }
1902
+ return false;
1903
+ } },
1904
+ handlePaste: createPasteHandler({
1905
+ onPaste,
1906
+ onUploadImage,
1907
+ extensions: effectiveExtensions
1908
+ }),
1909
+ handleDrop: createDropHandler({
1910
+ onPaste,
1911
+ onUploadImage
1912
+ })
1913
+ },
1914
+ ...rest
1915
+ });
1916
+ return {
1917
+ editor,
1918
+ isEditorEmpty: (0, _tiptap_react.useEditorState)({
1919
+ editor,
1920
+ selector: (context) => {
1921
+ if (!context.editor) return true;
1922
+ return isDocumentVisuallyEmpty(context.editor.state.doc);
1923
+ }
1924
+ }) ?? true,
1925
+ extensions: effectiveExtensions,
1926
+ contentError,
1927
+ isCollaborative
1928
+ };
1929
+ }
1930
+
1931
+ //#endregion
1932
+ Object.defineProperty(exports, 'AlignmentAttribute', {
1933
+ enumerable: true,
1934
+ get: function () {
1935
+ return AlignmentAttribute;
1936
+ }
1937
+ });
1938
+ Object.defineProperty(exports, 'Blockquote', {
1939
+ enumerable: true,
1940
+ get: function () {
1941
+ return Blockquote;
1942
+ }
1943
+ });
1944
+ Object.defineProperty(exports, 'Body', {
1945
+ enumerable: true,
1946
+ get: function () {
1947
+ return Body;
1948
+ }
1949
+ });
1950
+ Object.defineProperty(exports, 'Bold', {
1951
+ enumerable: true,
1952
+ get: function () {
1953
+ return Bold;
1954
+ }
1955
+ });
1956
+ Object.defineProperty(exports, 'BulletList', {
1957
+ enumerable: true,
1958
+ get: function () {
1959
+ return BulletList;
1960
+ }
1961
+ });
1962
+ Object.defineProperty(exports, 'Button', {
1963
+ enumerable: true,
1964
+ get: function () {
1965
+ return Button;
1966
+ }
1967
+ });
1968
+ Object.defineProperty(exports, 'ClassAttribute', {
1969
+ enumerable: true,
1970
+ get: function () {
1971
+ return ClassAttribute;
1972
+ }
1973
+ });
1974
+ Object.defineProperty(exports, 'Code', {
1975
+ enumerable: true,
1976
+ get: function () {
1977
+ return Code;
1978
+ }
1979
+ });
1980
+ Object.defineProperty(exports, 'CodeBlockPrism', {
1981
+ enumerable: true,
1982
+ get: function () {
1983
+ return CodeBlockPrism;
1984
+ }
1985
+ });
1986
+ Object.defineProperty(exports, 'Div', {
1987
+ enumerable: true,
1988
+ get: function () {
1989
+ return Div;
1990
+ }
1991
+ });
1992
+ Object.defineProperty(exports, 'Divider', {
1993
+ enumerable: true,
1994
+ get: function () {
1995
+ return Divider;
1996
+ }
1997
+ });
1998
+ Object.defineProperty(exports, 'HardBreak', {
1999
+ enumerable: true,
2000
+ get: function () {
2001
+ return HardBreak;
2002
+ }
2003
+ });
2004
+ Object.defineProperty(exports, 'Heading', {
2005
+ enumerable: true,
2006
+ get: function () {
2007
+ return Heading;
2008
+ }
2009
+ });
2010
+ Object.defineProperty(exports, 'Italic', {
2011
+ enumerable: true,
2012
+ get: function () {
2013
+ return Italic;
2014
+ }
2015
+ });
2016
+ Object.defineProperty(exports, 'Link', {
2017
+ enumerable: true,
2018
+ get: function () {
2019
+ return Link;
2020
+ }
2021
+ });
2022
+ Object.defineProperty(exports, 'ListItem', {
2023
+ enumerable: true,
2024
+ get: function () {
2025
+ return ListItem;
2026
+ }
2027
+ });
2028
+ Object.defineProperty(exports, 'MaxNesting', {
2029
+ enumerable: true,
2030
+ get: function () {
2031
+ return MaxNesting;
2032
+ }
2033
+ });
2034
+ Object.defineProperty(exports, 'OrderedList', {
2035
+ enumerable: true,
2036
+ get: function () {
2037
+ return OrderedList;
2038
+ }
2039
+ });
2040
+ Object.defineProperty(exports, 'Paragraph', {
2041
+ enumerable: true,
2042
+ get: function () {
2043
+ return Paragraph;
2044
+ }
2045
+ });
2046
+ Object.defineProperty(exports, 'Placeholder', {
2047
+ enumerable: true,
2048
+ get: function () {
2049
+ return Placeholder;
2050
+ }
2051
+ });
2052
+ Object.defineProperty(exports, 'PreservedStyle', {
2053
+ enumerable: true,
2054
+ get: function () {
2055
+ return PreservedStyle;
2056
+ }
2057
+ });
2058
+ Object.defineProperty(exports, 'PreviewText', {
2059
+ enumerable: true,
2060
+ get: function () {
2061
+ return PreviewText;
2062
+ }
2063
+ });
2064
+ Object.defineProperty(exports, 'Section', {
2065
+ enumerable: true,
2066
+ get: function () {
2067
+ return Section$1;
2068
+ }
2069
+ });
2070
+ Object.defineProperty(exports, 'StarterKit', {
2071
+ enumerable: true,
2072
+ get: function () {
2073
+ return StarterKit;
2074
+ }
2075
+ });
2076
+ Object.defineProperty(exports, 'Strike', {
2077
+ enumerable: true,
2078
+ get: function () {
2079
+ return Strike;
2080
+ }
2081
+ });
2082
+ Object.defineProperty(exports, 'StyleAttribute', {
2083
+ enumerable: true,
2084
+ get: function () {
2085
+ return StyleAttribute;
2086
+ }
2087
+ });
2088
+ Object.defineProperty(exports, 'Sup', {
2089
+ enumerable: true,
2090
+ get: function () {
2091
+ return Sup;
2092
+ }
2093
+ });
2094
+ Object.defineProperty(exports, 'Table', {
2095
+ enumerable: true,
2096
+ get: function () {
2097
+ return Table;
2098
+ }
2099
+ });
2100
+ Object.defineProperty(exports, 'TableCell', {
2101
+ enumerable: true,
2102
+ get: function () {
2103
+ return TableCell;
2104
+ }
2105
+ });
2106
+ Object.defineProperty(exports, 'TableHeader', {
2107
+ enumerable: true,
2108
+ get: function () {
2109
+ return TableHeader;
2110
+ }
2111
+ });
2112
+ Object.defineProperty(exports, 'TableRow', {
2113
+ enumerable: true,
2114
+ get: function () {
2115
+ return TableRow;
2116
+ }
2117
+ });
2118
+ Object.defineProperty(exports, 'Text', {
2119
+ enumerable: true,
2120
+ get: function () {
2121
+ return Text;
2122
+ }
2123
+ });
2124
+ Object.defineProperty(exports, 'Underline', {
2125
+ enumerable: true,
2126
+ get: function () {
2127
+ return Underline;
2128
+ }
2129
+ });
2130
+ Object.defineProperty(exports, 'Uppercase', {
2131
+ enumerable: true,
2132
+ get: function () {
2133
+ return Uppercase;
2134
+ }
2135
+ });
2136
+ Object.defineProperty(exports, 'composeReactEmail', {
2137
+ enumerable: true,
2138
+ get: function () {
2139
+ return composeReactEmail;
2140
+ }
2141
+ });
2142
+ Object.defineProperty(exports, 'isDocumentVisuallyEmpty', {
2143
+ enumerable: true,
2144
+ get: function () {
2145
+ return isDocumentVisuallyEmpty;
2146
+ }
2147
+ });
2148
+ Object.defineProperty(exports, 'processStylesForUnlink', {
2149
+ enumerable: true,
2150
+ get: function () {
2151
+ return processStylesForUnlink;
2152
+ }
2153
+ });
2154
+ Object.defineProperty(exports, 'useEditor', {
2155
+ enumerable: true,
2156
+ get: function () {
2157
+ return useEditor;
2158
+ }
2159
+ });