@react-email/editor 0.0.0-experimental.39 → 0.0.0-experimental.40
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 +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/{extension-CnC8y63H.mjs → extension-DyY8_bh4.mjs} +8 -17
- package/dist/{extension-CnC8y63H.mjs.map → extension-DyY8_bh4.mjs.map} +1 -1
- package/dist/{extension-dGpPpEvD.cjs → extension-w5VaUeSw.cjs} +6 -15
- package/dist/extensions/index.cjs +6 -3
- package/dist/extensions/index.d.cts +44 -1
- package/dist/extensions/index.d.cts.map +1 -1
- package/dist/extensions/index.d.mts +44 -1
- package/dist/extensions/index.d.mts.map +1 -1
- package/dist/extensions/index.mjs +3 -3
- package/dist/{extensions-DWsu9kwZ.mjs → extensions-BvfmaKCn.mjs} +196 -22
- package/dist/extensions-BvfmaKCn.mjs.map +1 -0
- package/dist/{extensions-aMMnHcs9.cjs → extensions-CkjPj2JO.cjs} +211 -19
- package/dist/{global-content-5rAU84QT.mjs → global-content-D_WYaFgX.mjs} +2 -2
- package/dist/global-content-D_WYaFgX.mjs.map +1 -0
- package/dist/{global-content-62RO9uoQ.cjs → global-content-bJgotqmA.cjs} +1 -1
- package/dist/index-C4KcMQ0R.d.cts.map +1 -1
- package/dist/index-CxX7W63O.d.mts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.d.cts +6 -6
- package/dist/plugins/index.d.cts.map +1 -1
- package/dist/plugins/index.d.mts +6 -6
- package/dist/plugins/index.d.mts.map +1 -1
- package/dist/plugins/index.mjs +1 -1
- package/dist/ui/index.d.cts +70 -70
- package/dist/ui/index.d.cts.map +1 -1
- package/dist/ui/index.d.mts +70 -70
- package/dist/ui/index.d.mts.map +1 -1
- package/package.json +11 -5
- package/dist/extensions-DWsu9kwZ.mjs.map +0 -1
- package/dist/global-content-5rAU84QT.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/extensions/alignment-attribute.tsx","../../src/extensions/body.tsx","../../src/extensions/bold.tsx","../../src/extensions/button.tsx","../../src/extensions/class-attribute.tsx","../../src/extensions/code-block.tsx","../../src/extensions/div.tsx","../../src/extensions/divider.tsx","../../src/extensions/global-content.ts","../../src/extensions/heading.tsx","../../src/extensions/link.tsx","../../src/extensions/max-nesting.ts","../../src/extensions/placeholder.ts","../../src/extensions/preview-text.ts","../../src/extensions/section.tsx","../../src/extensions/style-attribute.tsx","../../src/extensions/sup.tsx","../../src/extensions/table.tsx","../../src/extensions/underline.tsx","../../src/extensions/uppercase.tsx","../../src/extensions/blockquote.tsx","../../src/extensions/bullet-list.tsx","../../src/extensions/code.tsx","../../src/extensions/columns.tsx","../../src/extensions/hard-break.tsx","../../src/extensions/italic.tsx","../../src/extensions/list-item.tsx","../../src/extensions/ordered-list.tsx","../../src/extensions/paragraph.tsx","../../src/extensions/preserved-style.tsx","../../src/extensions/strike.tsx","../../src/extensions/text.tsx","../../src/extensions/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;UAEiB,gBAAA;;;;;;;;;;2CAW0B;;;;cAK9B,oBAAkB,UAAA;;;UCTd,WAAA;kBACC;;cAGL,MAAI,UAAA,aAAA;;;KCTL,WAAA,GAAc;cAqBb,MAAM,UAAU;;;UChBZ,mBAAA;kBACC;;;;;;uBAOK;iCACU,4BAA4B;;;;cAKhD,QAAM,UAAA,qBAAA;;;UCrBF,qBAAA;;;;;;;;;;uCAWsB;;;;wBAIf;;;;cAKX,gBAAc,UAAA;;;UCVV,qBAAA,SAA8B;;;;cAKlC,gBAAc,UAAA;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/extensions/alignment-attribute.tsx","../../src/extensions/body.tsx","../../src/extensions/bold.tsx","../../src/extensions/button.tsx","../../src/extensions/class-attribute.tsx","../../src/extensions/code-block.tsx","../../src/extensions/container.tsx","../../src/extensions/div.tsx","../../src/extensions/divider.tsx","../../src/extensions/global-content.ts","../../src/extensions/heading.tsx","../../src/extensions/link.tsx","../../src/extensions/max-nesting.ts","../../src/extensions/placeholder.ts","../../src/extensions/preview-text.ts","../../src/extensions/section.tsx","../../src/extensions/style-attribute.tsx","../../src/extensions/sup.tsx","../../src/extensions/table.tsx","../../src/extensions/trailing-node.tsx","../../src/extensions/underline.tsx","../../src/extensions/uppercase.tsx","../../src/extensions/blockquote.tsx","../../src/extensions/bullet-list.tsx","../../src/extensions/code.tsx","../../src/extensions/columns.tsx","../../src/extensions/hard-break.tsx","../../src/extensions/italic.tsx","../../src/extensions/list-item.tsx","../../src/extensions/ordered-list.tsx","../../src/extensions/paragraph.tsx","../../src/extensions/preserved-style.tsx","../../src/extensions/strike.tsx","../../src/extensions/text.tsx","../../src/extensions/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;UAEiB,gBAAA;;;;;;;;;;2CAW0B;;;;cAK9B,oBAAkB,UAAA;;;UCTd,WAAA;kBACC;;cAGL,MAAI,UAAA,aAAA;;;KCTL,WAAA,GAAc;cAqBb,MAAM,UAAU;;;UChBZ,mBAAA;kBACC;;;;;;uBAOK;iCACU,4BAA4B;;;;cAKhD,QAAM,UAAA,qBAAA;;;UCrBF,qBAAA;;;;;;;;;;uCAWsB;;;;wBAIf;;;;cAKX,gBAAc,UAAA;;;UCVV,qBAAA,SAA8B;;;;cAKlC,gBAAc,UAAA;;;UCgCV,gBAAA;kBACC;;cAGL,WAAS,UAAA,kBAAA;;;UC5CL,UAAA;kBACC;;cAGL,KAAG,UAAA,YAAA;;;KCRJ,cAAA,GAAiB;cAMhB,SAAS,UAAU;;;UCPf,oBAAA;;QAET;;;;uDAK+C;;;mBAIpC,cAAc;;;iBAoCjB,gBAAA,sBAAsC;cAQzC,eAAa,KAAA;;;KCvDd,cAAA,GAAiB;c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yByLqB,iBzBzLrB,CAAA,GAAA,KAAA;EAAA,gBAAA,EyB0LmB,OzB1LnB,CyB0L2B,mBzB1L3B,CAAA,GAAA,KAAA;;AAQgC,cyBqLpB,UzBrLoB,EyBqLV,SzBrLU,CyBqLV,iBzBrLU,EAAA,GAAA,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as Div, B as AlignmentAttribute, C as processStylesForUnlink, D as Divider, E as HardBreak, F as Button, I as BulletList, L as Bold, M as CodeBlockPrism, N as Code, P as ClassAttribute, R as Body, S as PreservedStyle, T as Heading, _ as Paragraph, a as skipTrailingNodeMeta, b as ListItem, c as TableCell, d as Sup, f as StyleAttribute, g as Placeholder, h as PreviewText, i as TrailingNode, j as Container, l as TableHeader, m as Section, n as Uppercase, o as Text, p as Strike, r as Underline, s as Table, t as StarterKit, u as TableRow, v as OrderedList, w as Italic, x as Link, y as MaxNesting, z as Blockquote } from "../extensions-BvfmaKCn.mjs";
|
|
2
2
|
import { a as MAX_COLUMNS_DEPTH, c as getColumnsDepth, i as FourColumns, n as COLUMN_PARENT_TYPES, o as ThreeColumns, r as ColumnsColumn, s as TwoColumns } from "../event-bus-CHEzOS_O.mjs";
|
|
3
|
-
import { n as getGlobalContent, t as GlobalContent } from "../global-content-
|
|
3
|
+
import { n as getGlobalContent, t as GlobalContent } from "../global-content-D_WYaFgX.mjs";
|
|
4
4
|
|
|
5
|
-
export { AlignmentAttribute, Blockquote, Body, Bold, BulletList, Button, COLUMN_PARENT_TYPES, ClassAttribute, Code, CodeBlockPrism, ColumnsColumn, Div, Divider, FourColumns, GlobalContent, HardBreak, Heading, Italic, Link, ListItem, MAX_COLUMNS_DEPTH, MaxNesting, OrderedList, Paragraph, Placeholder, PreservedStyle, PreviewText, Section, StarterKit, Strike, StyleAttribute, Sup, Table, TableCell, TableHeader, TableRow, Text, ThreeColumns, TwoColumns, Underline, Uppercase, getColumnsDepth, getGlobalContent, processStylesForUnlink };
|
|
5
|
+
export { AlignmentAttribute, Blockquote, Body, Bold, BulletList, Button, COLUMN_PARENT_TYPES, ClassAttribute, Code, CodeBlockPrism, ColumnsColumn, Container, Div, Divider, FourColumns, GlobalContent, HardBreak, Heading, Italic, Link, ListItem, MAX_COLUMNS_DEPTH, MaxNesting, OrderedList, Paragraph, Placeholder, PreservedStyle, PreviewText, Section, StarterKit, Strike, StyleAttribute, Sup, Table, TableCell, TableHeader, TableRow, Text, ThreeColumns, TrailingNode, TwoColumns, Underline, Uppercase, getColumnsDepth, getGlobalContent, processStylesForUnlink, skipTrailingNodeMeta };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { n as inlineCssToJs, r as resolveConflictingStyles } from "./styles-_TMw3YxC.mjs";
|
|
2
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-
|
|
3
|
+
import { t as GlobalContent } from "./global-content-D_WYaFgX.mjs";
|
|
4
4
|
import { UndoRedo } from "@tiptap/extensions";
|
|
5
5
|
import { NodeViewContent, NodeViewWrapper, ReactNodeViewRenderer, useEditor, useEditorState } from "@tiptap/react";
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import { generateJSON } from "@tiptap/html";
|
|
8
8
|
import * as ReactEmailComponents from "@react-email/components";
|
|
9
|
-
import { Body, Button, CodeBlock, Column, Head, Heading, Hr, Html, Link, Preview, Row, Section, pretty, render, toPlainText } from "@react-email/components";
|
|
9
|
+
import { Body, Button, CodeBlock, Column, Container, Head, Heading, Hr, Html, Link, Preview, Row, Section, pretty, render, toPlainText } from "@react-email/components";
|
|
10
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { Extension, InputRule, Mark, Node as Node$1, findChildren, mergeAttributes } from "@tiptap/core";
|
|
12
12
|
import TipTapStarterKit from "@tiptap/starter-kit";
|
|
@@ -179,14 +179,7 @@ function DefaultBaseTemplate({ children, previewText }) {
|
|
|
179
179
|
})
|
|
180
180
|
] }),
|
|
181
181
|
previewText && previewText !== "" && /* @__PURE__ */ jsx(Preview, { children: previewText }),
|
|
182
|
-
/* @__PURE__ */ jsx(Body, { children
|
|
183
|
-
width: "100%",
|
|
184
|
-
align: "center",
|
|
185
|
-
children: /* @__PURE__ */ jsx(Section, {
|
|
186
|
-
style: { width: "100%" },
|
|
187
|
-
children
|
|
188
|
-
})
|
|
189
|
-
}) })
|
|
182
|
+
/* @__PURE__ */ jsx(Body, { children })
|
|
190
183
|
] });
|
|
191
184
|
}
|
|
192
185
|
|
|
@@ -800,6 +793,107 @@ const CodeBlockPrism = EmailNode.from(CodeBlock$1.extend({
|
|
|
800
793
|
});
|
|
801
794
|
});
|
|
802
795
|
|
|
796
|
+
//#endregion
|
|
797
|
+
//#region src/utils/is-collaboration.ts
|
|
798
|
+
const COLLABORATION_EXTENSION_NAMES = new Set(["liveblocksExtension", "collaboration"]);
|
|
799
|
+
function hasCollaborationExtension(exts) {
|
|
800
|
+
return exts.some((ext) => COLLABORATION_EXTENSION_NAMES.has(ext.name));
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
//#endregion
|
|
804
|
+
//#region src/extensions/container.tsx
|
|
805
|
+
function hasContainerNode(doc) {
|
|
806
|
+
let found = false;
|
|
807
|
+
doc.forEach((node) => {
|
|
808
|
+
if (node.type.name === "container") found = true;
|
|
809
|
+
});
|
|
810
|
+
return found;
|
|
811
|
+
}
|
|
812
|
+
function wrapInContainer(state) {
|
|
813
|
+
const { doc } = state;
|
|
814
|
+
const containerType = state.schema.nodes.container;
|
|
815
|
+
const contentNodes = [];
|
|
816
|
+
const globalContentNodes = [];
|
|
817
|
+
doc.forEach((node) => {
|
|
818
|
+
if (node.type.name === "globalContent") globalContentNodes.push(node);
|
|
819
|
+
else contentNodes.push(node);
|
|
820
|
+
});
|
|
821
|
+
const containerContent = contentNodes.length > 0 ? contentNodes : [state.schema.nodes.paragraph.create()];
|
|
822
|
+
const containerNode = containerType.create(null, containerContent);
|
|
823
|
+
const newDocContent = [...globalContentNodes, containerNode];
|
|
824
|
+
const tr = state.tr;
|
|
825
|
+
tr.replaceWith(0, doc.content.size, newDocContent);
|
|
826
|
+
tr.setMeta("addToHistory", false);
|
|
827
|
+
return tr;
|
|
828
|
+
}
|
|
829
|
+
const Container$1 = EmailNode.create({
|
|
830
|
+
name: "container",
|
|
831
|
+
group: "block",
|
|
832
|
+
content: "block+",
|
|
833
|
+
defining: true,
|
|
834
|
+
isolating: true,
|
|
835
|
+
selectable: false,
|
|
836
|
+
draggable: false,
|
|
837
|
+
addOptions() {
|
|
838
|
+
return { HTMLAttributes: {} };
|
|
839
|
+
},
|
|
840
|
+
parseHTML() {
|
|
841
|
+
return [{ tag: "div[data-type=\"container\"]" }, {
|
|
842
|
+
tag: "table[role=\"presentation\"]",
|
|
843
|
+
priority: 60,
|
|
844
|
+
getAttrs: (node) => {
|
|
845
|
+
if (typeof node === "string") return false;
|
|
846
|
+
const table = node;
|
|
847
|
+
if (!table.style.maxWidth) return false;
|
|
848
|
+
if (!table.querySelector(":scope > tbody > tr:only-child > td:only-child")) return false;
|
|
849
|
+
return null;
|
|
850
|
+
},
|
|
851
|
+
contentElement: (node) => node.querySelector(":scope > tbody > tr > td")
|
|
852
|
+
}];
|
|
853
|
+
},
|
|
854
|
+
renderHTML({ HTMLAttributes }) {
|
|
855
|
+
return [
|
|
856
|
+
"div",
|
|
857
|
+
mergeAttributes({
|
|
858
|
+
"data-type": "container",
|
|
859
|
+
class: "node-container"
|
|
860
|
+
}, this.options.HTMLAttributes, HTMLAttributes),
|
|
861
|
+
0
|
|
862
|
+
];
|
|
863
|
+
},
|
|
864
|
+
addProseMirrorPlugins() {
|
|
865
|
+
const isCollaborative = hasCollaborationExtension(this.editor.extensionManager.extensions);
|
|
866
|
+
return [new Plugin({
|
|
867
|
+
key: new PluginKey("containerEnforcer"),
|
|
868
|
+
view: isCollaborative ? void 0 : (editorView) => {
|
|
869
|
+
if (!hasContainerNode(editorView.state.doc)) {
|
|
870
|
+
const tr = wrapInContainer(editorView.state);
|
|
871
|
+
editorView.dispatch(tr);
|
|
872
|
+
}
|
|
873
|
+
return {};
|
|
874
|
+
},
|
|
875
|
+
appendTransaction(_transactions, oldState, newState) {
|
|
876
|
+
if (hasContainerNode(newState.doc)) return null;
|
|
877
|
+
if (newState.doc.eq(oldState.doc)) return null;
|
|
878
|
+
return wrapInContainer(newState);
|
|
879
|
+
}
|
|
880
|
+
})];
|
|
881
|
+
},
|
|
882
|
+
renderToReactEmail({ children, node, style }) {
|
|
883
|
+
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
884
|
+
return /* @__PURE__ */ jsx(Container, {
|
|
885
|
+
className: node.attrs?.class || void 0,
|
|
886
|
+
style: {
|
|
887
|
+
...style,
|
|
888
|
+
...inlineStyles,
|
|
889
|
+
width: "100%",
|
|
890
|
+
maxWidth: style?.width ?? style?.maxWidth
|
|
891
|
+
},
|
|
892
|
+
children
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
|
|
803
897
|
//#endregion
|
|
804
898
|
//#region src/extensions/div.tsx
|
|
805
899
|
const Div = EmailNode.create({
|
|
@@ -854,23 +948,24 @@ function isDocumentVisuallyEmpty(doc) {
|
|
|
854
948
|
const node = doc.child(index);
|
|
855
949
|
if (node.type.name === "globalContent") continue;
|
|
856
950
|
nonGlobalNodeCount += 1;
|
|
857
|
-
if (firstNonGlobalNode === null) firstNonGlobalNode =
|
|
858
|
-
type: node.type,
|
|
859
|
-
textContent: node.textContent,
|
|
860
|
-
childCount: node.content.childCount
|
|
861
|
-
};
|
|
951
|
+
if (firstNonGlobalNode === null) firstNonGlobalNode = node;
|
|
862
952
|
}
|
|
863
953
|
if (nonGlobalNodeCount === 0) return true;
|
|
864
954
|
if (nonGlobalNodeCount !== 1) return false;
|
|
865
|
-
|
|
955
|
+
if (firstNonGlobalNode.type.name === "container") return hasOnlyEmptyParagraph(firstNonGlobalNode);
|
|
956
|
+
return isEmptyParagraph(firstNonGlobalNode);
|
|
957
|
+
}
|
|
958
|
+
function hasOnlyEmptyParagraph(node) {
|
|
959
|
+
if (node.childCount === 0) return true;
|
|
960
|
+
if (node.childCount !== 1) return false;
|
|
961
|
+
return isEmptyParagraph(node.child(0));
|
|
962
|
+
}
|
|
963
|
+
function isEmptyParagraph(node) {
|
|
964
|
+
return node.type.name === "paragraph" && node.textContent.length === 0;
|
|
866
965
|
}
|
|
867
966
|
|
|
868
967
|
//#endregion
|
|
869
968
|
//#region src/core/use-editor.ts
|
|
870
|
-
const COLLABORATION_EXTENSION_NAMES = new Set(["liveblocksExtension", "collaboration"]);
|
|
871
|
-
function hasCollaborationExtension(exts) {
|
|
872
|
-
return exts.some((ext) => COLLABORATION_EXTENSION_NAMES.has(ext.name));
|
|
873
|
-
}
|
|
874
969
|
function useEditor$1({ content, extensions = [], onUpdate, onPaste, onUploadImage, onReady, editable = true, ...rest }) {
|
|
875
970
|
const [contentError, setContentError] = React.useState(null);
|
|
876
971
|
const isCollaborative = hasCollaborationExtension(extensions);
|
|
@@ -1652,6 +1747,78 @@ const Text$1 = EmailNode.from(Text, ({ children }) => {
|
|
|
1652
1747
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
1653
1748
|
});
|
|
1654
1749
|
|
|
1750
|
+
//#endregion
|
|
1751
|
+
//#region src/extensions/trailing-node.tsx
|
|
1752
|
+
const skipTrailingNodeMeta = "skipTrailingNode";
|
|
1753
|
+
function nodeEqualsType({ types, node }) {
|
|
1754
|
+
return node && Array.isArray(types) && types.includes(node.type) || node?.type === types;
|
|
1755
|
+
}
|
|
1756
|
+
/**
|
|
1757
|
+
* This extension allows you to add an extra node at the end of a node.
|
|
1758
|
+
*
|
|
1759
|
+
* Differently from TipTap's native one, it allows you to pick which node to append the trailing node to.
|
|
1760
|
+
* @see https://www.tiptap.dev/api/extensions/trailing-node
|
|
1761
|
+
*
|
|
1762
|
+
* We could contribute this to TipTap's core extensions and I think we should at some once we get some time.
|
|
1763
|
+
*/
|
|
1764
|
+
const TrailingNode = Extension.create({
|
|
1765
|
+
name: "trailingNode",
|
|
1766
|
+
addOptions() {
|
|
1767
|
+
return {
|
|
1768
|
+
node: void 0,
|
|
1769
|
+
appendTo: "doc",
|
|
1770
|
+
notAfter: []
|
|
1771
|
+
};
|
|
1772
|
+
},
|
|
1773
|
+
addProseMirrorPlugins() {
|
|
1774
|
+
const plugin = new PluginKey(this.name);
|
|
1775
|
+
const defaultNode = this.options.node || this.editor.schema.topNodeType.contentMatch.defaultType?.name || "paragraph";
|
|
1776
|
+
const notAfter = Array.isArray(this.options.notAfter) ? this.options.notAfter : [this.options.notAfter].filter(Boolean);
|
|
1777
|
+
const disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => notAfter.concat(defaultNode).includes(node.name));
|
|
1778
|
+
const appendToType = this.editor.schema.nodes[this.options.appendTo || "doc"];
|
|
1779
|
+
const getInsertPositions = (doc) => {
|
|
1780
|
+
const positions = [];
|
|
1781
|
+
if (doc.type === appendToType) {
|
|
1782
|
+
if (!nodeEqualsType({
|
|
1783
|
+
node: doc.lastChild,
|
|
1784
|
+
types: disabledNodes
|
|
1785
|
+
})) positions.push(doc.content.size);
|
|
1786
|
+
}
|
|
1787
|
+
doc.descendants((node, pos) => {
|
|
1788
|
+
if (node.type !== appendToType) return;
|
|
1789
|
+
if (!nodeEqualsType({
|
|
1790
|
+
node: node.lastChild,
|
|
1791
|
+
types: disabledNodes
|
|
1792
|
+
})) positions.push(pos + node.nodeSize - 1);
|
|
1793
|
+
});
|
|
1794
|
+
return positions;
|
|
1795
|
+
};
|
|
1796
|
+
return [new Plugin({
|
|
1797
|
+
key: plugin,
|
|
1798
|
+
appendTransaction: (transactions, __, state) => {
|
|
1799
|
+
const { doc, tr, schema } = state;
|
|
1800
|
+
const shouldInsert = plugin.getState(state);
|
|
1801
|
+
const type = schema.nodes[defaultNode];
|
|
1802
|
+
if (transactions.some((transaction) => transaction.getMeta(skipTrailingNodeMeta))) return;
|
|
1803
|
+
if (!shouldInsert) return;
|
|
1804
|
+
const positions = getInsertPositions(doc);
|
|
1805
|
+
for (const pos of positions.sort((a, b) => b - a)) tr.insert(pos, type.create());
|
|
1806
|
+
return positions.length > 0 ? tr : void 0;
|
|
1807
|
+
},
|
|
1808
|
+
state: {
|
|
1809
|
+
init: (_, state) => {
|
|
1810
|
+
return getInsertPositions(state.doc).length > 0;
|
|
1811
|
+
},
|
|
1812
|
+
apply: (tr, value) => {
|
|
1813
|
+
if (!tr.docChanged) return value;
|
|
1814
|
+
if (tr.getMeta("__uniqueIDTransaction")) return value;
|
|
1815
|
+
return getInsertPositions(tr.doc).length > 0;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
})];
|
|
1819
|
+
}
|
|
1820
|
+
});
|
|
1821
|
+
|
|
1655
1822
|
//#endregion
|
|
1656
1823
|
//#region src/extensions/underline.tsx
|
|
1657
1824
|
const Underline = EmailMark.from(UnderlineBase, ({ children, style }) => /* @__PURE__ */ jsx("u", {
|
|
@@ -1714,6 +1881,7 @@ const starterKitExtensions = {
|
|
|
1714
1881
|
TwoColumns,
|
|
1715
1882
|
ThreeColumns,
|
|
1716
1883
|
FourColumns,
|
|
1884
|
+
Container: Container$1,
|
|
1717
1885
|
ColumnsColumn,
|
|
1718
1886
|
Paragraph,
|
|
1719
1887
|
BulletList,
|
|
@@ -1724,6 +1892,7 @@ const starterKitExtensions = {
|
|
|
1724
1892
|
Italic,
|
|
1725
1893
|
Placeholder,
|
|
1726
1894
|
PreviewText,
|
|
1895
|
+
TrailingNode,
|
|
1727
1896
|
Bold,
|
|
1728
1897
|
Strike,
|
|
1729
1898
|
Heading: Heading$2,
|
|
@@ -1757,6 +1926,10 @@ const StarterKit = Extension.create({
|
|
|
1757
1926
|
defaultLanguage: "javascript",
|
|
1758
1927
|
HTMLAttributes: { class: "prism node-codeBlock" }
|
|
1759
1928
|
},
|
|
1929
|
+
TrailingNode: {
|
|
1930
|
+
node: "paragraph",
|
|
1931
|
+
appendTo: "container"
|
|
1932
|
+
},
|
|
1760
1933
|
Code: { HTMLAttributes: {
|
|
1761
1934
|
class: "node-inlineCode",
|
|
1762
1935
|
spellcheck: "false"
|
|
@@ -1791,6 +1964,7 @@ const StarterKit = Extension.create({
|
|
|
1791
1964
|
TableCell: {},
|
|
1792
1965
|
TableHeader: {},
|
|
1793
1966
|
Body: {},
|
|
1967
|
+
Container: {},
|
|
1794
1968
|
Div: {},
|
|
1795
1969
|
Button: {},
|
|
1796
1970
|
Section: {},
|
|
@@ -1910,5 +2084,5 @@ const StarterKit = Extension.create({
|
|
|
1910
2084
|
});
|
|
1911
2085
|
|
|
1912
2086
|
//#endregion
|
|
1913
|
-
export {
|
|
1914
|
-
//# sourceMappingURL=extensions-
|
|
2087
|
+
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
|