@react-email/editor 0.0.0-experimental.41 → 0.0.0-experimental.43

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 (67) hide show
  1. package/dist/core/index.cjs +4 -3
  2. package/dist/core/index.d.cts +2 -2
  3. package/dist/core/index.d.mts +3 -3
  4. package/dist/core/index.mjs +3 -3
  5. package/dist/{create-paste-handler-CGR738bC.d.mts → create-paste-handler-DsJYKisA.d.mts} +1 -1
  6. package/dist/{create-paste-handler-CGR738bC.d.mts.map → create-paste-handler-DsJYKisA.d.mts.map} +1 -1
  7. package/dist/{event-bus-fb8U7hrl.cjs → event-bus-BJn1dJM1.cjs} +20 -3
  8. package/dist/{event-bus-CHEzOS_O.mjs → event-bus-DJpnfDHw.mjs} +14 -3
  9. package/dist/{event-bus-CHEzOS_O.mjs.map → event-bus-DJpnfDHw.mjs.map} +1 -1
  10. package/dist/{extension-w5VaUeSw.cjs → extension-CF0s-pGh.cjs} +301 -37
  11. package/dist/{extension-DyY8_bh4.mjs → extension-DcToBuV0.mjs} +301 -13
  12. package/dist/extension-DcToBuV0.mjs.map +1 -0
  13. package/dist/extensions/index.cjs +3 -3
  14. package/dist/extensions/index.d.cts +1 -1
  15. package/dist/extensions/index.d.cts.map +1 -1
  16. package/dist/extensions/index.d.mts +2 -2
  17. package/dist/extensions/index.d.mts.map +1 -1
  18. package/dist/extensions/index.mjs +3 -3
  19. package/dist/{extensions-CkjPj2JO.cjs → extensions-B6VCxUmi.cjs} +68 -25
  20. package/dist/{extensions-BvfmaKCn.mjs → extensions-mStGDfMH.mjs} +63 -20
  21. package/dist/extensions-mStGDfMH.mjs.map +1 -0
  22. package/dist/{styles-C-cCyJCn.cjs → global-content-C5WjNoMX.cjs} +88 -0
  23. package/dist/{styles-_TMw3YxC.mjs → global-content-CjA49_jE.mjs} +78 -2
  24. package/dist/global-content-CjA49_jE.mjs.map +1 -0
  25. package/dist/{index-C4KcMQ0R.d.cts → index-LCPnE_xx.d.cts} +66 -3
  26. package/dist/index-LCPnE_xx.d.cts.map +1 -0
  27. package/dist/{index-CxX7W63O.d.mts → index-i5JdL0UD.d.mts} +67 -4
  28. package/dist/index-i5JdL0UD.d.mts.map +1 -0
  29. package/dist/index.cjs +4 -4
  30. package/dist/index.d.mts +3 -3
  31. package/dist/index.d.mts.map +1 -1
  32. package/dist/index.mjs +3 -3
  33. package/dist/plugins/index.cjs +1 -5
  34. package/dist/plugins/index.d.cts +5 -123
  35. package/dist/plugins/index.d.cts.map +1 -1
  36. package/dist/plugins/index.d.mts +5 -123
  37. package/dist/plugins/index.d.mts.map +1 -1
  38. package/dist/plugins/index.mjs +2 -2
  39. package/dist/{root-pS4l8bVZ.mjs → root-BVs63m-4.mjs} +39 -39
  40. package/dist/root-BVs63m-4.mjs.map +1 -0
  41. package/dist/{root-Jq1R3tkX.cjs → root-D6lslKju.cjs} +2 -2
  42. package/dist/{set-text-alignment-OA8IMWmO.mjs → set-text-alignment-GMXOPMlJ.mjs} +1 -1
  43. package/dist/{set-text-alignment-OA8IMWmO.mjs.map → set-text-alignment-GMXOPMlJ.mjs.map} +1 -1
  44. package/dist/types-BNEbRz-a.d.cts +47 -0
  45. package/dist/types-BNEbRz-a.d.cts.map +1 -0
  46. package/dist/types-C8k-blF7.d.mts +47 -0
  47. package/dist/types-C8k-blF7.d.mts.map +1 -0
  48. package/dist/ui/index.cjs +645 -2
  49. package/dist/ui/index.d.cts +307 -128
  50. package/dist/ui/index.d.cts.map +1 -1
  51. package/dist/ui/index.d.mts +263 -84
  52. package/dist/ui/index.d.mts.map +1 -1
  53. package/dist/ui/index.mjs +630 -3
  54. package/dist/ui/index.mjs.map +1 -1
  55. package/dist/utils/index.cjs +1 -1
  56. package/dist/utils/index.mjs +1 -1
  57. package/package.json +2 -2
  58. package/dist/extension-DyY8_bh4.mjs.map +0 -1
  59. package/dist/extensions-BvfmaKCn.mjs.map +0 -1
  60. package/dist/global-content-D_WYaFgX.mjs +0 -78
  61. package/dist/global-content-D_WYaFgX.mjs.map +0 -1
  62. package/dist/global-content-bJgotqmA.cjs +0 -89
  63. package/dist/index-C4KcMQ0R.d.cts.map +0 -1
  64. package/dist/index-CxX7W63O.d.mts.map +0 -1
  65. package/dist/root-pS4l8bVZ.mjs.map +0 -1
  66. package/dist/styles-_TMw3YxC.mjs.map +0 -1
  67. /package/dist/{set-text-alignment-Cv72txmv.cjs → set-text-alignment-aNb7Ml9N.cjs} +0 -0
