@react-email/editor 0.0.0-experimental.42 → 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.
- package/dist/core/index.cjs +4 -3
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +3 -3
- package/dist/{create-paste-handler-CGR738bC.d.mts → create-paste-handler-DsJYKisA.d.mts} +1 -1
- package/dist/{create-paste-handler-CGR738bC.d.mts.map → create-paste-handler-DsJYKisA.d.mts.map} +1 -1
- package/dist/{event-bus-fb8U7hrl.cjs → event-bus-BJn1dJM1.cjs} +20 -3
- package/dist/{event-bus-CHEzOS_O.mjs → event-bus-DJpnfDHw.mjs} +14 -3
- package/dist/{event-bus-CHEzOS_O.mjs.map → event-bus-DJpnfDHw.mjs.map} +1 -1
- package/dist/{extension-D23sh0Nj.cjs → extension-CF0s-pGh.cjs} +298 -35
- package/dist/{extension-BZsTEb_s.mjs → extension-DcToBuV0.mjs} +298 -11
- package/dist/extension-DcToBuV0.mjs.map +1 -0
- package/dist/extensions/index.cjs +3 -3
- package/dist/extensions/index.d.cts +1 -1
- package/dist/extensions/index.d.cts.map +1 -1
- package/dist/extensions/index.d.mts +2 -2
- package/dist/extensions/index.d.mts.map +1 -1
- package/dist/extensions/index.mjs +3 -3
- package/dist/{extensions-wGY7l1wH.cjs → extensions-B6VCxUmi.cjs} +67 -25
- package/dist/{extensions-D-VkzZTa.mjs → extensions-mStGDfMH.mjs} +62 -20
- package/dist/extensions-mStGDfMH.mjs.map +1 -0
- package/dist/{styles-C-cCyJCn.cjs → global-content-C5WjNoMX.cjs} +88 -0
- package/dist/{styles-_TMw3YxC.mjs → global-content-CjA49_jE.mjs} +78 -2
- package/dist/global-content-CjA49_jE.mjs.map +1 -0
- package/dist/{index-C4KcMQ0R.d.cts → index-LCPnE_xx.d.cts} +66 -3
- package/dist/index-LCPnE_xx.d.cts.map +1 -0
- package/dist/{index-CxX7W63O.d.mts → index-i5JdL0UD.d.mts} +67 -4
- package/dist/index-i5JdL0UD.d.mts.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/plugins/index.cjs +1 -5
- package/dist/plugins/index.d.cts +5 -123
- package/dist/plugins/index.d.cts.map +1 -1
- package/dist/plugins/index.d.mts +5 -123
- package/dist/plugins/index.d.mts.map +1 -1
- package/dist/plugins/index.mjs +2 -2
- package/dist/{root-pS4l8bVZ.mjs → root-BVs63m-4.mjs} +39 -39
- package/dist/root-BVs63m-4.mjs.map +1 -0
- package/dist/{root-Jq1R3tkX.cjs → root-D6lslKju.cjs} +2 -2
- package/dist/{set-text-alignment-OA8IMWmO.mjs → set-text-alignment-GMXOPMlJ.mjs} +1 -1
- package/dist/{set-text-alignment-OA8IMWmO.mjs.map → set-text-alignment-GMXOPMlJ.mjs.map} +1 -1
- package/dist/types-BNEbRz-a.d.cts +47 -0
- package/dist/types-BNEbRz-a.d.cts.map +1 -0
- package/dist/types-C8k-blF7.d.mts +47 -0
- package/dist/types-C8k-blF7.d.mts.map +1 -0
- package/dist/ui/index.cjs +645 -2
- package/dist/ui/index.d.cts +307 -128
- package/dist/ui/index.d.cts.map +1 -1
- package/dist/ui/index.d.mts +307 -128
- package/dist/ui/index.d.mts.map +1 -1
- package/dist/ui/index.mjs +630 -3
- package/dist/ui/index.mjs.map +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/extension-BZsTEb_s.mjs.map +0 -1
- package/dist/extensions-D-VkzZTa.mjs.map +0 -1
- package/dist/global-content-D_WYaFgX.mjs +0 -78
- package/dist/global-content-D_WYaFgX.mjs.map +0 -1
- package/dist/global-content-bJgotqmA.cjs +0 -89
- package/dist/index-C4KcMQ0R.d.cts.map +0 -1
- package/dist/index-CxX7W63O.d.mts.map +0 -1
- package/dist/root-pS4l8bVZ.mjs.map +0 -1
- package/dist/styles-_TMw3YxC.mjs.map +0 -1
- /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-
|
|
2
|
-
const
|
|
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 =
|
|
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
|
-
...
|
|
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 =
|
|
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
|
-
...
|
|
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 =
|
|
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
|
-
...
|
|
576
|
+
...require_global_content.inlineCssToJs(node.attrs?.style)
|
|
578
577
|
},
|
|
579
578
|
children
|
|
580
579
|
}));
|
|
@@ -899,7 +898,7 @@ const Container = require_event_bus.EmailNode.create({
|
|
|
899
898
|
})];
|
|
900
899
|
},
|
|
901
900
|
renderToReactEmail({ children, node, style }) {
|
|
902
|
-
const inlineStyles =
|
|
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,
|
|
905
904
|
align: style.align || "center",
|
|
@@ -947,7 +946,7 @@ const Div = require_event_bus.EmailNode.create({
|
|
|
947
946
|
return { ...require_event_bus.createStandardAttributes([...require_event_bus.COMMON_HTML_ATTRIBUTES, ...require_event_bus.LAYOUT_ATTRIBUTES]) };
|
|
948
947
|
},
|
|
949
948
|
renderToReactEmail({ children, node, style }) {
|
|
950
|
-
const inlineStyles =
|
|
949
|
+
const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
|
|
951
950
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
952
951
|
className: node.attrs?.class || void 0,
|
|
953
952
|
style: {
|
|
@@ -1074,7 +1073,7 @@ const Divider = require_event_bus.EmailNode.from(_tiptap_extension_horizontal_ru
|
|
|
1074
1073
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Hr, {
|
|
1075
1074
|
...rest,
|
|
1076
1075
|
className: "node-hr",
|
|
1077
|
-
style:
|
|
1076
|
+
style: require_global_content.inlineCssToJs(node.attrs.style)
|
|
1078
1077
|
}) });
|
|
1079
1078
|
});
|
|
1080
1079
|
}
|
|
@@ -1083,7 +1082,7 @@ const Divider = require_event_bus.EmailNode.from(_tiptap_extension_horizontal_ru
|
|
|
1083
1082
|
className: node.attrs?.class || void 0,
|
|
1084
1083
|
style: {
|
|
1085
1084
|
...style,
|
|
1086
|
-
...
|
|
1085
|
+
...require_global_content.inlineCssToJs(node.attrs?.style)
|
|
1087
1086
|
}
|
|
1088
1087
|
});
|
|
1089
1088
|
});
|
|
@@ -1101,7 +1100,7 @@ const Heading = require_event_bus.EmailNode.from(_tiptap_extension_heading.Headi
|
|
|
1101
1100
|
const attrs = {
|
|
1102
1101
|
...rest,
|
|
1103
1102
|
className: `node-h${level} ${className}`,
|
|
1104
|
-
style:
|
|
1103
|
+
style: require_global_content.inlineCssToJs(node.attrs.style)
|
|
1105
1104
|
};
|
|
1106
1105
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Heading, {
|
|
1107
1106
|
as: `h${level}`,
|
|
@@ -1115,7 +1114,7 @@ const Heading = require_event_bus.EmailNode.from(_tiptap_extension_heading.Headi
|
|
|
1115
1114
|
className: node.attrs?.class || void 0,
|
|
1116
1115
|
style: {
|
|
1117
1116
|
...style,
|
|
1118
|
-
...
|
|
1117
|
+
...require_global_content.inlineCssToJs(node.attrs?.style),
|
|
1119
1118
|
...getTextAlignment(node.attrs?.align ?? node.attrs?.alignment)
|
|
1120
1119
|
},
|
|
1121
1120
|
children
|
|
@@ -1163,7 +1162,7 @@ const PreservedStyle = EmailMark.create({
|
|
|
1163
1162
|
},
|
|
1164
1163
|
renderToReactEmail({ children, mark }) {
|
|
1165
1164
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1166
|
-
style: mark.attrs?.style ?
|
|
1165
|
+
style: mark.attrs?.style ? require_global_content.inlineCssToJs(mark.attrs.style) : void 0,
|
|
1167
1166
|
children
|
|
1168
1167
|
});
|
|
1169
1168
|
}
|
|
@@ -1212,7 +1211,7 @@ function processStylesForUnlink(styleString) {
|
|
|
1212
1211
|
//#endregion
|
|
1213
1212
|
//#region src/extensions/link.tsx
|
|
1214
1213
|
const Link = EmailMark.from(_tiptap_extension_link.default, ({ children, mark, style }) => {
|
|
1215
|
-
const linkMarkStyle = mark.attrs?.style ?
|
|
1214
|
+
const linkMarkStyle = mark.attrs?.style ? require_global_content.inlineCssToJs(mark.attrs.style) : {};
|
|
1216
1215
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Link, {
|
|
1217
1216
|
href: mark.attrs?.href ?? void 0,
|
|
1218
1217
|
rel: mark.attrs?.rel ?? void 0,
|
|
@@ -1289,7 +1288,7 @@ const ListItem = require_event_bus.EmailNode.from(_tiptap_extension_list_item.de
|
|
|
1289
1288
|
className: node.attrs?.class || void 0,
|
|
1290
1289
|
style: {
|
|
1291
1290
|
...style,
|
|
1292
|
-
...
|
|
1291
|
+
...require_global_content.inlineCssToJs(node.attrs?.style),
|
|
1293
1292
|
...getTextAlignment(node.attrs?.align || node.attrs?.alignment)
|
|
1294
1293
|
},
|
|
1295
1294
|
children
|
|
@@ -1377,7 +1376,7 @@ const OrderedList = require_event_bus.EmailNode.from(_tiptap_extension_ordered_l
|
|
|
1377
1376
|
start: node.attrs?.start,
|
|
1378
1377
|
style: {
|
|
1379
1378
|
...style,
|
|
1380
|
-
...
|
|
1379
|
+
...require_global_content.inlineCssToJs(node.attrs?.style)
|
|
1381
1380
|
},
|
|
1382
1381
|
children
|
|
1383
1382
|
}));
|
|
@@ -1390,7 +1389,7 @@ const Paragraph = require_event_bus.EmailNode.from(_tiptap_extension_paragraph.d
|
|
|
1390
1389
|
className: node.attrs?.class || void 0,
|
|
1391
1390
|
style: {
|
|
1392
1391
|
...style,
|
|
1393
|
-
...
|
|
1392
|
+
...require_global_content.inlineCssToJs(node.attrs?.style),
|
|
1394
1393
|
...getTextAlignment(node.attrs?.align || node.attrs?.alignment)
|
|
1395
1394
|
},
|
|
1396
1395
|
children: isEmpty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("br", {}) : children
|
|
@@ -1450,6 +1449,9 @@ const PreviewText = _tiptap_core.Node.create({
|
|
|
1450
1449
|
|
|
1451
1450
|
//#endregion
|
|
1452
1451
|
//#region src/extensions/section.tsx
|
|
1452
|
+
function isSectionEmpty(node) {
|
|
1453
|
+
return node.textContent === "" && node.content.size <= node.childCount * 2;
|
|
1454
|
+
}
|
|
1453
1455
|
const Section$1 = require_event_bus.EmailNode.create({
|
|
1454
1456
|
name: "section",
|
|
1455
1457
|
group: "block",
|
|
@@ -1469,6 +1471,46 @@ const Section$1 = require_event_bus.EmailNode.create({
|
|
|
1469
1471
|
0
|
|
1470
1472
|
];
|
|
1471
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
|
+
},
|
|
1472
1514
|
addCommands() {
|
|
1473
1515
|
return { insertSection: () => ({ commands }) => {
|
|
1474
1516
|
return commands.insertContent({
|
|
@@ -1481,7 +1523,7 @@ const Section$1 = require_event_bus.EmailNode.create({
|
|
|
1481
1523
|
} };
|
|
1482
1524
|
},
|
|
1483
1525
|
renderToReactEmail({ children, node, style }) {
|
|
1484
|
-
const inlineStyles =
|
|
1526
|
+
const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
|
|
1485
1527
|
const textAlign = node.attrs?.align || node.attrs?.alignment;
|
|
1486
1528
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Section, {
|
|
1487
1529
|
className: node.attrs?.class || void 0,
|
|
@@ -1616,7 +1658,7 @@ const Table = require_event_bus.EmailNode.create({
|
|
|
1616
1658
|
];
|
|
1617
1659
|
},
|
|
1618
1660
|
renderToReactEmail({ children, node, style }) {
|
|
1619
|
-
const inlineStyles =
|
|
1661
|
+
const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
|
|
1620
1662
|
const alignment = node.attrs?.align || node.attrs?.alignment;
|
|
1621
1663
|
const width = node.attrs?.width;
|
|
1622
1664
|
const centeringStyles = alignment === "center" ? {
|
|
@@ -1626,7 +1668,7 @@ const Table = require_event_bus.EmailNode.create({
|
|
|
1626
1668
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Section, {
|
|
1627
1669
|
className: node.attrs?.class || void 0,
|
|
1628
1670
|
align: alignment,
|
|
1629
|
-
style:
|
|
1671
|
+
style: require_global_content.resolveConflictingStyles(style, {
|
|
1630
1672
|
...inlineStyles,
|
|
1631
1673
|
...centeringStyles
|
|
1632
1674
|
}),
|
|
@@ -1668,7 +1710,7 @@ const TableRow = require_event_bus.EmailNode.create({
|
|
|
1668
1710
|
];
|
|
1669
1711
|
},
|
|
1670
1712
|
renderToReactEmail({ children, node, style }) {
|
|
1671
|
-
const inlineStyles =
|
|
1713
|
+
const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
|
|
1672
1714
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
1673
1715
|
className: node.attrs?.class || void 0,
|
|
1674
1716
|
style: {
|
|
@@ -1713,7 +1755,7 @@ const TableCell = require_event_bus.EmailNode.create({
|
|
|
1713
1755
|
];
|
|
1714
1756
|
},
|
|
1715
1757
|
renderToReactEmail({ children, node, style }) {
|
|
1716
|
-
const inlineStyles =
|
|
1758
|
+
const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
|
|
1717
1759
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Column, {
|
|
1718
1760
|
className: node.attrs?.class || void 0,
|
|
1719
1761
|
align: node.attrs?.align || node.attrs?.alignment,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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) => {
|
|
@@ -967,14 +966,14 @@ function isEmptyParagraph(node) {
|
|
|
967
966
|
|
|
968
967
|
//#endregion
|
|
969
968
|
//#region src/core/use-editor.ts
|
|
970
|
-
function useEditor$1({ content, extensions = [], onUpdate, onPaste, onUploadImage, onReady, editable = true, ...rest }) {
|
|
971
|
-
const [contentError, setContentError] = React.useState(null);
|
|
972
|
-
const isCollaborative = hasCollaborationExtension(extensions);
|
|
973
|
-
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(() => [
|
|
974
973
|
StarterKit,
|
|
975
974
|
...isCollaborative ? [] : [UndoRedo],
|
|
976
|
-
...extensions
|
|
977
|
-
], [extensions, isCollaborative]);
|
|
975
|
+
...extensions$1
|
|
976
|
+
], [extensions$1, isCollaborative]);
|
|
978
977
|
const editor = useEditor({
|
|
979
978
|
content: isCollaborative ? void 0 : content,
|
|
980
979
|
extensions: effectiveExtensions,
|
|
@@ -1431,6 +1430,9 @@ const PreviewText = Node$1.create({
|
|
|
1431
1430
|
|
|
1432
1431
|
//#endregion
|
|
1433
1432
|
//#region src/extensions/section.tsx
|
|
1433
|
+
function isSectionEmpty(node) {
|
|
1434
|
+
return node.textContent === "" && node.content.size <= node.childCount * 2;
|
|
1435
|
+
}
|
|
1434
1436
|
const Section$1 = EmailNode.create({
|
|
1435
1437
|
name: "section",
|
|
1436
1438
|
group: "block",
|
|
@@ -1450,6 +1452,46 @@ const Section$1 = EmailNode.create({
|
|
|
1450
1452
|
0
|
|
1451
1453
|
];
|
|
1452
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
|
+
},
|
|
1453
1495
|
addCommands() {
|
|
1454
1496
|
return { insertSection: () => ({ commands }) => {
|
|
1455
1497
|
return commands.insertContent({
|
|
@@ -2047,8 +2089,8 @@ const StarterKit = Extension.create({
|
|
|
2047
2089
|
};
|
|
2048
2090
|
},
|
|
2049
2091
|
addExtensions() {
|
|
2050
|
-
const extensions = [];
|
|
2051
|
-
if (this.options.TiptapStarterKit !== false) extensions.push(TipTapStarterKit.configure({
|
|
2092
|
+
const extensions$1 = [];
|
|
2093
|
+
if (this.options.TiptapStarterKit !== false) extensions$1.push(TipTapStarterKit.configure({
|
|
2052
2094
|
undoRedo: false,
|
|
2053
2095
|
heading: false,
|
|
2054
2096
|
link: false,
|
|
@@ -2078,12 +2120,12 @@ const StarterKit = Extension.create({
|
|
|
2078
2120
|
for (const [name, extension] of Object.entries(starterKitExtensions)) {
|
|
2079
2121
|
const key = name;
|
|
2080
2122
|
const extensionOptions = this.options[key];
|
|
2081
|
-
if (extensionOptions !== false) extensions.push(extension.configure(extensionOptions));
|
|
2123
|
+
if (extensionOptions !== false) extensions$1.push(extension.configure(extensionOptions));
|
|
2082
2124
|
}
|
|
2083
|
-
return extensions;
|
|
2125
|
+
return extensions$1;
|
|
2084
2126
|
}
|
|
2085
2127
|
});
|
|
2086
2128
|
|
|
2087
2129
|
//#endregion
|
|
2088
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 };
|
|
2089
|
-
//# sourceMappingURL=extensions-
|
|
2131
|
+
//# sourceMappingURL=extensions-mStGDfMH.mjs.map
|