@react-email/editor 0.0.0-experimental.42 → 0.0.0-experimental.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.cjs +4 -3
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +3 -3
- package/dist/{create-paste-handler-CGR738bC.d.mts → create-paste-handler-DsJYKisA.d.mts} +1 -1
- package/dist/{create-paste-handler-CGR738bC.d.mts.map → create-paste-handler-DsJYKisA.d.mts.map} +1 -1
- package/dist/{event-bus-fb8U7hrl.cjs → event-bus-BJn1dJM1.cjs} +20 -3
- package/dist/{event-bus-CHEzOS_O.mjs → event-bus-DJpnfDHw.mjs} +14 -3
- package/dist/{event-bus-CHEzOS_O.mjs.map → event-bus-DJpnfDHw.mjs.map} +1 -1
- package/dist/{extension-D23sh0Nj.cjs → extension-CF0s-pGh.cjs} +298 -35
- package/dist/{extension-BZsTEb_s.mjs → extension-DcToBuV0.mjs} +298 -11
- package/dist/extension-DcToBuV0.mjs.map +1 -0
- package/dist/extensions/index.cjs +3 -3
- package/dist/extensions/index.d.cts +1 -1
- package/dist/extensions/index.d.cts.map +1 -1
- package/dist/extensions/index.d.mts +2 -2
- package/dist/extensions/index.d.mts.map +1 -1
- package/dist/extensions/index.mjs +3 -3
- package/dist/{extensions-wGY7l1wH.cjs → extensions-B6VCxUmi.cjs} +67 -25
- package/dist/{extensions-D-VkzZTa.mjs → extensions-mStGDfMH.mjs} +62 -20
- package/dist/extensions-mStGDfMH.mjs.map +1 -0
- package/dist/{styles-C-cCyJCn.cjs → global-content-C5WjNoMX.cjs} +88 -0
- package/dist/{styles-_TMw3YxC.mjs → global-content-CjA49_jE.mjs} +78 -2
- package/dist/global-content-CjA49_jE.mjs.map +1 -0
- package/dist/{index-C4KcMQ0R.d.cts → index-LCPnE_xx.d.cts} +66 -3
- package/dist/index-LCPnE_xx.d.cts.map +1 -0
- package/dist/{index-CxX7W63O.d.mts → index-i5JdL0UD.d.mts} +67 -4
- package/dist/index-i5JdL0UD.d.mts.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/plugins/index.cjs +1 -5
- package/dist/plugins/index.d.cts +5 -123
- package/dist/plugins/index.d.cts.map +1 -1
- package/dist/plugins/index.d.mts +5 -123
- package/dist/plugins/index.d.mts.map +1 -1
- package/dist/plugins/index.mjs +2 -2
- package/dist/{root-pS4l8bVZ.mjs → root-BVs63m-4.mjs} +39 -39
- package/dist/root-BVs63m-4.mjs.map +1 -0
- package/dist/{root-Jq1R3tkX.cjs → root-D6lslKju.cjs} +2 -2
- package/dist/{set-text-alignment-OA8IMWmO.mjs → set-text-alignment-GMXOPMlJ.mjs} +1 -1
- package/dist/{set-text-alignment-OA8IMWmO.mjs.map → set-text-alignment-GMXOPMlJ.mjs.map} +1 -1
- package/dist/types-BNEbRz-a.d.cts +47 -0
- package/dist/types-BNEbRz-a.d.cts.map +1 -0
- package/dist/types-C8k-blF7.d.mts +47 -0
- package/dist/types-C8k-blF7.d.mts.map +1 -0
- package/dist/ui/index.cjs +645 -2
- package/dist/ui/index.d.cts +307 -128
- package/dist/ui/index.d.cts.map +1 -1
- package/dist/ui/index.d.mts +307 -128
- package/dist/ui/index.d.mts.map +1 -1
- package/dist/ui/index.mjs +630 -3
- 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 +2 -2
- package/dist/extension-BZsTEb_s.mjs.map +0 -1
- package/dist/extensions-D-VkzZTa.mjs.map +0 -1
- package/dist/global-content-D_WYaFgX.mjs +0 -78
- package/dist/global-content-D_WYaFgX.mjs.map +0 -1
- package/dist/global-content-bJgotqmA.cjs +0 -89
- package/dist/index-C4KcMQ0R.d.cts.map +0 -1
- package/dist/index-CxX7W63O.d.mts.map +0 -1
- package/dist/root-pS4l8bVZ.mjs.map +0 -1
- package/dist/styles-_TMw3YxC.mjs.map +0 -1
- /package/dist/{set-text-alignment-Cv72txmv.cjs → set-text-alignment-aNb7Ml9N.cjs} +0 -0
package/dist/core/index.cjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
const require_event_bus = require('../event-bus-
|
|
2
|
-
const require_extensions = require('../extensions-
|
|
1
|
+
const require_event_bus = require('../event-bus-BJn1dJM1.cjs');
|
|
2
|
+
const require_extensions = require('../extensions-B6VCxUmi.cjs');
|
|
3
3
|
|
|
4
4
|
exports.EmailMark = require_extensions.EmailMark;
|
|
5
5
|
exports.EmailNode = require_event_bus.EmailNode;
|
|
6
6
|
exports.composeReactEmail = require_extensions.composeReactEmail;
|
|
7
7
|
exports.editorEventBus = require_event_bus.editorEventBus;
|
|
8
8
|
exports.isDocumentVisuallyEmpty = require_extensions.isDocumentVisuallyEmpty;
|
|
9
|
-
exports.useEditor = require_extensions.useEditor;
|
|
9
|
+
exports.useEditor = require_extensions.useEditor;
|
|
10
|
+
exports.useEditorEvent = require_event_bus.useEditorEvent;
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { EditorEventHandler, EditorEventMap, EditorEventName, EditorEventSubscription, EmailMark, EmailMarkConfig, EmailNode, EmailNodeConfig, MarkRendererComponent, NodeRendererComponent, SerializedMark, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditor };
|
|
1
|
+
import { S as useEditorEvent, _ as EditorEventHandler, a as EventSubscription, b as EditorEventSubscription, c as EmailNode, d as EmailMark, f as EmailMarkConfig, g as isDocumentVisuallyEmpty, h as composeReactEmail, i as EventHandler, l as EmailNodeConfig, m as SerializedMark, n as CustomPlaceholder, o as NodeClickedEvent, p as MarkRendererComponent, r as DispatchOptions, s as PlaceholderItem, t as useEditor, u as NodeRendererComponent, v as EditorEventMap, x as editorEventBus, y as EditorEventName } from "../index-LCPnE_xx.cjs";
|
|
2
|
+
export { CustomPlaceholder, DispatchOptions, EditorEventHandler, EditorEventMap, EditorEventName, EditorEventSubscription, EmailMark, EmailMarkConfig, EmailNode, EmailNodeConfig, EventHandler, EventSubscription, MarkRendererComponent, NodeClickedEvent, NodeRendererComponent, PlaceholderItem, SerializedMark, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditor, useEditorEvent };
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import "../create-paste-handler-
|
|
3
|
-
export { EditorEventHandler, EditorEventMap, EditorEventName, EditorEventSubscription, EmailMark, EmailMarkConfig, EmailNode, EmailNodeConfig, MarkRendererComponent, NodeRendererComponent, SerializedMark, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditor };
|
|
1
|
+
import { S as useEditorEvent, _ as EditorEventHandler, a as EventSubscription, b as EditorEventSubscription, c as EmailNode, d as EmailMark, f as EmailMarkConfig, g as isDocumentVisuallyEmpty, h as composeReactEmail, i as EventHandler, l as EmailNodeConfig, m as SerializedMark, n as CustomPlaceholder, o as NodeClickedEvent, p as MarkRendererComponent, r as DispatchOptions, s as PlaceholderItem, t as useEditor, u as NodeRendererComponent, v as EditorEventMap, x as editorEventBus, y as EditorEventName } from "../index-i5JdL0UD.mjs";
|
|
2
|
+
import "../create-paste-handler-DsJYKisA.mjs";
|
|
3
|
+
export { CustomPlaceholder, DispatchOptions, EditorEventHandler, EditorEventMap, EditorEventName, EditorEventSubscription, EmailMark, EmailMarkConfig, EmailNode, EmailNodeConfig, EventHandler, EventSubscription, MarkRendererComponent, NodeClickedEvent, NodeRendererComponent, PlaceholderItem, SerializedMark, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditor, useEditorEvent };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as EmailMark, O as useEditor, V as composeReactEmail, k as isDocumentVisuallyEmpty } from "../extensions-
|
|
2
|
-
import {
|
|
1
|
+
import { H as EmailMark, O as useEditor, V as composeReactEmail, k as isDocumentVisuallyEmpty } from "../extensions-mStGDfMH.mjs";
|
|
2
|
+
import { g as EmailNode, n as useEditorEvent, t as editorEventBus } from "../event-bus-DJpnfDHw.mjs";
|
|
3
3
|
|
|
4
|
-
export { EmailMark, EmailNode, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditor };
|
|
4
|
+
export { EmailMark, EmailNode, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditor, useEditorEvent };
|
|
@@ -11,4 +11,4 @@ type UploadImageHandler = (file: File, view: EditorView, pos: number, preserveAt
|
|
|
11
11
|
}) => void | Promise<void>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { UploadImageHandler as n, PasteHandler as t };
|
|
14
|
-
//# sourceMappingURL=create-paste-handler-
|
|
14
|
+
//# sourceMappingURL=create-paste-handler-DsJYKisA.d.mts.map
|
package/dist/{create-paste-handler-CGR738bC.d.mts.map → create-paste-handler-DsJYKisA.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-paste-handler-
|
|
1
|
+
{"version":3,"file":"create-paste-handler-DsJYKisA.d.mts","names":[],"sources":["../src/core/create-paste-handler.ts"],"sourcesContent":[],"mappings":";;;;KAMY,YAAA,sBACQ,YACZ;AAFI,KAKA,kBAAA,GAJQ,CAAA,IACZ,EAIA,IAJA,EAAA,IAAU,EAKV,UALU,EAAA,GAAA,EAAA,MAAA,EAAA,kBAaC,CAbD,EAAA;EAGN,KAAA,CAAA,EAAA,MAAA;EACJ,MAAA,CAAA,EAAA,MAAA;EACA,SAAA,CAAA,EAAA,MAAA;EAQI,IAAA,CAAA,EAAA,MAAA;CAAO,EAAA,GAAA,IAAA,GAAP,OAAO,CAAA,IAAA,CAAA"}
|
|
@@ -25,7 +25,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
const
|
|
28
|
+
const require_global_content = require('./global-content-C5WjNoMX.cjs');
|
|
29
|
+
let react = require("react");
|
|
29
30
|
let _react_email_components = require("@react-email/components");
|
|
30
31
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
31
32
|
let _tiptap_core = require("@tiptap/core");
|
|
@@ -220,7 +221,7 @@ function createColumnsNode(config, includeCommands) {
|
|
|
220
221
|
} };
|
|
221
222
|
} },
|
|
222
223
|
renderToReactEmail({ children, node, style }) {
|
|
223
|
-
const inlineStyles =
|
|
224
|
+
const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
|
|
224
225
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Row, {
|
|
225
226
|
className: node.attrs?.class || void 0,
|
|
226
227
|
style: {
|
|
@@ -295,7 +296,7 @@ const ColumnsColumn = EmailNode.create({
|
|
|
295
296
|
};
|
|
296
297
|
},
|
|
297
298
|
renderToReactEmail({ children, node, style }) {
|
|
298
|
-
const inlineStyles =
|
|
299
|
+
const inlineStyles = require_global_content.inlineCssToJs(node.attrs?.style);
|
|
299
300
|
const width = node.attrs?.width;
|
|
300
301
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Column, {
|
|
301
302
|
className: node.attrs?.class || void 0,
|
|
@@ -350,6 +351,16 @@ var EditorEventBus = class {
|
|
|
350
351
|
}
|
|
351
352
|
};
|
|
352
353
|
const editorEventBus = new EditorEventBus();
|
|
354
|
+
function useEditorEvent(eventName, handler, options) {
|
|
355
|
+
(0, react.useEffect)(() => {
|
|
356
|
+
const subscription = editorEventBus.on(eventName, handler, options);
|
|
357
|
+
return () => subscription.unsubscribe();
|
|
358
|
+
}, [
|
|
359
|
+
eventName,
|
|
360
|
+
handler,
|
|
361
|
+
options
|
|
362
|
+
]);
|
|
363
|
+
}
|
|
353
364
|
|
|
354
365
|
//#endregion
|
|
355
366
|
Object.defineProperty(exports, 'COLUMN_PARENT_TYPES', {
|
|
@@ -447,4 +458,10 @@ Object.defineProperty(exports, 'getColumnsDepth', {
|
|
|
447
458
|
get: function () {
|
|
448
459
|
return getColumnsDepth;
|
|
449
460
|
}
|
|
461
|
+
});
|
|
462
|
+
Object.defineProperty(exports, 'useEditorEvent', {
|
|
463
|
+
enumerable: true,
|
|
464
|
+
get: function () {
|
|
465
|
+
return useEditorEvent;
|
|
466
|
+
}
|
|
450
467
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as inlineCssToJs } from "./global-content-CjA49_jE.mjs";
|
|
2
|
+
import { useEffect } from "react";
|
|
2
3
|
import { Column, Row } from "@react-email/components";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import { Node, mergeAttributes } from "@tiptap/core";
|
|
@@ -323,7 +324,17 @@ var EditorEventBus = class {
|
|
|
323
324
|
}
|
|
324
325
|
};
|
|
325
326
|
const editorEventBus = new EditorEventBus();
|
|
327
|
+
function useEditorEvent(eventName, handler, options) {
|
|
328
|
+
useEffect(() => {
|
|
329
|
+
const subscription = editorEventBus.on(eventName, handler, options);
|
|
330
|
+
return () => subscription.unsubscribe();
|
|
331
|
+
}, [
|
|
332
|
+
eventName,
|
|
333
|
+
handler,
|
|
334
|
+
options
|
|
335
|
+
]);
|
|
336
|
+
}
|
|
326
337
|
|
|
327
338
|
//#endregion
|
|
328
|
-
export {
|
|
329
|
-
//# sourceMappingURL=event-bus-
|
|
339
|
+
export { FourColumns as a, TwoColumns as c, LAYOUT_ATTRIBUTES as d, TABLE_ATTRIBUTES as f, EmailNode as g, createStandardAttributes as h, ColumnsColumn as i, getColumnsDepth as l, TABLE_HEADER_ATTRIBUTES as m, useEditorEvent as n, MAX_COLUMNS_DEPTH as o, TABLE_CELL_ATTRIBUTES as p, COLUMN_PARENT_TYPES as r, ThreeColumns as s, editorEventBus as t, COMMON_HTML_ATTRIBUTES as u };
|
|
340
|
+
//# sourceMappingURL=event-bus-DJpnfDHw.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus-CHEzOS_O.mjs","names":[],"sources":["../src/core/serializer/email-node.ts","../src/utils/attribute-helpers.ts","../src/extensions/columns.tsx","../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","/**\n * Creates TipTap attribute definitions for a list of HTML attributes.\n * Each attribute will have the same pattern:\n * - default: null\n * - parseHTML: extracts the attribute from the element\n * - renderHTML: conditionally renders the attribute if it has a value\n *\n * @param attributeNames - Array of HTML attribute names to create definitions for\n * @returns Object with TipTap attribute definitions\n *\n * @example\n * const attrs = createStandardAttributes(['class', 'id', 'title']);\n * // Returns:\n * // {\n * // class: {\n * // default: null,\n * // parseHTML: (element) => element.getAttribute('class'),\n * // renderHTML: (attributes) => attributes.class ? { class: attributes.class } : {}\n * // },\n * // ...\n * // }\n */\nexport function createStandardAttributes(attributeNames: readonly string[]) {\n return Object.fromEntries(\n attributeNames.map((attr) => [\n attr,\n {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute(attr),\n renderHTML: (attributes: Record<string, unknown>) => {\n if (!attributes[attr]) {\n return {};\n }\n\n return {\n [attr]: attributes[attr],\n };\n },\n },\n ]),\n );\n}\n\n/**\n * Common HTML attributes used across multiple extensions.\n * These preserve attributes during HTML import and editing for better\n * fidelity when importing existing email templates.\n */\nexport const COMMON_HTML_ATTRIBUTES = [\n 'id',\n 'class',\n 'title',\n 'lang',\n 'dir',\n 'data-id',\n] as const;\n\n/**\n * Layout-specific HTML attributes used for positioning and sizing.\n */\nexport const LAYOUT_ATTRIBUTES = ['align', 'width', 'height'] as const;\n\n/**\n * Table-specific HTML attributes used for table layout and styling.\n */\nexport const TABLE_ATTRIBUTES = [\n 'border',\n 'cellpadding',\n 'cellspacing',\n] as const;\n\n/**\n * Table cell-specific HTML attributes.\n */\nexport const TABLE_CELL_ATTRIBUTES = [\n 'valign',\n 'bgcolor',\n 'colspan',\n 'rowspan',\n] as const;\n\n/**\n * Table header cell-specific HTML attributes.\n * These are additional attributes that only apply to <th> elements.\n */\nexport const TABLE_HEADER_ATTRIBUTES = [\n ...TABLE_CELL_ATTRIBUTES,\n 'scope',\n] as const;\n","import { Column, Row } from '@react-email/components';\nimport { type CommandProps, mergeAttributes } from '@tiptap/core';\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model';\nimport { TextSelection } from '@tiptap/pm/state';\nimport { EmailNode } from '../core/serializer/email-node';\nimport {\n COMMON_HTML_ATTRIBUTES,\n createStandardAttributes,\n LAYOUT_ATTRIBUTES,\n} from '../utils/attribute-helpers';\nimport { inlineCssToJs } from '../utils/styles';\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n columns: {\n insertColumns: (count: 2 | 3 | 4) => ReturnType;\n };\n }\n}\n\nexport const COLUMN_PARENT_TYPES = [\n 'twoColumns',\n 'threeColumns',\n 'fourColumns',\n] as const;\n\nconst COLUMN_PARENT_SET = new Set<string>(COLUMN_PARENT_TYPES);\n\nexport const MAX_COLUMNS_DEPTH = 3;\n\nexport function getColumnsDepth(doc: ProseMirrorNode, from: number): number {\n const $from = doc.resolve(from);\n let depth = 0;\n for (let d = $from.depth; d > 0; d--) {\n if (COLUMN_PARENT_SET.has($from.node(d).type.name)) {\n depth++;\n }\n }\n return depth;\n}\n\ninterface ColumnsVariantConfig {\n name: (typeof COLUMN_PARENT_TYPES)[number];\n columnCount: number;\n content: string;\n dataType: string;\n}\n\nconst VARIANTS: ColumnsVariantConfig[] = [\n {\n name: 'twoColumns',\n columnCount: 2,\n content: 'columnsColumn columnsColumn',\n dataType: 'two-columns',\n },\n {\n name: 'threeColumns',\n columnCount: 3,\n content: 'columnsColumn columnsColumn columnsColumn',\n dataType: 'three-columns',\n },\n {\n name: 'fourColumns',\n columnCount: 4,\n content: 'columnsColumn{4}',\n dataType: 'four-columns',\n },\n];\n\nconst NODE_TYPE_MAP: Record<number, (typeof COLUMN_PARENT_TYPES)[number]> = {\n 2: 'twoColumns',\n 3: 'threeColumns',\n 4: 'fourColumns',\n};\n\nfunction createColumnsNode(\n config: ColumnsVariantConfig,\n includeCommands: boolean,\n) {\n return EmailNode.create({\n name: config.name,\n group: 'block',\n content: config.content,\n isolating: true,\n defining: true,\n\n addAttributes() {\n return createStandardAttributes([\n ...LAYOUT_ATTRIBUTES,\n ...COMMON_HTML_ATTRIBUTES,\n ]);\n },\n\n parseHTML() {\n return [{ tag: `div[data-type=\"${config.dataType}\"]` }];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n 'div',\n mergeAttributes(\n { 'data-type': config.dataType, class: 'node-columns' },\n HTMLAttributes,\n ),\n 0,\n ];\n },\n\n ...(includeCommands && {\n addCommands() {\n return {\n insertColumns:\n (count: 2 | 3 | 4) =>\n ({\n commands,\n state,\n }: CommandProps & {\n state: { doc: ProseMirrorNode; selection: { from: number } };\n }) => {\n if (\n getColumnsDepth(state.doc, state.selection.from) >=\n MAX_COLUMNS_DEPTH\n ) {\n return false;\n }\n const nodeType = NODE_TYPE_MAP[count];\n const children = Array.from({ length: count }, () => ({\n type: 'columnsColumn',\n content: [{ type: 'paragraph', content: [] }],\n }));\n return commands.insertContent({\n type: nodeType,\n content: children,\n });\n },\n };\n },\n }),\n\n renderToReactEmail({ children, node, style }) {\n const inlineStyles = inlineCssToJs(node.attrs?.style);\n return (\n <Row\n className={node.attrs?.class || undefined}\n style={{ ...style, ...inlineStyles }}\n >\n {children}\n </Row>\n );\n },\n });\n}\n\nexport const TwoColumns = createColumnsNode(VARIANTS[0], true);\nexport const ThreeColumns = createColumnsNode(VARIANTS[1], false);\nexport const FourColumns = createColumnsNode(VARIANTS[2], false);\n\nexport const ColumnsColumn = EmailNode.create({\n name: 'columnsColumn',\n group: 'columnsColumn',\n content: 'block+',\n isolating: true,\n\n addAttributes() {\n return {\n ...createStandardAttributes([\n ...LAYOUT_ATTRIBUTES,\n ...COMMON_HTML_ATTRIBUTES,\n ]),\n };\n },\n\n parseHTML() {\n return [{ tag: 'div[data-type=\"column\"]' }];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n 'div',\n mergeAttributes(\n { 'data-type': 'column', class: 'node-column' },\n HTMLAttributes,\n ),\n 0,\n ];\n },\n\n addKeyboardShortcuts() {\n return {\n Backspace: ({ editor }) => {\n const { state } = editor;\n const { selection } = state;\n const { empty, $from } = selection;\n\n if (!empty) return false;\n\n for (let depth = $from.depth; depth >= 1; depth--) {\n if ($from.pos !== $from.start(depth)) break;\n\n const indexInParent = $from.index(depth - 1);\n\n if (indexInParent === 0) continue;\n\n const parent = $from.node(depth - 1);\n const prevNode = parent.child(indexInParent - 1);\n\n if (COLUMN_PARENT_SET.has(prevNode.type.name)) {\n const deleteFrom = $from.before(depth) - prevNode.nodeSize;\n const deleteTo = $from.before(depth);\n editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));\n return true;\n }\n\n break;\n }\n\n return false;\n },\n 'Mod-a': ({ editor }) => {\n const { state } = editor;\n const { $from } = state.selection;\n\n for (let d = $from.depth; d > 0; d--) {\n if ($from.node(d).type.name !== 'columnsColumn') {\n continue;\n }\n\n const columnStart = $from.start(d);\n const columnEnd = $from.end(d);\n const { from, to } = state.selection;\n\n if (from === columnStart && to === columnEnd) {\n return false;\n }\n\n editor.view.dispatch(\n state.tr.setSelection(\n TextSelection.create(state.doc, columnStart, columnEnd),\n ),\n );\n return true;\n }\n\n return false;\n },\n };\n },\n\n renderToReactEmail({ children, node, style }) {\n const inlineStyles = inlineCssToJs(node.attrs?.style);\n const width = node.attrs?.width;\n return (\n <Column\n className={node.attrs?.class || undefined}\n style={{\n ...style,\n ...inlineStyles,\n ...(width ? { width } : {}),\n }}\n >\n {children}\n </Column>\n );\n },\n});\n","const 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}\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"],"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;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC3EvC,SAAgB,yBAAyB,gBAAmC;AAC1E,QAAO,OAAO,YACZ,eAAe,KAAK,SAAS,CAC3B,MACA;EACE,SAAS;EACT,YAAY,YAAyB,QAAQ,aAAa,KAAK;EAC/D,aAAa,eAAwC;AACnD,OAAI,CAAC,WAAW,MACd,QAAO,EAAE;AAGX,UAAO,GACJ,OAAO,WAAW,OACpB;;EAEJ,CACF,CAAC,CACH;;;;;;;AAQH,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;CACD;;;;AAKD,MAAa,oBAAoB;CAAC;CAAS;CAAS;CAAS;;;;AAK7D,MAAa,mBAAmB;CAC9B;CACA;CACA;CACD;;;;AAKD,MAAa,wBAAwB;CACnC;CACA;C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AC/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"}
|
|
1
|
+
{"version":3,"file":"event-bus-DJpnfDHw.mjs","names":[],"sources":["../src/core/serializer/email-node.ts","../src/utils/attribute-helpers.ts","../src/extensions/columns.tsx","../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","/**\n * Creates TipTap attribute definitions for a list of HTML attributes.\n * Each attribute will have the same pattern:\n * - default: null\n * - parseHTML: extracts the attribute from the element\n * - renderHTML: conditionally renders the attribute if it has a value\n *\n * @param attributeNames - Array of HTML attribute names to create definitions for\n * @returns Object with TipTap attribute definitions\n *\n * @example\n * const attrs = createStandardAttributes(['class', 'id', 'title']);\n * // Returns:\n * // {\n * // class: {\n * // default: null,\n * // parseHTML: (element) => element.getAttribute('class'),\n * // renderHTML: (attributes) => attributes.class ? { class: attributes.class } : {}\n * // },\n * // ...\n * // }\n */\nexport function createStandardAttributes(attributeNames: readonly string[]) {\n return Object.fromEntries(\n attributeNames.map((attr) => [\n attr,\n {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute(attr),\n renderHTML: (attributes: Record<string, unknown>) => {\n if (!attributes[attr]) {\n return {};\n }\n\n return {\n [attr]: attributes[attr],\n };\n },\n },\n ]),\n );\n}\n\n/**\n * Common HTML attributes used across multiple extensions.\n * These preserve attributes during HTML import and editing for better\n * fidelity when importing existing email templates.\n */\nexport const COMMON_HTML_ATTRIBUTES = [\n 'id',\n 'class',\n 'title',\n 'lang',\n 'dir',\n 'data-id',\n] as const;\n\n/**\n * Layout-specific HTML attributes used for positioning and sizing.\n */\nexport const LAYOUT_ATTRIBUTES = ['align', 'width', 'height'] as const;\n\n/**\n * Table-specific HTML attributes used for table layout and styling.\n */\nexport const TABLE_ATTRIBUTES = [\n 'border',\n 'cellpadding',\n 'cellspacing',\n] as const;\n\n/**\n * Table cell-specific HTML attributes.\n */\nexport const TABLE_CELL_ATTRIBUTES = [\n 'valign',\n 'bgcolor',\n 'colspan',\n 'rowspan',\n] as const;\n\n/**\n * Table header cell-specific HTML attributes.\n * These are additional attributes that only apply to <th> elements.\n */\nexport const TABLE_HEADER_ATTRIBUTES = [\n ...TABLE_CELL_ATTRIBUTES,\n 'scope',\n] as const;\n","import { Column, Row } from '@react-email/components';\nimport { type CommandProps, mergeAttributes } from '@tiptap/core';\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model';\nimport { TextSelection } from '@tiptap/pm/state';\nimport { EmailNode } from '../core/serializer/email-node';\nimport {\n COMMON_HTML_ATTRIBUTES,\n createStandardAttributes,\n LAYOUT_ATTRIBUTES,\n} from '../utils/attribute-helpers';\nimport { inlineCssToJs } from '../utils/styles';\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n columns: {\n insertColumns: (count: 2 | 3 | 4) => ReturnType;\n };\n }\n}\n\nexport const COLUMN_PARENT_TYPES = [\n 'twoColumns',\n 'threeColumns',\n 'fourColumns',\n] as const;\n\nconst COLUMN_PARENT_SET = new Set<string>(COLUMN_PARENT_TYPES);\n\nexport const MAX_COLUMNS_DEPTH = 3;\n\nexport function getColumnsDepth(doc: ProseMirrorNode, from: number): number {\n const $from = doc.resolve(from);\n let depth = 0;\n for (let d = $from.depth; d > 0; d--) {\n if (COLUMN_PARENT_SET.has($from.node(d).type.name)) {\n depth++;\n }\n }\n return depth;\n}\n\ninterface ColumnsVariantConfig {\n name: (typeof COLUMN_PARENT_TYPES)[number];\n columnCount: number;\n content: string;\n dataType: string;\n}\n\nconst VARIANTS: ColumnsVariantConfig[] = [\n {\n name: 'twoColumns',\n columnCount: 2,\n content: 'columnsColumn columnsColumn',\n dataType: 'two-columns',\n },\n {\n name: 'threeColumns',\n columnCount: 3,\n content: 'columnsColumn columnsColumn columnsColumn',\n dataType: 'three-columns',\n },\n {\n name: 'fourColumns',\n columnCount: 4,\n content: 'columnsColumn{4}',\n dataType: 'four-columns',\n },\n];\n\nconst NODE_TYPE_MAP: Record<number, (typeof COLUMN_PARENT_TYPES)[number]> = {\n 2: 'twoColumns',\n 3: 'threeColumns',\n 4: 'fourColumns',\n};\n\nfunction createColumnsNode(\n config: ColumnsVariantConfig,\n includeCommands: boolean,\n) {\n return EmailNode.create({\n name: config.name,\n group: 'block',\n content: config.content,\n isolating: true,\n defining: true,\n\n addAttributes() {\n return createStandardAttributes([\n ...LAYOUT_ATTRIBUTES,\n ...COMMON_HTML_ATTRIBUTES,\n ]);\n },\n\n parseHTML() {\n return [{ tag: `div[data-type=\"${config.dataType}\"]` }];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n 'div',\n mergeAttributes(\n { 'data-type': config.dataType, class: 'node-columns' },\n HTMLAttributes,\n ),\n 0,\n ];\n },\n\n ...(includeCommands && {\n addCommands() {\n return {\n insertColumns:\n (count: 2 | 3 | 4) =>\n ({\n commands,\n state,\n }: CommandProps & {\n state: { doc: ProseMirrorNode; selection: { from: number } };\n }) => {\n if (\n getColumnsDepth(state.doc, state.selection.from) >=\n MAX_COLUMNS_DEPTH\n ) {\n return false;\n }\n const nodeType = NODE_TYPE_MAP[count];\n const children = Array.from({ length: count }, () => ({\n type: 'columnsColumn',\n content: [{ type: 'paragraph', content: [] }],\n }));\n return commands.insertContent({\n type: nodeType,\n content: children,\n });\n },\n };\n },\n }),\n\n renderToReactEmail({ children, node, style }) {\n const inlineStyles = inlineCssToJs(node.attrs?.style);\n return (\n <Row\n className={node.attrs?.class || undefined}\n style={{ ...style, ...inlineStyles }}\n >\n {children}\n </Row>\n );\n },\n });\n}\n\nexport const TwoColumns = createColumnsNode(VARIANTS[0], true);\nexport const ThreeColumns = createColumnsNode(VARIANTS[1], false);\nexport const FourColumns = createColumnsNode(VARIANTS[2], false);\n\nexport const ColumnsColumn = EmailNode.create({\n name: 'columnsColumn',\n group: 'columnsColumn',\n content: 'block+',\n isolating: true,\n\n addAttributes() {\n return {\n ...createStandardAttributes([\n ...LAYOUT_ATTRIBUTES,\n ...COMMON_HTML_ATTRIBUTES,\n ]),\n };\n },\n\n parseHTML() {\n return [{ tag: 'div[data-type=\"column\"]' }];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n 'div',\n mergeAttributes(\n { 'data-type': 'column', class: 'node-column' },\n HTMLAttributes,\n ),\n 0,\n ];\n },\n\n addKeyboardShortcuts() {\n return {\n Backspace: ({ editor }) => {\n const { state } = editor;\n const { selection } = state;\n const { empty, $from } = selection;\n\n if (!empty) return false;\n\n for (let depth = $from.depth; depth >= 1; depth--) {\n if ($from.pos !== $from.start(depth)) break;\n\n const indexInParent = $from.index(depth - 1);\n\n if (indexInParent === 0) continue;\n\n const parent = $from.node(depth - 1);\n const prevNode = parent.child(indexInParent - 1);\n\n if (COLUMN_PARENT_SET.has(prevNode.type.name)) {\n const deleteFrom = $from.before(depth) - prevNode.nodeSize;\n const deleteTo = $from.before(depth);\n editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));\n return true;\n }\n\n break;\n }\n\n return false;\n },\n 'Mod-a': ({ editor }) => {\n const { state } = editor;\n const { $from } = state.selection;\n\n for (let d = $from.depth; d > 0; d--) {\n if ($from.node(d).type.name !== 'columnsColumn') {\n continue;\n }\n\n const columnStart = $from.start(d);\n const columnEnd = $from.end(d);\n const { from, to } = state.selection;\n\n if (from === columnStart && to === columnEnd) {\n return false;\n }\n\n editor.view.dispatch(\n state.tr.setSelection(\n TextSelection.create(state.doc, columnStart, columnEnd),\n ),\n );\n return true;\n }\n\n return false;\n },\n };\n },\n\n renderToReactEmail({ children, node, style }) {\n const inlineStyles = inlineCssToJs(node.attrs?.style);\n const width = node.attrs?.width;\n return (\n <Column\n className={node.attrs?.class || undefined}\n style={{\n ...style,\n ...inlineStyles,\n ...(width ? { width } : {}),\n }}\n >\n {children}\n </Column>\n );\n },\n});\n","import { 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}\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,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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"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const require_event_bus = require('./event-bus-
|
|
2
|
-
const
|
|
3
|
-
const require_global_content = require('./global-content-bJgotqmA.cjs');
|
|
1
|
+
const require_event_bus = require('./event-bus-BJn1dJM1.cjs');
|
|
2
|
+
const require_global_content = require('./global-content-C5WjNoMX.cjs');
|
|
4
3
|
let _tiptap_react = require("@tiptap/react");
|
|
5
4
|
let _react_email_components = require("@react-email/components");
|
|
6
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -24,7 +23,7 @@ function transformToCssJs(styleArray, baseFontSize) {
|
|
|
24
23
|
}
|
|
25
24
|
cssJS[input.classReference][input.prop] = value;
|
|
26
25
|
}
|
|
27
|
-
for (const key of Object.keys(cssJS))
|
|
26
|
+
for (const key of Object.keys(cssJS)) require_global_content.ensureBorderStyleFallback(cssJS[key]);
|
|
28
27
|
return cssJS;
|
|
29
28
|
}
|
|
30
29
|
function mergeCssJs(original, newCssJs) {
|
|
@@ -106,7 +105,47 @@ const THEME_BASIC = [
|
|
|
106
105
|
id: "body",
|
|
107
106
|
title: "Background",
|
|
108
107
|
classReference: "body",
|
|
109
|
-
inputs: [
|
|
108
|
+
inputs: [
|
|
109
|
+
{
|
|
110
|
+
label: "Background",
|
|
111
|
+
type: "color",
|
|
112
|
+
value: "#ffffff",
|
|
113
|
+
prop: "backgroundColor",
|
|
114
|
+
classReference: "body"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
label: "Padding Top",
|
|
118
|
+
type: "number",
|
|
119
|
+
value: 0,
|
|
120
|
+
unit: "px",
|
|
121
|
+
prop: "paddingTop",
|
|
122
|
+
classReference: "body"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
label: "Padding Right",
|
|
126
|
+
type: "number",
|
|
127
|
+
value: 0,
|
|
128
|
+
unit: "px",
|
|
129
|
+
prop: "paddingRight",
|
|
130
|
+
classReference: "body"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
label: "Padding Bottom",
|
|
134
|
+
type: "number",
|
|
135
|
+
value: 0,
|
|
136
|
+
unit: "px",
|
|
137
|
+
prop: "paddingBottom",
|
|
138
|
+
classReference: "body"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
label: "Padding Left",
|
|
142
|
+
type: "number",
|
|
143
|
+
value: 0,
|
|
144
|
+
unit: "px",
|
|
145
|
+
prop: "paddingLeft",
|
|
146
|
+
classReference: "body"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
110
149
|
},
|
|
111
150
|
{
|
|
112
151
|
id: "container",
|
|
@@ -134,11 +173,32 @@ const THEME_BASIC = [
|
|
|
134
173
|
classReference: "container"
|
|
135
174
|
},
|
|
136
175
|
{
|
|
137
|
-
label: "
|
|
176
|
+
label: "Height",
|
|
177
|
+
type: "number",
|
|
178
|
+
unit: "px",
|
|
179
|
+
prop: "height",
|
|
180
|
+
classReference: "container"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
label: "Text",
|
|
184
|
+
type: "color",
|
|
185
|
+
value: "#000000",
|
|
186
|
+
prop: "color",
|
|
187
|
+
classReference: "container"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
label: "Background",
|
|
191
|
+
type: "color",
|
|
192
|
+
value: "#ffffff",
|
|
193
|
+
prop: "backgroundColor",
|
|
194
|
+
classReference: "container"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
label: "Padding Top",
|
|
138
198
|
type: "number",
|
|
139
199
|
value: 0,
|
|
140
200
|
unit: "px",
|
|
141
|
-
prop: "
|
|
201
|
+
prop: "paddingTop",
|
|
142
202
|
classReference: "container"
|
|
143
203
|
},
|
|
144
204
|
{
|
|
@@ -148,6 +208,37 @@ const THEME_BASIC = [
|
|
|
148
208
|
unit: "px",
|
|
149
209
|
prop: "paddingRight",
|
|
150
210
|
classReference: "container"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
label: "Padding Bottom",
|
|
214
|
+
type: "number",
|
|
215
|
+
value: 0,
|
|
216
|
+
unit: "px",
|
|
217
|
+
prop: "paddingBottom",
|
|
218
|
+
classReference: "container"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
label: "Padding Left",
|
|
222
|
+
type: "number",
|
|
223
|
+
value: 0,
|
|
224
|
+
unit: "px",
|
|
225
|
+
prop: "paddingLeft",
|
|
226
|
+
classReference: "container"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
label: "Corner radius",
|
|
230
|
+
type: "number",
|
|
231
|
+
value: 0,
|
|
232
|
+
unit: "px",
|
|
233
|
+
prop: "borderRadius",
|
|
234
|
+
classReference: "container"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
label: "Border color",
|
|
238
|
+
type: "color",
|
|
239
|
+
value: "#000000",
|
|
240
|
+
prop: "borderColor",
|
|
241
|
+
classReference: "container"
|
|
151
242
|
}
|
|
152
243
|
]
|
|
153
244
|
},
|
|
@@ -365,10 +456,206 @@ const THEME_BASIC = [
|
|
|
365
456
|
]
|
|
366
457
|
}
|
|
367
458
|
];
|
|
368
|
-
const THEME_MINIMAL =
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
459
|
+
const THEME_MINIMAL = [
|
|
460
|
+
{
|
|
461
|
+
id: "body",
|
|
462
|
+
title: "Background",
|
|
463
|
+
classReference: "body",
|
|
464
|
+
inputs: [
|
|
465
|
+
{
|
|
466
|
+
label: "Background",
|
|
467
|
+
type: "color",
|
|
468
|
+
value: "#ffffff",
|
|
469
|
+
prop: "backgroundColor",
|
|
470
|
+
classReference: "body"
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
label: "Padding Top",
|
|
474
|
+
type: "number",
|
|
475
|
+
value: 0,
|
|
476
|
+
unit: "px",
|
|
477
|
+
prop: "paddingTop",
|
|
478
|
+
classReference: "body"
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
label: "Padding Right",
|
|
482
|
+
type: "number",
|
|
483
|
+
value: 0,
|
|
484
|
+
unit: "px",
|
|
485
|
+
prop: "paddingRight",
|
|
486
|
+
classReference: "body"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
label: "Padding Bottom",
|
|
490
|
+
type: "number",
|
|
491
|
+
value: 0,
|
|
492
|
+
unit: "px",
|
|
493
|
+
prop: "paddingBottom",
|
|
494
|
+
classReference: "body"
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
label: "Padding Left",
|
|
498
|
+
type: "number",
|
|
499
|
+
value: 0,
|
|
500
|
+
unit: "px",
|
|
501
|
+
prop: "paddingLeft",
|
|
502
|
+
classReference: "body"
|
|
503
|
+
}
|
|
504
|
+
]
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
id: "container",
|
|
508
|
+
title: "Content",
|
|
509
|
+
classReference: "container",
|
|
510
|
+
inputs: [
|
|
511
|
+
{
|
|
512
|
+
label: "Align",
|
|
513
|
+
type: "select",
|
|
514
|
+
value: "left",
|
|
515
|
+
options: {
|
|
516
|
+
left: "Left",
|
|
517
|
+
center: "Center",
|
|
518
|
+
right: "Right"
|
|
519
|
+
},
|
|
520
|
+
prop: "align",
|
|
521
|
+
classReference: "container"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
label: "Width",
|
|
525
|
+
type: "number",
|
|
526
|
+
value: 600,
|
|
527
|
+
unit: "px",
|
|
528
|
+
prop: "width",
|
|
529
|
+
classReference: "container"
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
label: "Height",
|
|
533
|
+
type: "number",
|
|
534
|
+
unit: "px",
|
|
535
|
+
prop: "height",
|
|
536
|
+
classReference: "container"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
label: "Text",
|
|
540
|
+
type: "color",
|
|
541
|
+
value: "#000000",
|
|
542
|
+
prop: "color",
|
|
543
|
+
classReference: "container"
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
label: "Background",
|
|
547
|
+
type: "color",
|
|
548
|
+
value: "#ffffff",
|
|
549
|
+
prop: "backgroundColor",
|
|
550
|
+
classReference: "container"
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
label: "Padding Top",
|
|
554
|
+
type: "number",
|
|
555
|
+
value: 0,
|
|
556
|
+
unit: "px",
|
|
557
|
+
prop: "paddingTop",
|
|
558
|
+
classReference: "container"
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
label: "Padding Right",
|
|
562
|
+
type: "number",
|
|
563
|
+
value: 0,
|
|
564
|
+
unit: "px",
|
|
565
|
+
prop: "paddingRight",
|
|
566
|
+
classReference: "container"
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
label: "Padding Bottom",
|
|
570
|
+
type: "number",
|
|
571
|
+
value: 0,
|
|
572
|
+
unit: "px",
|
|
573
|
+
prop: "paddingBottom",
|
|
574
|
+
classReference: "container"
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
label: "Padding Left",
|
|
578
|
+
type: "number",
|
|
579
|
+
value: 0,
|
|
580
|
+
unit: "px",
|
|
581
|
+
prop: "paddingLeft",
|
|
582
|
+
classReference: "container"
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
label: "Corner radius",
|
|
586
|
+
type: "number",
|
|
587
|
+
value: 0,
|
|
588
|
+
unit: "px",
|
|
589
|
+
prop: "borderRadius",
|
|
590
|
+
classReference: "container"
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
label: "Border color",
|
|
594
|
+
type: "color",
|
|
595
|
+
value: "#000000",
|
|
596
|
+
prop: "borderColor",
|
|
597
|
+
classReference: "container"
|
|
598
|
+
}
|
|
599
|
+
]
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
id: "typography",
|
|
603
|
+
title: "Text",
|
|
604
|
+
classReference: "body",
|
|
605
|
+
inputs: []
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
id: "h1",
|
|
609
|
+
title: "Title",
|
|
610
|
+
category: "Text",
|
|
611
|
+
classReference: "h1",
|
|
612
|
+
inputs: []
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
id: "h2",
|
|
616
|
+
title: "Subtitle",
|
|
617
|
+
category: "Text",
|
|
618
|
+
classReference: "h2",
|
|
619
|
+
inputs: []
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
id: "h3",
|
|
623
|
+
title: "Heading",
|
|
624
|
+
category: "Text",
|
|
625
|
+
classReference: "h3",
|
|
626
|
+
inputs: []
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
id: "link",
|
|
630
|
+
title: "Link",
|
|
631
|
+
classReference: "link",
|
|
632
|
+
inputs: []
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
id: "image",
|
|
636
|
+
title: "Image",
|
|
637
|
+
classReference: "image",
|
|
638
|
+
inputs: []
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
id: "button",
|
|
642
|
+
title: "Button",
|
|
643
|
+
classReference: "button",
|
|
644
|
+
inputs: []
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
id: "code-block",
|
|
648
|
+
title: "Code Block",
|
|
649
|
+
classReference: "codeBlock",
|
|
650
|
+
inputs: []
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
id: "inline-code",
|
|
654
|
+
title: "Inline Code",
|
|
655
|
+
classReference: "inlineCode",
|
|
656
|
+
inputs: []
|
|
657
|
+
}
|
|
658
|
+
];
|
|
372
659
|
const RESET_BASIC = {
|
|
373
660
|
reset: {
|
|
374
661
|
margin: "0",
|
|
@@ -1174,24 +1461,6 @@ Object.defineProperty(exports, 'getThemeComponentKey', {
|
|
|
1174
1461
|
return getThemeComponentKey;
|
|
1175
1462
|
}
|
|
1176
1463
|
});
|
|
1177
|
-
Object.defineProperty(exports, 'injectGlobalPlainCss', {
|
|
1178
|
-
enumerable: true,
|
|
1179
|
-
get: function () {
|
|
1180
|
-
return injectGlobalPlainCss;
|
|
1181
|
-
}
|
|
1182
|
-
});
|
|
1183
|
-
Object.defineProperty(exports, 'injectThemeCss', {
|
|
1184
|
-
enumerable: true,
|
|
1185
|
-
get: function () {
|
|
1186
|
-
return injectThemeCss;
|
|
1187
|
-
}
|
|
1188
|
-
});
|
|
1189
|
-
Object.defineProperty(exports, 'mergeCssJs', {
|
|
1190
|
-
enumerable: true,
|
|
1191
|
-
get: function () {
|
|
1192
|
-
return mergeCssJs;
|
|
1193
|
-
}
|
|
1194
|
-
});
|
|
1195
1464
|
Object.defineProperty(exports, 'resolveResetValue', {
|
|
1196
1465
|
enumerable: true,
|
|
1197
1466
|
get: function () {
|
|
@@ -1222,12 +1491,6 @@ Object.defineProperty(exports, 'stylesToCss', {
|
|
|
1222
1491
|
return stylesToCss;
|
|
1223
1492
|
}
|
|
1224
1493
|
});
|
|
1225
|
-
Object.defineProperty(exports, 'transformToCssJs', {
|
|
1226
|
-
enumerable: true,
|
|
1227
|
-
get: function () {
|
|
1228
|
-
return transformToCssJs;
|
|
1229
|
-
}
|
|
1230
|
-
});
|
|
1231
1494
|
Object.defineProperty(exports, 'useEmailTheming', {
|
|
1232
1495
|
enumerable: true,
|
|
1233
1496
|
get: function () {
|