@react-email/editor 0.0.0-experimental.25 → 0.0.0-experimental.27
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/{columns-ZSaLdkg9.cjs → columns-BXN-NNd4.cjs} +3 -183
- package/dist/{columns-CUxUEHje.mjs → columns-Cos2lqfu.mjs} +3 -171
- package/dist/columns-Cos2lqfu.mjs.map +1 -0
- package/dist/core/index.cjs +2 -2
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +2 -2
- package/dist/{core-Rxnpk8B_.cjs → core-B1NP2Drs.cjs} +59 -142
- package/dist/{core-C5_RDJBI.mjs → core-Dr1J3aZd.mjs} +39 -110
- package/dist/core-Dr1J3aZd.mjs.map +1 -0
- package/dist/extensions/index.cjs +5 -4
- package/dist/extensions/index.d.cts +5 -4
- package/dist/extensions/index.d.cts.map +1 -1
- package/dist/extensions/index.d.mts +5 -4
- package/dist/extensions/index.d.mts.map +1 -1
- package/dist/extensions/index.mjs +3 -2
- package/dist/global-content-BRvA4PRG.cjs +89 -0
- package/dist/global-content-kdUzYcsA.mjs +78 -0
- package/dist/global-content-kdUzYcsA.mjs.map +1 -0
- package/dist/{index-CfslA7KT.d.cts → index-jGyVEd5q.d.cts} +6 -5
- package/dist/index-jGyVEd5q.d.cts.map +1 -0
- package/dist/{index-hbHRR7oB.d.mts → index-ozCcANmD.d.mts} +6 -5
- package/dist/index-ozCcANmD.d.mts.map +1 -0
- package/dist/plugins/index.cjs +747 -0
- package/dist/plugins/index.d.cts +79 -0
- package/dist/plugins/index.d.cts.map +1 -0
- package/dist/plugins/index.d.mts +79 -0
- package/dist/plugins/index.d.mts.map +1 -0
- package/dist/plugins/index.mjs +742 -0
- package/dist/plugins/index.mjs.map +1 -0
- package/dist/{set-text-alignment-DZvgnbvz.mjs → set-text-alignment-BO24ieeE.mjs} +1 -1
- package/dist/{set-text-alignment-DZvgnbvz.mjs.map → set-text-alignment-BO24ieeE.mjs.map} +1 -1
- package/dist/styles-C-cCyJCn.cjs +211 -0
- package/dist/styles-DLviD0JK.mjs +194 -0
- package/dist/styles-DLviD0JK.mjs.map +1 -0
- package/dist/ui/index.cjs +2 -2
- package/dist/ui/index.d.cts +42 -42
- package/dist/ui/index.d.cts.map +1 -1
- package/dist/ui/index.d.mts +42 -42
- package/dist/ui/index.d.mts.map +1 -1
- package/dist/ui/index.mjs +2 -2
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +13 -3
- package/dist/columns-CUxUEHje.mjs.map +0 -1
- package/dist/core-C5_RDJBI.mjs.map +0 -1
- package/dist/index-CfslA7KT.d.cts.map +0 -1
- package/dist/index-hbHRR7oB.d.mts.map +0 -1
- /package/dist/{set-text-alignment-Bx3bPteH.cjs → set-text-alignment-CbECklB4.cjs} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
const require_columns = require('./columns-
|
|
1
|
+
const require_columns = require('./columns-BXN-NNd4.cjs');
|
|
2
|
+
const require_styles = require('./styles-C-cCyJCn.cjs');
|
|
3
|
+
const require_global_content = require('./global-content-BRvA4PRG.cjs');
|
|
2
4
|
let _react_email_components = require("@react-email/components");
|
|
3
5
|
_react_email_components = require_columns.__toESM(_react_email_components);
|
|
4
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -138,45 +140,46 @@ const composeReactEmail = async ({ editor, preview }) => {
|
|
|
138
140
|
const data = editor.getJSON();
|
|
139
141
|
const extensions = editor.extensionManager.extensions;
|
|
140
142
|
const serializerPlugin = extensions.map((ext) => ext.options?.serializerPlugin).filter((p) => Boolean(p)).at(-1);
|
|
141
|
-
const
|
|
142
|
-
const emailMarkComponentRegistry = Object.fromEntries(extensions.filter((ext) => ext instanceof EmailMark).map((extension) => [extension.name, extension.config.renderToReactEmail]));
|
|
143
|
-
function renderMark(mark, node, children, depth) {
|
|
144
|
-
const markStyle = serializerPlugin?.getNodeStyles({
|
|
145
|
-
type: mark.type,
|
|
146
|
-
attrs: mark.attrs ?? {}
|
|
147
|
-
}, depth, editor) ?? {};
|
|
148
|
-
const markRenderer = emailMarkComponentRegistry[mark.type];
|
|
149
|
-
if (markRenderer) return markRenderer({
|
|
150
|
-
mark,
|
|
151
|
-
node,
|
|
152
|
-
style: markStyle,
|
|
153
|
-
children
|
|
154
|
-
});
|
|
155
|
-
return children;
|
|
156
|
-
}
|
|
143
|
+
const typeToExtensionMap = Object.fromEntries(extensions.map((extension) => [extension.name, extension]));
|
|
157
144
|
function parseContent(content, depth = 0) {
|
|
158
145
|
if (!content) return;
|
|
159
146
|
return content.map((node, index) => {
|
|
160
147
|
const style = serializerPlugin?.getNodeStyles(node, depth, editor) ?? {};
|
|
161
|
-
const inlineStyles =
|
|
162
|
-
if (node.type
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
148
|
+
const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
|
|
149
|
+
if (!node.type) return null;
|
|
150
|
+
const emailNode = typeToExtensionMap[node.type];
|
|
151
|
+
if (!emailNode || !(emailNode instanceof require_columns.EmailNode)) return null;
|
|
152
|
+
const NodeComponent = emailNode.config.renderToReactEmail;
|
|
153
|
+
const childDepth = NODES_WITH_INCREMENTED_CHILD_DEPTH.has(node.type) ? depth + 1 : depth;
|
|
154
|
+
let children = node.text ? node.text : parseContent(node.content, childDepth);
|
|
155
|
+
if (node.marks) for (const mark of node.marks) {
|
|
156
|
+
const emailMark = typeToExtensionMap[mark.type];
|
|
157
|
+
if (emailMark instanceof EmailMark) {
|
|
158
|
+
const MarkComponent = emailMark.config.renderToReactEmail;
|
|
159
|
+
children = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkComponent, {
|
|
160
|
+
mark,
|
|
161
|
+
node,
|
|
162
|
+
style: serializerPlugin?.getNodeStyles({
|
|
163
|
+
type: mark.type,
|
|
164
|
+
attrs: mark.attrs ?? {}
|
|
165
|
+
}, depth, editor) ?? {},
|
|
166
|
+
extension: emailMark,
|
|
167
|
+
children
|
|
168
|
+
});
|
|
169
|
+
}
|
|
178
170
|
}
|
|
179
|
-
return
|
|
171
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeComponent, {
|
|
172
|
+
node: node.type === "table" && inlineStyles.width && !node.attrs?.width ? {
|
|
173
|
+
...node,
|
|
174
|
+
attrs: {
|
|
175
|
+
...node.attrs,
|
|
176
|
+
width: inlineStyles.width
|
|
177
|
+
}
|
|
178
|
+
} : node,
|
|
179
|
+
style,
|
|
180
|
+
extension: emailNode,
|
|
181
|
+
children
|
|
182
|
+
}, index);
|
|
180
183
|
});
|
|
181
184
|
}
|
|
182
185
|
const unformattedHtml = await (0, _react_email_components.render)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(serializerPlugin?.BaseTemplate ?? DefaultBaseTemplate, {
|
|
@@ -263,7 +266,7 @@ const Blockquote = require_columns.EmailNode.from(_tiptap_extension_blockquote.d
|
|
|
263
266
|
className: node.attrs?.class || void 0,
|
|
264
267
|
style: {
|
|
265
268
|
...style,
|
|
266
|
-
...
|
|
269
|
+
...require_styles.inlineCssToJs(node.attrs?.style),
|
|
267
270
|
...getTextAlignment(node.attrs?.align || node.attrs?.alignment)
|
|
268
271
|
},
|
|
269
272
|
children
|
|
@@ -302,7 +305,7 @@ const Body = require_columns.EmailNode.create({
|
|
|
302
305
|
];
|
|
303
306
|
},
|
|
304
307
|
renderToReactEmail({ children, node, style }) {
|
|
305
|
-
const inlineStyles =
|
|
308
|
+
const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
|
|
306
309
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
307
310
|
className: node.attrs?.class || void 0,
|
|
308
311
|
style: {
|
|
@@ -340,7 +343,7 @@ const BulletList = require_columns.EmailNode.from(_tiptap_extension_bullet_list.
|
|
|
340
343
|
className: node.attrs?.class || void 0,
|
|
341
344
|
style: {
|
|
342
345
|
...style,
|
|
343
|
-
...
|
|
346
|
+
...require_styles.inlineCssToJs(node.attrs?.style)
|
|
344
347
|
},
|
|
345
348
|
children
|
|
346
349
|
}));
|
|
@@ -408,7 +411,7 @@ const Button = require_columns.EmailNode.create({
|
|
|
408
411
|
};
|
|
409
412
|
},
|
|
410
413
|
renderToReactEmail({ children, node, style }) {
|
|
411
|
-
const inlineStyles =
|
|
414
|
+
const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
|
|
412
415
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Row, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Column, {
|
|
413
416
|
align: node.attrs?.align || node.attrs?.alignment,
|
|
414
417
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Button, {
|
|
@@ -471,7 +474,7 @@ const ClassAttribute = _tiptap_core.Extension.create({
|
|
|
471
474
|
const Code = EmailMark.from(_tiptap_extension_code.default, ({ children, node, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
472
475
|
style: {
|
|
473
476
|
...style,
|
|
474
|
-
...
|
|
477
|
+
...require_styles.inlineCssToJs(node.attrs?.style)
|
|
475
478
|
},
|
|
476
479
|
children
|
|
477
480
|
}));
|
|
@@ -742,7 +745,7 @@ const Div = require_columns.EmailNode.create({
|
|
|
742
745
|
return { ...require_columns.createStandardAttributes([...require_columns.COMMON_HTML_ATTRIBUTES, ...require_columns.LAYOUT_ATTRIBUTES]) };
|
|
743
746
|
},
|
|
744
747
|
renderToReactEmail({ children, node, style }) {
|
|
745
|
-
const inlineStyles =
|
|
748
|
+
const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
|
|
746
749
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
747
750
|
className: node.attrs?.class || void 0,
|
|
748
751
|
style: {
|
|
@@ -779,7 +782,7 @@ const Divider = require_columns.EmailNode.from(_tiptap_extension_horizontal_rule
|
|
|
779
782
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Hr, {
|
|
780
783
|
...rest,
|
|
781
784
|
className: "node-hr",
|
|
782
|
-
style:
|
|
785
|
+
style: require_styles.inlineCssToJs(node.attrs.style)
|
|
783
786
|
}) });
|
|
784
787
|
});
|
|
785
788
|
}
|
|
@@ -788,85 +791,11 @@ const Divider = require_columns.EmailNode.from(_tiptap_extension_horizontal_rule
|
|
|
788
791
|
className: node.attrs?.class || void 0,
|
|
789
792
|
style: {
|
|
790
793
|
...style,
|
|
791
|
-
...
|
|
794
|
+
...require_styles.inlineCssToJs(node.attrs?.style)
|
|
792
795
|
}
|
|
793
796
|
});
|
|
794
797
|
});
|
|
795
798
|
|
|
796
|
-
//#endregion
|
|
797
|
-
//#region src/extensions/global-content.ts
|
|
798
|
-
const GLOBAL_CONTENT_NODE_TYPE = "globalContent";
|
|
799
|
-
let cachedGlobalPosition = null;
|
|
800
|
-
function findGlobalContentPositions(doc) {
|
|
801
|
-
const positions = [];
|
|
802
|
-
doc.descendants((node, position) => {
|
|
803
|
-
if (node.type.name === GLOBAL_CONTENT_NODE_TYPE) positions.push(position);
|
|
804
|
-
});
|
|
805
|
-
return positions;
|
|
806
|
-
}
|
|
807
|
-
function getCachedGlobalContentPosition(doc) {
|
|
808
|
-
if (cachedGlobalPosition != null) try {
|
|
809
|
-
if (doc.nodeAt(cachedGlobalPosition)?.type.name === GLOBAL_CONTENT_NODE_TYPE) return cachedGlobalPosition;
|
|
810
|
-
} catch {
|
|
811
|
-
cachedGlobalPosition = null;
|
|
812
|
-
}
|
|
813
|
-
cachedGlobalPosition = findGlobalContentPositions(doc)[0] ?? null;
|
|
814
|
-
return cachedGlobalPosition;
|
|
815
|
-
}
|
|
816
|
-
function getGlobalContent(key, editor) {
|
|
817
|
-
const position = getCachedGlobalContentPosition(editor.state.doc);
|
|
818
|
-
if (cachedGlobalPosition == null) return null;
|
|
819
|
-
return editor.state.doc.nodeAt(position)?.attrs.data[key] ?? null;
|
|
820
|
-
}
|
|
821
|
-
const GlobalContent = _tiptap_core.Node.create({
|
|
822
|
-
name: GLOBAL_CONTENT_NODE_TYPE,
|
|
823
|
-
addOptions() {
|
|
824
|
-
return {
|
|
825
|
-
key: GLOBAL_CONTENT_NODE_TYPE,
|
|
826
|
-
data: {}
|
|
827
|
-
};
|
|
828
|
-
},
|
|
829
|
-
group: "block",
|
|
830
|
-
selectable: false,
|
|
831
|
-
draggable: false,
|
|
832
|
-
atom: true,
|
|
833
|
-
addAttributes() {
|
|
834
|
-
return { data: { default: this.options.data } };
|
|
835
|
-
},
|
|
836
|
-
parseHTML() {
|
|
837
|
-
return [{ tag: `div[data-type="${this.name}"]` }];
|
|
838
|
-
},
|
|
839
|
-
renderHTML({ HTMLAttributes }) {
|
|
840
|
-
return ["div", (0, _tiptap_core.mergeAttributes)(HTMLAttributes, {
|
|
841
|
-
"data-type": this.name,
|
|
842
|
-
style: "width: 100%; height: 1px; visibility: hidden;"
|
|
843
|
-
})];
|
|
844
|
-
},
|
|
845
|
-
addCommands() {
|
|
846
|
-
return { setGlobalContent: (key, value) => ({ tr, dispatch }) => {
|
|
847
|
-
const ensureGlobalPosition = () => {
|
|
848
|
-
const positions = findGlobalContentPositions(tr.doc);
|
|
849
|
-
for (let i = positions.length - 1; i > 0; i--) tr.delete(positions[i], positions[i] + 1);
|
|
850
|
-
const pos = positions[0] ?? -1;
|
|
851
|
-
if (pos >= 0) cachedGlobalPosition = pos;
|
|
852
|
-
else {
|
|
853
|
-
cachedGlobalPosition = 0;
|
|
854
|
-
tr.insert(0, this.type.create());
|
|
855
|
-
}
|
|
856
|
-
};
|
|
857
|
-
if (dispatch) {
|
|
858
|
-
ensureGlobalPosition();
|
|
859
|
-
if (cachedGlobalPosition == null) return false;
|
|
860
|
-
tr.setNodeAttribute(cachedGlobalPosition, "data", {
|
|
861
|
-
...tr.doc.nodeAt(cachedGlobalPosition)?.attrs.data,
|
|
862
|
-
[key]: value
|
|
863
|
-
});
|
|
864
|
-
}
|
|
865
|
-
return true;
|
|
866
|
-
} };
|
|
867
|
-
}
|
|
868
|
-
});
|
|
869
|
-
|
|
870
799
|
//#endregion
|
|
871
800
|
//#region src/extensions/hard-break.tsx
|
|
872
801
|
const HardBreak = require_columns.EmailNode.from(_tiptap_extension_hard_break.default, () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("br", {}));
|
|
@@ -880,7 +809,7 @@ const Heading = require_columns.EmailNode.from(_tiptap_extension_heading.Heading
|
|
|
880
809
|
const attrs = {
|
|
881
810
|
...rest,
|
|
882
811
|
className: `node-h${level} ${className}`,
|
|
883
|
-
style:
|
|
812
|
+
style: require_styles.inlineCssToJs(node.attrs.style)
|
|
884
813
|
};
|
|
885
814
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Heading, {
|
|
886
815
|
as: `h${level}`,
|
|
@@ -894,7 +823,7 @@ const Heading = require_columns.EmailNode.from(_tiptap_extension_heading.Heading
|
|
|
894
823
|
className: node.attrs?.class || void 0,
|
|
895
824
|
style: {
|
|
896
825
|
...style,
|
|
897
|
-
...
|
|
826
|
+
...require_styles.inlineCssToJs(node.attrs?.style),
|
|
898
827
|
...getTextAlignment(node.attrs?.align ?? node.attrs?.alignment)
|
|
899
828
|
},
|
|
900
829
|
children
|
|
@@ -942,7 +871,7 @@ const PreservedStyle = EmailMark.create({
|
|
|
942
871
|
},
|
|
943
872
|
renderToReactEmail({ children, mark }) {
|
|
944
873
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
945
|
-
style: mark.attrs?.style ?
|
|
874
|
+
style: mark.attrs?.style ? require_styles.inlineCssToJs(mark.attrs.style) : void 0,
|
|
946
875
|
children
|
|
947
876
|
});
|
|
948
877
|
}
|
|
@@ -991,7 +920,7 @@ function processStylesForUnlink(styleString) {
|
|
|
991
920
|
//#endregion
|
|
992
921
|
//#region src/extensions/link.tsx
|
|
993
922
|
const Link = EmailMark.from(_tiptap_extension_link.default, ({ children, mark, style }) => {
|
|
994
|
-
const linkMarkStyle = mark.attrs?.style ?
|
|
923
|
+
const linkMarkStyle = mark.attrs?.style ? require_styles.inlineCssToJs(mark.attrs.style) : {};
|
|
995
924
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Link, {
|
|
996
925
|
href: mark.attrs?.href ?? void 0,
|
|
997
926
|
rel: mark.attrs?.rel ?? void 0,
|
|
@@ -1068,7 +997,7 @@ const ListItem = require_columns.EmailNode.from(_tiptap_extension_list_item.defa
|
|
|
1068
997
|
className: node.attrs?.class || void 0,
|
|
1069
998
|
style: {
|
|
1070
999
|
...style,
|
|
1071
|
-
...
|
|
1000
|
+
...require_styles.inlineCssToJs(node.attrs?.style),
|
|
1072
1001
|
...getTextAlignment(node.attrs?.align || node.attrs?.alignment)
|
|
1073
1002
|
},
|
|
1074
1003
|
children
|
|
@@ -1156,7 +1085,7 @@ const OrderedList = require_columns.EmailNode.from(_tiptap_extension_ordered_lis
|
|
|
1156
1085
|
start: node.attrs?.start,
|
|
1157
1086
|
style: {
|
|
1158
1087
|
...style,
|
|
1159
|
-
...
|
|
1088
|
+
...require_styles.inlineCssToJs(node.attrs?.style)
|
|
1160
1089
|
},
|
|
1161
1090
|
children
|
|
1162
1091
|
}));
|
|
@@ -1169,7 +1098,7 @@ const Paragraph = require_columns.EmailNode.from(_tiptap_extension_paragraph.def
|
|
|
1169
1098
|
className: node.attrs?.class || void 0,
|
|
1170
1099
|
style: {
|
|
1171
1100
|
...style,
|
|
1172
|
-
...
|
|
1101
|
+
...require_styles.inlineCssToJs(node.attrs?.style),
|
|
1173
1102
|
...getTextAlignment(node.attrs?.align || node.attrs?.alignment)
|
|
1174
1103
|
},
|
|
1175
1104
|
children: isEmpty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("br", {}) : children
|
|
@@ -1260,7 +1189,7 @@ const Section$1 = require_columns.EmailNode.create({
|
|
|
1260
1189
|
} };
|
|
1261
1190
|
},
|
|
1262
1191
|
renderToReactEmail({ children, node, style }) {
|
|
1263
|
-
const inlineStyles =
|
|
1192
|
+
const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
|
|
1264
1193
|
const textAlign = node.attrs?.align || node.attrs?.alignment;
|
|
1265
1194
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Section, {
|
|
1266
1195
|
className: node.attrs?.class || void 0,
|
|
@@ -1395,7 +1324,7 @@ const Table = require_columns.EmailNode.create({
|
|
|
1395
1324
|
];
|
|
1396
1325
|
},
|
|
1397
1326
|
renderToReactEmail({ children, node, style }) {
|
|
1398
|
-
const inlineStyles =
|
|
1327
|
+
const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
|
|
1399
1328
|
const alignment = node.attrs?.align || node.attrs?.alignment;
|
|
1400
1329
|
const width = node.attrs?.width;
|
|
1401
1330
|
const centeringStyles = alignment === "center" ? {
|
|
@@ -1405,7 +1334,7 @@ const Table = require_columns.EmailNode.create({
|
|
|
1405
1334
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Section, {
|
|
1406
1335
|
className: node.attrs?.class || void 0,
|
|
1407
1336
|
align: alignment,
|
|
1408
|
-
style:
|
|
1337
|
+
style: require_styles.resolveConflictingStyles(style, {
|
|
1409
1338
|
...inlineStyles,
|
|
1410
1339
|
...centeringStyles
|
|
1411
1340
|
}),
|
|
@@ -1447,7 +1376,7 @@ const TableRow = require_columns.EmailNode.create({
|
|
|
1447
1376
|
];
|
|
1448
1377
|
},
|
|
1449
1378
|
renderToReactEmail({ children, node, style }) {
|
|
1450
|
-
const inlineStyles =
|
|
1379
|
+
const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
|
|
1451
1380
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
1452
1381
|
className: node.attrs?.class || void 0,
|
|
1453
1382
|
style: {
|
|
@@ -1492,7 +1421,7 @@ const TableCell = require_columns.EmailNode.create({
|
|
|
1492
1421
|
];
|
|
1493
1422
|
},
|
|
1494
1423
|
renderToReactEmail({ children, node, style }) {
|
|
1495
|
-
const inlineStyles =
|
|
1424
|
+
const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
|
|
1496
1425
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Column, {
|
|
1497
1426
|
className: node.attrs?.class || void 0,
|
|
1498
1427
|
align: node.attrs?.align || node.attrs?.alignment,
|
|
@@ -1635,7 +1564,7 @@ const starterKitExtensions = {
|
|
|
1635
1564
|
Div,
|
|
1636
1565
|
Button,
|
|
1637
1566
|
Section: Section$1,
|
|
1638
|
-
GlobalContent,
|
|
1567
|
+
GlobalContent: require_global_content.GlobalContent,
|
|
1639
1568
|
Text,
|
|
1640
1569
|
AlignmentAttribute,
|
|
1641
1570
|
StyleAttribute,
|
|
@@ -2063,12 +1992,6 @@ Object.defineProperty(exports, 'Divider', {
|
|
|
2063
1992
|
return Divider;
|
|
2064
1993
|
}
|
|
2065
1994
|
});
|
|
2066
|
-
Object.defineProperty(exports, 'GlobalContent', {
|
|
2067
|
-
enumerable: true,
|
|
2068
|
-
get: function () {
|
|
2069
|
-
return GlobalContent;
|
|
2070
|
-
}
|
|
2071
|
-
});
|
|
2072
1995
|
Object.defineProperty(exports, 'HardBreak', {
|
|
2073
1996
|
enumerable: true,
|
|
2074
1997
|
get: function () {
|
|
@@ -2213,12 +2136,6 @@ Object.defineProperty(exports, 'composeReactEmail', {
|
|
|
2213
2136
|
return composeReactEmail;
|
|
2214
2137
|
}
|
|
2215
2138
|
});
|
|
2216
|
-
Object.defineProperty(exports, 'getGlobalContent', {
|
|
2217
|
-
enumerable: true,
|
|
2218
|
-
get: function () {
|
|
2219
|
-
return getGlobalContent;
|
|
2220
|
-
}
|
|
2221
|
-
});
|
|
2222
2139
|
Object.defineProperty(exports, 'isDocumentVisuallyEmpty', {
|
|
2223
2140
|
enumerable: true,
|
|
2224
2141
|
get: function () {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as ThreeColumns, c as COMMON_HTML_ATTRIBUTES, d as TABLE_CELL_ATTRIBUTES, f as TABLE_HEADER_ATTRIBUTES, h as editorEventBus, l as LAYOUT_ATTRIBUTES, m as EmailNode, n as ColumnsColumn, o as TwoColumns, p as createStandardAttributes, r as FourColumns, u as TABLE_ATTRIBUTES } from "./columns-Cos2lqfu.mjs";
|
|
2
|
+
import { n as inlineCssToJs, r as resolveConflictingStyles } from "./styles-DLviD0JK.mjs";
|
|
3
|
+
import { t as GlobalContent } from "./global-content-kdUzYcsA.mjs";
|
|
2
4
|
import * as ReactEmailComponents from "@react-email/components";
|
|
3
5
|
import { Body, Button, CodeBlock, Column, Head, Heading, Hr, Html, Link, Preview, Row, Section, pretty, render, toPlainText } from "@react-email/components";
|
|
4
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -119,45 +121,46 @@ const composeReactEmail = async ({ editor, preview }) => {
|
|
|
119
121
|
const data = editor.getJSON();
|
|
120
122
|
const extensions = editor.extensionManager.extensions;
|
|
121
123
|
const serializerPlugin = extensions.map((ext) => ext.options?.serializerPlugin).filter((p) => Boolean(p)).at(-1);
|
|
122
|
-
const
|
|
123
|
-
const emailMarkComponentRegistry = Object.fromEntries(extensions.filter((ext) => ext instanceof EmailMark).map((extension) => [extension.name, extension.config.renderToReactEmail]));
|
|
124
|
-
function renderMark(mark, node, children, depth) {
|
|
125
|
-
const markStyle = serializerPlugin?.getNodeStyles({
|
|
126
|
-
type: mark.type,
|
|
127
|
-
attrs: mark.attrs ?? {}
|
|
128
|
-
}, depth, editor) ?? {};
|
|
129
|
-
const markRenderer = emailMarkComponentRegistry[mark.type];
|
|
130
|
-
if (markRenderer) return markRenderer({
|
|
131
|
-
mark,
|
|
132
|
-
node,
|
|
133
|
-
style: markStyle,
|
|
134
|
-
children
|
|
135
|
-
});
|
|
136
|
-
return children;
|
|
137
|
-
}
|
|
124
|
+
const typeToExtensionMap = Object.fromEntries(extensions.map((extension) => [extension.name, extension]));
|
|
138
125
|
function parseContent(content, depth = 0) {
|
|
139
126
|
if (!content) return;
|
|
140
127
|
return content.map((node, index) => {
|
|
141
128
|
const style = serializerPlugin?.getNodeStyles(node, depth, editor) ?? {};
|
|
142
129
|
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
143
|
-
if (node.type
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
130
|
+
if (!node.type) return null;
|
|
131
|
+
const emailNode = typeToExtensionMap[node.type];
|
|
132
|
+
if (!emailNode || !(emailNode instanceof EmailNode)) return null;
|
|
133
|
+
const NodeComponent = emailNode.config.renderToReactEmail;
|
|
134
|
+
const childDepth = NODES_WITH_INCREMENTED_CHILD_DEPTH.has(node.type) ? depth + 1 : depth;
|
|
135
|
+
let children = node.text ? node.text : parseContent(node.content, childDepth);
|
|
136
|
+
if (node.marks) for (const mark of node.marks) {
|
|
137
|
+
const emailMark = typeToExtensionMap[mark.type];
|
|
138
|
+
if (emailMark instanceof EmailMark) {
|
|
139
|
+
const MarkComponent = emailMark.config.renderToReactEmail;
|
|
140
|
+
children = /* @__PURE__ */ jsx(MarkComponent, {
|
|
141
|
+
mark,
|
|
142
|
+
node,
|
|
143
|
+
style: serializerPlugin?.getNodeStyles({
|
|
144
|
+
type: mark.type,
|
|
145
|
+
attrs: mark.attrs ?? {}
|
|
146
|
+
}, depth, editor) ?? {},
|
|
147
|
+
extension: emailMark,
|
|
148
|
+
children
|
|
149
|
+
});
|
|
150
|
+
}
|
|
159
151
|
}
|
|
160
|
-
return
|
|
152
|
+
return /* @__PURE__ */ jsx(NodeComponent, {
|
|
153
|
+
node: node.type === "table" && inlineStyles.width && !node.attrs?.width ? {
|
|
154
|
+
...node,
|
|
155
|
+
attrs: {
|
|
156
|
+
...node.attrs,
|
|
157
|
+
width: inlineStyles.width
|
|
158
|
+
}
|
|
159
|
+
} : node,
|
|
160
|
+
style,
|
|
161
|
+
extension: emailNode,
|
|
162
|
+
children
|
|
163
|
+
}, index);
|
|
161
164
|
});
|
|
162
165
|
}
|
|
163
166
|
const unformattedHtml = await render(/* @__PURE__ */ jsx(serializerPlugin?.BaseTemplate ?? DefaultBaseTemplate, {
|
|
@@ -774,80 +777,6 @@ const Divider = EmailNode.from(HorizontalRule.extend({
|
|
|
774
777
|
});
|
|
775
778
|
});
|
|
776
779
|
|
|
777
|
-
//#endregion
|
|
778
|
-
//#region src/extensions/global-content.ts
|
|
779
|
-
const GLOBAL_CONTENT_NODE_TYPE = "globalContent";
|
|
780
|
-
let cachedGlobalPosition = null;
|
|
781
|
-
function findGlobalContentPositions(doc) {
|
|
782
|
-
const positions = [];
|
|
783
|
-
doc.descendants((node, position) => {
|
|
784
|
-
if (node.type.name === GLOBAL_CONTENT_NODE_TYPE) positions.push(position);
|
|
785
|
-
});
|
|
786
|
-
return positions;
|
|
787
|
-
}
|
|
788
|
-
function getCachedGlobalContentPosition(doc) {
|
|
789
|
-
if (cachedGlobalPosition != null) try {
|
|
790
|
-
if (doc.nodeAt(cachedGlobalPosition)?.type.name === GLOBAL_CONTENT_NODE_TYPE) return cachedGlobalPosition;
|
|
791
|
-
} catch {
|
|
792
|
-
cachedGlobalPosition = null;
|
|
793
|
-
}
|
|
794
|
-
cachedGlobalPosition = findGlobalContentPositions(doc)[0] ?? null;
|
|
795
|
-
return cachedGlobalPosition;
|
|
796
|
-
}
|
|
797
|
-
function getGlobalContent(key, editor) {
|
|
798
|
-
const position = getCachedGlobalContentPosition(editor.state.doc);
|
|
799
|
-
if (cachedGlobalPosition == null) return null;
|
|
800
|
-
return editor.state.doc.nodeAt(position)?.attrs.data[key] ?? null;
|
|
801
|
-
}
|
|
802
|
-
const GlobalContent = Node$1.create({
|
|
803
|
-
name: GLOBAL_CONTENT_NODE_TYPE,
|
|
804
|
-
addOptions() {
|
|
805
|
-
return {
|
|
806
|
-
key: GLOBAL_CONTENT_NODE_TYPE,
|
|
807
|
-
data: {}
|
|
808
|
-
};
|
|
809
|
-
},
|
|
810
|
-
group: "block",
|
|
811
|
-
selectable: false,
|
|
812
|
-
draggable: false,
|
|
813
|
-
atom: true,
|
|
814
|
-
addAttributes() {
|
|
815
|
-
return { data: { default: this.options.data } };
|
|
816
|
-
},
|
|
817
|
-
parseHTML() {
|
|
818
|
-
return [{ tag: `div[data-type="${this.name}"]` }];
|
|
819
|
-
},
|
|
820
|
-
renderHTML({ HTMLAttributes }) {
|
|
821
|
-
return ["div", mergeAttributes(HTMLAttributes, {
|
|
822
|
-
"data-type": this.name,
|
|
823
|
-
style: "width: 100%; height: 1px; visibility: hidden;"
|
|
824
|
-
})];
|
|
825
|
-
},
|
|
826
|
-
addCommands() {
|
|
827
|
-
return { setGlobalContent: (key, value) => ({ tr, dispatch }) => {
|
|
828
|
-
const ensureGlobalPosition = () => {
|
|
829
|
-
const positions = findGlobalContentPositions(tr.doc);
|
|
830
|
-
for (let i = positions.length - 1; i > 0; i--) tr.delete(positions[i], positions[i] + 1);
|
|
831
|
-
const pos = positions[0] ?? -1;
|
|
832
|
-
if (pos >= 0) cachedGlobalPosition = pos;
|
|
833
|
-
else {
|
|
834
|
-
cachedGlobalPosition = 0;
|
|
835
|
-
tr.insert(0, this.type.create());
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
if (dispatch) {
|
|
839
|
-
ensureGlobalPosition();
|
|
840
|
-
if (cachedGlobalPosition == null) return false;
|
|
841
|
-
tr.setNodeAttribute(cachedGlobalPosition, "data", {
|
|
842
|
-
...tr.doc.nodeAt(cachedGlobalPosition)?.attrs.data,
|
|
843
|
-
[key]: value
|
|
844
|
-
});
|
|
845
|
-
}
|
|
846
|
-
return true;
|
|
847
|
-
} };
|
|
848
|
-
}
|
|
849
|
-
});
|
|
850
|
-
|
|
851
780
|
//#endregion
|
|
852
781
|
//#region src/extensions/hard-break.tsx
|
|
853
782
|
const HardBreak = EmailNode.from(HardBreakBase, () => /* @__PURE__ */ jsx("br", {}));
|
|
@@ -1978,5 +1907,5 @@ function useEditor$1({ content, extensions = [], onUpdate, onPaste, onUploadImag
|
|
|
1978
1907
|
}
|
|
1979
1908
|
|
|
1980
1909
|
//#endregion
|
|
1981
|
-
export {
|
|
1982
|
-
//# sourceMappingURL=core-
|
|
1910
|
+
export { ClassAttribute as A, Italic as C, Div as D, Divider as E, Blockquote as F, AlignmentAttribute as I, composeReactEmail as L, BulletList as M, Bold as N, CodeBlockPrism as O, Body$1 as P, isDocumentVisuallyEmpty as R, processStylesForUnlink as S, HardBreak as T, OrderedList as _, Text$1 as a, Link$1 as b, TableHeader as c, StyleAttribute as d, Strike as f, Paragraph as g, Placeholder as h, Underline as i, Button$1 as j, Code as k, TableRow as l, PreviewText as m, StarterKit as n, Table as o, Section$1 as p, Uppercase as r, TableCell as s, useEditor$1 as t, Sup as u, MaxNesting as v, Heading$2 as w, PreservedStyle as x, ListItem as y };
|
|
1911
|
+
//# sourceMappingURL=core-Dr1J3aZd.mjs.map
|