@react-email/editor 0.0.0-experimental.22 → 0.0.0-experimental.25
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-CUxUEHje.mjs +497 -0
- package/dist/columns-CUxUEHje.mjs.map +1 -0
- package/dist/columns-ZSaLdkg9.cjs +630 -0
- package/dist/core/index.cjs +8 -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-C5_RDJBI.mjs +1982 -0
- package/dist/core-C5_RDJBI.mjs.map +1 -0
- package/dist/core-Rxnpk8B_.cjs +2239 -0
- package/dist/extensions/index.cjs +47 -0
- package/dist/extensions/index.d.cts +394 -0
- package/dist/extensions/index.d.cts.map +1 -0
- package/dist/extensions/index.d.mts +394 -0
- package/dist/extensions/index.d.mts.map +1 -0
- package/dist/extensions/index.mjs +4 -0
- package/dist/index-CfslA7KT.d.cts +130 -0
- package/dist/index-CfslA7KT.d.cts.map +1 -0
- package/dist/index-hbHRR7oB.d.mts +130 -0
- package/dist/index-hbHRR7oB.d.mts.map +1 -0
- package/dist/set-text-alignment-Bx3bPteH.cjs +24 -0
- package/dist/set-text-alignment-DZvgnbvz.mjs +19 -0
- package/dist/set-text-alignment-DZvgnbvz.mjs.map +1 -0
- package/dist/ui/index.cjs +1646 -0
- package/dist/ui/index.d.cts +668 -0
- package/dist/ui/index.d.cts.map +1 -0
- package/dist/ui/index.d.mts +668 -0
- package/dist/ui/index.d.mts.map +1 -0
- package/dist/ui/index.mjs +1584 -0
- package/dist/ui/index.mjs.map +1 -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 +3 -0
- package/package.json +39 -11
- package/dist/index.cjs +0 -4228
- package/dist/index.d.cts +0 -1175
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -1175
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -4072
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,630 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
let _react_email_components = require("@react-email/components");
|
|
29
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
let _tiptap_core = require("@tiptap/core");
|
|
31
|
+
let _tiptap_pm_state = require("@tiptap/pm/state");
|
|
32
|
+
|
|
33
|
+
//#region src/core/event-bus.ts
|
|
34
|
+
const EVENT_PREFIX = "@react-email/editor:";
|
|
35
|
+
var EditorEventBus = class {
|
|
36
|
+
prefixEventName(eventName) {
|
|
37
|
+
return `${EVENT_PREFIX}${String(eventName)}`;
|
|
38
|
+
}
|
|
39
|
+
dispatch(eventName, payload, options) {
|
|
40
|
+
const target = options?.target ?? window;
|
|
41
|
+
const prefixedEventName = this.prefixEventName(eventName);
|
|
42
|
+
const event = new CustomEvent(prefixedEventName, {
|
|
43
|
+
detail: payload,
|
|
44
|
+
bubbles: false,
|
|
45
|
+
cancelable: false
|
|
46
|
+
});
|
|
47
|
+
target.dispatchEvent(event);
|
|
48
|
+
}
|
|
49
|
+
on(eventName, handler, options) {
|
|
50
|
+
const target = options?.target ?? window;
|
|
51
|
+
const prefixedEventName = this.prefixEventName(eventName);
|
|
52
|
+
const abortController = new AbortController();
|
|
53
|
+
const wrappedHandler = (event) => {
|
|
54
|
+
const customEvent = event;
|
|
55
|
+
const result = handler(customEvent.detail);
|
|
56
|
+
if (result instanceof Promise) result.catch((error) => {
|
|
57
|
+
console.error(`Error in async event handler for ${prefixedEventName}:`, {
|
|
58
|
+
event: customEvent.detail,
|
|
59
|
+
error
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
target.addEventListener(prefixedEventName, wrappedHandler, {
|
|
64
|
+
...options,
|
|
65
|
+
signal: abortController.signal
|
|
66
|
+
});
|
|
67
|
+
return { unsubscribe: () => {
|
|
68
|
+
abortController.abort();
|
|
69
|
+
} };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const editorEventBus = new EditorEventBus();
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/utils/styles.ts
|
|
76
|
+
const WHITE_SPACE_REGEX = /\s+/;
|
|
77
|
+
const inlineCssToJs = (inlineStyle, options = {}) => {
|
|
78
|
+
const styleObject = {};
|
|
79
|
+
if (!inlineStyle || inlineStyle === "" || typeof inlineStyle === "object") return styleObject;
|
|
80
|
+
inlineStyle.split(";").forEach((style) => {
|
|
81
|
+
if (style.trim()) {
|
|
82
|
+
const [key, value] = style.split(":");
|
|
83
|
+
const valueTrimmed = value?.trim();
|
|
84
|
+
if (!valueTrimmed) return;
|
|
85
|
+
const formattedKey = key.trim().replace(/-\w/g, (match) => match[1].toUpperCase());
|
|
86
|
+
styleObject[formattedKey] = options?.removeUnit ? valueTrimmed.replace(/px|%/g, "") : valueTrimmed;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return styleObject;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Expands CSS shorthand properties (margin, padding) into their longhand equivalents.
|
|
93
|
+
* This prevents shorthand properties from overriding specific longhand properties in email clients.
|
|
94
|
+
*
|
|
95
|
+
* @param styles - Style object that may contain shorthand properties
|
|
96
|
+
* @returns New style object with shorthand properties expanded to longhand
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* expandShorthandProperties({ margin: '0', paddingTop: '10px' })
|
|
100
|
+
* // Returns: { marginTop: '0', marginRight: '0', marginBottom: '0', marginLeft: '0', paddingTop: '10px' }
|
|
101
|
+
*/
|
|
102
|
+
function expandShorthandProperties(styles) {
|
|
103
|
+
if (!styles || typeof styles !== "object") return {};
|
|
104
|
+
const expanded = {};
|
|
105
|
+
for (const key in styles) {
|
|
106
|
+
const value = styles[key];
|
|
107
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
108
|
+
switch (key) {
|
|
109
|
+
case "margin": {
|
|
110
|
+
const values = parseShorthandValue(value);
|
|
111
|
+
expanded.marginTop = values.top;
|
|
112
|
+
expanded.marginRight = values.right;
|
|
113
|
+
expanded.marginBottom = values.bottom;
|
|
114
|
+
expanded.marginLeft = values.left;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case "padding": {
|
|
118
|
+
const values = parseShorthandValue(value);
|
|
119
|
+
expanded.paddingTop = values.top;
|
|
120
|
+
expanded.paddingRight = values.right;
|
|
121
|
+
expanded.paddingBottom = values.bottom;
|
|
122
|
+
expanded.paddingLeft = values.left;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case "border": {
|
|
126
|
+
const values = convertBorderValue(value);
|
|
127
|
+
expanded.borderStyle = values.style;
|
|
128
|
+
expanded.borderWidth = values.width;
|
|
129
|
+
expanded.borderColor = values.color;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case "borderTopLeftRadius":
|
|
133
|
+
case "borderTopRightRadius":
|
|
134
|
+
case "borderBottomLeftRadius":
|
|
135
|
+
case "borderBottomRightRadius":
|
|
136
|
+
expanded[key] = value;
|
|
137
|
+
if (styles.borderTopLeftRadius && styles.borderTopRightRadius && styles.borderBottomLeftRadius && styles.borderBottomRightRadius) {
|
|
138
|
+
const values = [
|
|
139
|
+
styles.borderTopLeftRadius,
|
|
140
|
+
styles.borderTopRightRadius,
|
|
141
|
+
styles.borderBottomLeftRadius,
|
|
142
|
+
styles.borderBottomRightRadius
|
|
143
|
+
];
|
|
144
|
+
if (new Set(values).size === 1) expanded.borderRadius = values[0];
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
default: expanded[key] = value;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return expanded;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Parses CSS shorthand value (1-4 values) into individual side values.
|
|
154
|
+
* Follows CSS specification for shorthand property value parsing.
|
|
155
|
+
*
|
|
156
|
+
* @param value - Shorthand value string (e.g., '0', '10px 20px', '5px 10px 15px 20px')
|
|
157
|
+
* @returns Object with top, right, bottom, left values
|
|
158
|
+
*/
|
|
159
|
+
function parseShorthandValue(value) {
|
|
160
|
+
const stringValue = String(value).trim();
|
|
161
|
+
const parts = stringValue.split(WHITE_SPACE_REGEX);
|
|
162
|
+
const len = parts.length;
|
|
163
|
+
if (len === 1) return {
|
|
164
|
+
top: parts[0],
|
|
165
|
+
right: parts[0],
|
|
166
|
+
bottom: parts[0],
|
|
167
|
+
left: parts[0]
|
|
168
|
+
};
|
|
169
|
+
if (len === 2) return {
|
|
170
|
+
top: parts[0],
|
|
171
|
+
right: parts[1],
|
|
172
|
+
bottom: parts[0],
|
|
173
|
+
left: parts[1]
|
|
174
|
+
};
|
|
175
|
+
if (len === 3) return {
|
|
176
|
+
top: parts[0],
|
|
177
|
+
right: parts[1],
|
|
178
|
+
bottom: parts[2],
|
|
179
|
+
left: parts[1]
|
|
180
|
+
};
|
|
181
|
+
if (len === 4) return {
|
|
182
|
+
top: parts[0],
|
|
183
|
+
right: parts[1],
|
|
184
|
+
bottom: parts[2],
|
|
185
|
+
left: parts[3]
|
|
186
|
+
};
|
|
187
|
+
return {
|
|
188
|
+
top: stringValue,
|
|
189
|
+
right: stringValue,
|
|
190
|
+
bottom: stringValue,
|
|
191
|
+
left: stringValue
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function convertBorderValue(value) {
|
|
195
|
+
const stringValue = String(value).trim();
|
|
196
|
+
const parts = stringValue.split(WHITE_SPACE_REGEX);
|
|
197
|
+
switch (parts.length) {
|
|
198
|
+
case 1: return {
|
|
199
|
+
style: "solid",
|
|
200
|
+
width: parts[0],
|
|
201
|
+
color: "black"
|
|
202
|
+
};
|
|
203
|
+
case 2: return {
|
|
204
|
+
style: parts[1],
|
|
205
|
+
width: parts[0],
|
|
206
|
+
color: "black"
|
|
207
|
+
};
|
|
208
|
+
case 3: return {
|
|
209
|
+
style: parts[1],
|
|
210
|
+
width: parts[0],
|
|
211
|
+
color: parts[2]
|
|
212
|
+
};
|
|
213
|
+
case 4: return {
|
|
214
|
+
style: parts[1],
|
|
215
|
+
width: parts[0],
|
|
216
|
+
color: parts[2]
|
|
217
|
+
};
|
|
218
|
+
default: return {
|
|
219
|
+
style: "solid",
|
|
220
|
+
width: stringValue,
|
|
221
|
+
color: "black"
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Resolves conflicts between reset styles and inline styles by expanding
|
|
227
|
+
* shorthand properties (margin, padding) to longhand before merging.
|
|
228
|
+
* This prevents shorthand properties from overriding specific longhand properties.
|
|
229
|
+
*
|
|
230
|
+
* @param resetStyles - Base reset styles that may contain shorthand properties
|
|
231
|
+
* @param inlineStyles - Inline styles that should override reset styles
|
|
232
|
+
* @returns Merged styles with inline styles taking precedence
|
|
233
|
+
*/
|
|
234
|
+
function resolveConflictingStyles(resetStyles, inlineStyles) {
|
|
235
|
+
const expandedResetStyles = expandShorthandProperties(resetStyles);
|
|
236
|
+
const expandedInlineStyles = expandShorthandProperties(inlineStyles);
|
|
237
|
+
return {
|
|
238
|
+
...expandedResetStyles,
|
|
239
|
+
...expandedInlineStyles
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/core/serializer/email-node.ts
|
|
245
|
+
var EmailNode = class EmailNode extends _tiptap_core.Node {
|
|
246
|
+
constructor(config) {
|
|
247
|
+
super(config);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Create a new Node instance
|
|
251
|
+
* @param config - Node configuration object or a function that returns a configuration object
|
|
252
|
+
*/
|
|
253
|
+
static create(config) {
|
|
254
|
+
return new EmailNode(typeof config === "function" ? config() : config);
|
|
255
|
+
}
|
|
256
|
+
static from(node, renderToReactEmail) {
|
|
257
|
+
const customNode = EmailNode.create({});
|
|
258
|
+
Object.assign(customNode, { ...node });
|
|
259
|
+
customNode.config = {
|
|
260
|
+
...node.config,
|
|
261
|
+
renderToReactEmail
|
|
262
|
+
};
|
|
263
|
+
return customNode;
|
|
264
|
+
}
|
|
265
|
+
configure(options) {
|
|
266
|
+
return super.configure(options);
|
|
267
|
+
}
|
|
268
|
+
extend(extendedConfig) {
|
|
269
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
270
|
+
return super.extend(resolvedConfig);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/utils/attribute-helpers.ts
|
|
276
|
+
/**
|
|
277
|
+
* Creates TipTap attribute definitions for a list of HTML attributes.
|
|
278
|
+
* Each attribute will have the same pattern:
|
|
279
|
+
* - default: null
|
|
280
|
+
* - parseHTML: extracts the attribute from the element
|
|
281
|
+
* - renderHTML: conditionally renders the attribute if it has a value
|
|
282
|
+
*
|
|
283
|
+
* @param attributeNames - Array of HTML attribute names to create definitions for
|
|
284
|
+
* @returns Object with TipTap attribute definitions
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* const attrs = createStandardAttributes(['class', 'id', 'title']);
|
|
288
|
+
* // Returns:
|
|
289
|
+
* // {
|
|
290
|
+
* // class: {
|
|
291
|
+
* // default: null,
|
|
292
|
+
* // parseHTML: (element) => element.getAttribute('class'),
|
|
293
|
+
* // renderHTML: (attributes) => attributes.class ? { class: attributes.class } : {}
|
|
294
|
+
* // },
|
|
295
|
+
* // ...
|
|
296
|
+
* // }
|
|
297
|
+
*/
|
|
298
|
+
function createStandardAttributes(attributeNames) {
|
|
299
|
+
return Object.fromEntries(attributeNames.map((attr) => [attr, {
|
|
300
|
+
default: null,
|
|
301
|
+
parseHTML: (element) => element.getAttribute(attr),
|
|
302
|
+
renderHTML: (attributes) => {
|
|
303
|
+
if (!attributes[attr]) return {};
|
|
304
|
+
return { [attr]: attributes[attr] };
|
|
305
|
+
}
|
|
306
|
+
}]));
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Common HTML attributes used across multiple extensions.
|
|
310
|
+
* These preserve attributes during HTML import and editing for better
|
|
311
|
+
* fidelity when importing existing email templates.
|
|
312
|
+
*/
|
|
313
|
+
const COMMON_HTML_ATTRIBUTES = [
|
|
314
|
+
"id",
|
|
315
|
+
"class",
|
|
316
|
+
"title",
|
|
317
|
+
"lang",
|
|
318
|
+
"dir",
|
|
319
|
+
"data-id"
|
|
320
|
+
];
|
|
321
|
+
/**
|
|
322
|
+
* Layout-specific HTML attributes used for positioning and sizing.
|
|
323
|
+
*/
|
|
324
|
+
const LAYOUT_ATTRIBUTES = [
|
|
325
|
+
"align",
|
|
326
|
+
"width",
|
|
327
|
+
"height"
|
|
328
|
+
];
|
|
329
|
+
/**
|
|
330
|
+
* Table-specific HTML attributes used for table layout and styling.
|
|
331
|
+
*/
|
|
332
|
+
const TABLE_ATTRIBUTES = [
|
|
333
|
+
"border",
|
|
334
|
+
"cellpadding",
|
|
335
|
+
"cellspacing"
|
|
336
|
+
];
|
|
337
|
+
/**
|
|
338
|
+
* Table cell-specific HTML attributes.
|
|
339
|
+
*/
|
|
340
|
+
const TABLE_CELL_ATTRIBUTES = [
|
|
341
|
+
"valign",
|
|
342
|
+
"bgcolor",
|
|
343
|
+
"colspan",
|
|
344
|
+
"rowspan"
|
|
345
|
+
];
|
|
346
|
+
/**
|
|
347
|
+
* Table header cell-specific HTML attributes.
|
|
348
|
+
* These are additional attributes that only apply to <th> elements.
|
|
349
|
+
*/
|
|
350
|
+
const TABLE_HEADER_ATTRIBUTES = [...TABLE_CELL_ATTRIBUTES, "scope"];
|
|
351
|
+
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/extensions/columns.tsx
|
|
354
|
+
const COLUMN_PARENT_TYPES = [
|
|
355
|
+
"twoColumns",
|
|
356
|
+
"threeColumns",
|
|
357
|
+
"fourColumns"
|
|
358
|
+
];
|
|
359
|
+
const COLUMN_PARENT_SET = new Set(COLUMN_PARENT_TYPES);
|
|
360
|
+
const MAX_COLUMNS_DEPTH = 3;
|
|
361
|
+
function getColumnsDepth(doc, from) {
|
|
362
|
+
const $from = doc.resolve(from);
|
|
363
|
+
let depth = 0;
|
|
364
|
+
for (let d = $from.depth; d > 0; d--) if (COLUMN_PARENT_SET.has($from.node(d).type.name)) depth++;
|
|
365
|
+
return depth;
|
|
366
|
+
}
|
|
367
|
+
const VARIANTS = [
|
|
368
|
+
{
|
|
369
|
+
name: "twoColumns",
|
|
370
|
+
columnCount: 2,
|
|
371
|
+
content: "columnsColumn columnsColumn",
|
|
372
|
+
dataType: "two-columns"
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: "threeColumns",
|
|
376
|
+
columnCount: 3,
|
|
377
|
+
content: "columnsColumn columnsColumn columnsColumn",
|
|
378
|
+
dataType: "three-columns"
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: "fourColumns",
|
|
382
|
+
columnCount: 4,
|
|
383
|
+
content: "columnsColumn{4}",
|
|
384
|
+
dataType: "four-columns"
|
|
385
|
+
}
|
|
386
|
+
];
|
|
387
|
+
const NODE_TYPE_MAP = {
|
|
388
|
+
2: "twoColumns",
|
|
389
|
+
3: "threeColumns",
|
|
390
|
+
4: "fourColumns"
|
|
391
|
+
};
|
|
392
|
+
function createColumnsNode(config, includeCommands) {
|
|
393
|
+
return EmailNode.create({
|
|
394
|
+
name: config.name,
|
|
395
|
+
group: "block",
|
|
396
|
+
content: config.content,
|
|
397
|
+
isolating: true,
|
|
398
|
+
defining: true,
|
|
399
|
+
addAttributes() {
|
|
400
|
+
return createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]);
|
|
401
|
+
},
|
|
402
|
+
parseHTML() {
|
|
403
|
+
return [{ tag: `div[data-type="${config.dataType}"]` }];
|
|
404
|
+
},
|
|
405
|
+
renderHTML({ HTMLAttributes }) {
|
|
406
|
+
return [
|
|
407
|
+
"div",
|
|
408
|
+
(0, _tiptap_core.mergeAttributes)({
|
|
409
|
+
"data-type": config.dataType,
|
|
410
|
+
class: "node-columns"
|
|
411
|
+
}, HTMLAttributes),
|
|
412
|
+
0
|
|
413
|
+
];
|
|
414
|
+
},
|
|
415
|
+
...includeCommands && { addCommands() {
|
|
416
|
+
return { insertColumns: (count) => ({ commands, state }) => {
|
|
417
|
+
if (getColumnsDepth(state.doc, state.selection.from) >= MAX_COLUMNS_DEPTH) return false;
|
|
418
|
+
const nodeType = NODE_TYPE_MAP[count];
|
|
419
|
+
const children = Array.from({ length: count }, () => ({
|
|
420
|
+
type: "columnsColumn",
|
|
421
|
+
content: [{
|
|
422
|
+
type: "paragraph",
|
|
423
|
+
content: []
|
|
424
|
+
}]
|
|
425
|
+
}));
|
|
426
|
+
return commands.insertContent({
|
|
427
|
+
type: nodeType,
|
|
428
|
+
content: children
|
|
429
|
+
});
|
|
430
|
+
} };
|
|
431
|
+
} },
|
|
432
|
+
renderToReactEmail({ children, node, style }) {
|
|
433
|
+
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
434
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Row, {
|
|
435
|
+
className: node.attrs?.class || void 0,
|
|
436
|
+
style: {
|
|
437
|
+
...style,
|
|
438
|
+
...inlineStyles
|
|
439
|
+
},
|
|
440
|
+
children
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
const TwoColumns = createColumnsNode(VARIANTS[0], true);
|
|
446
|
+
const ThreeColumns = createColumnsNode(VARIANTS[1], false);
|
|
447
|
+
const FourColumns = createColumnsNode(VARIANTS[2], false);
|
|
448
|
+
const ColumnsColumn = EmailNode.create({
|
|
449
|
+
name: "columnsColumn",
|
|
450
|
+
group: "columnsColumn",
|
|
451
|
+
content: "block+",
|
|
452
|
+
isolating: true,
|
|
453
|
+
addAttributes() {
|
|
454
|
+
return { ...createStandardAttributes([...LAYOUT_ATTRIBUTES, ...COMMON_HTML_ATTRIBUTES]) };
|
|
455
|
+
},
|
|
456
|
+
parseHTML() {
|
|
457
|
+
return [{ tag: "div[data-type=\"column\"]" }];
|
|
458
|
+
},
|
|
459
|
+
renderHTML({ HTMLAttributes }) {
|
|
460
|
+
return [
|
|
461
|
+
"div",
|
|
462
|
+
(0, _tiptap_core.mergeAttributes)({
|
|
463
|
+
"data-type": "column",
|
|
464
|
+
class: "node-column"
|
|
465
|
+
}, HTMLAttributes),
|
|
466
|
+
0
|
|
467
|
+
];
|
|
468
|
+
},
|
|
469
|
+
addKeyboardShortcuts() {
|
|
470
|
+
return {
|
|
471
|
+
Backspace: ({ editor }) => {
|
|
472
|
+
const { state } = editor;
|
|
473
|
+
const { selection } = state;
|
|
474
|
+
const { empty, $from } = selection;
|
|
475
|
+
if (!empty) return false;
|
|
476
|
+
for (let depth = $from.depth; depth >= 1; depth--) {
|
|
477
|
+
if ($from.pos !== $from.start(depth)) break;
|
|
478
|
+
const indexInParent = $from.index(depth - 1);
|
|
479
|
+
if (indexInParent === 0) continue;
|
|
480
|
+
const prevNode = $from.node(depth - 1).child(indexInParent - 1);
|
|
481
|
+
if (COLUMN_PARENT_SET.has(prevNode.type.name)) {
|
|
482
|
+
const deleteFrom = $from.before(depth) - prevNode.nodeSize;
|
|
483
|
+
const deleteTo = $from.before(depth);
|
|
484
|
+
editor.view.dispatch(state.tr.delete(deleteFrom, deleteTo));
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
return false;
|
|
490
|
+
},
|
|
491
|
+
"Mod-a": ({ editor }) => {
|
|
492
|
+
const { state } = editor;
|
|
493
|
+
const { $from } = state.selection;
|
|
494
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
495
|
+
if ($from.node(d).type.name !== "columnsColumn") continue;
|
|
496
|
+
const columnStart = $from.start(d);
|
|
497
|
+
const columnEnd = $from.end(d);
|
|
498
|
+
const { from, to } = state.selection;
|
|
499
|
+
if (from === columnStart && to === columnEnd) return false;
|
|
500
|
+
editor.view.dispatch(state.tr.setSelection(_tiptap_pm_state.TextSelection.create(state.doc, columnStart, columnEnd)));
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
},
|
|
507
|
+
renderToReactEmail({ children, node, style }) {
|
|
508
|
+
const inlineStyles = inlineCssToJs(node.attrs?.style);
|
|
509
|
+
const width = node.attrs?.width;
|
|
510
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_email_components.Column, {
|
|
511
|
+
className: node.attrs?.class || void 0,
|
|
512
|
+
style: {
|
|
513
|
+
...style,
|
|
514
|
+
...inlineStyles,
|
|
515
|
+
...width ? { width } : {}
|
|
516
|
+
},
|
|
517
|
+
children
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
//#endregion
|
|
523
|
+
Object.defineProperty(exports, 'COLUMN_PARENT_TYPES', {
|
|
524
|
+
enumerable: true,
|
|
525
|
+
get: function () {
|
|
526
|
+
return COLUMN_PARENT_TYPES;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
Object.defineProperty(exports, 'COMMON_HTML_ATTRIBUTES', {
|
|
530
|
+
enumerable: true,
|
|
531
|
+
get: function () {
|
|
532
|
+
return COMMON_HTML_ATTRIBUTES;
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
Object.defineProperty(exports, 'ColumnsColumn', {
|
|
536
|
+
enumerable: true,
|
|
537
|
+
get: function () {
|
|
538
|
+
return ColumnsColumn;
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
Object.defineProperty(exports, 'EmailNode', {
|
|
542
|
+
enumerable: true,
|
|
543
|
+
get: function () {
|
|
544
|
+
return EmailNode;
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
Object.defineProperty(exports, 'FourColumns', {
|
|
548
|
+
enumerable: true,
|
|
549
|
+
get: function () {
|
|
550
|
+
return FourColumns;
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
Object.defineProperty(exports, 'LAYOUT_ATTRIBUTES', {
|
|
554
|
+
enumerable: true,
|
|
555
|
+
get: function () {
|
|
556
|
+
return LAYOUT_ATTRIBUTES;
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
Object.defineProperty(exports, 'MAX_COLUMNS_DEPTH', {
|
|
560
|
+
enumerable: true,
|
|
561
|
+
get: function () {
|
|
562
|
+
return MAX_COLUMNS_DEPTH;
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
Object.defineProperty(exports, 'TABLE_ATTRIBUTES', {
|
|
566
|
+
enumerable: true,
|
|
567
|
+
get: function () {
|
|
568
|
+
return TABLE_ATTRIBUTES;
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
Object.defineProperty(exports, 'TABLE_CELL_ATTRIBUTES', {
|
|
572
|
+
enumerable: true,
|
|
573
|
+
get: function () {
|
|
574
|
+
return TABLE_CELL_ATTRIBUTES;
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
Object.defineProperty(exports, 'TABLE_HEADER_ATTRIBUTES', {
|
|
578
|
+
enumerable: true,
|
|
579
|
+
get: function () {
|
|
580
|
+
return TABLE_HEADER_ATTRIBUTES;
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
Object.defineProperty(exports, 'ThreeColumns', {
|
|
584
|
+
enumerable: true,
|
|
585
|
+
get: function () {
|
|
586
|
+
return ThreeColumns;
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
Object.defineProperty(exports, 'TwoColumns', {
|
|
590
|
+
enumerable: true,
|
|
591
|
+
get: function () {
|
|
592
|
+
return TwoColumns;
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
Object.defineProperty(exports, '__toESM', {
|
|
596
|
+
enumerable: true,
|
|
597
|
+
get: function () {
|
|
598
|
+
return __toESM;
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
Object.defineProperty(exports, 'createStandardAttributes', {
|
|
602
|
+
enumerable: true,
|
|
603
|
+
get: function () {
|
|
604
|
+
return createStandardAttributes;
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
Object.defineProperty(exports, 'editorEventBus', {
|
|
608
|
+
enumerable: true,
|
|
609
|
+
get: function () {
|
|
610
|
+
return editorEventBus;
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
Object.defineProperty(exports, 'getColumnsDepth', {
|
|
614
|
+
enumerable: true,
|
|
615
|
+
get: function () {
|
|
616
|
+
return getColumnsDepth;
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
Object.defineProperty(exports, 'inlineCssToJs', {
|
|
620
|
+
enumerable: true,
|
|
621
|
+
get: function () {
|
|
622
|
+
return inlineCssToJs;
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
Object.defineProperty(exports, 'resolveConflictingStyles', {
|
|
626
|
+
enumerable: true,
|
|
627
|
+
get: function () {
|
|
628
|
+
return resolveConflictingStyles;
|
|
629
|
+
}
|
|
630
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const require_columns = require('../columns-ZSaLdkg9.cjs');
|
|
2
|
+
const require_core = require('../core-Rxnpk8B_.cjs');
|
|
3
|
+
|
|
4
|
+
exports.EmailNode = require_columns.EmailNode;
|
|
5
|
+
exports.composeReactEmail = require_core.composeReactEmail;
|
|
6
|
+
exports.editorEventBus = require_columns.editorEventBus;
|
|
7
|
+
exports.isDocumentVisuallyEmpty = require_core.isDocumentVisuallyEmpty;
|
|
8
|
+
exports.useEditor = require_core.useEditor;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as composeReactEmail, c as EditorEventMap, d as editorEventBus, i as RendererComponent, l as EditorEventName, n as EmailNode, o as isDocumentVisuallyEmpty, r as EmailNodeConfig, s as EditorEventHandler, t as useEditor, u as EditorEventSubscription } from "../index-CfslA7KT.cjs";
|
|
2
|
+
export { EditorEventHandler, EditorEventMap, EditorEventName, EditorEventSubscription, EmailNode, EmailNodeConfig, RendererComponent, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditor };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as composeReactEmail, c as EditorEventMap, d as editorEventBus, i as RendererComponent, l as EditorEventName, n as EmailNode, o as isDocumentVisuallyEmpty, r as EmailNodeConfig, s as EditorEventHandler, t as useEditor, u as EditorEventSubscription } from "../index-hbHRR7oB.mjs";
|
|
2
|
+
export { EditorEventHandler, EditorEventMap, EditorEventName, EditorEventSubscription, EmailNode, EmailNodeConfig, RendererComponent, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditor };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { _ as editorEventBus, m as EmailNode } from "../columns-CUxUEHje.mjs";
|
|
2
|
+
import { B as isDocumentVisuallyEmpty, t as useEditor, z as composeReactEmail } from "../core-C5_RDJBI.mjs";
|
|
3
|
+
|
|
4
|
+
export { EmailNode, composeReactEmail, editorEventBus, isDocumentVisuallyEmpty, useEditor };
|