@react-email/editor 0.0.0-experimental.45 → 0.0.0-experimental.47
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/{event-bus-BFzKTuhV.mjs → columns-DC8gJU2D.mjs} +5 -88
- package/dist/columns-DC8gJU2D.mjs.map +1 -0
- package/dist/{event-bus-D-uahiao.cjs → columns-DFnIRlLe.cjs} +6 -107
- package/dist/core/index.cjs +5 -6
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.mts +2 -3
- package/dist/core/index.mjs +3 -3
- package/dist/core-BxIUuTKo.mjs +156 -0
- package/dist/core-BxIUuTKo.mjs.map +1 -0
- package/dist/core-i3eza_VQ.cjs +173 -0
- package/dist/event-bus-BxVEXi1L.mjs +88 -0
- package/dist/event-bus-BxVEXi1L.mjs.map +1 -0
- package/dist/event-bus-GmFPYJu2.cjs +105 -0
- package/dist/{extension-B_ImOuII.mjs → extension-79zQ_3No.mjs} +11 -10
- package/dist/{extension-B_ImOuII.mjs.map → extension-79zQ_3No.mjs.map} +1 -1
- package/dist/{extension-DHsEsAaO.cjs → extension-ATLgVzTR.cjs} +12 -11
- package/dist/extensions/index.cjs +10 -10
- package/dist/extensions/index.d.cts +1 -1
- package/dist/extensions/index.d.mts +1 -2
- package/dist/extensions/index.d.mts.map +1 -1
- package/dist/extensions/index.mjs +3 -3
- package/dist/{extensions-BT49qi4I.mjs → extensions-CGtkbFUL.mjs} +13 -352
- package/dist/extensions-CGtkbFUL.mjs.map +1 -0
- package/dist/{extensions-5sSJryUX.cjs → extensions-DE0L4Pim.cjs} +79 -455
- package/dist/global-content-CaNsyaPw.mjs +78 -0
- package/dist/global-content-CaNsyaPw.mjs.map +1 -0
- package/dist/global-content-Dcc6RTLp.cjs +89 -0
- package/dist/{index-BL2rehV8.d.mts → index-BMsf5s28.d.mts} +3 -34
- package/dist/index-BMsf5s28.d.mts.map +1 -0
- package/dist/{index-DJgMqa5C.d.cts → index-DNriNUPU.d.cts} +3 -34
- package/dist/index-DNriNUPU.d.cts.map +1 -0
- package/dist/index.cjs +140 -11
- package/dist/index.d.cts +9 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +9 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +136 -7
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.d.cts +1 -1
- package/dist/plugins/index.d.mts +1 -1
- package/dist/plugins/index.mjs +1 -1
- package/dist/{root-CJuwiIRn.mjs → root-DCHEkXs2.mjs} +272 -224
- package/dist/root-DCHEkXs2.mjs.map +1 -0
- package/dist/{root-CEAehvsX.cjs → root-DLdCJfdP.cjs} +288 -234
- package/dist/{set-text-alignment-GMXOPMlJ.mjs → set-text-alignment-BDkB4Vfh.mjs} +1 -1
- package/dist/{set-text-alignment-GMXOPMlJ.mjs.map → set-text-alignment-BDkB4Vfh.mjs.map} +1 -1
- package/dist/{global-content-D3TNgSN6.cjs → styles-CYEzPPfZ.cjs} +0 -88
- package/dist/{global-content-6jVh6L0b.mjs → styles-DZ9S92ix.mjs} +2 -78
- package/dist/styles-DZ9S92ix.mjs.map +1 -0
- package/dist/{types-BNEbRz-a.d.cts → types-B-hiUAR9.d.cts} +1 -1
- package/dist/{types-BNEbRz-a.d.cts.map → types-B-hiUAR9.d.cts.map} +1 -1
- package/dist/{types-C8k-blF7.d.mts → types-J7sLqbPy.d.mts} +1 -1
- package/dist/{types-C8k-blF7.d.mts.map → types-J7sLqbPy.d.mts.map} +1 -1
- package/dist/ui/index.cjs +20 -69
- package/dist/ui/index.d.cts +112 -143
- package/dist/ui/index.d.cts.map +1 -1
- package/dist/ui/index.d.mts +111 -142
- package/dist/ui/index.d.mts.map +1 -1
- package/dist/ui/index.mjs +5 -53
- package/dist/ui/index.mjs.map +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +1 -1
- package/readme.md +1 -1
- package/dist/create-paste-handler-B8BtjBk3.d.cts +0 -14
- package/dist/create-paste-handler-B8BtjBk3.d.cts.map +0 -1
- package/dist/create-paste-handler-DsJYKisA.d.mts +0 -14
- package/dist/create-paste-handler-DsJYKisA.d.mts.map +0 -1
- package/dist/event-bus-BFzKTuhV.mjs.map +0 -1
- package/dist/extensions-BT49qi4I.mjs.map +0 -1
- package/dist/global-content-6jVh6L0b.mjs.map +0 -1
- package/dist/index-BL2rehV8.d.mts.map +0 -1
- package/dist/index-DJgMqa5C.d.cts.map +0 -1
- package/dist/root-CJuwiIRn.mjs.map +0 -1
- /package/dist/{set-text-alignment-aNb7Ml9N.cjs → set-text-alignment-BlyZq1GA.cjs} +0 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
const require_columns = require('./columns-DFnIRlLe.cjs');
|
|
2
|
+
const require_styles = require('./styles-CYEzPPfZ.cjs');
|
|
3
|
+
const require_event_bus = require('./event-bus-GmFPYJu2.cjs');
|
|
4
|
+
let _react_email_components = require("@react-email/components");
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
let _tiptap_core = require("@tiptap/core");
|
|
7
|
+
|
|
8
|
+
//#region src/core/serializer/default-base-template.tsx
|
|
9
|
+
function DefaultBaseTemplate({ children, previewText }) {
|
|
10
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_react_email_components.Html, { children: [
|
|
11
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_react_email_components.Head, { children: [
|
|
12
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
|
|
13
|
+
content: "width=device-width",
|
|
14
|
+
name: "viewport"
|
|
15
|
+
}),
|
|
16
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
|
|
17
|
+
content: "IE=edge",
|
|
18
|
+
httpEquiv: "X-UA-Compatible"
|
|
19
|
+
}),
|
|
20
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", { name: "x-apple-disable-message-reformatting" }),
|
|
21
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
|
|
22
|
+
content: "telephone=no,address=no,email=no,date=no,url=no",
|
|
23
|
+
name: "format-detection"
|
|
24
|
+
})
|
|
25
|
+
] }),
|
|
26
|
+
previewText && previewText !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Preview, { children: previewText }),
|
|
27
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Body, { children })
|
|
28
|
+
] });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/core/serializer/email-mark.ts
|
|
33
|
+
var EmailMark = class EmailMark extends _tiptap_core.Mark {
|
|
34
|
+
constructor(config) {
|
|
35
|
+
super(config);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a new Mark instance
|
|
39
|
+
* @param config - Mark configuration object or a function that returns a configuration object
|
|
40
|
+
*/
|
|
41
|
+
static create(config) {
|
|
42
|
+
return new EmailMark(typeof config === "function" ? config() : config);
|
|
43
|
+
}
|
|
44
|
+
static from(mark, renderToReactEmail) {
|
|
45
|
+
const customMark = EmailMark.create({});
|
|
46
|
+
Object.assign(customMark, { ...mark });
|
|
47
|
+
customMark.config = {
|
|
48
|
+
...mark.config,
|
|
49
|
+
renderToReactEmail
|
|
50
|
+
};
|
|
51
|
+
return customMark;
|
|
52
|
+
}
|
|
53
|
+
configure(options) {
|
|
54
|
+
return super.configure(options);
|
|
55
|
+
}
|
|
56
|
+
extend(extendedConfig) {
|
|
57
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
58
|
+
return super.extend(resolvedConfig);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/core/serializer/compose-react-email.tsx
|
|
64
|
+
const NODES_WITH_INCREMENTED_CHILD_DEPTH = new Set(["bulletList", "orderedList"]);
|
|
65
|
+
function getMarkRank(schema, markName) {
|
|
66
|
+
return schema.marks[markName]?.rank ?? Number.MAX_SAFE_INTEGER;
|
|
67
|
+
}
|
|
68
|
+
/** Sort marks by schema rank (Tiptap extension priority → ProseMirror order). */
|
|
69
|
+
function sortMarksBySchema(marks, schema) {
|
|
70
|
+
return [...marks].sort((a, b) => getMarkRank(schema, b.type) - getMarkRank(schema, a.type));
|
|
71
|
+
}
|
|
72
|
+
const composeReactEmail = async ({ editor, preview }) => {
|
|
73
|
+
const data = editor.getJSON();
|
|
74
|
+
const extensions = editor.extensionManager.extensions;
|
|
75
|
+
const serializerPlugin = extensions.map((ext) => ext.options?.serializerPlugin).filter((p) => Boolean(p)).at(-1);
|
|
76
|
+
const typeToExtensionMap = Object.fromEntries(extensions.map((extension) => [extension.name, extension]));
|
|
77
|
+
function parseContent(content, depth = 0) {
|
|
78
|
+
if (!content) return;
|
|
79
|
+
return content.map((node, index) => {
|
|
80
|
+
const style = serializerPlugin?.getNodeStyles(node, depth, editor) ?? {};
|
|
81
|
+
const inlineStyles = require_styles.inlineCssToJs(node.attrs?.style);
|
|
82
|
+
if (!node.type) return null;
|
|
83
|
+
const emailNode = typeToExtensionMap[node.type];
|
|
84
|
+
if (!emailNode || !(emailNode instanceof require_event_bus.EmailNode)) return null;
|
|
85
|
+
const NodeComponent = emailNode.config.renderToReactEmail;
|
|
86
|
+
const childDepth = NODES_WITH_INCREMENTED_CHILD_DEPTH.has(node.type) ? depth + 1 : depth;
|
|
87
|
+
let renderedNode = node.text ? node.text : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeComponent, {
|
|
88
|
+
node: node.type === "table" && inlineStyles.width && !node.attrs?.width ? {
|
|
89
|
+
...node,
|
|
90
|
+
attrs: {
|
|
91
|
+
...node.attrs,
|
|
92
|
+
width: inlineStyles.width
|
|
93
|
+
}
|
|
94
|
+
} : node,
|
|
95
|
+
style,
|
|
96
|
+
extension: emailNode,
|
|
97
|
+
children: parseContent(node.content, childDepth)
|
|
98
|
+
}, index);
|
|
99
|
+
if (node.marks) for (const mark of sortMarksBySchema(node.marks, editor.schema)) {
|
|
100
|
+
const emailMark = typeToExtensionMap[mark.type];
|
|
101
|
+
if (emailMark instanceof EmailMark) {
|
|
102
|
+
const MarkComponent = emailMark.config.renderToReactEmail;
|
|
103
|
+
renderedNode = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkComponent, {
|
|
104
|
+
mark,
|
|
105
|
+
node,
|
|
106
|
+
style: serializerPlugin?.getNodeStyles({
|
|
107
|
+
type: mark.type,
|
|
108
|
+
attrs: mark.attrs ?? {}
|
|
109
|
+
}, depth, editor) ?? {},
|
|
110
|
+
extension: emailMark,
|
|
111
|
+
children: renderedNode
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return renderedNode;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const unformattedHtml = await (0, _react_email_components.render)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(serializerPlugin?.BaseTemplate ?? DefaultBaseTemplate, {
|
|
119
|
+
previewText: preview,
|
|
120
|
+
editor,
|
|
121
|
+
children: parseContent(data.content)
|
|
122
|
+
}));
|
|
123
|
+
const [prettyHtml, text] = await Promise.all([(0, _react_email_components.pretty)(unformattedHtml), (0, _react_email_components.toPlainText)(unformattedHtml)]);
|
|
124
|
+
return {
|
|
125
|
+
html: prettyHtml,
|
|
126
|
+
text
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/core/is-document-visually-empty.ts
|
|
132
|
+
function isDocumentVisuallyEmpty(doc) {
|
|
133
|
+
let nonGlobalNodeCount = 0;
|
|
134
|
+
let firstNonGlobalNode = null;
|
|
135
|
+
for (let index = 0; index < doc.childCount; index += 1) {
|
|
136
|
+
const node = doc.child(index);
|
|
137
|
+
if (node.type.name === "globalContent") continue;
|
|
138
|
+
nonGlobalNodeCount += 1;
|
|
139
|
+
if (firstNonGlobalNode === null) firstNonGlobalNode = node;
|
|
140
|
+
}
|
|
141
|
+
if (nonGlobalNodeCount === 0) return true;
|
|
142
|
+
if (nonGlobalNodeCount !== 1) return false;
|
|
143
|
+
if (firstNonGlobalNode.type.name === "container") return hasOnlyEmptyParagraph(firstNonGlobalNode);
|
|
144
|
+
return isEmptyParagraph(firstNonGlobalNode);
|
|
145
|
+
}
|
|
146
|
+
function hasOnlyEmptyParagraph(node) {
|
|
147
|
+
if (node.childCount === 0) return true;
|
|
148
|
+
if (node.childCount !== 1) return false;
|
|
149
|
+
return isEmptyParagraph(node.child(0));
|
|
150
|
+
}
|
|
151
|
+
function isEmptyParagraph(node) {
|
|
152
|
+
return node.type.name === "paragraph" && node.content.size === 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
Object.defineProperty(exports, 'EmailMark', {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () {
|
|
159
|
+
return EmailMark;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(exports, 'composeReactEmail', {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function () {
|
|
165
|
+
return composeReactEmail;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, 'isDocumentVisuallyEmpty', {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function () {
|
|
171
|
+
return isDocumentVisuallyEmpty;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { Node } from "@tiptap/core";
|
|
3
|
+
|
|
4
|
+
//#region src/core/serializer/email-node.ts
|
|
5
|
+
var EmailNode = class EmailNode extends Node {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
super(config);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a new Node instance
|
|
11
|
+
* @param config - Node configuration object or a function that returns a configuration object
|
|
12
|
+
*/
|
|
13
|
+
static create(config) {
|
|
14
|
+
return new EmailNode(typeof config === "function" ? config() : config);
|
|
15
|
+
}
|
|
16
|
+
static from(node, renderToReactEmail) {
|
|
17
|
+
const customNode = EmailNode.create({});
|
|
18
|
+
Object.assign(customNode, { ...node });
|
|
19
|
+
customNode.config = {
|
|
20
|
+
...node.config,
|
|
21
|
+
renderToReactEmail
|
|
22
|
+
};
|
|
23
|
+
return customNode;
|
|
24
|
+
}
|
|
25
|
+
configure(options) {
|
|
26
|
+
return super.configure(options);
|
|
27
|
+
}
|
|
28
|
+
extend(extendedConfig) {
|
|
29
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
30
|
+
return super.extend(resolvedConfig);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/core/event-bus.ts
|
|
36
|
+
const EVENT_PREFIX = "@react-email/editor:";
|
|
37
|
+
var EditorEventBus = class {
|
|
38
|
+
prefixEventName(eventName) {
|
|
39
|
+
return `${EVENT_PREFIX}${String(eventName)}`;
|
|
40
|
+
}
|
|
41
|
+
dispatch(eventName, payload, options) {
|
|
42
|
+
const target = options?.target ?? window;
|
|
43
|
+
const prefixedEventName = this.prefixEventName(eventName);
|
|
44
|
+
const event = new CustomEvent(prefixedEventName, {
|
|
45
|
+
detail: payload,
|
|
46
|
+
bubbles: false,
|
|
47
|
+
cancelable: false
|
|
48
|
+
});
|
|
49
|
+
target.dispatchEvent(event);
|
|
50
|
+
}
|
|
51
|
+
on(eventName, handler, options) {
|
|
52
|
+
const target = options?.target ?? window;
|
|
53
|
+
const prefixedEventName = this.prefixEventName(eventName);
|
|
54
|
+
const abortController = new AbortController();
|
|
55
|
+
const wrappedHandler = (event) => {
|
|
56
|
+
const customEvent = event;
|
|
57
|
+
const result = handler(customEvent.detail);
|
|
58
|
+
if (result instanceof Promise) result.catch((error) => {
|
|
59
|
+
console.error(`Error in async event handler for ${prefixedEventName}:`, {
|
|
60
|
+
event: customEvent.detail,
|
|
61
|
+
error
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
target.addEventListener(prefixedEventName, wrappedHandler, {
|
|
66
|
+
...options,
|
|
67
|
+
signal: abortController.signal
|
|
68
|
+
});
|
|
69
|
+
return { unsubscribe: () => {
|
|
70
|
+
abortController.abort();
|
|
71
|
+
} };
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const editorEventBus = new EditorEventBus();
|
|
75
|
+
function useEditorEvent(eventName, handler, options) {
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
const subscription = editorEventBus.on(eventName, handler, options);
|
|
78
|
+
return () => subscription.unsubscribe();
|
|
79
|
+
}, [
|
|
80
|
+
eventName,
|
|
81
|
+
handler,
|
|
82
|
+
options
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { useEditorEvent as n, EmailNode as r, editorEventBus as t };
|
|
88
|
+
//# sourceMappingURL=event-bus-BxVEXi1L.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus-BxVEXi1L.mjs","names":[],"sources":["../src/core/serializer/email-node.ts","../src/core/event-bus.ts"],"sourcesContent":["import {\n type Editor,\n type JSONContent,\n Node,\n type NodeConfig,\n type NodeType,\n} from '@tiptap/core';\n\nexport type NodeRendererComponent = (props: {\n node: JSONContent;\n style: React.CSSProperties;\n children?: React.ReactNode;\n\n extension: EmailNode<any, any>;\n}) => React.ReactNode;\n\nexport interface EmailNodeConfig<Options, Storage>\n extends NodeConfig<Options, Storage> {\n renderToReactEmail: NodeRendererComponent;\n}\n\ntype ConfigParameter<Options, Storage> = Partial<\n Omit<EmailNodeConfig<Options, Storage>, 'renderToReactEmail'>\n> &\n Pick<EmailNodeConfig<Options, Storage>, 'renderToReactEmail'> &\n ThisType<{\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: NodeType;\n parent: (...args: any[]) => any;\n }>;\n\nexport class EmailNode<\n Options = Record<string, never>,\n Storage = Record<string, never>,\n> extends Node<Options, Storage> {\n declare config: EmailNodeConfig<Options, Storage>;\n\n // biome-ignore lint/complexity/noUselessConstructor: This is only meant to change the types for config, hence why we keep it\n constructor(config: ConfigParameter<Options, Storage>) {\n super(config);\n }\n\n /**\n * Create a new Node instance\n * @param config - Node configuration object or a function that returns a configuration object\n */\n static create<O = Record<string, never>, S = Record<string, never>>(\n config: ConfigParameter<O, S> | (() => ConfigParameter<O, S>),\n ) {\n // If the config is a function, execute it to get the configuration object\n const resolvedConfig = typeof config === 'function' ? config() : config;\n return new EmailNode<O, S>(resolvedConfig);\n }\n\n static from<O, S>(\n node: Node<O, S>,\n renderToReactEmail: NodeRendererComponent,\n ): EmailNode<O, S> {\n const customNode = EmailNode.create({} as ConfigParameter<O, S>);\n // This only makes a shallow copy, so if there's nested objects here mutating things will be dangerous\n Object.assign(customNode, { ...node });\n customNode.config = { ...node.config, renderToReactEmail };\n return customNode;\n }\n\n // Subclass return types for configure/extend; safe at runtime. TipTap's Node typings cause TS2416 when returning EmailNode.\n // @ts-expect-error - EmailNode is a valid Node subclass; base typings don't support subclass return types\n configure(options?: Partial<Options>) {\n return super.configure(options) as EmailNode<Options, Storage>;\n }\n\n // @ts-expect-error - same as configure: extend returns EmailNode for chaining; base typings are incompatible\n extend<\n ExtendedOptions = Options,\n ExtendedStorage = Storage,\n ExtendedConfig extends NodeConfig<\n ExtendedOptions,\n ExtendedStorage\n > = EmailNodeConfig<ExtendedOptions, ExtendedStorage>,\n >(\n extendedConfig?:\n | (() => Partial<ExtendedConfig>)\n | (Partial<ExtendedConfig> &\n ThisType<{\n name: string;\n options: ExtendedOptions;\n storage: ExtendedStorage;\n editor: Editor;\n type: NodeType;\n }>),\n ): EmailNode<ExtendedOptions, ExtendedStorage> {\n // If the extended config is a function, execute it to get the configuration object\n const resolvedConfig =\n typeof extendedConfig === 'function' ? extendedConfig() : extendedConfig;\n return super.extend(resolvedConfig) as EmailNode<\n ExtendedOptions,\n ExtendedStorage\n >;\n }\n}\n","import type { Attrs } from '@tiptap/pm/model';\nimport { useEffect } from 'react';\n\nconst EVENT_PREFIX = '@react-email/editor:';\n\n/**\n * Base event map interface for the editor event bus.\n *\n * Components extend this via TypeScript module augmentation:\n * ```ts\n * declare module '@react-email/editor' {\n * interface EditorEventMap {\n * 'my-component:custom-event': { data: string };\n * }\n * }\n * ```\n */\nexport interface EditorEventMap {\n 'bubble-menu:add-link': undefined;\n 'node-clicked': NodeClickedEvent;\n}\n\nexport type NodeClickedEvent = {\n nodeType: string;\n nodeAttrs: Attrs;\n nodePos: { pos: number; inside: number };\n};\n\nexport type EditorEventName = keyof EditorEventMap;\n\nexport type EditorEventHandler<T extends EditorEventName> = (\n payload: EditorEventMap[T],\n) => void | Promise<void>;\n\nexport interface EditorEventSubscription {\n unsubscribe: () => void;\n}\n\nclass EditorEventBus {\n private prefixEventName(eventName: EditorEventName): string {\n return `${EVENT_PREFIX}${String(eventName)}`;\n }\n\n dispatch<T extends EditorEventName>(\n eventName: T,\n payload: EditorEventMap[T],\n options?: { target?: EventTarget },\n ): void {\n const target = options?.target ?? window;\n const prefixedEventName = this.prefixEventName(eventName);\n const event = new CustomEvent(prefixedEventName, {\n detail: payload,\n bubbles: false,\n cancelable: false,\n });\n target.dispatchEvent(event);\n }\n\n on<T extends EditorEventName>(\n eventName: T,\n handler: EditorEventHandler<T>,\n options?: AddEventListenerOptions & { target?: EventTarget },\n ): EditorEventSubscription {\n const target = options?.target ?? window;\n const prefixedEventName = this.prefixEventName(eventName);\n const abortController = new AbortController();\n\n const wrappedHandler = (event: Event) => {\n const customEvent = event as CustomEvent<EditorEventMap[T]>;\n const result = handler(customEvent.detail);\n\n if (result instanceof Promise) {\n result.catch((error) => {\n console.error(\n `Error in async event handler for ${prefixedEventName}:`,\n { event: customEvent.detail, error },\n );\n });\n }\n };\n\n target.addEventListener(prefixedEventName, wrappedHandler, {\n ...options,\n signal: abortController.signal,\n });\n\n return {\n unsubscribe: () => {\n abortController.abort();\n },\n };\n }\n}\n\nexport const editorEventBus = new EditorEventBus();\n\nexport function useEditorEvent<T extends EditorEventName>(\n eventName: T,\n handler: EditorEventHandler<T>,\n options?: AddEventListenerOptions & { target?: EventTarget },\n) {\n useEffect(() => {\n const subscription = editorEventBus.on(eventName, handler, options);\n\n return () => subscription.unsubscribe();\n }, [eventName, handler, options]);\n}\n"],"mappings":";;;;AAkCA,IAAa,YAAb,MAAa,kBAGH,KAAuB;CAI/B,YAAY,QAA2C;AACrD,QAAM,OAAO;;;;;;CAOf,OAAO,OACL,QACA;AAGA,SAAO,IAAI,UADY,OAAO,WAAW,aAAa,QAAQ,GAAG,OACvB;;CAG5C,OAAO,KACL,MACA,oBACiB;EACjB,MAAM,aAAa,UAAU,OAAO,EAAE,CAA0B;AAEhE,SAAO,OAAO,YAAY,EAAE,GAAG,MAAM,CAAC;AACtC,aAAW,SAAS;GAAE,GAAG,KAAK;GAAQ;GAAoB;AAC1D,SAAO;;CAKT,UAAU,SAA4B;AACpC,SAAO,MAAM,UAAU,QAAQ;;CAIjC,OAQE,gBAU6C;EAE7C,MAAM,iBACJ,OAAO,mBAAmB,aAAa,gBAAgB,GAAG;AAC5D,SAAO,MAAM,OAAO,eAAe;;;;;;AC9FvC,MAAM,eAAe;AAmCrB,IAAM,iBAAN,MAAqB;CACnB,AAAQ,gBAAgB,WAAoC;AAC1D,SAAO,GAAG,eAAe,OAAO,UAAU;;CAG5C,SACE,WACA,SACA,SACM;EACN,MAAM,SAAS,SAAS,UAAU;EAClC,MAAM,oBAAoB,KAAK,gBAAgB,UAAU;EACzD,MAAM,QAAQ,IAAI,YAAY,mBAAmB;GAC/C,QAAQ;GACR,SAAS;GACT,YAAY;GACb,CAAC;AACF,SAAO,cAAc,MAAM;;CAG7B,GACE,WACA,SACA,SACyB;EACzB,MAAM,SAAS,SAAS,UAAU;EAClC,MAAM,oBAAoB,KAAK,gBAAgB,UAAU;EACzD,MAAM,kBAAkB,IAAI,iBAAiB;EAE7C,MAAM,kBAAkB,UAAiB;GACvC,MAAM,cAAc;GACpB,MAAM,SAAS,QAAQ,YAAY,OAAO;AAE1C,OAAI,kBAAkB,QACpB,QAAO,OAAO,UAAU;AACtB,YAAQ,MACN,oCAAoC,kBAAkB,IACtD;KAAE,OAAO,YAAY;KAAQ;KAAO,CACrC;KACD;;AAIN,SAAO,iBAAiB,mBAAmB,gBAAgB;GACzD,GAAG;GACH,QAAQ,gBAAgB;GACzB,CAAC;AAEF,SAAO,EACL,mBAAmB;AACjB,mBAAgB,OAAO;KAE1B;;;AAIL,MAAa,iBAAiB,IAAI,gBAAgB;AAElD,SAAgB,eACd,WACA,SACA,SACA;AACA,iBAAgB;EACd,MAAM,eAAe,eAAe,GAAG,WAAW,SAAS,QAAQ;AAEnE,eAAa,aAAa,aAAa;IACtC;EAAC;EAAW;EAAS;EAAQ,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const require_columns = require('./columns-DFnIRlLe.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
let _tiptap_core = require("@tiptap/core");
|
|
4
|
+
|
|
5
|
+
//#region src/core/serializer/email-node.ts
|
|
6
|
+
var EmailNode = class EmailNode extends _tiptap_core.Node {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
super(config);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Create a new Node instance
|
|
12
|
+
* @param config - Node configuration object or a function that returns a configuration object
|
|
13
|
+
*/
|
|
14
|
+
static create(config) {
|
|
15
|
+
return new EmailNode(typeof config === "function" ? config() : config);
|
|
16
|
+
}
|
|
17
|
+
static from(node, renderToReactEmail) {
|
|
18
|
+
const customNode = EmailNode.create({});
|
|
19
|
+
Object.assign(customNode, { ...node });
|
|
20
|
+
customNode.config = {
|
|
21
|
+
...node.config,
|
|
22
|
+
renderToReactEmail
|
|
23
|
+
};
|
|
24
|
+
return customNode;
|
|
25
|
+
}
|
|
26
|
+
configure(options) {
|
|
27
|
+
return super.configure(options);
|
|
28
|
+
}
|
|
29
|
+
extend(extendedConfig) {
|
|
30
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
31
|
+
return super.extend(resolvedConfig);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/core/event-bus.ts
|
|
37
|
+
const EVENT_PREFIX = "@react-email/editor:";
|
|
38
|
+
var EditorEventBus = class {
|
|
39
|
+
prefixEventName(eventName) {
|
|
40
|
+
return `${EVENT_PREFIX}${String(eventName)}`;
|
|
41
|
+
}
|
|
42
|
+
dispatch(eventName, payload, options) {
|
|
43
|
+
const target = options?.target ?? window;
|
|
44
|
+
const prefixedEventName = this.prefixEventName(eventName);
|
|
45
|
+
const event = new CustomEvent(prefixedEventName, {
|
|
46
|
+
detail: payload,
|
|
47
|
+
bubbles: false,
|
|
48
|
+
cancelable: false
|
|
49
|
+
});
|
|
50
|
+
target.dispatchEvent(event);
|
|
51
|
+
}
|
|
52
|
+
on(eventName, handler, options) {
|
|
53
|
+
const target = options?.target ?? window;
|
|
54
|
+
const prefixedEventName = this.prefixEventName(eventName);
|
|
55
|
+
const abortController = new AbortController();
|
|
56
|
+
const wrappedHandler = (event) => {
|
|
57
|
+
const customEvent = event;
|
|
58
|
+
const result = handler(customEvent.detail);
|
|
59
|
+
if (result instanceof Promise) result.catch((error) => {
|
|
60
|
+
console.error(`Error in async event handler for ${prefixedEventName}:`, {
|
|
61
|
+
event: customEvent.detail,
|
|
62
|
+
error
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
target.addEventListener(prefixedEventName, wrappedHandler, {
|
|
67
|
+
...options,
|
|
68
|
+
signal: abortController.signal
|
|
69
|
+
});
|
|
70
|
+
return { unsubscribe: () => {
|
|
71
|
+
abortController.abort();
|
|
72
|
+
} };
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const editorEventBus = new EditorEventBus();
|
|
76
|
+
function useEditorEvent(eventName, handler, options) {
|
|
77
|
+
(0, react.useEffect)(() => {
|
|
78
|
+
const subscription = editorEventBus.on(eventName, handler, options);
|
|
79
|
+
return () => subscription.unsubscribe();
|
|
80
|
+
}, [
|
|
81
|
+
eventName,
|
|
82
|
+
handler,
|
|
83
|
+
options
|
|
84
|
+
]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
Object.defineProperty(exports, 'EmailNode', {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () {
|
|
91
|
+
return EmailNode;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(exports, 'editorEventBus', {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function () {
|
|
97
|
+
return editorEventBus;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(exports, 'useEditorEvent', {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function () {
|
|
103
|
+
return useEditorEvent;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as ensureBorderStyleFallback } from "./styles-DZ9S92ix.mjs";
|
|
2
|
+
import { n as getGlobalContent } from "./global-content-CaNsyaPw.mjs";
|
|
2
3
|
import { useEditorState } from "@tiptap/react";
|
|
3
4
|
import { Body, Head, Html, Preview } from "@react-email/components";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -115,7 +116,7 @@ const THEME_BASIC = [
|
|
|
115
116
|
{
|
|
116
117
|
label: "Padding Top",
|
|
117
118
|
type: "number",
|
|
118
|
-
value: 0,
|
|
119
|
+
value: void 0,
|
|
119
120
|
unit: "px",
|
|
120
121
|
prop: "paddingTop",
|
|
121
122
|
classReference: "body"
|
|
@@ -123,7 +124,7 @@ const THEME_BASIC = [
|
|
|
123
124
|
{
|
|
124
125
|
label: "Padding Right",
|
|
125
126
|
type: "number",
|
|
126
|
-
value: 0,
|
|
127
|
+
value: void 0,
|
|
127
128
|
unit: "px",
|
|
128
129
|
prop: "paddingRight",
|
|
129
130
|
classReference: "body"
|
|
@@ -131,7 +132,7 @@ const THEME_BASIC = [
|
|
|
131
132
|
{
|
|
132
133
|
label: "Padding Bottom",
|
|
133
134
|
type: "number",
|
|
134
|
-
value: 0,
|
|
135
|
+
value: void 0,
|
|
135
136
|
unit: "px",
|
|
136
137
|
prop: "paddingBottom",
|
|
137
138
|
classReference: "body"
|
|
@@ -139,7 +140,7 @@ const THEME_BASIC = [
|
|
|
139
140
|
{
|
|
140
141
|
label: "Padding Left",
|
|
141
142
|
type: "number",
|
|
142
|
-
value: 0,
|
|
143
|
+
value: void 0,
|
|
143
144
|
unit: "px",
|
|
144
145
|
prop: "paddingLeft",
|
|
145
146
|
classReference: "body"
|
|
@@ -471,7 +472,7 @@ const THEME_MINIMAL = [
|
|
|
471
472
|
{
|
|
472
473
|
label: "Padding Top",
|
|
473
474
|
type: "number",
|
|
474
|
-
value: 0,
|
|
475
|
+
value: void 0,
|
|
475
476
|
unit: "px",
|
|
476
477
|
prop: "paddingTop",
|
|
477
478
|
classReference: "body"
|
|
@@ -479,7 +480,7 @@ const THEME_MINIMAL = [
|
|
|
479
480
|
{
|
|
480
481
|
label: "Padding Right",
|
|
481
482
|
type: "number",
|
|
482
|
-
value: 0,
|
|
483
|
+
value: void 0,
|
|
483
484
|
unit: "px",
|
|
484
485
|
prop: "paddingRight",
|
|
485
486
|
classReference: "body"
|
|
@@ -487,7 +488,7 @@ const THEME_MINIMAL = [
|
|
|
487
488
|
{
|
|
488
489
|
label: "Padding Bottom",
|
|
489
490
|
type: "number",
|
|
490
|
-
value: 0,
|
|
491
|
+
value: void 0,
|
|
491
492
|
unit: "px",
|
|
492
493
|
prop: "paddingBottom",
|
|
493
494
|
classReference: "body"
|
|
@@ -495,7 +496,7 @@ const THEME_MINIMAL = [
|
|
|
495
496
|
{
|
|
496
497
|
label: "Padding Left",
|
|
497
498
|
type: "number",
|
|
498
|
-
value: 0,
|
|
499
|
+
value: void 0,
|
|
499
500
|
unit: "px",
|
|
500
501
|
prop: "paddingLeft",
|
|
501
502
|
classReference: "body"
|
|
@@ -1395,4 +1396,4 @@ const EmailTheming = Extension.create({
|
|
|
1395
1396
|
|
|
1396
1397
|
//#endregion
|
|
1397
1398
|
export { resolveResetValue as _, setCurrentTheme as a, stylesToCss as c, EDITOR_THEMES as d, INBOX_EMAIL_DEFAULTS as f, getThemeBodyFontSizePx as g, getPanelTitle as h, getThemeComponentKey as i, useEmailTheming as l, SUPPORTED_CSS_PROPERTIES as m, getMergedCssJs as n, setGlobalCssInjected as o, RESET_THEMES as p, getResolvedNodeStyles as r, setGlobalStyles as s, EmailTheming as t, DEFAULT_INBOX_FONT_SIZE_PX as u };
|
|
1398
|
-
//# sourceMappingURL=extension-
|
|
1399
|
+
//# sourceMappingURL=extension-79zQ_3No.mjs.map
|