@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.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Extension, Mark, Node, findChildren, markInputRule, markPasteRule, mergeAttributes } from "@tiptap/core";
|
|
2
|
+
import { StarterKit } from "@tiptap/starter-kit";
|
|
2
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
4
|
import * as ReactEmailComponents from "@react-email/components";
|
|
4
5
|
import { Button as Button$1, CodeBlock, Column, Row, Section as Section$1 } from "@react-email/components";
|
|
@@ -420,12 +421,12 @@ const Body = EmailNode.create({
|
|
|
420
421
|
0
|
|
421
422
|
];
|
|
422
423
|
},
|
|
423
|
-
renderToReactEmail({ children, node,
|
|
424
|
+
renderToReactEmail({ children, node, style }) {
|
|
424
425
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
425
426
|
return /* @__PURE__ */ jsx("div", {
|
|
426
427
|
className: node.attrs?.class || void 0,
|
|
427
428
|
style: {
|
|
428
|
-
...
|
|
429
|
+
...style,
|
|
429
430
|
...inlineStyles
|
|
430
431
|
},
|
|
431
432
|
children
|
|
@@ -581,7 +582,7 @@ const Button = EmailNode.create({
|
|
|
581
582
|
}
|
|
582
583
|
};
|
|
583
584
|
},
|
|
584
|
-
renderToReactEmail({ children, node,
|
|
585
|
+
renderToReactEmail({ children, node, style }) {
|
|
585
586
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
586
587
|
return /* @__PURE__ */ jsx(Row, { children: /* @__PURE__ */ jsx(Column, {
|
|
587
588
|
align: node.attrs?.align || node.attrs?.alignment,
|
|
@@ -589,8 +590,7 @@ const Button = EmailNode.create({
|
|
|
589
590
|
className: node.attrs?.class || void 0,
|
|
590
591
|
href: node.attrs?.href,
|
|
591
592
|
style: {
|
|
592
|
-
...
|
|
593
|
-
...styles.button,
|
|
593
|
+
...style,
|
|
594
594
|
...inlineStyles
|
|
595
595
|
},
|
|
596
596
|
children
|
|
@@ -845,7 +845,7 @@ const CodeBlockPrism = EmailNode.from(CodeBlock$1.extend({
|
|
|
845
845
|
defaultTheme: this.options.defaultTheme
|
|
846
846
|
})];
|
|
847
847
|
}
|
|
848
|
-
}), ({ node,
|
|
848
|
+
}), ({ node, style }) => {
|
|
849
849
|
const language = node.attrs?.language ? `${node.attrs.language}` : "javascript";
|
|
850
850
|
const userTheme = ReactEmailComponents[node.attrs?.theme];
|
|
851
851
|
const theme = userTheme ? {
|
|
@@ -869,181 +869,11 @@ const CodeBlockPrism = EmailNode.from(CodeBlock$1.extend({
|
|
|
869
869
|
theme,
|
|
870
870
|
style: {
|
|
871
871
|
width: "auto",
|
|
872
|
-
...
|
|
872
|
+
...style
|
|
873
873
|
}
|
|
874
874
|
});
|
|
875
875
|
});
|
|
876
876
|
|
|
877
|
-
//#endregion
|
|
878
|
-
//#region src/extensions/columns.tsx
|
|
879
|
-
const COLUMN_PARENT_TYPES = [
|
|
880
|
-
"twoColumns",
|
|
881
|
-
"threeColumns",
|
|
882
|
-
"fourColumns"
|
|
883
|
-
];
|
|
884
|
-
const COLUMN_PARENT_SET = new Set(COLUMN_PARENT_TYPES);
|
|
885
|
-
const MAX_COLUMNS_DEPTH = 3;
|
|
886
|
-
function getColumnsDepth(doc, from) {
|
|
887
|
-
const $from = doc.resolve(from);
|
|
888
|
-
let depth = 0;
|
|
889
|
-
for (let d = $from.depth; d > 0; d--) if (COLUMN_PARENT_SET.has($from.node(d).type.name)) depth++;
|
|
890
|
-
return depth;
|
|
891
|
-
}
|
|
892
|
-
const VARIANTS = [
|
|
893
|
-
{
|
|
894
|
-
name: "twoColumns",
|
|
895
|
-
columnCount: 2,
|
|
896
|
-
content: "columnsColumn columnsColumn",
|
|
897
|
-
dataType: "two-columns"
|
|
898
|
-
},
|
|
899
|
-
{
|
|
900
|
-
name: "threeColumns",
|
|
901
|
-
columnCount: 3,
|
|
902
|
-
content: "columnsColumn columnsColumn columnsColumn",
|
|
903
|
-
dataType: "three-columns"
|
|
904
|
-
},
|
|
905
|
-
{
|
|
906
|
-
name: "fourColumns",
|
|
907
|
-
columnCount: 4,
|
|
908
|
-
content: "columnsColumn{4}",
|
|
909
|
-
dataType: "four-columns"
|
|
910
|
-
}
|
|
911
|
-
];
|
|
912
|
-
const NODE_TYPE_MAP = {
|
|
913
|
-
2: "twoColumns",
|
|
914
|
-
3: "threeColumns",
|
|
915
|
-
4: "fourColumns"
|
|
916
|
-
};
|
|
917
|
-
function createColumnsNode(config, includeCommands) {
|
|
918
|
-
return EmailNode.create({
|
|
919
|
-
name: config.name,
|
|
920
|
-
group: "block",
|
|
921
|
-
content: config.content,
|
|
922
|
-
isolating: true,
|
|
923
|
-
defining: true,
|
|
924
|
-
addAttributes() {
|
|
925
|
-
return createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]);
|
|
926
|
-
},
|
|
927
|
-
parseHTML() {
|
|
928
|
-
return [{ tag: `div[data-type="${config.dataType}"]` }];
|
|
929
|
-
},
|
|
930
|
-
renderHTML({ HTMLAttributes }) {
|
|
931
|
-
return [
|
|
932
|
-
"div",
|
|
933
|
-
mergeAttributes({
|
|
934
|
-
"data-type": config.dataType,
|
|
935
|
-
class: "node-columns"
|
|
936
|
-
}, HTMLAttributes),
|
|
937
|
-
0
|
|
938
|
-
];
|
|
939
|
-
},
|
|
940
|
-
...includeCommands && { addCommands() {
|
|
941
|
-
return { insertColumns: (count) => ({ commands, state }) => {
|
|
942
|
-
if (getColumnsDepth(state.doc, state.selection.from) >= MAX_COLUMNS_DEPTH) return false;
|
|
943
|
-
const nodeType = NODE_TYPE_MAP[count];
|
|
944
|
-
const children = Array.from({ length: count }, () => ({
|
|
945
|
-
type: "columnsColumn",
|
|
946
|
-
content: [{
|
|
947
|
-
type: "paragraph",
|
|
948
|
-
content: []
|
|
949
|
-
}]
|
|
950
|
-
}));
|
|
951
|
-
return commands.insertContent({
|
|
952
|
-
type: nodeType,
|
|
953
|
-
content: children
|
|
954
|
-
});
|
|
955
|
-
} };
|
|
956
|
-
} },
|
|
957
|
-
renderToReactEmail({ children, node, styles }) {
|
|
958
|
-
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
959
|
-
return /* @__PURE__ */ jsx(Row, {
|
|
960
|
-
className: node.attrs?.class || void 0,
|
|
961
|
-
style: {
|
|
962
|
-
...styles.reset,
|
|
963
|
-
...inlineStyles
|
|
964
|
-
},
|
|
965
|
-
children
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
const TwoColumns = createColumnsNode(VARIANTS[0], true);
|
|
971
|
-
const ThreeColumns = createColumnsNode(VARIANTS[1], false);
|
|
972
|
-
const FourColumns = createColumnsNode(VARIANTS[2], false);
|
|
973
|
-
const ColumnsColumn = EmailNode.create({
|
|
974
|
-
name: "columnsColumn",
|
|
975
|
-
group: "columnsColumn",
|
|
976
|
-
content: "block+",
|
|
977
|
-
isolating: true,
|
|
978
|
-
addAttributes() {
|
|
979
|
-
return { ...createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]) };
|
|
980
|
-
},
|
|
981
|
-
parseHTML() {
|
|
982
|
-
return [{ tag: "div[data-type=\"column\"]" }];
|
|
983
|
-
},
|
|
984
|
-
renderHTML({ HTMLAttributes }) {
|
|
985
|
-
return [
|
|
986
|
-
"div",
|
|
987
|
-
mergeAttributes({
|
|
988
|
-
"data-type": "column",
|
|
989
|
-
class: "node-column"
|
|
990
|
-
}, HTMLAttributes),
|
|
991
|
-
0
|
|
992
|
-
];
|
|
993
|
-
},
|
|
994
|
-
addKeyboardShortcuts() {
|
|
995
|
-
return {
|
|
996
|
-
Backspace: ({ editor }) => {
|
|
997
|
-
const { state } = editor;
|
|
998
|
-
const { selection } = state;
|
|
999
|
-
const { empty, $from } = selection;
|
|
1000
|
-
if (!empty) return false;
|
|
1001
|
-
for (let depth = $from.depth; depth >= 1; depth--) {
|
|
1002
|
-
if ($from.pos !== $from.start(depth)) break;
|
|
1003
|
-
const indexInParent = $from.index(depth - 1);
|
|
1004
|
-
if (indexInParent === 0) continue;
|
|
1005
|
-
const prevNode = $from.node(depth - 1).child(indexInParent - 1);
|
|
1006
|
-
if (COLUMN_PARENT_SET.has(prevNode.type.name)) {
|
|
1007
|
-
const deleteFrom = $from.before(depth) - prevNode.nodeSize;
|
|
1008
|
-
const deleteTo = $from.before(depth);
|
|
1009
|
-
editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));
|
|
1010
|
-
return true;
|
|
1011
|
-
}
|
|
1012
|
-
break;
|
|
1013
|
-
}
|
|
1014
|
-
return false;
|
|
1015
|
-
},
|
|
1016
|
-
"Mod-a": ({ editor }) => {
|
|
1017
|
-
const { state } = editor;
|
|
1018
|
-
const { $from } = state.selection;
|
|
1019
|
-
for (let d = $from.depth; d > 0; d--) {
|
|
1020
|
-
if ($from.node(d).type.name !== "columnsColumn") continue;
|
|
1021
|
-
const columnStart = $from.start(d);
|
|
1022
|
-
const columnEnd = $from.end(d);
|
|
1023
|
-
const { from, to } = state.selection;
|
|
1024
|
-
if (from === columnStart && to === columnEnd) return false;
|
|
1025
|
-
editor.view.dispatch(state.tr.setSelection(TextSelection.create(state.doc, columnStart, columnEnd)));
|
|
1026
|
-
return true;
|
|
1027
|
-
}
|
|
1028
|
-
return false;
|
|
1029
|
-
}
|
|
1030
|
-
};
|
|
1031
|
-
},
|
|
1032
|
-
renderToReactEmail({ children, node, styles }) {
|
|
1033
|
-
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1034
|
-
const width = node.attrs?.width;
|
|
1035
|
-
return /* @__PURE__ */ jsx(Column, {
|
|
1036
|
-
className: node.attrs?.class || void 0,
|
|
1037
|
-
style: {
|
|
1038
|
-
...styles.reset,
|
|
1039
|
-
...inlineStyles,
|
|
1040
|
-
...width ? { width } : {}
|
|
1041
|
-
},
|
|
1042
|
-
children
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
|
-
|
|
1047
877
|
//#endregion
|
|
1048
878
|
//#region src/extensions/div.tsx
|
|
1049
879
|
const Div = EmailNode.create({
|
|
@@ -1076,12 +906,12 @@ const Div = EmailNode.create({
|
|
|
1076
906
|
addAttributes() {
|
|
1077
907
|
return { ...createStandardAttributes([...COMMON_HTML_ATTRIBUTES, ...LAYOUT_ATTRIBUTES]) };
|
|
1078
908
|
},
|
|
1079
|
-
renderToReactEmail({ children, node,
|
|
909
|
+
renderToReactEmail({ children, node, style }) {
|
|
1080
910
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1081
911
|
return /* @__PURE__ */ jsx("div", {
|
|
1082
912
|
className: node.attrs?.class || void 0,
|
|
1083
913
|
style: {
|
|
1084
|
-
...
|
|
914
|
+
...style,
|
|
1085
915
|
...inlineStyles
|
|
1086
916
|
},
|
|
1087
917
|
children
|
|
@@ -1332,14 +1162,14 @@ const Section = EmailNode.create({
|
|
|
1332
1162
|
});
|
|
1333
1163
|
} };
|
|
1334
1164
|
},
|
|
1335
|
-
renderToReactEmail({ children, node,
|
|
1165
|
+
renderToReactEmail({ children, node, style }) {
|
|
1336
1166
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1337
1167
|
const textAlign = node.attrs?.align || node.attrs?.alignment;
|
|
1338
1168
|
return /* @__PURE__ */ jsx(Section$1, {
|
|
1339
1169
|
className: node.attrs?.class || void 0,
|
|
1340
1170
|
align: textAlign,
|
|
1341
1171
|
style: {
|
|
1342
|
-
...
|
|
1172
|
+
...style,
|
|
1343
1173
|
...inlineStyles,
|
|
1344
1174
|
...getTextAlignment(textAlign)
|
|
1345
1175
|
},
|
|
@@ -1472,7 +1302,7 @@ const Table = EmailNode.create({
|
|
|
1472
1302
|
]
|
|
1473
1303
|
];
|
|
1474
1304
|
},
|
|
1475
|
-
renderToReactEmail({ children, node,
|
|
1305
|
+
renderToReactEmail({ children, node, style }) {
|
|
1476
1306
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1477
1307
|
const alignment = node.attrs?.align || node.attrs?.alignment;
|
|
1478
1308
|
const width = node.attrs?.width;
|
|
@@ -1483,7 +1313,7 @@ const Table = EmailNode.create({
|
|
|
1483
1313
|
return /* @__PURE__ */ jsx(Section$1, {
|
|
1484
1314
|
className: node.attrs?.class || void 0,
|
|
1485
1315
|
align: alignment,
|
|
1486
|
-
style: resolveConflictingStyles(
|
|
1316
|
+
style: resolveConflictingStyles(style, {
|
|
1487
1317
|
...inlineStyles,
|
|
1488
1318
|
...centeringStyles
|
|
1489
1319
|
}),
|
|
@@ -1524,12 +1354,12 @@ const TableRow = EmailNode.create({
|
|
|
1524
1354
|
0
|
|
1525
1355
|
];
|
|
1526
1356
|
},
|
|
1527
|
-
renderToReactEmail({ children, node,
|
|
1357
|
+
renderToReactEmail({ children, node, style }) {
|
|
1528
1358
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1529
1359
|
return /* @__PURE__ */ jsx("tr", {
|
|
1530
1360
|
className: node.attrs?.class || void 0,
|
|
1531
1361
|
style: {
|
|
1532
|
-
...
|
|
1362
|
+
...style,
|
|
1533
1363
|
...inlineStyles
|
|
1534
1364
|
},
|
|
1535
1365
|
children
|
|
@@ -1569,13 +1399,13 @@ const TableCell = EmailNode.create({
|
|
|
1569
1399
|
0
|
|
1570
1400
|
];
|
|
1571
1401
|
},
|
|
1572
|
-
renderToReactEmail({ children, node,
|
|
1402
|
+
renderToReactEmail({ children, node, style }) {
|
|
1573
1403
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1574
1404
|
return /* @__PURE__ */ jsx(Column, {
|
|
1575
1405
|
className: node.attrs?.class || void 0,
|
|
1576
1406
|
align: node.attrs?.align || node.attrs?.alignment,
|
|
1577
1407
|
style: {
|
|
1578
|
-
...
|
|
1408
|
+
...style,
|
|
1579
1409
|
...inlineStyles
|
|
1580
1410
|
},
|
|
1581
1411
|
children
|
|
@@ -1656,6 +1486,297 @@ const Uppercase = Mark.create({
|
|
|
1656
1486
|
}
|
|
1657
1487
|
});
|
|
1658
1488
|
|
|
1489
|
+
//#endregion
|
|
1490
|
+
//#region src/extensions/columns.tsx
|
|
1491
|
+
const COLUMN_PARENT_TYPES = [
|
|
1492
|
+
"twoColumns",
|
|
1493
|
+
"threeColumns",
|
|
1494
|
+
"fourColumns"
|
|
1495
|
+
];
|
|
1496
|
+
const COLUMN_PARENT_SET = new Set(COLUMN_PARENT_TYPES);
|
|
1497
|
+
const MAX_COLUMNS_DEPTH = 3;
|
|
1498
|
+
function getColumnsDepth(doc, from) {
|
|
1499
|
+
const $from = doc.resolve(from);
|
|
1500
|
+
let depth = 0;
|
|
1501
|
+
for (let d = $from.depth; d > 0; d--) if (COLUMN_PARENT_SET.has($from.node(d).type.name)) depth++;
|
|
1502
|
+
return depth;
|
|
1503
|
+
}
|
|
1504
|
+
const VARIANTS = [
|
|
1505
|
+
{
|
|
1506
|
+
name: "twoColumns",
|
|
1507
|
+
columnCount: 2,
|
|
1508
|
+
content: "columnsColumn columnsColumn",
|
|
1509
|
+
dataType: "two-columns"
|
|
1510
|
+
},
|
|
1511
|
+
{
|
|
1512
|
+
name: "threeColumns",
|
|
1513
|
+
columnCount: 3,
|
|
1514
|
+
content: "columnsColumn columnsColumn columnsColumn",
|
|
1515
|
+
dataType: "three-columns"
|
|
1516
|
+
},
|
|
1517
|
+
{
|
|
1518
|
+
name: "fourColumns",
|
|
1519
|
+
columnCount: 4,
|
|
1520
|
+
content: "columnsColumn{4}",
|
|
1521
|
+
dataType: "four-columns"
|
|
1522
|
+
}
|
|
1523
|
+
];
|
|
1524
|
+
const NODE_TYPE_MAP = {
|
|
1525
|
+
2: "twoColumns",
|
|
1526
|
+
3: "threeColumns",
|
|
1527
|
+
4: "fourColumns"
|
|
1528
|
+
};
|
|
1529
|
+
function createColumnsNode(config, includeCommands) {
|
|
1530
|
+
return EmailNode.create({
|
|
1531
|
+
name: config.name,
|
|
1532
|
+
group: "block",
|
|
1533
|
+
content: config.content,
|
|
1534
|
+
isolating: true,
|
|
1535
|
+
defining: true,
|
|
1536
|
+
addAttributes() {
|
|
1537
|
+
return createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]);
|
|
1538
|
+
},
|
|
1539
|
+
parseHTML() {
|
|
1540
|
+
return [{ tag: `div[data-type="${config.dataType}"]` }];
|
|
1541
|
+
},
|
|
1542
|
+
renderHTML({ HTMLAttributes }) {
|
|
1543
|
+
return [
|
|
1544
|
+
"div",
|
|
1545
|
+
mergeAttributes({
|
|
1546
|
+
"data-type": config.dataType,
|
|
1547
|
+
class: "node-columns"
|
|
1548
|
+
}, HTMLAttributes),
|
|
1549
|
+
0
|
|
1550
|
+
];
|
|
1551
|
+
},
|
|
1552
|
+
...includeCommands && { addCommands() {
|
|
1553
|
+
return { insertColumns: (count) => ({ commands, state }) => {
|
|
1554
|
+
if (getColumnsDepth(state.doc, state.selection.from) >= MAX_COLUMNS_DEPTH) return false;
|
|
1555
|
+
const nodeType = NODE_TYPE_MAP[count];
|
|
1556
|
+
const children = Array.from({ length: count }, () => ({
|
|
1557
|
+
type: "columnsColumn",
|
|
1558
|
+
content: [{
|
|
1559
|
+
type: "paragraph",
|
|
1560
|
+
content: []
|
|
1561
|
+
}]
|
|
1562
|
+
}));
|
|
1563
|
+
return commands.insertContent({
|
|
1564
|
+
type: nodeType,
|
|
1565
|
+
content: children
|
|
1566
|
+
});
|
|
1567
|
+
} };
|
|
1568
|
+
} },
|
|
1569
|
+
renderToReactEmail({ children, node, style }) {
|
|
1570
|
+
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1571
|
+
return /* @__PURE__ */ jsx(Row, {
|
|
1572
|
+
className: node.attrs?.class || void 0,
|
|
1573
|
+
style: {
|
|
1574
|
+
...style,
|
|
1575
|
+
...inlineStyles
|
|
1576
|
+
},
|
|
1577
|
+
children
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
const TwoColumns = createColumnsNode(VARIANTS[0], true);
|
|
1583
|
+
const ThreeColumns = createColumnsNode(VARIANTS[1], false);
|
|
1584
|
+
const FourColumns = createColumnsNode(VARIANTS[2], false);
|
|
1585
|
+
const ColumnsColumn = EmailNode.create({
|
|
1586
|
+
name: "columnsColumn",
|
|
1587
|
+
group: "columnsColumn",
|
|
1588
|
+
content: "block+",
|
|
1589
|
+
isolating: true,
|
|
1590
|
+
addAttributes() {
|
|
1591
|
+
return { ...createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]) };
|
|
1592
|
+
},
|
|
1593
|
+
parseHTML() {
|
|
1594
|
+
return [{ tag: "div[data-type=\"column\"]" }];
|
|
1595
|
+
},
|
|
1596
|
+
renderHTML({ HTMLAttributes }) {
|
|
1597
|
+
return [
|
|
1598
|
+
"div",
|
|
1599
|
+
mergeAttributes({
|
|
1600
|
+
"data-type": "column",
|
|
1601
|
+
class: "node-column"
|
|
1602
|
+
}, HTMLAttributes),
|
|
1603
|
+
0
|
|
1604
|
+
];
|
|
1605
|
+
},
|
|
1606
|
+
addKeyboardShortcuts() {
|
|
1607
|
+
return {
|
|
1608
|
+
Backspace: ({ editor }) => {
|
|
1609
|
+
const { state } = editor;
|
|
1610
|
+
const { selection } = state;
|
|
1611
|
+
const { empty, $from } = selection;
|
|
1612
|
+
if (!empty) return false;
|
|
1613
|
+
for (let depth = $from.depth; depth >= 1; depth--) {
|
|
1614
|
+
if ($from.pos !== $from.start(depth)) break;
|
|
1615
|
+
const indexInParent = $from.index(depth - 1);
|
|
1616
|
+
if (indexInParent === 0) continue;
|
|
1617
|
+
const prevNode = $from.node(depth - 1).child(indexInParent - 1);
|
|
1618
|
+
if (COLUMN_PARENT_SET.has(prevNode.type.name)) {
|
|
1619
|
+
const deleteFrom = $from.before(depth) - prevNode.nodeSize;
|
|
1620
|
+
const deleteTo = $from.before(depth);
|
|
1621
|
+
editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));
|
|
1622
|
+
return true;
|
|
1623
|
+
}
|
|
1624
|
+
break;
|
|
1625
|
+
}
|
|
1626
|
+
return false;
|
|
1627
|
+
},
|
|
1628
|
+
"Mod-a": ({ editor }) => {
|
|
1629
|
+
const { state } = editor;
|
|
1630
|
+
const { $from } = state.selection;
|
|
1631
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
1632
|
+
if ($from.node(d).type.name !== "columnsColumn") continue;
|
|
1633
|
+
const columnStart = $from.start(d);
|
|
1634
|
+
const columnEnd = $from.end(d);
|
|
1635
|
+
const { from, to } = state.selection;
|
|
1636
|
+
if (from === columnStart && to === columnEnd) return false;
|
|
1637
|
+
editor.view.dispatch(state.tr.setSelection(TextSelection.create(state.doc, columnStart, columnEnd)));
|
|
1638
|
+
return true;
|
|
1639
|
+
}
|
|
1640
|
+
return false;
|
|
1641
|
+
}
|
|
1642
|
+
};
|
|
1643
|
+
},
|
|
1644
|
+
renderToReactEmail({ children, node, style }) {
|
|
1645
|
+
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
1646
|
+
const width = node.attrs?.width;
|
|
1647
|
+
return /* @__PURE__ */ jsx(Column, {
|
|
1648
|
+
className: node.attrs?.class || void 0,
|
|
1649
|
+
style: {
|
|
1650
|
+
...style,
|
|
1651
|
+
...inlineStyles,
|
|
1652
|
+
...width ? { width } : {}
|
|
1653
|
+
},
|
|
1654
|
+
children
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
|
|
1659
|
+
//#endregion
|
|
1660
|
+
//#region src/extensions/index.ts
|
|
1661
|
+
const coreExtensions = [
|
|
1662
|
+
StarterKit.configure({
|
|
1663
|
+
undoRedo: false,
|
|
1664
|
+
heading: false,
|
|
1665
|
+
link: false,
|
|
1666
|
+
underline: false,
|
|
1667
|
+
trailingNode: false,
|
|
1668
|
+
bold: false,
|
|
1669
|
+
gapcursor: false,
|
|
1670
|
+
listItem: {},
|
|
1671
|
+
bulletList: { HTMLAttributes: { class: "node-bulletList" } },
|
|
1672
|
+
paragraph: { HTMLAttributes: { class: "node-paragraph" } },
|
|
1673
|
+
orderedList: { HTMLAttributes: { class: "node-orderedList" } },
|
|
1674
|
+
blockquote: { HTMLAttributes: { class: "node-blockquote" } },
|
|
1675
|
+
codeBlock: false,
|
|
1676
|
+
code: { HTMLAttributes: {
|
|
1677
|
+
class: "node-inlineCode",
|
|
1678
|
+
spellcheck: "false"
|
|
1679
|
+
} },
|
|
1680
|
+
horizontalRule: false,
|
|
1681
|
+
dropcursor: {
|
|
1682
|
+
color: "#61a8f8",
|
|
1683
|
+
class: "rounded-full animate-[fade-in_300ms_ease-in-out] !z-40",
|
|
1684
|
+
width: 4
|
|
1685
|
+
}
|
|
1686
|
+
}),
|
|
1687
|
+
CodeBlockPrism.configure({
|
|
1688
|
+
defaultLanguage: "javascript",
|
|
1689
|
+
HTMLAttributes: { class: "prism node-codeBlock" }
|
|
1690
|
+
}),
|
|
1691
|
+
Placeholder,
|
|
1692
|
+
PreviewText,
|
|
1693
|
+
Bold,
|
|
1694
|
+
Sup,
|
|
1695
|
+
Uppercase,
|
|
1696
|
+
PreservedStyle,
|
|
1697
|
+
Table,
|
|
1698
|
+
TableRow,
|
|
1699
|
+
TableCell,
|
|
1700
|
+
TableHeader,
|
|
1701
|
+
Body,
|
|
1702
|
+
Div,
|
|
1703
|
+
Button,
|
|
1704
|
+
Section,
|
|
1705
|
+
AlignmentAttribute.configure({ types: [
|
|
1706
|
+
"heading",
|
|
1707
|
+
"paragraph",
|
|
1708
|
+
"image",
|
|
1709
|
+
"blockquote",
|
|
1710
|
+
"codeBlock",
|
|
1711
|
+
"bulletList",
|
|
1712
|
+
"orderedList",
|
|
1713
|
+
"listItem",
|
|
1714
|
+
"button",
|
|
1715
|
+
"youtube",
|
|
1716
|
+
"twitter",
|
|
1717
|
+
"table",
|
|
1718
|
+
"tableRow",
|
|
1719
|
+
"tableCell",
|
|
1720
|
+
"tableHeader",
|
|
1721
|
+
"columnsColumn"
|
|
1722
|
+
] }),
|
|
1723
|
+
StyleAttribute.configure({ types: [
|
|
1724
|
+
"heading",
|
|
1725
|
+
"paragraph",
|
|
1726
|
+
"image",
|
|
1727
|
+
"blockquote",
|
|
1728
|
+
"codeBlock",
|
|
1729
|
+
"bulletList",
|
|
1730
|
+
"orderedList",
|
|
1731
|
+
"listItem",
|
|
1732
|
+
"button",
|
|
1733
|
+
"youtube",
|
|
1734
|
+
"twitter",
|
|
1735
|
+
"horizontalRule",
|
|
1736
|
+
"footer",
|
|
1737
|
+
"section",
|
|
1738
|
+
"div",
|
|
1739
|
+
"body",
|
|
1740
|
+
"table",
|
|
1741
|
+
"tableRow",
|
|
1742
|
+
"tableCell",
|
|
1743
|
+
"tableHeader",
|
|
1744
|
+
"columnsColumn",
|
|
1745
|
+
"link"
|
|
1746
|
+
] }),
|
|
1747
|
+
ClassAttribute.configure({ types: [
|
|
1748
|
+
"heading",
|
|
1749
|
+
"paragraph",
|
|
1750
|
+
"image",
|
|
1751
|
+
"blockquote",
|
|
1752
|
+
"bulletList",
|
|
1753
|
+
"orderedList",
|
|
1754
|
+
"listItem",
|
|
1755
|
+
"button",
|
|
1756
|
+
"youtube",
|
|
1757
|
+
"twitter",
|
|
1758
|
+
"horizontalRule",
|
|
1759
|
+
"footer",
|
|
1760
|
+
"section",
|
|
1761
|
+
"div",
|
|
1762
|
+
"body",
|
|
1763
|
+
"table",
|
|
1764
|
+
"tableRow",
|
|
1765
|
+
"tableCell",
|
|
1766
|
+
"tableHeader",
|
|
1767
|
+
"columnsColumn",
|
|
1768
|
+
"link"
|
|
1769
|
+
] }),
|
|
1770
|
+
MaxNesting.configure({
|
|
1771
|
+
maxDepth: 50,
|
|
1772
|
+
nodeTypes: [
|
|
1773
|
+
"section",
|
|
1774
|
+
"bulletList",
|
|
1775
|
+
"orderedList"
|
|
1776
|
+
]
|
|
1777
|
+
})
|
|
1778
|
+
];
|
|
1779
|
+
|
|
1659
1780
|
//#endregion
|
|
1660
1781
|
//#region src/utils/set-text-alignment.ts
|
|
1661
1782
|
function setTextAlignment(editor, alignment) {
|
|
@@ -2251,5 +2372,5 @@ const BubbleMenu = {
|
|
|
2251
2372
|
};
|
|
2252
2373
|
|
|
2253
2374
|
//#endregion
|
|
2254
|
-
export { AlignmentAttribute, Body, Bold, BubbleMenu, BubbleMenuAlignCenter, BubbleMenuAlignLeft, BubbleMenuAlignRight, BubbleMenuBold, BubbleMenuCode, BubbleMenuItalic, BubbleMenuItem, BubbleMenuItemGroup, BubbleMenuLinkSelector, BubbleMenuNodeSelector, BubbleMenuRoot, BubbleMenuSeparator, BubbleMenuStrike, BubbleMenuUnderline, BubbleMenuUppercase, Button, COLUMN_PARENT_TYPES, ClassAttribute, CodeBlockPrism, ColumnsColumn, Div, EmailNode, FourColumns, MAX_COLUMNS_DEPTH, MaxNesting, NodeSelectorContent, NodeSelectorRoot, NodeSelectorTrigger, Placeholder, PreservedStyle, PreviewText, Section, StyleAttribute, Sup, Table, TableCell, TableHeader, TableRow, ThreeColumns, TwoColumns, Uppercase, editorEventBus, getColumnsDepth, processStylesForUnlink, setTextAlignment };
|
|
2375
|
+
export { AlignmentAttribute, Body, Bold, BubbleMenu, BubbleMenuAlignCenter, BubbleMenuAlignLeft, BubbleMenuAlignRight, BubbleMenuBold, BubbleMenuCode, BubbleMenuItalic, BubbleMenuItem, BubbleMenuItemGroup, BubbleMenuLinkSelector, BubbleMenuNodeSelector, BubbleMenuRoot, BubbleMenuSeparator, BubbleMenuStrike, BubbleMenuUnderline, BubbleMenuUppercase, Button, COLUMN_PARENT_TYPES, ClassAttribute, CodeBlockPrism, ColumnsColumn, Div, EmailNode, FourColumns, MAX_COLUMNS_DEPTH, MaxNesting, NodeSelectorContent, NodeSelectorRoot, NodeSelectorTrigger, Placeholder, PreservedStyle, PreviewText, Section, StyleAttribute, Sup, Table, TableCell, TableHeader, TableRow, ThreeColumns, TwoColumns, Uppercase, coreExtensions, editorEventBus, getColumnsDepth, processStylesForUnlink, setTextAlignment };
|
|
2255
2376
|
//# sourceMappingURL=index.mjs.map
|