@react-email/editor 0.0.0-experimental.7 → 0.0.0-experimental.8
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/index.d.mts +120 -123
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +97 -100
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +310 -187
- package/dist/index.mjs +309 -188
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23,6 +23,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
let __tiptap_core = require("@tiptap/core");
|
|
25
25
|
__tiptap_core = __toESM(__tiptap_core);
|
|
26
|
+
let __tiptap_starter_kit = require("@tiptap/starter-kit");
|
|
27
|
+
__tiptap_starter_kit = __toESM(__tiptap_starter_kit);
|
|
26
28
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
27
29
|
react_jsx_runtime = __toESM(react_jsx_runtime);
|
|
28
30
|
let __react_email_components = require("@react-email/components");
|
|
@@ -456,12 +458,12 @@ const Body = EmailNode.create({
|
|
|
456
458
|
0
|
|
457
459
|
];
|
|
458
460
|
},
|
|
459
|
-
renderToReactEmail({ children, node,
|
|
461
|
+
renderToReactEmail({ children, node, style }) {
|
|
460
462
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
461
463
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
462
464
|
className: node.attrs?.class || void 0,
|
|
463
465
|
style: {
|
|
464
|
-
...
|
|
466
|
+
...style,
|
|
465
467
|
...inlineStyles
|
|
466
468
|
},
|
|
467
469
|
children
|
|
@@ -617,7 +619,7 @@ const Button = EmailNode.create({
|
|
|
617
619
|
}
|
|
618
620
|
};
|
|
619
621
|
},
|
|
620
|
-
renderToReactEmail({ children, node,
|
|
622
|
+
renderToReactEmail({ children, node, style }) {
|
|
621
623
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
622
624
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__react_email_components.Row, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__react_email_components.Column, {
|
|
623
625
|
align: node.attrs?.align || node.attrs?.alignment,
|
|
@@ -625,8 +627,7 @@ const Button = EmailNode.create({
|
|
|
625
627
|
className: node.attrs?.class || void 0,
|
|
626
628
|
href: node.attrs?.href,
|
|
627
629
|
style: {
|
|
628
|
-
...
|
|
629
|
-
...styles.button,
|
|
630
|
+
...style,
|
|
630
631
|
...inlineStyles
|
|
631
632
|
},
|
|
632
633
|
children
|
|
@@ -881,7 +882,7 @@ const CodeBlockPrism = EmailNode.from(__tiptap_extension_code_block.default.exte
|
|
|
881
882
|
defaultTheme: this.options.defaultTheme
|
|
882
883
|
})];
|
|
883
884
|
}
|
|
884
|
-
}), ({ node,
|
|
885
|
+
}), ({ node, style }) => {
|
|
885
886
|
const language = node.attrs?.language ? `${node.attrs.language}` : "javascript";
|
|
886
887
|
const userTheme = __react_email_components[node.attrs?.theme];
|
|
887
888
|
const theme = userTheme ? {
|
|
@@ -905,181 +906,11 @@ const CodeBlockPrism = EmailNode.from(__tiptap_extension_code_block.default.exte
|
|
|
905
906
|
theme,
|
|
906
907
|
style: {
|
|
907
908
|
width: "auto",
|
|
908
|
-
...
|
|
909
|
+
...style
|
|
909
910
|
}
|
|
910
911
|
});
|
|
911
912
|
});
|
|
912
913
|
|
|
913
|
-
//#endregion
|
|
914
|
-
//#region src/extensions/columns.tsx
|
|
915
|
-
const COLUMN_PARENT_TYPES = [
|
|
916
|
-
"twoColumns",
|
|
917
|
-
"threeColumns",
|
|
918
|
-
"fourColumns"
|
|
919
|
-
];
|
|
920
|
-
const COLUMN_PARENT_SET = new Set(COLUMN_PARENT_TYPES);
|
|
921
|
-
const MAX_COLUMNS_DEPTH = 3;
|
|
922
|
-
function getColumnsDepth(doc, from) {
|
|
923
|
-
const $from = doc.resolve(from);
|
|
924
|
-
let depth = 0;
|
|
925
|
-
for (let d = $from.depth; d > 0; d--) if (COLUMN_PARENT_SET.has($from.node(d).type.name)) depth++;
|
|
926
|
-
return depth;
|
|
927
|
-
}
|
|
928
|
-
const VARIANTS = [
|
|
929
|
-
{
|
|
930
|
-
name: "twoColumns",
|
|
931
|
-
columnCount: 2,
|
|
932
|
-
content: "columnsColumn columnsColumn",
|
|
933
|
-
dataType: "two-columns"
|
|
934
|
-
},
|
|
935
|
-
{
|
|
936
|
-
name: "threeColumns",
|
|
937
|
-
columnCount: 3,
|
|
938
|
-
content: "columnsColumn columnsColumn columnsColumn",
|
|
939
|
-
dataType: "three-columns"
|
|
940
|
-
},
|
|
941
|
-
{
|
|
942
|
-
name: "fourColumns",
|
|
943
|
-
columnCount: 4,
|
|
944
|
-
content: "columnsColumn{4}",
|
|
945
|
-
dataType: "four-columns"
|
|
946
|
-
}
|
|
947
|
-
];
|
|
948
|
-
const NODE_TYPE_MAP = {
|
|
949
|
-
2: "twoColumns",
|
|
950
|
-
3: "threeColumns",
|
|
951
|
-
4: "fourColumns"
|
|
952
|
-
};
|
|
953
|
-
function createColumnsNode(config, includeCommands) {
|
|
954
|
-
return EmailNode.create({
|
|
955
|
-
name: config.name,
|
|
956
|
-
group: "block",
|
|
957
|
-
content: config.content,
|
|
958
|
-
isolating: true,
|
|
959
|
-
defining: true,
|
|
960
|
-
addAttributes() {
|
|
961
|
-
return createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]);
|
|
962
|
-
},
|
|
963
|
-
parseHTML() {
|
|
964
|
-
return [{ tag: `div[data-type="${config.dataType}"]` }];
|
|
965
|
-
},
|
|
966
|
-
renderHTML({ HTMLAttributes }) {
|
|
967
|
-
return [
|
|
968
|
-
"div",
|
|
969
|
-
(0, __tiptap_core.mergeAttributes)({
|
|
970
|
-
"data-type": config.dataType,
|
|
971
|
-
class: "node-columns"
|
|
972
|
-
}, HTMLAttributes),
|
|
973
|
-
0
|
|
974
|
-
];
|
|
975
|
-
},
|
|
976
|
-
...includeCommands && { addCommands() {
|
|
977
|
-
return { insertColumns: (count) => ({ commands, state }) => {
|
|
978
|
-
if (getColumnsDepth(state.doc, state.selection.from) >= MAX_COLUMNS_DEPTH) return false;
|
|
979
|
-
const nodeType = NODE_TYPE_MAP[count];
|
|
980
|
-
const children = Array.from({ length: count }, () => ({
|
|
981
|
-
type: "columnsColumn",
|
|
982
|
-
content: [{
|
|
983
|
-
type: "paragraph",
|
|
984
|
-
content: []
|
|
985
|
-
}]
|
|
986
|
-
}));
|
|
987
|
-
return commands.insertContent({
|
|
988
|
-
type: nodeType,
|
|
989
|
-
content: children
|
|
990
|
-
});
|
|
991
|
-
} };
|
|
992
|
-
} },
|
|
993
|
-
renderToReactEmail({ children, node, styles }) {
|
|
994
|
-
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
995
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__react_email_components.Row, {
|
|
996
|
-
className: node.attrs?.class || void 0,
|
|
997
|
-
style: {
|
|
998
|
-
...styles.reset,
|
|
999
|
-
...inlineStyles
|
|
1000
|
-
},
|
|
1001
|
-
children
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
const TwoColumns = createColumnsNode(VARIANTS[0], true);
|
|
1007
|
-
const ThreeColumns = createColumnsNode(VARIANTS[1], false);
|
|
1008
|
-
const FourColumns = createColumnsNode(VARIANTS[2], false);
|
|
1009
|
-
const ColumnsColumn = EmailNode.create({
|
|
1010
|
-
name: "columnsColumn",
|
|
1011
|
-
group: "columnsColumn",
|
|
1012
|
-
content: "block+",
|
|
1013
|
-
isolating: true,
|
|
1014
|
-
addAttributes() {
|
|
1015
|
-
return { ...createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]) };
|
|
1016
|
-
},
|
|
1017
|
-
parseHTML() {
|
|
1018
|
-
return [{ tag: "div[data-type=\"column\"]" }];
|
|
1019
|
-
},
|
|
1020
|
-
renderHTML({ HTMLAttributes }) {
|
|
1021
|
-
return [
|
|
1022
|
-
"div",
|
|
1023
|
-
(0, __tiptap_core.mergeAttributes)({
|
|
1024
|
-
"data-type": "column",
|
|
1025
|
-
class: "node-column"
|
|
1026
|
-
}, HTMLAttributes),
|
|
1027
|
-
0
|
|
1028
|
-
];
|
|
1029
|
-
},
|
|
1030
|
-
addKeyboardShortcuts() {
|
|
1031
|
-
return {
|
|
1032
|
-
Backspace: ({ editor }) => {
|
|
1033
|
-
const { state } = editor;
|
|
1034
|
-
const { selection } = state;
|
|
1035
|
-
const { empty, $from } = selection;
|
|
1036
|
-
if (!empty) return false;
|
|
1037
|
-
for (let depth = $from.depth; depth >= 1; depth--) {
|
|
1038
|
-
if ($from.pos !== $from.start(depth)) break;
|
|
1039
|
-
const indexInParent = $from.index(depth - 1);
|
|
1040
|
-
if (indexInParent === 0) continue;
|
|
1041
|
-
const prevNode = $from.node(depth - 1).child(indexInParent - 1);
|
|
1042
|
-
if (COLUMN_PARENT_SET.has(prevNode.type.name)) {
|
|
1043
|
-
const deleteFrom = $from.before(depth) - prevNode.nodeSize;
|
|
1044
|
-
const deleteTo = $from.before(depth);
|
|
1045
|
-
editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));
|
|
1046
|
-
return true;
|
|
1047
|
-
}
|
|
1048
|
-
break;
|
|
1049
|
-
}
|
|
1050
|
-
return false;
|
|
1051
|
-
},
|
|
1052
|
-
"Mod-a": ({ editor }) => {
|
|
1053
|
-
const { state } = editor;
|
|
1054
|
-
const { $from } = state.selection;
|
|
1055
|
-
for (let d = $from.depth; d > 0; d--) {
|
|
1056
|
-
if ($from.node(d).type.name !== "columnsColumn") continue;
|
|
1057
|
-
const columnStart = $from.start(d);
|
|
1058
|
-
const columnEnd = $from.end(d);
|
|
1059
|
-
const { from, to } = state.selection;
|
|
1060
|
-
if (from === columnStart && to === columnEnd) return false;
|
|
1061
|
-
editor.view.dispatch(state.tr.setSelection(__tiptap_pm_state.TextSelection.create(state.doc, columnStart, columnEnd)));
|
|
1062
|
-
return true;
|
|
1063
|
-
}
|
|
1064
|
-
return false;
|
|
1065
|
-
}
|
|
1066
|
-
};
|
|
1067
|
-
},
|
|
1068
|
-
renderToReactEmail({ children, node, styles }) {
|
|
1069
|
-
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1070
|
-
const width = node.attrs?.width;
|
|
1071
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__react_email_components.Column, {
|
|
1072
|
-
className: node.attrs?.class || void 0,
|
|
1073
|
-
style: {
|
|
1074
|
-
...styles.reset,
|
|
1075
|
-
...inlineStyles,
|
|
1076
|
-
...width ? { width } : {}
|
|
1077
|
-
},
|
|
1078
|
-
children
|
|
1079
|
-
});
|
|
1080
|
-
}
|
|
1081
|
-
});
|
|
1082
|
-
|
|
1083
914
|
//#endregion
|
|
1084
915
|
//#region src/extensions/div.tsx
|
|
1085
916
|
const Div = EmailNode.create({
|
|
@@ -1112,12 +943,12 @@ const Div = EmailNode.create({
|
|
|
1112
943
|
addAttributes() {
|
|
1113
944
|
return { ...createStandardAttributes([...COMMON_HTML_ATTRIBUTES, ...LAYOUT_ATTRIBUTES]) };
|
|
1114
945
|
},
|
|
1115
|
-
renderToReactEmail({ children, node,
|
|
946
|
+
renderToReactEmail({ children, node, style }) {
|
|
1116
947
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1117
948
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1118
949
|
className: node.attrs?.class || void 0,
|
|
1119
950
|
style: {
|
|
1120
|
-
...
|
|
951
|
+
...style,
|
|
1121
952
|
...inlineStyles
|
|
1122
953
|
},
|
|
1123
954
|
children
|
|
@@ -1368,14 +1199,14 @@ const Section = EmailNode.create({
|
|
|
1368
1199
|
});
|
|
1369
1200
|
} };
|
|
1370
1201
|
},
|
|
1371
|
-
renderToReactEmail({ children, node,
|
|
1202
|
+
renderToReactEmail({ children, node, style }) {
|
|
1372
1203
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1373
1204
|
const textAlign = node.attrs?.align || node.attrs?.alignment;
|
|
1374
1205
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__react_email_components.Section, {
|
|
1375
1206
|
className: node.attrs?.class || void 0,
|
|
1376
1207
|
align: textAlign,
|
|
1377
1208
|
style: {
|
|
1378
|
-
...
|
|
1209
|
+
...style,
|
|
1379
1210
|
...inlineStyles,
|
|
1380
1211
|
...getTextAlignment(textAlign)
|
|
1381
1212
|
},
|
|
@@ -1508,7 +1339,7 @@ const Table = EmailNode.create({
|
|
|
1508
1339
|
]
|
|
1509
1340
|
];
|
|
1510
1341
|
},
|
|
1511
|
-
renderToReactEmail({ children, node,
|
|
1342
|
+
renderToReactEmail({ children, node, style }) {
|
|
1512
1343
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1513
1344
|
const alignment = node.attrs?.align || node.attrs?.alignment;
|
|
1514
1345
|
const width = node.attrs?.width;
|
|
@@ -1519,7 +1350,7 @@ const Table = EmailNode.create({
|
|
|
1519
1350
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__react_email_components.Section, {
|
|
1520
1351
|
className: node.attrs?.class || void 0,
|
|
1521
1352
|
align: alignment,
|
|
1522
|
-
style: resolveConflictingStyles(
|
|
1353
|
+
style: resolveConflictingStyles(style, {
|
|
1523
1354
|
...inlineStyles,
|
|
1524
1355
|
...centeringStyles
|
|
1525
1356
|
}),
|
|
@@ -1560,12 +1391,12 @@ const TableRow = EmailNode.create({
|
|
|
1560
1391
|
0
|
|
1561
1392
|
];
|
|
1562
1393
|
},
|
|
1563
|
-
renderToReactEmail({ children, node,
|
|
1394
|
+
renderToReactEmail({ children, node, style }) {
|
|
1564
1395
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1565
1396
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
1566
1397
|
className: node.attrs?.class || void 0,
|
|
1567
1398
|
style: {
|
|
1568
|
-
...
|
|
1399
|
+
...style,
|
|
1569
1400
|
...inlineStyles
|
|
1570
1401
|
},
|
|
1571
1402
|
children
|
|
@@ -1605,13 +1436,13 @@ const TableCell = EmailNode.create({
|
|
|
1605
1436
|
0
|
|
1606
1437
|
];
|
|
1607
1438
|
},
|
|
1608
|
-
renderToReactEmail({ children, node,
|
|
1439
|
+
renderToReactEmail({ children, node, style }) {
|
|
1609
1440
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1610
1441
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__react_email_components.Column, {
|
|
1611
1442
|
className: node.attrs?.class || void 0,
|
|
1612
1443
|
align: node.attrs?.align || node.attrs?.alignment,
|
|
1613
1444
|
style: {
|
|
1614
|
-
...
|
|
1445
|
+
...style,
|
|
1615
1446
|
...inlineStyles
|
|
1616
1447
|
},
|
|
1617
1448
|
children
|
|
@@ -1692,6 +1523,297 @@ const Uppercase = __tiptap_core.Mark.create({
|
|
|
1692
1523
|
}
|
|
1693
1524
|
});
|
|
1694
1525
|
|
|
1526
|
+
//#endregion
|
|
1527
|
+
//#region src/extensions/columns.tsx
|
|
1528
|
+
const COLUMN_PARENT_TYPES = [
|
|
1529
|
+
"twoColumns",
|
|
1530
|
+
"threeColumns",
|
|
1531
|
+
"fourColumns"
|
|
1532
|
+
];
|
|
1533
|
+
const COLUMN_PARENT_SET = new Set(COLUMN_PARENT_TYPES);
|
|
1534
|
+
const MAX_COLUMNS_DEPTH = 3;
|
|
1535
|
+
function getColumnsDepth(doc, from) {
|
|
1536
|
+
const $from = doc.resolve(from);
|
|
1537
|
+
let depth = 0;
|
|
1538
|
+
for (let d = $from.depth; d > 0; d--) if (COLUMN_PARENT_SET.has($from.node(d).type.name)) depth++;
|
|
1539
|
+
return depth;
|
|
1540
|
+
}
|
|
1541
|
+
const VARIANTS = [
|
|
1542
|
+
{
|
|
1543
|
+
name: "twoColumns",
|
|
1544
|
+
columnCount: 2,
|
|
1545
|
+
content: "columnsColumn columnsColumn",
|
|
1546
|
+
dataType: "two-columns"
|
|
1547
|
+
},
|
|
1548
|
+
{
|
|
1549
|
+
name: "threeColumns",
|
|
1550
|
+
columnCount: 3,
|
|
1551
|
+
content: "columnsColumn columnsColumn columnsColumn",
|
|
1552
|
+
dataType: "three-columns"
|
|
1553
|
+
},
|
|
1554
|
+
{
|
|
1555
|
+
name: "fourColumns",
|
|
1556
|
+
columnCount: 4,
|
|
1557
|
+
content: "columnsColumn{4}",
|
|
1558
|
+
dataType: "four-columns"
|
|
1559
|
+
}
|
|
1560
|
+
];
|
|
1561
|
+
const NODE_TYPE_MAP = {
|
|
1562
|
+
2: "twoColumns",
|
|
1563
|
+
3: "threeColumns",
|
|
1564
|
+
4: "fourColumns"
|
|
1565
|
+
};
|
|
1566
|
+
function createColumnsNode(config, includeCommands) {
|
|
1567
|
+
return EmailNode.create({
|
|
1568
|
+
name: config.name,
|
|
1569
|
+
group: "block",
|
|
1570
|
+
content: config.content,
|
|
1571
|
+
isolating: true,
|
|
1572
|
+
defining: true,
|
|
1573
|
+
addAttributes() {
|
|
1574
|
+
return createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]);
|
|
1575
|
+
},
|
|
1576
|
+
parseHTML() {
|
|
1577
|
+
return [{ tag: `div[data-type="${config.dataType}"]` }];
|
|
1578
|
+
},
|
|
1579
|
+
renderHTML({ HTMLAttributes }) {
|
|
1580
|
+
return [
|
|
1581
|
+
"div",
|
|
1582
|
+
(0, __tiptap_core.mergeAttributes)({
|
|
1583
|
+
"data-type": config.dataType,
|
|
1584
|
+
class: "node-columns"
|
|
1585
|
+
}, HTMLAttributes),
|
|
1586
|
+
0
|
|
1587
|
+
];
|
|
1588
|
+
},
|
|
1589
|
+
...includeCommands && { addCommands() {
|
|
1590
|
+
return { insertColumns: (count) => ({ commands, state }) => {
|
|
1591
|
+
if (getColumnsDepth(state.doc, state.selection.from) >= MAX_COLUMNS_DEPTH) return false;
|
|
1592
|
+
const nodeType = NODE_TYPE_MAP[count];
|
|
1593
|
+
const children = Array.from({ length: count }, () => ({
|
|
1594
|
+
type: "columnsColumn",
|
|
1595
|
+
content: [{
|
|
1596
|
+
type: "paragraph",
|
|
1597
|
+
content: []
|
|
1598
|
+
}]
|
|
1599
|
+
}));
|
|
1600
|
+
return commands.insertContent({
|
|
1601
|
+
type: nodeType,
|
|
1602
|
+
content: children
|
|
1603
|
+
});
|
|
1604
|
+
} };
|
|
1605
|
+
} },
|
|
1606
|
+
renderToReactEmail({ children, node, style }) {
|
|
1607
|
+
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1608
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__react_email_components.Row, {
|
|
1609
|
+
className: node.attrs?.class || void 0,
|
|
1610
|
+
style: {
|
|
1611
|
+
...style,
|
|
1612
|
+
...inlineStyles
|
|
1613
|
+
},
|
|
1614
|
+
children
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
const TwoColumns = createColumnsNode(VARIANTS[0], true);
|
|
1620
|
+
const ThreeColumns = createColumnsNode(VARIANTS[1], false);
|
|
1621
|
+
const FourColumns = createColumnsNode(VARIANTS[2], false);
|
|
1622
|
+
const ColumnsColumn = EmailNode.create({
|
|
1623
|
+
name: "columnsColumn",
|
|
1624
|
+
group: "columnsColumn",
|
|
1625
|
+
content: "block+",
|
|
1626
|
+
isolating: true,
|
|
1627
|
+
addAttributes() {
|
|
1628
|
+
return { ...createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]) };
|
|
1629
|
+
},
|
|
1630
|
+
parseHTML() {
|
|
1631
|
+
return [{ tag: "div[data-type=\"column\"]" }];
|
|
1632
|
+
},
|
|
1633
|
+
renderHTML({ HTMLAttributes }) {
|
|
1634
|
+
return [
|
|
1635
|
+
"div",
|
|
1636
|
+
(0, __tiptap_core.mergeAttributes)({
|
|
1637
|
+
"data-type": "column",
|
|
1638
|
+
class: "node-column"
|
|
1639
|
+
}, HTMLAttributes),
|
|
1640
|
+
0
|
|
1641
|
+
];
|
|
1642
|
+
},
|
|
1643
|
+
addKeyboardShortcuts() {
|
|
1644
|
+
return {
|
|
1645
|
+
Backspace: ({ editor }) => {
|
|
1646
|
+
const { state } = editor;
|
|
1647
|
+
const { selection } = state;
|
|
1648
|
+
const { empty, $from } = selection;
|
|
1649
|
+
if (!empty) return false;
|
|
1650
|
+
for (let depth = $from.depth; depth >= 1; depth--) {
|
|
1651
|
+
if ($from.pos !== $from.start(depth)) break;
|
|
1652
|
+
const indexInParent = $from.index(depth - 1);
|
|
1653
|
+
if (indexInParent === 0) continue;
|
|
1654
|
+
const prevNode = $from.node(depth - 1).child(indexInParent - 1);
|
|
1655
|
+
if (COLUMN_PARENT_SET.has(prevNode.type.name)) {
|
|
1656
|
+
const deleteFrom = $from.before(depth) - prevNode.nodeSize;
|
|
1657
|
+
const deleteTo = $from.before(depth);
|
|
1658
|
+
editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));
|
|
1659
|
+
return true;
|
|
1660
|
+
}
|
|
1661
|
+
break;
|
|
1662
|
+
}
|
|
1663
|
+
return false;
|
|
1664
|
+
},
|
|
1665
|
+
"Mod-a": ({ editor }) => {
|
|
1666
|
+
const { state } = editor;
|
|
1667
|
+
const { $from } = state.selection;
|
|
1668
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
1669
|
+
if ($from.node(d).type.name !== "columnsColumn") continue;
|
|
1670
|
+
const columnStart = $from.start(d);
|
|
1671
|
+
const columnEnd = $from.end(d);
|
|
1672
|
+
const { from, to } = state.selection;
|
|
1673
|
+
if (from === columnStart && to === columnEnd) return false;
|
|
1674
|
+
editor.view.dispatch(state.tr.setSelection(__tiptap_pm_state.TextSelection.create(state.doc, columnStart, columnEnd)));
|
|
1675
|
+
return true;
|
|
1676
|
+
}
|
|
1677
|
+
return false;
|
|
1678
|
+
}
|
|
1679
|
+
};
|
|
1680
|
+
},
|
|
1681
|
+
renderToReactEmail({ children, node, style }) {
|
|
1682
|
+
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1683
|
+
const width = node.attrs?.width;
|
|
1684
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__react_email_components.Column, {
|
|
1685
|
+
className: node.attrs?.class || void 0,
|
|
1686
|
+
style: {
|
|
1687
|
+
...style,
|
|
1688
|
+
...inlineStyles,
|
|
1689
|
+
...width ? { width } : {}
|
|
1690
|
+
},
|
|
1691
|
+
children
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1695
|
+
|
|
1696
|
+
//#endregion
|
|
1697
|
+
//#region src/extensions/index.ts
|
|
1698
|
+
const coreExtensions = [
|
|
1699
|
+
__tiptap_starter_kit.StarterKit.configure({
|
|
1700
|
+
undoRedo: false,
|
|
1701
|
+
heading: false,
|
|
1702
|
+
link: false,
|
|
1703
|
+
underline: false,
|
|
1704
|
+
trailingNode: false,
|
|
1705
|
+
bold: false,
|
|
1706
|
+
gapcursor: false,
|
|
1707
|
+
listItem: {},
|
|
1708
|
+
bulletList: { HTMLAttributes: { class: "node-bulletList" } },
|
|
1709
|
+
paragraph: { HTMLAttributes: { class: "node-paragraph" } },
|
|
1710
|
+
orderedList: { HTMLAttributes: { class: "node-orderedList" } },
|
|
1711
|
+
blockquote: { HTMLAttributes: { class: "node-blockquote" } },
|
|
1712
|
+
codeBlock: false,
|
|
1713
|
+
code: { HTMLAttributes: {
|
|
1714
|
+
class: "node-inlineCode",
|
|
1715
|
+
spellcheck: "false"
|
|
1716
|
+
} },
|
|
1717
|
+
horizontalRule: false,
|
|
1718
|
+
dropcursor: {
|
|
1719
|
+
color: "#61a8f8",
|
|
1720
|
+
class: "rounded-full animate-[fade-in_300ms_ease-in-out] !z-40",
|
|
1721
|
+
width: 4
|
|
1722
|
+
}
|
|
1723
|
+
}),
|
|
1724
|
+
CodeBlockPrism.configure({
|
|
1725
|
+
defaultLanguage: "javascript",
|
|
1726
|
+
HTMLAttributes: { class: "prism node-codeBlock" }
|
|
1727
|
+
}),
|
|
1728
|
+
Placeholder,
|
|
1729
|
+
PreviewText,
|
|
1730
|
+
Bold,
|
|
1731
|
+
Sup,
|
|
1732
|
+
Uppercase,
|
|
1733
|
+
PreservedStyle,
|
|
1734
|
+
Table,
|
|
1735
|
+
TableRow,
|
|
1736
|
+
TableCell,
|
|
1737
|
+
TableHeader,
|
|
1738
|
+
Body,
|
|
1739
|
+
Div,
|
|
1740
|
+
Button,
|
|
1741
|
+
Section,
|
|
1742
|
+
AlignmentAttribute.configure({ types: [
|
|
1743
|
+
"heading",
|
|
1744
|
+
"paragraph",
|
|
1745
|
+
"image",
|
|
1746
|
+
"blockquote",
|
|
1747
|
+
"codeBlock",
|
|
1748
|
+
"bulletList",
|
|
1749
|
+
"orderedList",
|
|
1750
|
+
"listItem",
|
|
1751
|
+
"button",
|
|
1752
|
+
"youtube",
|
|
1753
|
+
"twitter",
|
|
1754
|
+
"table",
|
|
1755
|
+
"tableRow",
|
|
1756
|
+
"tableCell",
|
|
1757
|
+
"tableHeader",
|
|
1758
|
+
"columnsColumn"
|
|
1759
|
+
] }),
|
|
1760
|
+
StyleAttribute.configure({ types: [
|
|
1761
|
+
"heading",
|
|
1762
|
+
"paragraph",
|
|
1763
|
+
"image",
|
|
1764
|
+
"blockquote",
|
|
1765
|
+
"codeBlock",
|
|
1766
|
+
"bulletList",
|
|
1767
|
+
"orderedList",
|
|
1768
|
+
"listItem",
|
|
1769
|
+
"button",
|
|
1770
|
+
"youtube",
|
|
1771
|
+
"twitter",
|
|
1772
|
+
"horizontalRule",
|
|
1773
|
+
"footer",
|
|
1774
|
+
"section",
|
|
1775
|
+
"div",
|
|
1776
|
+
"body",
|
|
1777
|
+
"table",
|
|
1778
|
+
"tableRow",
|
|
1779
|
+
"tableCell",
|
|
1780
|
+
"tableHeader",
|
|
1781
|
+
"columnsColumn",
|
|
1782
|
+
"link"
|
|
1783
|
+
] }),
|
|
1784
|
+
ClassAttribute.configure({ types: [
|
|
1785
|
+
"heading",
|
|
1786
|
+
"paragraph",
|
|
1787
|
+
"image",
|
|
1788
|
+
"blockquote",
|
|
1789
|
+
"bulletList",
|
|
1790
|
+
"orderedList",
|
|
1791
|
+
"listItem",
|
|
1792
|
+
"button",
|
|
1793
|
+
"youtube",
|
|
1794
|
+
"twitter",
|
|
1795
|
+
"horizontalRule",
|
|
1796
|
+
"footer",
|
|
1797
|
+
"section",
|
|
1798
|
+
"div",
|
|
1799
|
+
"body",
|
|
1800
|
+
"table",
|
|
1801
|
+
"tableRow",
|
|
1802
|
+
"tableCell",
|
|
1803
|
+
"tableHeader",
|
|
1804
|
+
"columnsColumn",
|
|
1805
|
+
"link"
|
|
1806
|
+
] }),
|
|
1807
|
+
MaxNesting.configure({
|
|
1808
|
+
maxDepth: 50,
|
|
1809
|
+
nodeTypes: [
|
|
1810
|
+
"section",
|
|
1811
|
+
"bulletList",
|
|
1812
|
+
"orderedList"
|
|
1813
|
+
]
|
|
1814
|
+
})
|
|
1815
|
+
];
|
|
1816
|
+
|
|
1695
1817
|
//#endregion
|
|
1696
1818
|
//#region src/utils/set-text-alignment.ts
|
|
1697
1819
|
function setTextAlignment(editor, alignment) {
|
|
@@ -2332,6 +2454,7 @@ exports.TableRow = TableRow;
|
|
|
2332
2454
|
exports.ThreeColumns = ThreeColumns;
|
|
2333
2455
|
exports.TwoColumns = TwoColumns;
|
|
2334
2456
|
exports.Uppercase = Uppercase;
|
|
2457
|
+
exports.coreExtensions = coreExtensions;
|
|
2335
2458
|
exports.editorEventBus = editorEventBus;
|
|
2336
2459
|
exports.getColumnsDepth = getColumnsDepth;
|
|
2337
2460
|
exports.processStylesForUnlink = processStylesForUnlink;
|