@@ -1,6 +1,5 @@
1
- const require_event_bus = require('./event-bus-fb8U7hrl.cjs');
2
- const require_styles = require('./styles-C-cCyJCn.cjs');
3
- const require_global_content = require('./global-content-bJgotqmA.cjs');
1
+ const require_event_bus = require('./event-bus-BJn1dJM1.cjs');
2
+ const require_global_content = require('./global-content-C5WjNoMX.cjs');
4
3
  let _tiptap_extensions = require("@tiptap/extensions");
5
4
  let _tiptap_react = require("@tiptap/react");
6
5
  let react = require("react");
@@ -245,7 +244,7 @@ const composeReactEmail = async ({ editor, preview }) => {
245
244
  if (!content) return;
246
245
  return content.map((node, index) => {
247
246
  const style = serializerPlugin?.getNodeStyles(node, depth, editor) ?? {};
248
- const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
247
+ const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
249
248
  if (!node.type) return null;
250
249
  const emailNode = typeToExtensionMap[node.type];
251
250
  if (!emailNode || !(emailNode instanceof require_event_bus.EmailNode)) return null;
@@ -366,7 +365,7 @@ const Blockquote = require_event_bus.EmailNode.from(_tiptap_extension_blockquote
366
365
  className: node.attrs?.class || void 0,
367
366
  style: {
368
367
  ...style,
369
- ...require_styles.inlineCssToJs(node.attrs?.style),
368
+ ...require_global_content.inlineCssToJs(node.attrs?.style),
370
369
  ...getTextAlignment(node.attrs?.align || node.attrs?.alignment)
371
370
  },
372
371
  children
@@ -405,7 +404,7 @@ const Body = require_event_bus.EmailNode.create({
405
404
  ];
406
405
  },
407
406
  renderToReactEmail({ children, node, style }) {
408
- const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
407
+ const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
409
408
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
410
409
  className: node.attrs?.class || void 0,
411
410
  style: {
@@ -443,7 +442,7 @@ const BulletList = require_event_bus.EmailNode.from(_tiptap_extension_bullet_lis
443
442
  className: node.attrs?.class || void 0,
444
443
  style: {
445
444
  ...style,
446
- ...require_styles.inlineCssToJs(node.attrs?.style)
445
+ ...require_global_content.inlineCssToJs(node.attrs?.style)
447
446
  },
448
447
  children
449
448
  }));
@@ -511,7 +510,7 @@ const Button = require_event_bus.EmailNode.create({
511
510
  };
512
511
  },
513
512
  renderToReactEmail({ children, node, style }) {
514
- const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
513
+ const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
515
514
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Row, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Column, {
516
515
  align: node.attrs?.align || node.attrs?.alignment,
517
516
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Button, {
@@ -574,7 +573,7 @@ const ClassAttribute = _tiptap_core.Extension.create({
574
573
  const Code = EmailMark.from(_tiptap_extension_code.default, ({ children, node, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
575
574
  style: {
576
575
  ...style,
577
- ...require_styles.inlineCssToJs(node.attrs?.style)
576
+ ...require_global_content.inlineCssToJs(node.attrs?.style)
578
577
  },
579
578
  children
580
579
  }));
@@ -899,9 +898,10 @@ const Container = require_event_bus.EmailNode.create({
899
898
  })];
900
899
  },
901
900
  renderToReactEmail({ children, node, style }) {
902
- const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
901
+ const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
903
902
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Container, {
904
903
  className: node.attrs?.class || void 0,
904
+ align: style.align || "center",
905
905
  style: {
906
906
  ...style,
907
907
  ...inlineStyles,
@@ -946,7 +946,7 @@ const Div = require_event_bus.EmailNode.create({
946
946
  return { ...require_event_bus.createStandardAttributes([...require_event_bus.COMMON_HTML_ATTRIBUTES, ...require_event_bus.LAYOUT_ATTRIBUTES]) };
947
947
  },
948
948
  renderToReactEmail({ children, node, style }) {
949
- const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
949
+ const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
950
950
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
951
951
  className: node.attrs?.class || void 0,
952
952
  style: {
@@ -1073,7 +1073,7 @@ const Divider = require_event_bus.EmailNode.from(_tiptap_extension_horizontal_ru
1073
1073
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Hr, {
1074
1074
  ...rest,
1075
1075
  className: "node-hr",
1076
- style: require_styles.inlineCssToJs(node.attrs.style)
1076
+ style: require_global_content.inlineCssToJs(node.attrs.style)
1077
1077
  }) });
1078
1078
  });
1079
1079
  }
@@ -1082,7 +1082,7 @@ const Divider = require_event_bus.EmailNode.from(_tiptap_extension_horizontal_ru
1082
1082
  className: node.attrs?.class || void 0,
1083
1083
  style: {
1084
1084
  ...style,
1085
- ...require_styles.inlineCssToJs(node.attrs?.style)
1085
+ ...require_global_content.inlineCssToJs(node.attrs?.style)
1086
1086
  }
1087
1087
  });
1088
1088
  });
@@ -1100,7 +1100,7 @@ const Heading = require_event_bus.EmailNode.from(_tiptap_extension_heading.Headi
1100
1100
  const attrs = {
1101
1101
  ...rest,
1102
1102
  className: `node-h${level} ${className}`,
1103
- style: require_styles.inlineCssToJs(node.attrs.style)
1103
+ style: require_global_content.inlineCssToJs(node.attrs.style)
1104
1104
  };
1105
1105
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Heading, {
1106
1106
  as: `h${level}`,
@@ -1114,7 +1114,7 @@ const Heading = require_event_bus.EmailNode.from(_tiptap_extension_heading.Headi
1114
1114
  className: node.attrs?.class || void 0,
1115
1115
  style: {
1116
1116
  ...style,
1117
- ...require_styles.inlineCssToJs(node.attrs?.style),
1117
+ ...require_global_content.inlineCssToJs(node.attrs?.style),
1118
1118
  ...getTextAlignment(node.attrs?.align ?? node.attrs?.alignment)
1119
1119
  },
1120
1120
  children
@@ -1162,7 +1162,7 @@ const PreservedStyle = EmailMark.create({
1162
1162
  },
1163
1163
  renderToReactEmail({ children, mark }) {
1164
1164
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1165
- style: mark.attrs?.style ? require_styles.inlineCssToJs(mark.attrs.style) : void 0,
1165
+ style: mark.attrs?.style ? require_global_content.inlineCssToJs(mark.attrs.style) : void 0,
1166
1166
  children
1167
1167
  });
1168
1168
  }
@@ -1211,7 +1211,7 @@ function processStylesForUnlink(styleString) {
1211
1211
  //#endregion
1212
1212
  //#region src/extensions/link.tsx
1213
1213
  const Link = EmailMark.from(_tiptap_extension_link.default, ({ children, mark, style }) => {
1214
- const linkMarkStyle = mark.attrs?.style ? require_styles.inlineCssToJs(mark.attrs.style) : {};
1214
+ const linkMarkStyle = mark.attrs?.style ? require_global_content.inlineCssToJs(mark.attrs.style) : {};
1215
1215
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Link, {
1216
1216
  href: mark.attrs?.href ?? void 0,
1217
1217
  rel: mark.attrs?.rel ?? void 0,
@@ -1288,7 +1288,7 @@ const ListItem = require_event_bus.EmailNode.from(_tiptap_extension_list_item.de
1288
1288
  className: node.attrs?.class || void 0,
1289
1289
  style: {
1290
1290
  ...style,
1291
- ...require_styles.inlineCssToJs(node.attrs?.style),
1291
+ ...require_global_content.inlineCssToJs(node.attrs?.style),
1292
1292
  ...getTextAlignment(node.attrs?.align || node.attrs?.alignment)
1293
1293
  },
1294
1294
  children
@@ -1376,7 +1376,7 @@ const OrderedList = require_event_bus.EmailNode.from(_tiptap_extension_ordered_l
1376
1376
  start: node.attrs?.start,
1377
1377
  style: {
1378
1378
  ...style,
1379
- ...require_styles.inlineCssToJs(node.attrs?.style)
1379
+ ...require_global_content.inlineCssToJs(node.attrs?.style)
1380
1380
  },
1381
1381
  children
1382
1382
  }));
@@ -1389,7 +1389,7 @@ const Paragraph = require_event_bus.EmailNode.from(_tiptap_extension_paragraph.d
1389
1389
  className: node.attrs?.class || void 0,
1390
1390
  style: {
1391
1391
  ...style,
1392
- ...require_styles.inlineCssToJs(node.attrs?.style),
1392
+ ...require_global_content.inlineCssToJs(node.attrs?.style),
1393
1393
  ...getTextAlignment(node.attrs?.align || node.attrs?.alignment)
1394
1394
  },
1395
1395
  children: isEmpty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("br", {}) : children
@@ -1449,6 +1449,9 @@ const PreviewText = _tiptap_core.Node.create({
1449
1449
 
1450
1450
  //#endregion
1451
1451
  //#region src/extensions/section.tsx
1452
+ function isSectionEmpty(node) {
1453
+ return node.textContent === "" && node.content.size <= node.childCount * 2;
1454
+ }
1452
1455
  const Section$1 = require_event_bus.EmailNode.create({
1453
1456
  name: "section",
1454
1457
  group: "block",
@@ -1468,6 +1471,46 @@ const Section$1 = require_event_bus.EmailNode.create({
1468
1471
  0
1469
1472
  ];
1470
1473
  },
1474
+ addKeyboardShortcuts() {
1475
+ return { Backspace: ({ editor }) => {
1476
+ const { state } = editor;
1477
+ const { selection } = state;
1478
+ const { empty, $from } = selection;
1479
+ if (!empty) return false;
1480
+ for (let depth = $from.depth; depth >= 1; depth--) {
1481
+ if ($from.node(depth).type.name !== "section") continue;
1482
+ if ($from.parentOffset !== 0) return false;
1483
+ let atStart = true;
1484
+ for (let d = depth; d < $from.depth; d++) if ($from.index(d) !== 0) {
1485
+ atStart = false;
1486
+ break;
1487
+ }
1488
+ if (!atStart) return false;
1489
+ if (!isSectionEmpty($from.node(depth))) return false;
1490
+ const tr = state.tr;
1491
+ const from = $from.before(depth);
1492
+ const to = $from.after(depth);
1493
+ if ($from.node(depth - 1).childCount === 1) tr.replaceWith(from, to, state.schema.nodes.paragraph.create());
1494
+ else tr.delete(from, to);
1495
+ editor.view.dispatch(tr);
1496
+ return true;
1497
+ }
1498
+ for (let depth = $from.depth; depth >= 1; depth--) {
1499
+ if ($from.pos !== $from.start(depth)) break;
1500
+ const indexInParent = $from.index(depth - 1);
1501
+ if (indexInParent === 0) continue;
1502
+ const prevNode = $from.node(depth - 1).child(indexInParent - 1);
1503
+ if (prevNode.type.name === "section" && isSectionEmpty(prevNode)) {
1504
+ const deleteFrom = $from.before(depth) - prevNode.nodeSize;
1505
+ const deleteTo = $from.before(depth);
1506
+ editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));
1507
+ return true;
1508
+ }
1509
+ break;
1510
+ }
1511
+ return false;
1512
+ } };
1513
+ },
1471
1514
  addCommands() {
1472
1515
  return { insertSection: () => ({ commands }) => {
1473
1516
  return commands.insertContent({
@@ -1480,7 +1523,7 @@ const Section$1 = require_event_bus.EmailNode.create({
1480
1523
  } };
1481
1524
  },
1482
1525
  renderToReactEmail({ children, node, style }) {
1483
- const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
1526
+ const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
1484
1527
  const textAlign = node.attrs?.align || node.attrs?.alignment;
1485
1528
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Section, {
1486
1529
  className: node.attrs?.class || void 0,
@@ -1615,7 +1658,7 @@ const Table = require_event_bus.EmailNode.create({
1615
1658
  ];
1616
1659
  },
1617
1660
  renderToReactEmail({ children, node, style }) {
1618
- const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
1661
+ const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
1619
1662
  const alignment = node.attrs?.align || node.attrs?.alignment;
1620
1663
  const width = node.attrs?.width;
1621
1664
  const centeringStyles = alignment === "center" ? {
@@ -1625,7 +1668,7 @@ const Table = require_event_bus.EmailNode.create({
1625
1668
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Section, {
1626
1669
  className: node.attrs?.class || void 0,
1627
1670
  align: alignment,
1628
- style: require_styles.resolveConflictingStyles(style, {
1671
+ style: require_global_content.resolveConflictingStyles(style, {
1629
1672
  ...inlineStyles,
1630
1673
  ...centeringStyles
1631
1674
  }),
@@ -1667,7 +1710,7 @@ const TableRow = require_event_bus.EmailNode.create({
1667
1710
  ];
1668
1711
  },
1669
1712
  renderToReactEmail({ children, node, style }) {
1670
- const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
1713
+ const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
1671
1714
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
1672
1715
  className: node.attrs?.class || void 0,
1673
1716
  style: {
@@ -1712,7 +1755,7 @@ const TableCell = require_event_bus.EmailNode.create({
1712
1755
  ];
1713
1756
  },
1714
1757
  renderToReactEmail({ children, node, style }) {
1715
- const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
1758
+ const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
1716
1759
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Column, {
1717
1760
  className: node.attrs?.class || void 0,
1718
1761
  align: node.attrs?.align || node.attrs?.alignment,
@@ -1,9 +1,8 @@
1
- import { n as inlineCssToJs, r as resolveConflictingStyles } from "./styles-_TMw3YxC.mjs";
2
- import { d as TABLE_ATTRIBUTES, f as TABLE_CELL_ATTRIBUTES, h as EmailNode, i as FourColumns, l as COMMON_HTML_ATTRIBUTES, m as createStandardAttributes, o as ThreeColumns, p as TABLE_HEADER_ATTRIBUTES, r as ColumnsColumn, s as TwoColumns, t as editorEventBus, u as LAYOUT_ATTRIBUTES } from "./event-bus-CHEzOS_O.mjs";
3
- import { t as GlobalContent } from "./global-content-D_WYaFgX.mjs";
1
+ import { a as resolveConflictingStyles, i as inlineCssToJs, t as GlobalContent } from "./global-content-CjA49_jE.mjs";
2
+ import { a as FourColumns, c as TwoColumns, d as LAYOUT_ATTRIBUTES, f as TABLE_ATTRIBUTES, g as EmailNode, h as createStandardAttributes, i as ColumnsColumn, m as TABLE_HEADER_ATTRIBUTES, p as TABLE_CELL_ATTRIBUTES, s as ThreeColumns, t as editorEventBus, u as COMMON_HTML_ATTRIBUTES } from "./event-bus-DJpnfDHw.mjs";
4
3
  import { UndoRedo } from "@tiptap/extensions";
5
4
  import { NodeViewContent, NodeViewWrapper, ReactNodeViewRenderer, useEditor, useEditorState } from "@tiptap/react";
6
- import * as React from "react";
5
+ import * as React$1 from "react";
7
6
  import { generateJSON } from "@tiptap/html";
8
7
  import * as ReactEmailComponents from "@react-email/components";
9
8
  import { Body, Button, CodeBlock, Column, Container, Head, Heading, Hr, Html, Link, Preview, Row, Section, pretty, render, toPlainText } from "@react-email/components";
@@ -122,7 +121,7 @@ function sanitizeElement(el) {
122
121
 
123
122
  //#endregion
124
123
  //#region src/core/create-paste-handler.ts
125
- function createPasteHandler({ onPaste, onUploadImage, extensions }) {
124
+ function createPasteHandler({ onPaste, onUploadImage, extensions: extensions$1 }) {
126
125
  return (view, event, slice) => {
127
126
  const text = event.clipboardData?.getData("text/plain");
128
127
  if (text && onPaste?.(text, view)) {
@@ -149,7 +148,7 @@ function createPasteHandler({ onPaste, onUploadImage, extensions }) {
149
148
  if (slice.content.childCount === 1) return false;
150
149
  if (event.clipboardData?.getData?.("text/html")) {
151
150
  event.preventDefault();
152
- const jsonContent = generateJSON(sanitizePastedHtml(event.clipboardData.getData("text/html")), extensions);
151
+ const jsonContent = generateJSON(sanitizePastedHtml(event.clipboardData.getData("text/html")), extensions$1);
153
152
  const node = view.state.schema.nodeFromJSON(jsonContent);
154
153
  const transaction = view.state.tr.replaceSelectionWith(node, false);
155
154
  view.dispatch(transaction);
@@ -219,9 +218,9 @@ var EmailMark = class EmailMark extends Mark {
219
218
  const NODES_WITH_INCREMENTED_CHILD_DEPTH = new Set(["bulletList", "orderedList"]);
220
219
  const composeReactEmail = async ({ editor, preview }) => {
221
220
  const data = editor.getJSON();
222
- const extensions = editor.extensionManager.extensions;
223
- const serializerPlugin = extensions.map((ext) => ext.options?.serializerPlugin).filter((p) => Boolean(p)).at(-1);
224
- const typeToExtensionMap = Object.fromEntries(extensions.map((extension) => [extension.name, extension]));
221
+ const extensions$1 = editor.extensionManager.extensions;
222
+ const serializerPlugin = extensions$1.map((ext) => ext.options?.serializerPlugin).filter((p) => Boolean(p)).at(-1);
223
+ const typeToExtensionMap = Object.fromEntries(extensions$1.map((extension) => [extension.name, extension]));
225
224
  function parseContent(content, depth = 0) {
226
225
  if (!content) return;
227
226
  return content.map((node, index) => {
@@ -883,6 +882,7 @@ const Container$1 = EmailNode.create({
883
882
  const inlineStyles = inlineCssToJs(node.attrs?.style);
884
883
  return /* @__PURE__ */ jsx(Container, {
885
884
  className: node.attrs?.class || void 0,
885
+ align: style.align || "center",
886
886
  style: {
887
887
  ...style,
888
888
  ...inlineStyles,
@@ -966,14 +966,14 @@ function isEmptyParagraph(node) {
966
966
 
967
967
  //#endregion
968
968
  //#region src/core/use-editor.ts
969
- function useEditor$1({ content, extensions = [], onUpdate, onPaste, onUploadImage, onReady, editable = true, ...rest }) {
970
- const [contentError, setContentError] = React.useState(null);
971
- const isCollaborative = hasCollaborationExtension(extensions);
972
- const effectiveExtensions = React.useMemo(() => [
969
+ function useEditor$1({ content, extensions: extensions$1 = [], onUpdate, onPaste, onUploadImage, onReady, editable = true, ...rest }) {
970
+ const [contentError, setContentError] = React$1.useState(null);
971
+ const isCollaborative = hasCollaborationExtension(extensions$1);
972
+ const effectiveExtensions = React$1.useMemo(() => [
973
973
  StarterKit,
974
974
  ...isCollaborative ? [] : [UndoRedo],
975
- ...extensions
976
- ], [extensions, isCollaborative]);
975
+ ...extensions$1
976
+ ], [extensions$1, isCollaborative]);
977
977
  const editor = useEditor({
978
978
  content: isCollaborative ? void 0 : content,
979
979
  extensions: effectiveExtensions,
@@ -1430,6 +1430,9 @@ const PreviewText = Node$1.create({
1430
1430
 
1431
1431
  //#endregion
1432
1432
  //#region src/extensions/section.tsx
1433
+ function isSectionEmpty(node) {
1434
+ return node.textContent === "" && node.content.size <= node.childCount * 2;
1435
+ }
1433
1436
  const Section$1 = EmailNode.create({
1434
1437
  name: "section",
1435
1438
  group: "block",
@@ -1449,6 +1452,46 @@ const Section$1 = EmailNode.create({
1449
1452
  0
1450
1453
  ];
1451
1454
  },
1455
+ addKeyboardShortcuts() {
1456
+ return { Backspace: ({ editor }) => {
1457
+ const { state } = editor;
1458
+ const { selection } = state;
1459
+ const { empty, $from } = selection;
1460
+ if (!empty) return false;
1461
+ for (let depth = $from.depth; depth >= 1; depth--) {
1462
+ if ($from.node(depth).type.name !== "section") continue;
1463
+ if ($from.parentOffset !== 0) return false;
1464
+ let atStart = true;
1465
+ for (let d = depth; d < $from.depth; d++) if ($from.index(d) !== 0) {
1466
+ atStart = false;
1467
+ break;
1468
+ }
1469
+ if (!atStart) return false;
1470
+ if (!isSectionEmpty($from.node(depth))) return false;
1471
+ const tr = state.tr;
1472
+ const from = $from.before(depth);
1473
+ const to = $from.after(depth);
1474
+ if ($from.node(depth - 1).childCount === 1) tr.replaceWith(from, to, state.schema.nodes.paragraph.create());
1475
+ else tr.delete(from, to);
1476
+ editor.view.dispatch(tr);
1477
+ return true;
1478
+ }
1479
+ for (let depth = $from.depth; depth >= 1; depth--) {
1480
+ if ($from.pos !== $from.start(depth)) break;
1481
+ const indexInParent = $from.index(depth - 1);
1482
+ if (indexInParent === 0) continue;
1483
+ const prevNode = $from.node(depth - 1).child(indexInParent - 1);
1484
+ if (prevNode.type.name === "section" && isSectionEmpty(prevNode)) {
1485
+ const deleteFrom = $from.before(depth) - prevNode.nodeSize;
1486
+ const deleteTo = $from.before(depth);
1487
+ editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));
1488
+ return true;
1489
+ }
1490
+ break;
1491
+ }
1492
+ return false;
1493
+ } };
1494
+ },
1452
1495
  addCommands() {
1453
1496
  return { insertSection: () => ({ commands }) => {
1454
1497
  return commands.insertContent({
@@ -2046,8 +2089,8 @@ const StarterKit = Extension.create({
2046
2089
  };
2047
2090
  },
2048
2091
  addExtensions() {
2049
- const extensions = [];
2050
- if (this.options.TiptapStarterKit !== false) extensions.push(TipTapStarterKit.configure({
2092
+ const extensions$1 = [];
2093
+ if (this.options.TiptapStarterKit !== false) extensions$1.push(TipTapStarterKit.configure({
2051
2094
  undoRedo: false,
2052
2095
  heading: false,
2053
2096
  link: false,
@@ -2077,12 +2120,12 @@ const StarterKit = Extension.create({
2077
2120
  for (const [name, extension] of Object.entries(starterKitExtensions)) {
2078
2121
  const key = name;
2079
2122
  const extensionOptions = this.options[key];
2080
- if (extensionOptions !== false) extensions.push(extension.configure(extensionOptions));
2123
+ if (extensionOptions !== false) extensions$1.push(extension.configure(extensionOptions));
2081
2124
  }
2082
- return extensions;
2125
+ return extensions$1;
2083
2126
  }
2084
2127
  });
2085
2128
 
2086
2129
  //#endregion
2087
2130
  export { Div as A, AlignmentAttribute as B, processStylesForUnlink as C, Divider as D, HardBreak as E, Button$1 as F, EmailMark as H, BulletList as I, Bold as L, CodeBlockPrism as M, Code as N, useEditor$1 as O, ClassAttribute as P, Body$1 as R, PreservedStyle as S, Heading$2 as T, createPasteHandler as U, composeReactEmail as V, createDropHandler as W, Paragraph as _, skipTrailingNodeMeta as a, ListItem as b, TableCell as c, Sup as d, StyleAttribute as f, Placeholder as g, PreviewText as h, TrailingNode as i, Container$1 as j, isDocumentVisuallyEmpty as k, TableHeader as l, Section$1 as m, Uppercase as n, Text$1 as o, Strike as p, Underline as r, Table as s, StarterKit as t, TableRow as u, OrderedList as v, Italic as w, Link$1 as x, MaxNesting as y, Blockquote as z };
2088
- //# sourceMappingURL=extensions-BvfmaKCn.mjs.map
2131
+ //# sourceMappingURL=extensions-mStGDfMH.mjs.map