@react-email/editor 0.0.0-experimental.8 → 1.0.0-canary.51
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-BItFgD76.mjs +273 -0
- package/dist/columns-BItFgD76.mjs.map +1 -0
- package/dist/columns-DqFvXgmK.cjs +394 -0
- package/dist/core/index.cjs +10 -0
- package/dist/core/index.d.cts +2 -0
- package/dist/core/index.d.mts +2 -0
- package/dist/core/index.mjs +4 -0
- package/dist/core-CbSTyrV4.mjs +151 -0
- package/dist/core-CbSTyrV4.mjs.map +1 -0
- package/dist/core-D7AzzMLI.cjs +167 -0
- package/dist/email-node-B-_g4X-S.mjs +254 -0
- package/dist/email-node-B-_g4X-S.mjs.map +1 -0
- package/dist/email-node-hLU5bGnX.cjs +288 -0
- package/dist/event-bus-CIJ___tH.cjs +65 -0
- package/dist/event-bus-CqrIUE24.mjs +55 -0
- package/dist/event-bus-CqrIUE24.mjs.map +1 -0
- package/dist/extension-BbjpP9mF.cjs +1625 -0
- package/dist/extension-C5qNDPZL.mjs +154 -0
- package/dist/extension-C5qNDPZL.mjs.map +1 -0
- package/dist/extension-Cs4Yq2gF.cjs +158 -0
- package/dist/extension-DlWknmE5.mjs +1495 -0
- package/dist/extension-DlWknmE5.mjs.map +1 -0
- package/dist/extensions/index.cjs +50 -0
- package/dist/extensions/index.d.cts +392 -0
- package/dist/extensions/index.d.cts.map +1 -0
- package/dist/extensions/index.d.mts +392 -0
- package/dist/extensions/index.d.mts.map +1 -0
- package/dist/extensions/index.mjs +4 -0
- package/dist/extensions-CHIQO3d-.mjs +1745 -0
- package/dist/extensions-CHIQO3d-.mjs.map +1 -0
- package/dist/extensions-DCrDvZ42.cjs +1981 -0
- package/dist/global-content-0-J-Te3N.mjs +77 -0
- package/dist/global-content-0-J-Te3N.mjs.map +1 -0
- package/dist/global-content-8M2KyrOL.cjs +87 -0
- package/dist/image-KwEYzhji.cjs +41 -0
- package/dist/image-Oc789YjV.mjs +37 -0
- package/dist/image-Oc789YjV.mjs.map +1 -0
- package/dist/index-CHAPu71g.d.cts +193 -0
- package/dist/index-CHAPu71g.d.cts.map +1 -0
- package/dist/index-D4UEWmJX.d.mts +193 -0
- package/dist/index-D4UEWmJX.d.mts.map +1 -0
- package/dist/index.cjs +216 -0
- package/dist/index.d.cts +38 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +33 -623
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +189 -2349
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/index.cjs +56 -0
- package/dist/plugins/index.d.cts +114 -0
- package/dist/plugins/index.d.cts.map +1 -0
- package/dist/plugins/index.d.mts +114 -0
- package/dist/plugins/index.d.mts.map +1 -0
- package/dist/plugins/index.mjs +34 -0
- package/dist/plugins/index.mjs.map +1 -0
- package/dist/root-CT5d4CKj.cjs +2798 -0
- package/dist/root-uvdshbyT.mjs +2295 -0
- package/dist/root-uvdshbyT.mjs.map +1 -0
- package/dist/set-text-alignment-BCRnE5So.mjs +19 -0
- package/dist/set-text-alignment-BCRnE5So.mjs.map +1 -0
- package/dist/set-text-alignment-Twg1EG4-.cjs +22 -0
- package/dist/style.css +974 -0
- package/dist/types-BG5XsXt9.d.mts +37 -0
- package/dist/types-BG5XsXt9.d.mts.map +1 -0
- package/dist/types-DnOcnDoO.d.mts +56 -0
- package/dist/types-DnOcnDoO.d.mts.map +1 -0
- package/dist/types-DzPTbbDC.d.cts +56 -0
- package/dist/types-DzPTbbDC.d.cts.map +1 -0
- package/dist/types-hURXpEIO.d.cts +37 -0
- package/dist/types-hURXpEIO.d.cts.map +1 -0
- package/dist/ui/bubble-menu/bubble-menu.css +291 -0
- package/dist/ui/index.cjs +2895 -0
- package/dist/ui/index.d.cts +1155 -0
- package/dist/ui/index.d.cts.map +1 -0
- package/dist/ui/index.d.mts +1157 -0
- package/dist/ui/index.d.mts.map +1 -0
- package/dist/ui/index.mjs +2784 -0
- package/dist/ui/index.mjs.map +1 -0
- package/dist/ui/inspector/inspector.css +293 -0
- package/dist/ui/slash-command/slash-command.css +44 -0
- package/dist/ui/themes/default.css +1140 -0
- package/dist/utils/index.cjs +3 -0
- package/dist/utils/index.d.cts +7 -0
- package/dist/utils/index.d.cts.map +1 -0
- package/dist/utils/index.d.mts +7 -0
- package/dist/utils/index.d.mts.map +1 -0
- package/dist/utils/index.mjs +2 -0
- package/package.json +100 -16
- package/readme.md +69 -0
- package/dist/index.d.ts +0 -628
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2461
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_email_node = require("../email-node-hLU5bGnX.cjs");
|
|
3
|
+
const require_core = require("../core-D7AzzMLI.cjs");
|
|
4
|
+
const require_event_bus = require("../event-bus-CIJ___tH.cjs");
|
|
5
|
+
exports.EmailMark = require_core.EmailMark;
|
|
6
|
+
exports.EmailNode = require_email_node.EmailNode;
|
|
7
|
+
exports.composeReactEmail = require_core.composeReactEmail;
|
|
8
|
+
exports.editorEventBus = require_event_bus.editorEventBus;
|
|
9
|
+
exports.isDocumentVisuallyEmpty = require_core.isDocumentVisuallyEmpty;
|
|
10
|
+
exports.useEditorEvent = require_event_bus.useEditorEvent;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as EditorEventName, a as PlaceholderItem, b as editorEventBus, c as NodeRendererComponent, d as MarkRendererComponent, f as SerializedMark, g as EditorEventMap, h as EditorEventHandler, i as EventSubscription, l as EmailMark, m as isDocumentVisuallyEmpty, n as DispatchOptions, o as EmailNode, p as composeReactEmail, r as EventHandler, s as EmailNodeConfig, t as CustomPlaceholder, u as EmailMarkConfig, v as EditorEventSubscription, x as useEditorEvent, y as NodeClickedEvent } from "../index-CHAPu71g.cjs";
|
|
2
|
+
export { CustomPlaceholder, DispatchOptions, EditorEventHandler, EditorEventMap, EditorEventName, EditorEventSubscription, EmailMark, EmailMarkConfig, EmailNode, EmailNodeConfig, EventHandler, EventSubscription, MarkRendererComponent, NodeClickedEvent, NodeRendererComponent, PlaceholderItem, SerializedMark, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditorEvent };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as EditorEventName, a as PlaceholderItem, b as editorEventBus, c as NodeRendererComponent, d as MarkRendererComponent, f as SerializedMark, g as EditorEventMap, h as EditorEventHandler, i as EventSubscription, l as EmailMark, m as isDocumentVisuallyEmpty, n as DispatchOptions, o as EmailNode, p as composeReactEmail, r as EventHandler, s as EmailNodeConfig, t as CustomPlaceholder, u as EmailMarkConfig, v as EditorEventSubscription, x as useEditorEvent, y as NodeClickedEvent } from "../index-D4UEWmJX.mjs";
|
|
2
|
+
export { CustomPlaceholder, DispatchOptions, EditorEventHandler, EditorEventMap, EditorEventName, EditorEventSubscription, EmailMark, EmailMarkConfig, EmailNode, EmailNodeConfig, EventHandler, EventSubscription, MarkRendererComponent, NodeClickedEvent, NodeRendererComponent, PlaceholderItem, SerializedMark, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditorEvent };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { t as EmailNode } from "../email-node-B-_g4X-S.mjs";
|
|
2
|
+
import { n as composeReactEmail, r as EmailMark, t as isDocumentVisuallyEmpty } from "../core-CbSTyrV4.mjs";
|
|
3
|
+
import { n as useEditorEvent, t as editorEventBus } from "../event-bus-CqrIUE24.mjs";
|
|
4
|
+
export { EmailMark, EmailNode, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditorEvent };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { i as inlineCssToJs, t as EmailNode } from "./email-node-B-_g4X-S.mjs";
|
|
2
|
+
import { Body, Head, Html, Preview, pretty, render, toPlainText } from "react-email";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Mark } from "@tiptap/core";
|
|
5
|
+
//#region src/core/serializer/default-base-template.tsx
|
|
6
|
+
function DefaultBaseTemplate({ children, previewText }) {
|
|
7
|
+
return /* @__PURE__ */ jsxs(Html, { children: [
|
|
8
|
+
/* @__PURE__ */ jsxs(Head, { children: [
|
|
9
|
+
/* @__PURE__ */ jsx("meta", {
|
|
10
|
+
content: "width=device-width",
|
|
11
|
+
name: "viewport"
|
|
12
|
+
}),
|
|
13
|
+
/* @__PURE__ */ jsx("meta", {
|
|
14
|
+
content: "IE=edge",
|
|
15
|
+
httpEquiv: "X-UA-Compatible"
|
|
16
|
+
}),
|
|
17
|
+
/* @__PURE__ */ jsx("meta", { name: "x-apple-disable-message-reformatting" }),
|
|
18
|
+
/* @__PURE__ */ jsx("meta", {
|
|
19
|
+
content: "telephone=no,address=no,email=no,date=no,url=no",
|
|
20
|
+
name: "format-detection"
|
|
21
|
+
})
|
|
22
|
+
] }),
|
|
23
|
+
previewText && previewText !== "" && /* @__PURE__ */ jsx(Preview, { children: previewText }),
|
|
24
|
+
/* @__PURE__ */ jsx(Body, { children })
|
|
25
|
+
] });
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/core/serializer/email-mark.ts
|
|
29
|
+
var EmailMark = class EmailMark extends Mark {
|
|
30
|
+
constructor(config) {
|
|
31
|
+
super(config);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a new Mark instance
|
|
35
|
+
* @param config - Mark configuration object or a function that returns a configuration object
|
|
36
|
+
*/
|
|
37
|
+
static create(config) {
|
|
38
|
+
return new EmailMark(typeof config === "function" ? config() : config);
|
|
39
|
+
}
|
|
40
|
+
static from(mark, renderToReactEmail) {
|
|
41
|
+
const customMark = EmailMark.create({});
|
|
42
|
+
Object.assign(customMark, { ...mark });
|
|
43
|
+
customMark.config = {
|
|
44
|
+
...mark.config,
|
|
45
|
+
renderToReactEmail
|
|
46
|
+
};
|
|
47
|
+
return customMark;
|
|
48
|
+
}
|
|
49
|
+
configure(options) {
|
|
50
|
+
return super.configure(options);
|
|
51
|
+
}
|
|
52
|
+
extend(extendedConfig) {
|
|
53
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
54
|
+
return super.extend(resolvedConfig);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/core/serializer/compose-react-email.tsx
|
|
59
|
+
const NODES_WITH_INCREMENTED_CHILD_DEPTH = new Set(["bulletList", "orderedList"]);
|
|
60
|
+
function getMarkRank(schema, markName) {
|
|
61
|
+
return schema.marks[markName]?.rank ?? Number.MAX_SAFE_INTEGER;
|
|
62
|
+
}
|
|
63
|
+
/** Sort marks by schema rank (Tiptap extension priority → ProseMirror order). */
|
|
64
|
+
function sortMarksBySchema(marks, schema) {
|
|
65
|
+
return [...marks].sort((a, b) => getMarkRank(schema, b.type) - getMarkRank(schema, a.type));
|
|
66
|
+
}
|
|
67
|
+
const composeReactEmail = async ({ editor, preview }) => {
|
|
68
|
+
const data = editor.getJSON();
|
|
69
|
+
const extensions = editor.extensionManager.extensions;
|
|
70
|
+
const serializerPlugin = extensions.map((ext) => ext.options?.serializerPlugin).filter((p) => Boolean(p)).at(-1);
|
|
71
|
+
const typeToExtensionMap = Object.fromEntries(extensions.map((extension) => [extension.name, extension]));
|
|
72
|
+
function parseContent(content, depth = 0) {
|
|
73
|
+
if (!content) return;
|
|
74
|
+
return content.map((node, index) => {
|
|
75
|
+
const style = serializerPlugin?.getNodeStyles(node, depth, editor) ?? {};
|
|
76
|
+
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
77
|
+
if (!node.type) return null;
|
|
78
|
+
const emailNode = typeToExtensionMap[node.type];
|
|
79
|
+
if (!emailNode || !(emailNode instanceof EmailNode)) return null;
|
|
80
|
+
const NodeComponent = emailNode.config.renderToReactEmail;
|
|
81
|
+
const childDepth = NODES_WITH_INCREMENTED_CHILD_DEPTH.has(node.type) ? depth + 1 : depth;
|
|
82
|
+
let renderedNode = node.text ? node.text : /* @__PURE__ */ jsx(NodeComponent, {
|
|
83
|
+
node: node.type === "table" && inlineStyles.width && !node.attrs?.width ? {
|
|
84
|
+
...node,
|
|
85
|
+
attrs: {
|
|
86
|
+
...node.attrs,
|
|
87
|
+
width: inlineStyles.width
|
|
88
|
+
}
|
|
89
|
+
} : node,
|
|
90
|
+
style,
|
|
91
|
+
extension: emailNode,
|
|
92
|
+
children: parseContent(node.content, childDepth)
|
|
93
|
+
}, index);
|
|
94
|
+
if (node.marks) for (const mark of sortMarksBySchema(node.marks, editor.schema)) {
|
|
95
|
+
const emailMark = typeToExtensionMap[mark.type];
|
|
96
|
+
if (emailMark instanceof EmailMark) {
|
|
97
|
+
const MarkComponent = emailMark.config.renderToReactEmail;
|
|
98
|
+
renderedNode = /* @__PURE__ */ jsx(MarkComponent, {
|
|
99
|
+
mark,
|
|
100
|
+
node,
|
|
101
|
+
style: serializerPlugin?.getNodeStyles({
|
|
102
|
+
type: mark.type,
|
|
103
|
+
attrs: mark.attrs ?? {}
|
|
104
|
+
}, depth, editor) ?? {},
|
|
105
|
+
extension: emailMark,
|
|
106
|
+
children: renderedNode
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return renderedNode;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const unformattedHtml = await render(/* @__PURE__ */ jsx(serializerPlugin?.BaseTemplate ?? DefaultBaseTemplate, {
|
|
114
|
+
previewText: preview,
|
|
115
|
+
editor,
|
|
116
|
+
children: parseContent(data.content)
|
|
117
|
+
}));
|
|
118
|
+
const [prettyHtml, text] = await Promise.all([pretty(unformattedHtml), toPlainText(unformattedHtml)]);
|
|
119
|
+
return {
|
|
120
|
+
html: prettyHtml,
|
|
121
|
+
text
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/core/is-document-visually-empty.ts
|
|
126
|
+
function isDocumentVisuallyEmpty(doc) {
|
|
127
|
+
let nonGlobalNodeCount = 0;
|
|
128
|
+
let firstNonGlobalNode = null;
|
|
129
|
+
for (let index = 0; index < doc.childCount; index += 1) {
|
|
130
|
+
const node = doc.child(index);
|
|
131
|
+
if (node.type.name === "globalContent") continue;
|
|
132
|
+
nonGlobalNodeCount += 1;
|
|
133
|
+
if (firstNonGlobalNode === null) firstNonGlobalNode = node;
|
|
134
|
+
}
|
|
135
|
+
if (nonGlobalNodeCount === 0) return true;
|
|
136
|
+
if (nonGlobalNodeCount !== 1) return false;
|
|
137
|
+
if (firstNonGlobalNode.type.name === "container") return hasOnlyEmptyParagraph(firstNonGlobalNode);
|
|
138
|
+
return isEmptyParagraph(firstNonGlobalNode);
|
|
139
|
+
}
|
|
140
|
+
function hasOnlyEmptyParagraph(node) {
|
|
141
|
+
if (node.childCount === 0) return true;
|
|
142
|
+
if (node.childCount !== 1) return false;
|
|
143
|
+
return isEmptyParagraph(node.child(0));
|
|
144
|
+
}
|
|
145
|
+
function isEmptyParagraph(node) {
|
|
146
|
+
return node.type.name === "paragraph" && node.content.size === 0;
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { composeReactEmail as n, EmailMark as r, isDocumentVisuallyEmpty as t };
|
|
150
|
+
|
|
151
|
+
//# sourceMappingURL=core-CbSTyrV4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-CbSTyrV4.mjs","names":[],"sources":["../src/core/serializer/default-base-template.tsx","../src/core/serializer/email-mark.ts","../src/core/serializer/compose-react-email.tsx","../src/core/is-document-visually-empty.ts"],"sourcesContent":["import type * as React from 'react';\nimport { Body, Head, Html, Preview } from 'react-email';\n\ntype BaseTemplateProps = {\n children: React.ReactNode;\n previewText?: string;\n};\n\nexport function DefaultBaseTemplate({\n children,\n previewText,\n}: BaseTemplateProps) {\n return (\n <Html>\n <Head>\n <meta content=\"width=device-width\" name=\"viewport\" />\n <meta content=\"IE=edge\" httpEquiv=\"X-UA-Compatible\" />\n <meta name=\"x-apple-disable-message-reformatting\" />\n <meta\n content=\"telephone=no,address=no,email=no,date=no,url=no\"\n name=\"format-detection\"\n />\n </Head>\n {previewText && previewText !== '' && <Preview>{previewText}</Preview>}\n\n <Body>{children}</Body>\n </Html>\n );\n}\n","import {\n type Editor,\n type JSONContent,\n Mark,\n type MarkConfig,\n type MarkType,\n} from '@tiptap/core';\n\nexport type SerializedMark = NonNullable<JSONContent['marks']>[number];\n\nexport type MarkRendererComponent = (props: {\n mark: SerializedMark;\n node: JSONContent;\n style: React.CSSProperties;\n children?: React.ReactNode;\n\n extension: EmailMark<any, any>;\n}) => React.ReactNode;\n\nexport interface EmailMarkConfig<Options, Storage>\n extends MarkConfig<Options, Storage> {\n renderToReactEmail: MarkRendererComponent;\n}\n\ntype ConfigParameter<Options, Storage> = Partial<\n Omit<EmailMarkConfig<Options, Storage>, 'renderToReactEmail'>\n> &\n Pick<EmailMarkConfig<Options, Storage>, 'renderToReactEmail'> &\n ThisType<{\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: MarkType;\n parent: (...args: any[]) => any;\n }>;\n\nexport class EmailMark<\n Options = Record<string, never>,\n Storage = Record<string, never>,\n> extends Mark<Options, Storage> {\n declare config: EmailMarkConfig<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 Mark instance\n * @param config - Mark 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 const resolvedConfig = typeof config === 'function' ? config() : config;\n return new EmailMark<O, S>(resolvedConfig);\n }\n\n static from<O, S>(\n mark: Mark<O, S>,\n renderToReactEmail: MarkRendererComponent,\n ): EmailMark<O, S> {\n const customMark = EmailMark.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(customMark, { ...mark });\n customMark.config = { ...mark.config, renderToReactEmail };\n return customMark;\n }\n\n // Subclass return types for configure/extend; safe at runtime. TipTap's Mark typings cause TS2416 when returning EmailMark.\n // @ts-expect-error - EmailMark is a valid Mark subclass; base typings don't support subclass return types\n configure(options?: Partial<Options>) {\n return super.configure(options) as EmailMark<Options, Storage>;\n }\n\n // @ts-expect-error - same as configure: extend returns EmailMark for chaining; base typings are incompatible\n extend<\n ExtendedOptions = Options,\n ExtendedStorage = Storage,\n ExtendedConfig extends MarkConfig<\n ExtendedOptions,\n ExtendedStorage\n > = EmailMarkConfig<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: MarkType;\n }>),\n ): EmailMark<ExtendedOptions, ExtendedStorage> {\n const resolvedConfig =\n typeof extendedConfig === 'function' ? extendedConfig() : extendedConfig;\n return super.extend(resolvedConfig) as EmailMark<\n ExtendedOptions,\n ExtendedStorage\n >;\n }\n}\n","import type { Editor, JSONContent } from '@tiptap/core';\nimport type { MarkType, Schema } from '@tiptap/pm/model';\nimport { pretty, render, toPlainText } from 'react-email';\nimport { inlineCssToJs } from '../../utils/styles';\nimport { DefaultBaseTemplate } from './default-base-template';\nimport { EmailMark } from './email-mark';\nimport { EmailNode } from './email-node';\nimport type { SerializerPlugin } from './serializer-plugin';\n\nconst NODES_WITH_INCREMENTED_CHILD_DEPTH = new Set([\n 'bulletList',\n 'orderedList',\n]);\n\n/**\n * ProseMirror assigns each mark type a numeric `rank` at schema compile time; the public\n * `MarkType` typings omit it, but it exists at runtime (see prosemirror-model `MarkType.compile`).\n */\ntype MarkTypeWithRank = MarkType & { rank: number };\n\nfunction getMarkRank(schema: Schema, markName: string): number {\n const markType = schema.marks[markName] as MarkTypeWithRank | undefined;\n return markType?.rank ?? Number.MAX_SAFE_INTEGER;\n}\n\n/** Sort marks by schema rank (Tiptap extension priority → ProseMirror order). */\nfunction sortMarksBySchema(\n marks: NonNullable<JSONContent['marks']>,\n schema: Schema,\n): NonNullable<JSONContent['marks']> {\n return [...marks].sort(\n (a, b) => getMarkRank(schema, b.type) - getMarkRank(schema, a.type),\n );\n}\n\ninterface ComposeReactEmailResult {\n html: string;\n text: string;\n}\n\nexport const composeReactEmail = async ({\n editor,\n preview,\n}: {\n editor: Editor;\n preview?: string;\n}): Promise<ComposeReactEmailResult> => {\n const data = editor.getJSON();\n const extensions = editor.extensionManager.extensions;\n\n const serializerPlugin = extensions\n .map(\n (ext) =>\n (ext as { options?: { serializerPlugin?: SerializerPlugin } }).options\n ?.serializerPlugin,\n )\n .filter((p) => Boolean(p))\n .at(-1);\n\n const typeToExtensionMap = Object.fromEntries(\n extensions.map((extension) => [extension.name, extension]),\n );\n\n function parseContent(content: JSONContent[] | undefined, depth = 0) {\n if (!content) {\n return;\n }\n\n return content.map((node: JSONContent, index: number) => {\n const style = serializerPlugin?.getNodeStyles(node, depth, editor) ?? {};\n\n const inlineStyles = inlineCssToJs(node.attrs?.style);\n\n if (!node.type) {\n return null;\n }\n\n const emailNode = typeToExtensionMap[node.type];\n if (!emailNode || !(emailNode instanceof EmailNode)) {\n return null;\n }\n\n const NodeComponent = emailNode.config.renderToReactEmail;\n const childDepth = NODES_WITH_INCREMENTED_CHILD_DEPTH.has(node.type)\n ? depth + 1\n : depth;\n\n let renderedNode: React.ReactNode = node.text ? (\n node.text\n ) : (\n <NodeComponent\n key={index}\n node={\n node.type === 'table' && inlineStyles.width && !node.attrs?.width\n ? {\n ...node,\n attrs: { ...node.attrs, width: inlineStyles.width },\n }\n : node\n }\n style={style}\n extension={emailNode}\n >\n {parseContent(node.content, childDepth)}\n </NodeComponent>\n );\n if (node.marks) {\n for (const mark of sortMarksBySchema(node.marks, editor.schema)) {\n const emailMark = typeToExtensionMap[mark.type];\n if (emailMark instanceof EmailMark) {\n const MarkComponent = emailMark.config.renderToReactEmail;\n const markStyle =\n serializerPlugin?.getNodeStyles(\n {\n type: mark.type,\n attrs: mark.attrs ?? {},\n },\n depth,\n editor,\n ) ?? {};\n renderedNode = (\n <MarkComponent\n mark={mark}\n node={node}\n style={markStyle}\n extension={emailMark}\n >\n {renderedNode}\n </MarkComponent>\n );\n }\n }\n }\n\n return renderedNode;\n });\n }\n\n const BaseTemplate = serializerPlugin?.BaseTemplate ?? DefaultBaseTemplate;\n\n const parsedContent = parseContent(data.content);\n const unformattedHtml = await render(\n <BaseTemplate previewText={preview} editor={editor}>\n {parsedContent}\n </BaseTemplate>,\n );\n\n const [prettyHtml, text] = await Promise.all([\n pretty(unformattedHtml),\n toPlainText(unformattedHtml),\n ]);\n\n return { html: prettyHtml, text };\n};\n","import type { Node } from '@tiptap/pm/model';\n\nexport function isDocumentVisuallyEmpty(doc: Node): boolean {\n let nonGlobalNodeCount = 0;\n let firstNonGlobalNode: Node | null = null;\n\n for (let index = 0; index < doc.childCount; index += 1) {\n const node = doc.child(index);\n\n if (node.type.name === 'globalContent') {\n continue;\n }\n\n nonGlobalNodeCount += 1;\n\n if (firstNonGlobalNode === null) {\n firstNonGlobalNode = node;\n }\n }\n\n if (nonGlobalNodeCount === 0) {\n return true;\n }\n\n if (nonGlobalNodeCount !== 1) {\n return false;\n }\n\n if (firstNonGlobalNode!.type.name === 'container') {\n return hasOnlyEmptyParagraph(firstNonGlobalNode!);\n }\n\n return isEmptyParagraph(firstNonGlobalNode!);\n}\n\nfunction hasOnlyEmptyParagraph(node: Node): boolean {\n if (node.childCount === 0) {\n return true;\n }\n\n if (node.childCount !== 1) {\n return false;\n }\n\n return isEmptyParagraph(node.child(0));\n}\n\nfunction isEmptyParagraph(node: Node): boolean {\n return node.type.name === 'paragraph' && node.content.size === 0;\n}\n"],"mappings":";;;;;AAQA,SAAgB,oBAAoB,EAClC,UACA,eACoB;AACpB,QACE,qBAAC,MAAD,EAAA,UAAA;EACE,qBAAC,MAAD,EAAA,UAAA;GACE,oBAAC,QA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MACa,CAAA;;;AAMxB,UAAO;IACP;;CAMJ,MAAM,kBAAkB,MAAM,OAC5B,oBAJmB,kBAAkB,gBAAgB,qBAIrD;EAAc,aAAa;EAAiB;YAFxB,aAAa,KAAK,QAAQ;EAI/B,CAAA,CAChB;CAED,MAAM,CAAC,YAAY,QAAQ,MAAM,QAAQ,IAAI,CAC3C,OAAO,gBAAgB,EACvB,YAAY,gBAAgB,CAC7B,CAAC;AAEF,QAAO;EAAE,MAAM;EAAY;EAAM;;;;ACtJnC,SAAgB,wBAAwB,KAAoB;CAC1D,IAAI,qBAAqB;CACzB,IAAI,qBAAkC;AAEtC,MAAK,IAAI,QAAQ,GAAG,QAAQ,IAAI,YAAY,SAAS,GAAG;EACtD,MAAM,OAAO,IAAI,MAAM,MAAM;AAE7B,MAAI,KAAK,KAAK,SAAS,gBACrB;AAGF,wBAAsB;AAEtB,MAAI,uBAAuB,KACzB,sBAAqB;;AAIzB,KAAI,uBAAuB,EACzB,QAAO;AAGT,KAAI,uBAAuB,EACzB,QAAO;AAGT,KAAI,mBAAoB,KAAK,SAAS,YACpC,QAAO,sBAAsB,mBAAoB;AAGnD,QAAO,iBAAiB,mBAAoB;;AAG9C,SAAS,sBAAsB,MAAqB;AAClD,KAAI,KAAK,eAAe,EACtB,QAAO;AAGT,KAAI,KAAK,eAAe,EACtB,QAAO;AAGT,QAAO,iBAAiB,KAAK,MAAM,EAAE,CAAC;;AAGxC,SAAS,iBAAiB,MAAqB;AAC7C,QAAO,KAAK,KAAK,SAAS,eAAe,KAAK,QAAQ,SAAS"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
require("./columns-DqFvXgmK.cjs");
|
|
2
|
+
const require_email_node = require("./email-node-hLU5bGnX.cjs");
|
|
3
|
+
let react_email = require("react-email");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
let _tiptap_core = require("@tiptap/core");
|
|
6
|
+
//#region src/core/serializer/default-base-template.tsx
|
|
7
|
+
function DefaultBaseTemplate({ children, previewText }) {
|
|
8
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_email.Html, { children: [
|
|
9
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_email.Head, { children: [
|
|
10
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
|
|
11
|
+
content: "width=device-width",
|
|
12
|
+
name: "viewport"
|
|
13
|
+
}),
|
|
14
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
|
|
15
|
+
content: "IE=edge",
|
|
16
|
+
httpEquiv: "X-UA-Compatible"
|
|
17
|
+
}),
|
|
18
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", { name: "x-apple-disable-message-reformatting" }),
|
|
19
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("meta", {
|
|
20
|
+
content: "telephone=no,address=no,email=no,date=no,url=no",
|
|
21
|
+
name: "format-detection"
|
|
22
|
+
})
|
|
23
|
+
] }),
|
|
24
|
+
previewText && previewText !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_email.Preview, { children: previewText }),
|
|
25
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_email.Body, { children })
|
|
26
|
+
] });
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/core/serializer/email-mark.ts
|
|
30
|
+
var EmailMark = class EmailMark extends _tiptap_core.Mark {
|
|
31
|
+
constructor(config) {
|
|
32
|
+
super(config);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a new Mark instance
|
|
36
|
+
* @param config - Mark configuration object or a function that returns a configuration object
|
|
37
|
+
*/
|
|
38
|
+
static create(config) {
|
|
39
|
+
return new EmailMark(typeof config === "function" ? config() : config);
|
|
40
|
+
}
|
|
41
|
+
static from(mark, renderToReactEmail) {
|
|
42
|
+
const customMark = EmailMark.create({});
|
|
43
|
+
Object.assign(customMark, { ...mark });
|
|
44
|
+
customMark.config = {
|
|
45
|
+
...mark.config,
|
|
46
|
+
renderToReactEmail
|
|
47
|
+
};
|
|
48
|
+
return customMark;
|
|
49
|
+
}
|
|
50
|
+
configure(options) {
|
|
51
|
+
return super.configure(options);
|
|
52
|
+
}
|
|
53
|
+
extend(extendedConfig) {
|
|
54
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
55
|
+
return super.extend(resolvedConfig);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/core/serializer/compose-react-email.tsx
|
|
60
|
+
const NODES_WITH_INCREMENTED_CHILD_DEPTH = new Set(["bulletList", "orderedList"]);
|
|
61
|
+
function getMarkRank(schema, markName) {
|
|
62
|
+
return schema.marks[markName]?.rank ?? Number.MAX_SAFE_INTEGER;
|
|
63
|
+
}
|
|
64
|
+
/** Sort marks by schema rank (Tiptap extension priority → ProseMirror order). */
|
|
65
|
+
function sortMarksBySchema(marks, schema) {
|
|
66
|
+
return [...marks].sort((a, b) => getMarkRank(schema, b.type) - getMarkRank(schema, a.type));
|
|
67
|
+
}
|
|
68
|
+
const composeReactEmail = async ({ editor, preview }) => {
|
|
69
|
+
const data = editor.getJSON();
|
|
70
|
+
const extensions = editor.extensionManager.extensions;
|
|
71
|
+
const serializerPlugin = extensions.map((ext) => ext.options?.serializerPlugin).filter((p) => Boolean(p)).at(-1);
|
|
72
|
+
const typeToExtensionMap = Object.fromEntries(extensions.map((extension) => [extension.name, extension]));
|
|
73
|
+
function parseContent(content, depth = 0) {
|
|
74
|
+
if (!content) return;
|
|
75
|
+
return content.map((node, index) => {
|
|
76
|
+
const style = serializerPlugin?.getNodeStyles(node, depth, editor) ?? {};
|
|
77
|
+
const inlineStyles = require_email_node.inlineCssToJs(node.attrs?.style);
|
|
78
|
+
if (!node.type) return null;
|
|
79
|
+
const emailNode = typeToExtensionMap[node.type];
|
|
80
|
+
if (!emailNode || !(emailNode instanceof require_email_node.EmailNode)) return null;
|
|
81
|
+
const NodeComponent = emailNode.config.renderToReactEmail;
|
|
82
|
+
const childDepth = NODES_WITH_INCREMENTED_CHILD_DEPTH.has(node.type) ? depth + 1 : depth;
|
|
83
|
+
let renderedNode = node.text ? node.text : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeComponent, {
|
|
84
|
+
node: node.type === "table" && inlineStyles.width && !node.attrs?.width ? {
|
|
85
|
+
...node,
|
|
86
|
+
attrs: {
|
|
87
|
+
...node.attrs,
|
|
88
|
+
width: inlineStyles.width
|
|
89
|
+
}
|
|
90
|
+
} : node,
|
|
91
|
+
style,
|
|
92
|
+
extension: emailNode,
|
|
93
|
+
children: parseContent(node.content, childDepth)
|
|
94
|
+
}, index);
|
|
95
|
+
if (node.marks) for (const mark of sortMarksBySchema(node.marks, editor.schema)) {
|
|
96
|
+
const emailMark = typeToExtensionMap[mark.type];
|
|
97
|
+
if (emailMark instanceof EmailMark) {
|
|
98
|
+
const MarkComponent = emailMark.config.renderToReactEmail;
|
|
99
|
+
renderedNode = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MarkComponent, {
|
|
100
|
+
mark,
|
|
101
|
+
node,
|
|
102
|
+
style: serializerPlugin?.getNodeStyles({
|
|
103
|
+
type: mark.type,
|
|
104
|
+
attrs: mark.attrs ?? {}
|
|
105
|
+
}, depth, editor) ?? {},
|
|
106
|
+
extension: emailMark,
|
|
107
|
+
children: renderedNode
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return renderedNode;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const unformattedHtml = await (0, react_email.render)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(serializerPlugin?.BaseTemplate ?? DefaultBaseTemplate, {
|
|
115
|
+
previewText: preview,
|
|
116
|
+
editor,
|
|
117
|
+
children: parseContent(data.content)
|
|
118
|
+
}));
|
|
119
|
+
const [prettyHtml, text] = await Promise.all([(0, react_email.pretty)(unformattedHtml), (0, react_email.toPlainText)(unformattedHtml)]);
|
|
120
|
+
return {
|
|
121
|
+
html: prettyHtml,
|
|
122
|
+
text
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/core/is-document-visually-empty.ts
|
|
127
|
+
function isDocumentVisuallyEmpty(doc) {
|
|
128
|
+
let nonGlobalNodeCount = 0;
|
|
129
|
+
let firstNonGlobalNode = null;
|
|
130
|
+
for (let index = 0; index < doc.childCount; index += 1) {
|
|
131
|
+
const node = doc.child(index);
|
|
132
|
+
if (node.type.name === "globalContent") continue;
|
|
133
|
+
nonGlobalNodeCount += 1;
|
|
134
|
+
if (firstNonGlobalNode === null) firstNonGlobalNode = node;
|
|
135
|
+
}
|
|
136
|
+
if (nonGlobalNodeCount === 0) return true;
|
|
137
|
+
if (nonGlobalNodeCount !== 1) return false;
|
|
138
|
+
if (firstNonGlobalNode.type.name === "container") return hasOnlyEmptyParagraph(firstNonGlobalNode);
|
|
139
|
+
return isEmptyParagraph(firstNonGlobalNode);
|
|
140
|
+
}
|
|
141
|
+
function hasOnlyEmptyParagraph(node) {
|
|
142
|
+
if (node.childCount === 0) return true;
|
|
143
|
+
if (node.childCount !== 1) return false;
|
|
144
|
+
return isEmptyParagraph(node.child(0));
|
|
145
|
+
}
|
|
146
|
+
function isEmptyParagraph(node) {
|
|
147
|
+
return node.type.name === "paragraph" && node.content.size === 0;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
Object.defineProperty(exports, "EmailMark", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function() {
|
|
153
|
+
return EmailMark;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "composeReactEmail", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function() {
|
|
159
|
+
return composeReactEmail;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(exports, "isDocumentVisuallyEmpty", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function() {
|
|
165
|
+
return isDocumentVisuallyEmpty;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
|
+
//#region src/utils/styles.ts
|
|
3
|
+
const WHITE_SPACE_REGEX = /\s+/;
|
|
4
|
+
const BORDER_WIDTH_TO_STYLE = {
|
|
5
|
+
borderWidth: "borderStyle",
|
|
6
|
+
borderTopWidth: "borderTopStyle",
|
|
7
|
+
borderRightWidth: "borderRightStyle",
|
|
8
|
+
borderBottomWidth: "borderBottomStyle",
|
|
9
|
+
borderLeftWidth: "borderLeftStyle"
|
|
10
|
+
};
|
|
11
|
+
const jsToInlineCss = (styleObject) => {
|
|
12
|
+
const parts = [];
|
|
13
|
+
for (const key in styleObject) {
|
|
14
|
+
const value = styleObject[key];
|
|
15
|
+
if (value !== 0 && value !== void 0 && value !== null && value !== "") {
|
|
16
|
+
const formattedKey = key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
17
|
+
parts.push(`${formattedKey}:${value}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return parts.join(";") + (parts.length ? ";" : "");
|
|
21
|
+
};
|
|
22
|
+
const splitDeclarations = (input) => {
|
|
23
|
+
const results = [];
|
|
24
|
+
let current = "";
|
|
25
|
+
let depth = 0;
|
|
26
|
+
for (const char of input) {
|
|
27
|
+
if (char === "(") depth++;
|
|
28
|
+
if (char === ")") depth--;
|
|
29
|
+
if (char === ";" && depth === 0) {
|
|
30
|
+
results.push(current);
|
|
31
|
+
current = "";
|
|
32
|
+
} else current += char;
|
|
33
|
+
}
|
|
34
|
+
if (current) results.push(current);
|
|
35
|
+
return results;
|
|
36
|
+
};
|
|
37
|
+
const inlineCssToJs = (inlineStyle, options = {}) => {
|
|
38
|
+
const styleObject = {};
|
|
39
|
+
if (!inlineStyle || inlineStyle === "" || typeof inlineStyle === "object") return styleObject;
|
|
40
|
+
splitDeclarations(inlineStyle).forEach((style) => {
|
|
41
|
+
const trimmed = style.trim();
|
|
42
|
+
if (trimmed) {
|
|
43
|
+
const separatorIndex = trimmed.indexOf(":");
|
|
44
|
+
if (separatorIndex === -1) return;
|
|
45
|
+
const key = trimmed.slice(0, separatorIndex);
|
|
46
|
+
const valueTrimmed = trimmed.slice(separatorIndex + 1).trim();
|
|
47
|
+
if (!valueTrimmed) return;
|
|
48
|
+
const formattedKey = key.trim().replace(/-\w/g, (match) => match[1].toUpperCase());
|
|
49
|
+
styleObject[formattedKey] = options?.removeUnit ? valueTrimmed.replace(/px|%/g, "") : valueTrimmed;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return styleObject;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Expands CSS shorthand properties (margin, padding) into their longhand equivalents.
|
|
56
|
+
* This prevents shorthand properties from overriding specific longhand properties in email clients.
|
|
57
|
+
*
|
|
58
|
+
* @param styles - Style object that may contain shorthand properties
|
|
59
|
+
* @returns New style object with shorthand properties expanded to longhand
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* expandShorthandProperties({ margin: '0', paddingTop: '10px' })
|
|
63
|
+
* // Returns: { marginTop: '0', marginRight: '0', marginBottom: '0', marginLeft: '0', paddingTop: '10px' }
|
|
64
|
+
*/
|
|
65
|
+
function expandShorthandProperties(styles) {
|
|
66
|
+
if (!styles || typeof styles !== "object") return {};
|
|
67
|
+
const expanded = {};
|
|
68
|
+
for (const key in styles) {
|
|
69
|
+
const value = styles[key];
|
|
70
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
71
|
+
switch (key) {
|
|
72
|
+
case "margin": {
|
|
73
|
+
const values = parseShorthandValue(value);
|
|
74
|
+
expanded.marginTop = values.top;
|
|
75
|
+
expanded.marginRight = values.right;
|
|
76
|
+
expanded.marginBottom = values.bottom;
|
|
77
|
+
expanded.marginLeft = values.left;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case "padding": {
|
|
81
|
+
const values = parseShorthandValue(value);
|
|
82
|
+
expanded.paddingTop = values.top;
|
|
83
|
+
expanded.paddingRight = values.right;
|
|
84
|
+
expanded.paddingBottom = values.bottom;
|
|
85
|
+
expanded.paddingLeft = values.left;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "border": {
|
|
89
|
+
const values = convertBorderValue(value);
|
|
90
|
+
expanded.borderStyle = values.style;
|
|
91
|
+
expanded.borderWidth = values.width;
|
|
92
|
+
expanded.borderColor = values.color;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
case "borderTopLeftRadius":
|
|
96
|
+
case "borderTopRightRadius":
|
|
97
|
+
case "borderBottomLeftRadius":
|
|
98
|
+
case "borderBottomRightRadius":
|
|
99
|
+
expanded[key] = value;
|
|
100
|
+
if (styles.borderTopLeftRadius && styles.borderTopRightRadius && styles.borderBottomLeftRadius && styles.borderBottomRightRadius) {
|
|
101
|
+
const values = [
|
|
102
|
+
styles.borderTopLeftRadius,
|
|
103
|
+
styles.borderTopRightRadius,
|
|
104
|
+
styles.borderBottomLeftRadius,
|
|
105
|
+
styles.borderBottomRightRadius
|
|
106
|
+
];
|
|
107
|
+
if (new Set(values).size === 1) expanded.borderRadius = values[0];
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
default: expanded[key] = value;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return expanded;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Parses CSS shorthand value (1-4 values) into individual side values.
|
|
117
|
+
* Follows CSS specification for shorthand property value parsing.
|
|
118
|
+
*
|
|
119
|
+
* @param value - Shorthand value string (e.g., '0', '10px 20px', '5px 10px 15px 20px')
|
|
120
|
+
* @returns Object with top, right, bottom, left values
|
|
121
|
+
*/
|
|
122
|
+
function parseShorthandValue(value) {
|
|
123
|
+
const stringValue = String(value).trim();
|
|
124
|
+
const parts = stringValue.split(WHITE_SPACE_REGEX);
|
|
125
|
+
const len = parts.length;
|
|
126
|
+
if (len === 1) return {
|
|
127
|
+
top: parts[0],
|
|
128
|
+
right: parts[0],
|
|
129
|
+
bottom: parts[0],
|
|
130
|
+
left: parts[0]
|
|
131
|
+
};
|
|
132
|
+
if (len === 2) return {
|
|
133
|
+
top: parts[0],
|
|
134
|
+
right: parts[1],
|
|
135
|
+
bottom: parts[0],
|
|
136
|
+
left: parts[1]
|
|
137
|
+
};
|
|
138
|
+
if (len === 3) return {
|
|
139
|
+
top: parts[0],
|
|
140
|
+
right: parts[1],
|
|
141
|
+
bottom: parts[2],
|
|
142
|
+
left: parts[1]
|
|
143
|
+
};
|
|
144
|
+
if (len === 4) return {
|
|
145
|
+
top: parts[0],
|
|
146
|
+
right: parts[1],
|
|
147
|
+
bottom: parts[2],
|
|
148
|
+
left: parts[3]
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
top: stringValue,
|
|
152
|
+
right: stringValue,
|
|
153
|
+
bottom: stringValue,
|
|
154
|
+
left: stringValue
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function convertBorderValue(value) {
|
|
158
|
+
const stringValue = String(value).trim();
|
|
159
|
+
const parts = stringValue.split(WHITE_SPACE_REGEX);
|
|
160
|
+
switch (parts.length) {
|
|
161
|
+
case 1: return {
|
|
162
|
+
style: "solid",
|
|
163
|
+
width: parts[0],
|
|
164
|
+
color: "black"
|
|
165
|
+
};
|
|
166
|
+
case 2: return {
|
|
167
|
+
style: parts[1],
|
|
168
|
+
width: parts[0],
|
|
169
|
+
color: "black"
|
|
170
|
+
};
|
|
171
|
+
case 3: return {
|
|
172
|
+
style: parts[1],
|
|
173
|
+
width: parts[0],
|
|
174
|
+
color: parts[2]
|
|
175
|
+
};
|
|
176
|
+
case 4: return {
|
|
177
|
+
style: parts[1],
|
|
178
|
+
width: parts[0],
|
|
179
|
+
color: parts[2]
|
|
180
|
+
};
|
|
181
|
+
default: return {
|
|
182
|
+
style: "solid",
|
|
183
|
+
width: stringValue,
|
|
184
|
+
color: "black"
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* When a border-width is present but border-style is missing, browsers default
|
|
190
|
+
* to `none` and the border is invisible. This adds `solid` as a sensible
|
|
191
|
+
* fallback so borders show up immediately after setting a width.
|
|
192
|
+
*/
|
|
193
|
+
function ensureBorderStyleFallback(styles) {
|
|
194
|
+
for (const [widthKey, styleKey] of Object.entries(BORDER_WIDTH_TO_STYLE)) {
|
|
195
|
+
const widthValue = styles[widthKey];
|
|
196
|
+
if (!widthValue || widthValue === "0" || widthValue === "0px") continue;
|
|
197
|
+
if (!styles[styleKey]) {
|
|
198
|
+
if (styleKey !== "borderStyle" && styles.borderStyle) continue;
|
|
199
|
+
styles[styleKey] = "solid";
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return styles;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Resolves conflicts between reset styles and inline styles by expanding
|
|
206
|
+
* shorthand properties (margin, padding) to longhand before merging.
|
|
207
|
+
* This prevents shorthand properties from overriding specific longhand properties.
|
|
208
|
+
*
|
|
209
|
+
* @param resetStyles - Base reset styles that may contain shorthand properties
|
|
210
|
+
* @param inlineStyles - Inline styles that should override reset styles
|
|
211
|
+
* @returns Merged styles with inline styles taking precedence
|
|
212
|
+
*/
|
|
213
|
+
function resolveConflictingStyles(resetStyles, inlineStyles) {
|
|
214
|
+
const expandedResetStyles = expandShorthandProperties(resetStyles);
|
|
215
|
+
const expandedInlineStyles = expandShorthandProperties(inlineStyles);
|
|
216
|
+
return {
|
|
217
|
+
...expandedResetStyles,
|
|
218
|
+
...expandedInlineStyles
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/core/serializer/email-node.ts
|
|
223
|
+
var EmailNode = class EmailNode extends Node {
|
|
224
|
+
constructor(config) {
|
|
225
|
+
super(config);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Create a new Node instance
|
|
229
|
+
* @param config - Node configuration object or a function that returns a configuration object
|
|
230
|
+
*/
|
|
231
|
+
static create(config) {
|
|
232
|
+
return new EmailNode(typeof config === "function" ? config() : config);
|
|
233
|
+
}
|
|
234
|
+
static from(node, renderToReactEmail) {
|
|
235
|
+
const customNode = EmailNode.create({});
|
|
236
|
+
Object.assign(customNode, { ...node });
|
|
237
|
+
customNode.config = {
|
|
238
|
+
...node.config,
|
|
239
|
+
renderToReactEmail
|
|
240
|
+
};
|
|
241
|
+
return customNode;
|
|
242
|
+
}
|
|
243
|
+
configure(options) {
|
|
244
|
+
return super.configure(options);
|
|
245
|
+
}
|
|
246
|
+
extend(extendedConfig) {
|
|
247
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
248
|
+
return super.extend(resolvedConfig);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
//#endregion
|
|
252
|
+
export { jsToInlineCss as a, inlineCssToJs as i, ensureBorderStyleFallback as n, resolveConflictingStyles as o, expandShorthandProperties as r, EmailNode as t };
|
|
253
|
+
|
|
254
|
+
//# sourceMappingURL=email-node-B-_g4X-S.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-node-B-_g4X-S.mjs","names":[],"sources":["../src/utils/styles.ts","../src/core/serializer/email-node.ts"],"sourcesContent":["import type { CssJs } from '../plugins/email-theming/types';\n\nconst WHITE_SPACE_REGEX = /\\s+/;\n\nconst BORDER_WIDTH_TO_STYLE: Record<string, string> = {\n borderWidth: 'borderStyle',\n borderTopWidth: 'borderTopStyle',\n borderRightWidth: 'borderRightStyle',\n borderBottomWidth: 'borderBottomStyle',\n borderLeftWidth: 'borderLeftStyle',\n};\n\nexport const jsToInlineCss = (styleObject: { [key: string]: any }) => {\n const parts: string[] = [];\n\n for (const key in styleObject) {\n const value = styleObject[key];\n if (value !== 0 && value !== undefined && value !== null && value !== '') {\n const KEBAB_CASE_REGEX = /[A-Z]/g;\n const formattedKey = key.replace(\n KEBAB_CASE_REGEX,\n (match) => `-${match.toLowerCase()}`,\n );\n parts.push(`${formattedKey}:${value}`);\n }\n }\n\n return parts.join(';') + (parts.length ? ';' : '');\n};\n\nconst splitDeclarations = (input: string): string[] => {\n const results: string[] = [];\n let current = '';\n let depth = 0;\n\n for (const char of input) {\n if (char === '(') depth++;\n if (char === ')') depth--;\n\n if (char === ';' && depth === 0) {\n results.push(current);\n current = '';\n } else {\n current += char;\n }\n }\n\n if (current) results.push(current);\n return results;\n};\n\nexport const inlineCssToJs = (\n inlineStyle: string,\n options: { removeUnit?: boolean } = {},\n) => {\n const styleObject: { [key: string]: string } = {};\n\n if (!inlineStyle || inlineStyle === '' || typeof inlineStyle === 'object') {\n return styleObject;\n }\n\n splitDeclarations(inlineStyle).forEach((style: string) => {\n const trimmed = style.trim();\n if (trimmed) {\n const separatorIndex = trimmed.indexOf(':');\n if (separatorIndex === -1) return;\n\n const key = trimmed.slice(0, separatorIndex);\n const value = trimmed.slice(separatorIndex + 1);\n const valueTrimmed = value.trim();\n\n if (!valueTrimmed) {\n return;\n }\n\n const formattedKey = key\n .trim()\n .replace(/-\\w/g, (match) => match[1].toUpperCase());\n\n const UNIT_REGEX = /px|%/g;\n const sanitizedValue = options?.removeUnit\n ? valueTrimmed.replace(UNIT_REGEX, '')\n : valueTrimmed;\n\n styleObject[formattedKey] = sanitizedValue;\n }\n });\n\n return styleObject;\n};\n\n/**\n * Expands CSS shorthand properties (margin, padding) into their longhand equivalents.\n * This prevents shorthand properties from overriding specific longhand properties in email clients.\n *\n * @param styles - Style object that may contain shorthand properties\n * @returns New style object with shorthand properties expanded to longhand\n *\n * @example\n * expandShorthandProperties({ margin: '0', paddingTop: '10px' })\n * // Returns: { marginTop: '0', marginRight: '0', marginBottom: '0', marginLeft: '0', paddingTop: '10px' }\n */\nexport function expandShorthandProperties(\n styles: Record<string, string>,\n): Record<string, string> {\n if (!styles || typeof styles !== 'object') {\n return {};\n }\n\n const expanded: Record<string, any> = {};\n\n for (const key in styles) {\n const value = styles[key];\n if (value === undefined || value === null || value === '') {\n continue;\n }\n\n switch (key) {\n case 'margin': {\n const values = parseShorthandValue(value);\n expanded.marginTop = values.top;\n expanded.marginRight = values.right;\n expanded.marginBottom = values.bottom;\n expanded.marginLeft = values.left;\n break;\n }\n case 'padding': {\n const values = parseShorthandValue(value);\n expanded.paddingTop = values.top;\n expanded.paddingRight = values.right;\n expanded.paddingBottom = values.bottom;\n expanded.paddingLeft = values.left;\n break;\n }\n case 'border': {\n const values = convertBorderValue(value);\n expanded.borderStyle = values.style;\n expanded.borderWidth = values.width;\n expanded.borderColor = values.color;\n break;\n }\n case 'borderTopLeftRadius':\n case 'borderTopRightRadius':\n case 'borderBottomLeftRadius':\n case 'borderBottomRightRadius': {\n // Always preserve the longhand property\n expanded[key] = value;\n\n // When all four corners are present and identical, also add the shorthand\n if (\n styles.borderTopLeftRadius &&\n styles.borderTopRightRadius &&\n styles.borderBottomLeftRadius &&\n styles.borderBottomRightRadius\n ) {\n const values = [\n styles.borderTopLeftRadius,\n styles.borderTopRightRadius,\n styles.borderBottomLeftRadius,\n styles.borderBottomRightRadius,\n ];\n\n if (new Set(values).size === 1) {\n expanded.borderRadius = values[0];\n }\n }\n\n break;\n }\n\n default: {\n // Keep all other properties as-is\n expanded[key] = value;\n }\n }\n }\n\n return expanded;\n}\n\n/**\n * Parses CSS shorthand value (1-4 values) into individual side values.\n * Follows CSS specification for shorthand property value parsing.\n *\n * @param value - Shorthand value string (e.g., '0', '10px 20px', '5px 10px 15px 20px')\n * @returns Object with top, right, bottom, left values\n */\nfunction parseShorthandValue(value: string | number): {\n top: string;\n right: string;\n bottom: string;\n left: string;\n} {\n const stringValue = String(value).trim();\n const parts = stringValue.split(WHITE_SPACE_REGEX);\n const len = parts.length;\n\n if (len === 1) {\n return { top: parts[0], right: parts[0], bottom: parts[0], left: parts[0] };\n }\n if (len === 2) {\n return { top: parts[0], right: parts[1], bottom: parts[0], left: parts[1] };\n }\n if (len === 3) {\n return { top: parts[0], right: parts[1], bottom: parts[2], left: parts[1] };\n }\n if (len === 4) {\n return { top: parts[0], right: parts[1], bottom: parts[2], left: parts[3] };\n }\n\n return {\n top: stringValue,\n right: stringValue,\n bottom: stringValue,\n left: stringValue,\n };\n}\n\nfunction convertBorderValue(value: string | number): {\n style: string;\n width: string;\n color: string;\n} {\n const stringValue = String(value).trim();\n const parts = stringValue.split(WHITE_SPACE_REGEX);\n\n switch (parts.length) {\n case 1:\n // border: 1px → all sides\n return {\n style: 'solid',\n width: parts[0],\n color: 'black',\n };\n case 2:\n // border: 1px solid → top/bottom, left/right\n return {\n style: parts[1],\n width: parts[0],\n color: 'black',\n };\n case 3:\n // border: 1px solid #000 → top, left/right, bottom\n return {\n style: parts[1],\n width: parts[0],\n color: parts[2],\n };\n case 4:\n // border: 1px solid #000 #fff → top, right, bottom, left\n return {\n style: parts[1],\n width: parts[0],\n color: parts[2],\n };\n default:\n // Invalid format, return the original value for all sides\n return {\n style: 'solid',\n width: stringValue,\n color: 'black',\n };\n }\n}\n\n/**\n * When a border-width is present but border-style is missing, browsers default\n * to `none` and the border is invisible. This adds `solid` as a sensible\n * fallback so borders show up immediately after setting a width.\n */\nexport function ensureBorderStyleFallback(\n styles: Record<string, string | number>,\n): Record<string, string | number> {\n for (const [widthKey, styleKey] of Object.entries(BORDER_WIDTH_TO_STYLE)) {\n const widthValue = styles[widthKey];\n if (!widthValue || widthValue === '0' || widthValue === '0px') {\n continue;\n }\n if (!styles[styleKey]) {\n // Keep shorthand borderStyle authoritative for each side when present.\n if (styleKey !== 'borderStyle' && styles.borderStyle) {\n continue;\n }\n styles[styleKey] = 'solid';\n }\n }\n return styles;\n}\n\n/**\n * Resolves conflicts between reset styles and inline styles by expanding\n * shorthand properties (margin, padding) to longhand before merging.\n * This prevents shorthand properties from overriding specific longhand properties.\n *\n * @param resetStyles - Base reset styles that may contain shorthand properties\n * @param inlineStyles - Inline styles that should override reset styles\n * @returns Merged styles with inline styles taking precedence\n */\nexport function resolveConflictingStyles(\n resetStyles: CssJs['reset'],\n inlineStyles: Record<string, string>,\n) {\n const expandedResetStyles = expandShorthandProperties(\n resetStyles as Record<string, string>,\n );\n const expandedInlineStyles = expandShorthandProperties(inlineStyles);\n\n return {\n ...expandedResetStyles,\n ...expandedInlineStyles,\n };\n}\n","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"],"mappings":";;AAEA,MAAM,oBAAoB;AAE1B,MAAM,wBAAgD;CACpD,aAAa;CACb,gBAAgB;CAChB,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CAClB;AAED,MAAa,iBAAiB,gBAAwC;CACpE,MAAM,QAAkB,EAAE;AAE1B,MAAK,MAAM,OAAO,aAAa;EAC7B,MAAM,QAAQ,YAAY;AAC1B,MAAI,UAAU,KAAK,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,IAAI;GAExE,MAAM,eAAe,IAAI,QADA,WAGtB,UAAU,IAAI,MAAM,aAAa,GACnC;AACD,SAAM,KAAK,GAAG,aAAa,GAAG,QAAQ;;;AAI1C,QAAO,MAAM,KAAK,IAAI,IAAI,MAAM,SAAS,MAAM;;AAGjD,MAAM,qB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