@maily-to/core 0.0.22 → 0.0.24

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.
@@ -0,0 +1,4366 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+
59
+ // src/extensions.ts
60
+ var extensions_exports = {};
61
+ __export(extensions_exports, {
62
+ ButtonExtension: () => ButtonExtension,
63
+ Color: () => Color,
64
+ ColumnExtension: () => ColumnExtension,
65
+ ColumnsExtension: () => ColumnsExtension,
66
+ DEFAULT_BUTTON_ALIGNMENT: () => DEFAULT_BUTTON_ALIGNMENT,
67
+ DEFAULT_BUTTON_BACKGROUND_COLOR: () => DEFAULT_BUTTON_BACKGROUND_COLOR,
68
+ DEFAULT_BUTTON_BORDER_RADIUS: () => DEFAULT_BUTTON_BORDER_RADIUS,
69
+ DEFAULT_BUTTON_PADDING_BOTTOM: () => DEFAULT_BUTTON_PADDING_BOTTOM,
70
+ DEFAULT_BUTTON_PADDING_LEFT: () => DEFAULT_BUTTON_PADDING_LEFT,
71
+ DEFAULT_BUTTON_PADDING_RIGHT: () => DEFAULT_BUTTON_PADDING_RIGHT,
72
+ DEFAULT_BUTTON_PADDING_TOP: () => DEFAULT_BUTTON_PADDING_TOP,
73
+ DEFAULT_BUTTON_TEXT_COLOR: () => DEFAULT_BUTTON_TEXT_COLOR,
74
+ DEFAULT_BUTTON_VARIANT: () => DEFAULT_BUTTON_VARIANT,
75
+ DEFAULT_COLUMNS_GAP: () => DEFAULT_COLUMNS_GAP,
76
+ DEFAULT_COLUMN_VERTICAL_ALIGN: () => DEFAULT_COLUMN_VERTICAL_ALIGN,
77
+ DEFAULT_COLUMN_WIDTH: () => DEFAULT_COLUMN_WIDTH,
78
+ DEFAULT_LOGO_SIZE: () => DEFAULT_LOGO_SIZE,
79
+ DEFAULT_SECTION_ALIGN: () => DEFAULT_SECTION_ALIGN,
80
+ DEFAULT_SECTION_BACKGROUND_COLOR: () => DEFAULT_SECTION_BACKGROUND_COLOR,
81
+ DEFAULT_SECTION_BORDER_COLOR: () => DEFAULT_SECTION_BORDER_COLOR,
82
+ DEFAULT_SECTION_BORDER_RADIUS: () => DEFAULT_SECTION_BORDER_RADIUS,
83
+ DEFAULT_SECTION_BORDER_WIDTH: () => DEFAULT_SECTION_BORDER_WIDTH,
84
+ DEFAULT_SECTION_MARGIN_BOTTOM: () => DEFAULT_SECTION_MARGIN_BOTTOM,
85
+ DEFAULT_SECTION_MARGIN_LEFT: () => DEFAULT_SECTION_MARGIN_LEFT,
86
+ DEFAULT_SECTION_MARGIN_RIGHT: () => DEFAULT_SECTION_MARGIN_RIGHT,
87
+ DEFAULT_SECTION_MARGIN_TOP: () => DEFAULT_SECTION_MARGIN_TOP,
88
+ DEFAULT_SECTION_PADDING_BOTTOM: () => DEFAULT_SECTION_PADDING_BOTTOM,
89
+ DEFAULT_SECTION_PADDING_LEFT: () => DEFAULT_SECTION_PADDING_LEFT,
90
+ DEFAULT_SECTION_PADDING_RIGHT: () => DEFAULT_SECTION_PADDING_RIGHT,
91
+ DEFAULT_SECTION_PADDING_TOP: () => DEFAULT_SECTION_PADDING_TOP,
92
+ DEFAULT_SECTION_SHOW_IF_KEY: () => DEFAULT_SECTION_SHOW_IF_KEY,
93
+ Footer: () => Footer,
94
+ ForExtension: () => ForExtension,
95
+ HorizontalRule: () => HorizontalRule,
96
+ ImageExtension: () => ImageExtension,
97
+ LinkExtension: () => LinkExtension,
98
+ LogoExtension: () => LogoExtension,
99
+ MailyKit: () => MailyKit,
100
+ SectionExtension: () => SectionExtension,
101
+ SlashCommandExtension: () => SlashCommandExtension,
102
+ Spacer: () => Spacer,
103
+ VariableExtension: () => VariableExtension,
104
+ VariableList: () => VariableList,
105
+ VariablePluginKey: () => VariablePluginKey,
106
+ allowedButtonBorderRadius: () => allowedButtonBorderRadius,
107
+ allowedButtonVariant: () => allowedButtonVariant,
108
+ allowedLogoAlignment: () => allowedLogoAlignment,
109
+ allowedLogoSize: () => allowedLogoSize,
110
+ allowedSpacerSize: () => allowedSpacerSize,
111
+ getSlashCommandSuggestions: () => getSlashCommandSuggestions,
112
+ getVariableSuggestions: () => getVariableSuggestions,
113
+ logoSizes: () => logoSizes
114
+ });
115
+ module.exports = __toCommonJS(extensions_exports);
116
+
117
+ // src/editor/extensions/maily-kit.tsx
118
+ var import_core12 = require("@tiptap/core");
119
+ var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
120
+ var import_extension_list_item = __toESM(require("@tiptap/extension-list-item"));
121
+ var import_extension_paragraph = __toESM(require("@tiptap/extension-paragraph"));
122
+ var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"));
123
+ var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"));
124
+ var import_extension_text_style = __toESM(require("@tiptap/extension-text-style"));
125
+ var import_extension_heading = __toESM(require("@tiptap/extension-heading"));
126
+ var import_extension_underline = __toESM(require("@tiptap/extension-underline"));
127
+ var import_extension_document = __toESM(require("@tiptap/extension-document"));
128
+ var import_extension_focus = __toESM(require("@tiptap/extension-focus"));
129
+ var import_extension_dropcursor = __toESM(require("@tiptap/extension-dropcursor"));
130
+
131
+ // src/editor/extensions/color.ts
132
+ var import_extension_color = __toESM(require("@tiptap/extension-color"));
133
+ var Color = import_extension_color.default.extend({
134
+ addStorage() {
135
+ return {
136
+ colors: /* @__PURE__ */ new Set()
137
+ };
138
+ }
139
+ });
140
+
141
+ // src/editor/extensions/horizontal-rule.tsx
142
+ var import_core = require("@tiptap/core");
143
+ var import_extension_horizontal_rule = require("@tiptap/extension-horizontal-rule");
144
+ var HorizontalRule = import_extension_horizontal_rule.HorizontalRule.extend({
145
+ addInputRules() {
146
+ return [
147
+ new import_core.InputRule({
148
+ find: /^(?:---|—-|___\s|\*\*\*\s)$/,
149
+ handler: ({ state, range }) => {
150
+ const attributes = {};
151
+ const { tr } = state;
152
+ const start = range.from;
153
+ const end = range.to;
154
+ tr.insert(start - 1, this.type.create(attributes)).delete(
155
+ tr.mapping.map(start),
156
+ tr.mapping.map(end)
157
+ );
158
+ }
159
+ })
160
+ ];
161
+ },
162
+ addOptions() {
163
+ return {
164
+ HTMLAttributes: {
165
+ class: "mly-relative"
166
+ }
167
+ };
168
+ }
169
+ });
170
+
171
+ // src/editor/nodes/footer.ts
172
+ var import_core2 = require("@tiptap/core");
173
+ var Footer = import_core2.Node.create({
174
+ name: "footer",
175
+ group: "block",
176
+ content: "inline*",
177
+ addAttributes() {
178
+ return {
179
+ "maily-component": {
180
+ default: "footer",
181
+ renderHTML: (attributes) => {
182
+ return {
183
+ "data-maily-component": attributes["maily-component"]
184
+ };
185
+ },
186
+ parseHTML: (element) => element == null ? void 0 : element.getAttribute("data-maily-component")
187
+ }
188
+ };
189
+ },
190
+ addCommands() {
191
+ return {
192
+ setFooter: () => ({ commands }) => {
193
+ return commands.setNode(this.name);
194
+ }
195
+ };
196
+ },
197
+ parseHTML() {
198
+ return [{ tag: 'small[data-maily-component="footer"]' }];
199
+ },
200
+ renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
201
+ return [
202
+ "small",
203
+ (0, import_core2.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes2, {
204
+ class: "footer mly-block mly-text-[13px] mly-text-slate-500 mly-relative"
205
+ }),
206
+ 0
207
+ ];
208
+ }
209
+ });
210
+
211
+ // src/editor/nodes/spacer.ts
212
+ var import_core4 = require("@tiptap/core");
213
+
214
+ // src/editor/utils/update-attribute.ts
215
+ function updateAttributes(type, attrs) {
216
+ return ({ commands }) => commands.command(({ tr, state, dispatch }) => {
217
+ if (dispatch) {
218
+ let lastPos = null;
219
+ tr.selection.ranges.forEach((range) => {
220
+ state.doc.nodesBetween(
221
+ range.$from.pos,
222
+ range.$to.pos,
223
+ (node, pos) => {
224
+ if (node.type.name === type) {
225
+ lastPos = pos;
226
+ }
227
+ }
228
+ );
229
+ });
230
+ if (lastPos !== null) {
231
+ const node = state.doc.nodeAt(lastPos);
232
+ if (node) {
233
+ tr.setNodeMarkup(lastPos, null, __spreadValues(__spreadValues({}, node.attrs), attrs));
234
+ } else {
235
+ for (const [key, value] of Object.entries(attrs)) {
236
+ tr.setNodeAttribute(lastPos, key, value);
237
+ }
238
+ }
239
+ }
240
+ if (type === "button") {
241
+ tr.setSelection(tr.selection);
242
+ }
243
+ }
244
+ return true;
245
+ });
246
+ }
247
+
248
+ // src/editor/nodes/section/section.ts
249
+ var import_core3 = require("@tiptap/core");
250
+ var DEFAULT_SECTION_BACKGROUND_COLOR = "#f7f7f7";
251
+ var DEFAULT_SECTION_ALIGN = "left";
252
+ var DEFAULT_SECTION_BORDER_WIDTH = 2;
253
+ var DEFAULT_SECTION_BORDER_COLOR = "#e2e2e2";
254
+ var DEFAULT_SECTION_BORDER_RADIUS = 0;
255
+ var DEFAULT_SECTION_MARGIN_TOP = 0;
256
+ var DEFAULT_SECTION_MARGIN_RIGHT = 0;
257
+ var DEFAULT_SECTION_MARGIN_BOTTOM = 0;
258
+ var DEFAULT_SECTION_MARGIN_LEFT = 0;
259
+ var DEFAULT_SECTION_PADDING_TOP = 5;
260
+ var DEFAULT_SECTION_PADDING_RIGHT = 5;
261
+ var DEFAULT_SECTION_PADDING_BOTTOM = 5;
262
+ var DEFAULT_SECTION_PADDING_LEFT = 5;
263
+ var DEFAULT_SECTION_SHOW_IF_KEY = null;
264
+ var SectionExtension = import_core3.Node.create({
265
+ name: "section",
266
+ group: "block",
267
+ content: "(block|columns)+",
268
+ defining: true,
269
+ isolating: true,
270
+ addAttributes() {
271
+ return {
272
+ borderRadius: {
273
+ default: 0,
274
+ parseHTML: (element) => {
275
+ var _a, _b;
276
+ return Number((_b = (_a = element == null ? void 0 : element.style) == null ? void 0 : _a.borderRadius) == null ? void 0 : _b.replace(/['"]+/g, ""));
277
+ },
278
+ renderHTML: (attributes) => {
279
+ if (!attributes.borderRadius) {
280
+ return {};
281
+ }
282
+ return {
283
+ style: `border-radius: ${attributes.borderRadius}px`
284
+ };
285
+ }
286
+ },
287
+ backgroundColor: {
288
+ default: DEFAULT_SECTION_BACKGROUND_COLOR,
289
+ parseHTML: (element) => {
290
+ return element.style.backgroundColor;
291
+ },
292
+ renderHTML: (attributes) => {
293
+ if (!attributes.backgroundColor) {
294
+ return {};
295
+ }
296
+ return {
297
+ style: `background-color: ${attributes.backgroundColor};--bg-color: ${attributes.backgroundColor}`
298
+ };
299
+ }
300
+ },
301
+ align: {
302
+ default: DEFAULT_SECTION_ALIGN,
303
+ parseHTML: (element) => {
304
+ return element.getAttribute("align") || DEFAULT_SECTION_ALIGN;
305
+ },
306
+ renderHTML(attributes) {
307
+ if (!attributes.align) {
308
+ return {};
309
+ }
310
+ return {
311
+ align: attributes.align
312
+ };
313
+ }
314
+ },
315
+ borderWidth: {
316
+ default: DEFAULT_SECTION_BORDER_WIDTH,
317
+ parseHTML: (element) => {
318
+ var _a, _b;
319
+ return Number((_b = (_a = element == null ? void 0 : element.style) == null ? void 0 : _a.borderWidth) == null ? void 0 : _b.replace(/['"]+/g, "")) || 0;
320
+ },
321
+ renderHTML: (attributes) => {
322
+ if (!attributes.borderWidth) {
323
+ return {};
324
+ }
325
+ return {
326
+ style: `border-width: ${attributes.borderWidth}px`
327
+ };
328
+ }
329
+ },
330
+ borderColor: {
331
+ default: DEFAULT_SECTION_BORDER_COLOR,
332
+ parseHTML: (element) => {
333
+ return element.style.borderColor;
334
+ },
335
+ renderHTML: (attributes) => {
336
+ if (!attributes.borderColor) {
337
+ return {};
338
+ }
339
+ return {
340
+ style: `border-color: ${attributes.borderColor}`
341
+ };
342
+ }
343
+ },
344
+ paddingTop: {
345
+ default: DEFAULT_SECTION_PADDING_TOP,
346
+ parseHTML: (element) => {
347
+ var _a, _b;
348
+ return Number((_b = (_a = element == null ? void 0 : element.style) == null ? void 0 : _a.paddingTop) == null ? void 0 : _b.replace(/['"]+/g, "")) || 0;
349
+ },
350
+ renderHTML: (attributes) => {
351
+ if (!attributes.paddingTop) {
352
+ return {};
353
+ }
354
+ return {
355
+ style: `padding-top: ${attributes.paddingTop}px`
356
+ };
357
+ }
358
+ },
359
+ paddingRight: {
360
+ default: DEFAULT_SECTION_PADDING_RIGHT,
361
+ parseHTML: (element) => {
362
+ var _a, _b;
363
+ return Number((_b = (_a = element == null ? void 0 : element.style) == null ? void 0 : _a.paddingRight) == null ? void 0 : _b.replace(/['"]+/g, "")) || 0;
364
+ },
365
+ renderHTML: (attributes) => {
366
+ if (!attributes.paddingRight) {
367
+ return {};
368
+ }
369
+ return {
370
+ style: `padding-right: ${attributes.paddingRight}px`
371
+ };
372
+ }
373
+ },
374
+ paddingBottom: {
375
+ default: DEFAULT_SECTION_PADDING_BOTTOM,
376
+ parseHTML: (element) => {
377
+ var _a, _b;
378
+ return Number((_b = (_a = element == null ? void 0 : element.style) == null ? void 0 : _a.paddingBottom) == null ? void 0 : _b.replace(/['"]+/g, "")) || 0;
379
+ },
380
+ renderHTML: (attributes) => {
381
+ if (!attributes.paddingBottom) {
382
+ return {};
383
+ }
384
+ return {
385
+ style: `padding-bottom: ${attributes.paddingBottom}px`
386
+ };
387
+ }
388
+ },
389
+ paddingLeft: {
390
+ default: DEFAULT_SECTION_PADDING_LEFT,
391
+ parseHTML: (element) => {
392
+ var _a, _b;
393
+ return Number((_b = (_a = element == null ? void 0 : element.style) == null ? void 0 : _a.paddingLeft) == null ? void 0 : _b.replace(/['"]+/g, "")) || 0;
394
+ },
395
+ renderHTML: (attributes) => {
396
+ if (!attributes.paddingLeft) {
397
+ return {};
398
+ }
399
+ return {
400
+ style: `padding-left: ${attributes.paddingLeft}px`
401
+ };
402
+ }
403
+ },
404
+ marginTop: {
405
+ default: DEFAULT_SECTION_MARGIN_TOP,
406
+ parseHTML: (element) => {
407
+ var _a, _b;
408
+ return Number((_b = (_a = element == null ? void 0 : element.style) == null ? void 0 : _a.marginTop) == null ? void 0 : _b.replace(/['"]+/g, "")) || 0;
409
+ },
410
+ renderHTML: (attributes) => {
411
+ if (!attributes.marginTop) {
412
+ return {};
413
+ }
414
+ return {
415
+ marginTop: attributes.marginTop
416
+ };
417
+ }
418
+ },
419
+ marginRight: {
420
+ default: DEFAULT_SECTION_MARGIN_RIGHT,
421
+ parseHTML: (element) => {
422
+ var _a, _b;
423
+ return Number((_b = (_a = element == null ? void 0 : element.style) == null ? void 0 : _a.marginRight) == null ? void 0 : _b.replace(/['"]+/g, "")) || 0;
424
+ },
425
+ renderHTML: (attributes) => {
426
+ if (!attributes.marginRight) {
427
+ return {};
428
+ }
429
+ return {
430
+ marginRight: attributes.marginRight
431
+ };
432
+ }
433
+ },
434
+ marginBottom: {
435
+ default: DEFAULT_SECTION_MARGIN_BOTTOM,
436
+ parseHTML: (element) => {
437
+ var _a, _b;
438
+ return Number((_b = (_a = element == null ? void 0 : element.style) == null ? void 0 : _a.marginBottom) == null ? void 0 : _b.replace(/['"]+/g, "")) || 0;
439
+ },
440
+ renderHTML: (attributes) => {
441
+ if (!attributes.marginBottom) {
442
+ return {};
443
+ }
444
+ return {
445
+ marginBottom: attributes.marginBottom
446
+ };
447
+ }
448
+ },
449
+ marginLeft: {
450
+ default: DEFAULT_SECTION_MARGIN_LEFT,
451
+ parseHTML: (element) => {
452
+ var _a, _b;
453
+ return Number((_b = (_a = element == null ? void 0 : element.style) == null ? void 0 : _a.marginLeft) == null ? void 0 : _b.replace(/['"]+/g, "")) || 0;
454
+ },
455
+ renderHTML: (attributes) => {
456
+ if (!attributes.marginLeft) {
457
+ return {};
458
+ }
459
+ return {
460
+ marginLeft: attributes.marginLeft
461
+ };
462
+ }
463
+ },
464
+ showIfKey: {
465
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
466
+ parseHTML: (element) => {
467
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
468
+ },
469
+ renderHTML(attributes) {
470
+ if (!attributes.showIfKey) {
471
+ return {};
472
+ }
473
+ return {
474
+ "data-show-if-key": attributes.showIfKey
475
+ };
476
+ }
477
+ }
478
+ };
479
+ },
480
+ addCommands() {
481
+ return {
482
+ setSection: () => ({ commands }) => {
483
+ return commands.insertContent({
484
+ type: this.name,
485
+ attrs: {
486
+ type: this.name
487
+ },
488
+ content: [
489
+ {
490
+ type: "paragraph"
491
+ }
492
+ ]
493
+ });
494
+ },
495
+ updateSection: (attrs) => updateAttributes(this.name, attrs)
496
+ };
497
+ },
498
+ renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
499
+ const {
500
+ marginTop = 0,
501
+ marginRight = 0,
502
+ marginBottom = 0,
503
+ marginLeft = 0
504
+ } = HTMLAttributes2;
505
+ return [
506
+ "table",
507
+ {
508
+ "data-type": this.name,
509
+ border: 0,
510
+ cellpadding: 0,
511
+ cellspacing: 0,
512
+ class: "mly-w-full mly-border-separate mly-relative mly-table-fixed",
513
+ style: `margin-top: ${marginTop}px; margin-right: ${marginRight}px; margin-bottom: ${marginBottom}px; margin-left: ${marginLeft}px;`
514
+ },
515
+ [
516
+ "tbody",
517
+ {
518
+ class: "mly-w-full"
519
+ },
520
+ [
521
+ "tr",
522
+ {
523
+ class: "mly-w-full"
524
+ },
525
+ [
526
+ "td",
527
+ (0, import_core3.mergeAttributes)(HTMLAttributes2, {
528
+ "data-type": "section-cell",
529
+ style: "border-style: solid",
530
+ class: "mly-w-full [text-align:revert-layer]"
531
+ }),
532
+ 0
533
+ ]
534
+ ]
535
+ ]
536
+ ];
537
+ },
538
+ parseHTML() {
539
+ return [
540
+ {
541
+ tag: 'table[data-type="section"]'
542
+ }
543
+ ];
544
+ }
545
+ });
546
+
547
+ // src/editor/nodes/spacer.ts
548
+ var allowedSpacerSize = ["sm", "md", "lg", "xl"];
549
+ var DEFAULT_HEIGHT = "sm";
550
+ function getHeightStyle(height) {
551
+ const heights = { sm: "8px", md: "16px", lg: "32px", xl: "64px" };
552
+ return `width: 100%; height: ${heights[height] || heights[DEFAULT_HEIGHT]}`;
553
+ }
554
+ var Spacer = import_core4.Node.create({
555
+ name: "spacer",
556
+ priority: 1e3,
557
+ group: "block",
558
+ draggable: true,
559
+ addAttributes() {
560
+ return {
561
+ height: {
562
+ default: null,
563
+ parseHTML: (element) => element.getAttribute("data-height"),
564
+ renderHTML: (attributes) => {
565
+ return {
566
+ "data-height": attributes.height
567
+ };
568
+ }
569
+ },
570
+ showIfKey: {
571
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
572
+ parseHTML: (element) => {
573
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
574
+ },
575
+ renderHTML(attributes) {
576
+ if (!attributes.showIfKey) {
577
+ return {};
578
+ }
579
+ return {
580
+ "data-show-if-key": attributes.showIfKey
581
+ };
582
+ }
583
+ }
584
+ };
585
+ },
586
+ addCommands() {
587
+ return {
588
+ setSpacer: (options) => ({ commands }) => {
589
+ return commands.insertContent({
590
+ type: this.name,
591
+ attrs: {
592
+ height: options.height
593
+ }
594
+ });
595
+ },
596
+ setSpacerSize: (height) => ({ commands }) => {
597
+ if (!allowedSpacerSize.includes(height)) {
598
+ throw new Error("Invalid spacer height");
599
+ }
600
+ return commands.updateAttributes("spacer", { height });
601
+ },
602
+ setSpacerShowIfKey: (showIfKey) => ({ commands }) => {
603
+ return commands.updateAttributes("spacer", { showIfKey });
604
+ },
605
+ unsetSpacer: () => ({ commands }) => {
606
+ return commands.deleteNode("spacer");
607
+ }
608
+ };
609
+ },
610
+ renderHTML({ HTMLAttributes: HTMLAttributes2, node }) {
611
+ const { height } = node.attrs;
612
+ HTMLAttributes2.style = getHeightStyle(height);
613
+ return [
614
+ "div",
615
+ (0, import_core4.mergeAttributes)(
616
+ {
617
+ "data-maily-component": this.name
618
+ },
619
+ this.options.HTMLAttributes,
620
+ HTMLAttributes2,
621
+ {
622
+ class: "spacer mly-relative mly-z-50",
623
+ contenteditable: false
624
+ }
625
+ )
626
+ ];
627
+ },
628
+ parseHTML() {
629
+ return [{ tag: `div[data-maily-component="${this.name}"]` }];
630
+ }
631
+ });
632
+
633
+ // src/editor/extensions/link-card.ts
634
+ var import_core5 = require("@tiptap/core");
635
+ var import_react2 = require("@tiptap/react");
636
+
637
+ // src/editor/nodes/link-card.tsx
638
+ var import_react = require("@tiptap/react");
639
+
640
+ // src/editor/components/input.tsx
641
+ var React = __toESM(require("react"));
642
+
643
+ // src/editor/utils/classname.ts
644
+ var import_clsx = require("clsx");
645
+ var import_tailwind_merge = require("tailwind-merge");
646
+ var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
647
+ prefix: "mly-"
648
+ });
649
+ function cn(...inputs) {
650
+ return twMerge((0, import_clsx.clsx)(inputs));
651
+ }
652
+
653
+ // src/editor/utils/constants.ts
654
+ var AUTOCOMPLETE_PASSWORD_MANAGERS_OFF = Object.freeze({
655
+ autoComplete: "off",
656
+ "data-1p-ignore": true,
657
+ "data-form-type": "other"
658
+ });
659
+
660
+ // src/editor/components/input.tsx
661
+ var import_jsx_runtime = require("react/jsx-runtime");
662
+ var Input = React.forwardRef(
663
+ (_a, ref) => {
664
+ var _b = _a, { className, type } = _b, props = __objRest(_b, ["className", "type"]);
665
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
666
+ "input",
667
+ __spreadValues(__spreadProps(__spreadValues({}, AUTOCOMPLETE_PASSWORD_MANAGERS_OFF), {
668
+ type,
669
+ className: cn(
670
+ "mly-flex mly-h-10 mly-w-full mly-rounded-md mly-border mly-border-gray-200 mly-bg-white mly-px-3 mly-py-2 mly-text-sm mly-ring-offset-white file:mly-border-0 file:mly-bg-transparent file:mly-text-sm file:mly-font-medium placeholder:mly-text-gray-500 focus-visible:mly-outline-none focus-visible:mly-ring-2 focus-visible:mly-ring-gray-400 focus-visible:mly-ring-offset-2 disabled:mly-cursor-not-allowed disabled:mly-opacity-50",
671
+ "mly-editor",
672
+ className
673
+ ),
674
+ ref
675
+ }), props)
676
+ );
677
+ }
678
+ );
679
+ Input.displayName = "Input";
680
+
681
+ // src/editor/components/popover.tsx
682
+ var React2 = __toESM(require("react"));
683
+ var PopoverPrimitive = __toESM(require("@radix-ui/react-popover"));
684
+ var import_jsx_runtime2 = require("react/jsx-runtime");
685
+ var Popover = PopoverPrimitive.Root;
686
+ var PopoverTrigger = PopoverPrimitive.Trigger;
687
+ var PopoverContent = React2.forwardRef((_a, ref) => {
688
+ var _b = _a, { className, align = "center", sideOffset = 4 } = _b, props = __objRest(_b, ["className", "align", "sideOffset"]);
689
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PopoverPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
690
+ PopoverPrimitive.Content,
691
+ __spreadValues({
692
+ ref,
693
+ align,
694
+ sideOffset,
695
+ className: cn(
696
+ "mly-z-[9999] mly-w-72 mly-rounded-md mly-border mly-border-gray-200 mly-bg-white mly-p-4 mly-text-gray-950 mly-shadow-md mly-outline-none",
697
+ "mly-editor",
698
+ className
699
+ )
700
+ }, props)
701
+ ) });
702
+ });
703
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
704
+
705
+ // src/editor/components/textarea.tsx
706
+ var React3 = __toESM(require("react"));
707
+ var import_jsx_runtime3 = require("react/jsx-runtime");
708
+ var Textarea = React3.forwardRef(
709
+ (_a, ref) => {
710
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
711
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
712
+ "textarea",
713
+ __spreadValues({
714
+ className: cn(
715
+ "mly-flex mly-min-h-24 mly-w-full mly-rounded-md mly-border mly-border-gray-200 mly-bg-white mly-px-3 mly-py-2 mly-text-sm mly-ring-offset-white file:mly-border-0 file:mly-bg-transparent file:mly-text-sm file:mly-font-medium placeholder:mly-text-gray-500 focus-visible:mly-outline-none focus-visible:mly-ring-2 focus-visible:mly-ring-gray-400 focus-visible:mly-ring-offset-2 disabled:mly-cursor-not-allowed disabled:mly-opacity-50",
716
+ "mly-editor",
717
+ className
718
+ ),
719
+ ref
720
+ }, props)
721
+ );
722
+ }
723
+ );
724
+ Textarea.displayName = "Textarea";
725
+
726
+ // src/editor/nodes/link-card.tsx
727
+ var import_jsx_runtime4 = require("react/jsx-runtime");
728
+ function LinkCardComponent(props) {
729
+ const { title, description, link, linkTitle, image: image2, badgeText, subTitle } = props.node.attrs;
730
+ const { getPos, editor } = props;
731
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
732
+ import_react.NodeViewWrapper,
733
+ {
734
+ className: `react-component ${props.selected && "ProseMirror-selectednode"}`,
735
+ draggable: editor.isEditable,
736
+ "data-drag-handle": editor.isEditable,
737
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Popover, { open: props.selected, children: [
738
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
739
+ "div",
740
+ {
741
+ tabIndex: -1,
742
+ onClick: (e) => {
743
+ e.preventDefault();
744
+ const pos = getPos();
745
+ editor.commands.setNodeSelection(pos);
746
+ },
747
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mly-no-prose mly-flex mly-flex-col mly-rounded-lg mly-border mly-border-gray-300", children: [
748
+ image2 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mly-relative mly-mb-1.5 mly-w-full mly-shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
749
+ "img",
750
+ {
751
+ src: image2,
752
+ alt: "link-card",
753
+ className: "mly-no-prose !mly-mb-0 mly-h-full mly-w-full mly-rounded-t-lg",
754
+ draggable: editor.isEditable
755
+ }
756
+ ) }),
757
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mly-flex mly-items-stretch mly-p-3", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cn("mly-flex mly-flex-col"), children: [
758
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "!mly-mb-1.5 mly-flex mly-items-center mly-gap-1.5", children: [
759
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { className: "!mly-mb-0 !mly-text-lg mly-font-semibold", children: title }),
760
+ badgeText && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "!mly-font-base text-xs mly-rounded-md mly-bg-yellow-200 mly-px-2 mly-py-1 mly-font-semibold mly-leading-none", children: badgeText }),
761
+ " ",
762
+ subTitle && !badgeText && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "!mly-font-base text-xs mly-font-regular mly-rounded-md mly-leading-none mly-text-gray-400", children: subTitle })
763
+ ] }),
764
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "!mly-my-0 !mly-text-base mly-text-gray-500", children: [
765
+ description,
766
+ " ",
767
+ linkTitle ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: link, className: "mly-font-semibold", children: linkTitle }) : null
768
+ ] })
769
+ ] }) })
770
+ ] })
771
+ }
772
+ ) }),
773
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
774
+ PopoverContent,
775
+ {
776
+ align: "end",
777
+ className: "mly-flex mly-w-96 mly-flex-col mly-gap-2",
778
+ sideOffset: 10,
779
+ onOpenAutoFocus: (e) => e.preventDefault(),
780
+ onCloseAutoFocus: (e) => e.preventDefault(),
781
+ children: [
782
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mly-w-full mly-space-y-1", children: [
783
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "mly-text-xs mly-font-normal mly-text-slate-400", children: "Image" }),
784
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
785
+ Input,
786
+ {
787
+ placeholder: "Add Image",
788
+ type: "url",
789
+ value: image2,
790
+ onChange: (e) => {
791
+ props.updateAttributes({
792
+ image: e.target.value
793
+ });
794
+ }
795
+ }
796
+ )
797
+ ] }),
798
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mly-w-full mly-space-y-1", children: [
799
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "mly-text-xs mly-font-normal mly-text-slate-400", children: "Title" }),
800
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
801
+ Input,
802
+ {
803
+ placeholder: "Add title",
804
+ value: title,
805
+ onChange: (e) => {
806
+ props.updateAttributes({
807
+ title: e.target.value
808
+ });
809
+ }
810
+ }
811
+ )
812
+ ] }),
813
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mly-w-full mly-space-y-1", children: [
814
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "mly-text-xs mly-font-normal mly-text-slate-400", children: "Description" }),
815
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
816
+ Textarea,
817
+ {
818
+ placeholder: "Add description here",
819
+ value: description,
820
+ onChange: (e) => {
821
+ props.updateAttributes({
822
+ description: e.target.value
823
+ });
824
+ }
825
+ }
826
+ )
827
+ ] }),
828
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mly-grid mly-grid-cols-2 mly-gap-2", children: [
829
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mly-w-full mly-space-y-1", children: [
830
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "mly-text-xs mly-font-normal mly-text-slate-400", children: "Link Title" }),
831
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
832
+ Input,
833
+ {
834
+ placeholder: "Add link title here",
835
+ value: linkTitle,
836
+ onChange: (e) => {
837
+ props.updateAttributes({
838
+ linkTitle: e.target.value
839
+ });
840
+ }
841
+ }
842
+ )
843
+ ] }),
844
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mly-w-full mly-space-y-1", children: [
845
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "mly-text-xs mly-font-normal mly-text-slate-400", children: "Link" }),
846
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
847
+ Input,
848
+ {
849
+ placeholder: "Add link here",
850
+ value: link,
851
+ onChange: (e) => {
852
+ props.updateAttributes({
853
+ link: e.target.value
854
+ });
855
+ }
856
+ }
857
+ )
858
+ ] })
859
+ ] }),
860
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mly-grid mly-grid-cols-2 mly-gap-2", children: [
861
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mly-w-full mly-space-y-1", children: [
862
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "mly-text-xs mly-font-normal mly-text-slate-400", children: "Badge Text" }),
863
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
864
+ Input,
865
+ {
866
+ placeholder: "Add badge text here",
867
+ value: badgeText,
868
+ onChange: (e) => {
869
+ props.updateAttributes({
870
+ badgeText: e.target.value
871
+ });
872
+ }
873
+ }
874
+ )
875
+ ] }),
876
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mly-w-full mly-space-y-1", children: [
877
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "mly-text-xs mly-font-normal mly-text-slate-400", children: "Sub Title" }),
878
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
879
+ Input,
880
+ {
881
+ placeholder: "Add sub title here",
882
+ value: subTitle,
883
+ onChange: (e) => {
884
+ props.updateAttributes({
885
+ subTitle: e.target.value
886
+ });
887
+ }
888
+ }
889
+ )
890
+ ] })
891
+ ] })
892
+ ]
893
+ }
894
+ )
895
+ ] })
896
+ }
897
+ );
898
+ }
899
+
900
+ // src/editor/extensions/link-card.ts
901
+ var LinkCardExtension = import_core5.Node.create({
902
+ name: "linkCard",
903
+ group: "block",
904
+ atom: true,
905
+ draggable: true,
906
+ addAttributes() {
907
+ return {
908
+ mailyComponent: {
909
+ default: "linkCard"
910
+ },
911
+ title: {
912
+ default: ""
913
+ },
914
+ description: {
915
+ default: ""
916
+ },
917
+ link: {
918
+ default: ""
919
+ },
920
+ linkTitle: {
921
+ default: ""
922
+ },
923
+ image: {
924
+ default: ""
925
+ },
926
+ subTitle: {
927
+ default: ""
928
+ },
929
+ badgeText: {
930
+ default: ""
931
+ }
932
+ };
933
+ },
934
+ parseHTML() {
935
+ return [
936
+ {
937
+ tag: `a[data-maily-component="${this.name}"]`
938
+ }
939
+ ];
940
+ },
941
+ renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
942
+ return [
943
+ "div",
944
+ (0, import_core5.mergeAttributes)(
945
+ {
946
+ "data-maily-component": this.name
947
+ },
948
+ HTMLAttributes2
949
+ )
950
+ ];
951
+ },
952
+ addCommands() {
953
+ return {
954
+ setLinkCard: () => ({ commands }) => {
955
+ return commands.insertContent({
956
+ type: this.name,
957
+ attrs: {
958
+ mailyComponent: this.name
959
+ }
960
+ });
961
+ }
962
+ };
963
+ },
964
+ addNodeView() {
965
+ return (0, import_react2.ReactNodeViewRenderer)(LinkCardComponent, {
966
+ className: "mly-relative"
967
+ });
968
+ }
969
+ });
970
+
971
+ // src/editor/utils/columns.ts
972
+ var import_model = require("@tiptap/pm/model");
973
+ var import_state = require("@tiptap/pm/state");
974
+ var import_uuid2 = require("uuid");
975
+ var import_core7 = require("@tiptap/core");
976
+
977
+ // src/editor/nodes/columns/column.ts
978
+ var import_core6 = require("@tiptap/core");
979
+ var import_uuid = require("uuid");
980
+ var DEFAULT_COLUMN_WIDTH = "auto";
981
+ var DEFAULT_COLUMN_VERTICAL_ALIGN = "top";
982
+ var ColumnExtension = import_core6.Node.create({
983
+ name: "column",
984
+ content: "block+",
985
+ isolating: true,
986
+ addAttributes() {
987
+ return {
988
+ columnId: {
989
+ default: null,
990
+ parseHTML: (element) => element.getAttribute("data-column-id") || (0, import_uuid.v4)(),
991
+ renderHTML: (attributes) => {
992
+ if (!attributes.columnId) {
993
+ return {
994
+ "data-column-id": (0, import_uuid.v4)()
995
+ };
996
+ }
997
+ return {
998
+ "data-column-id": attributes.columnId
999
+ };
1000
+ }
1001
+ },
1002
+ width: {
1003
+ default: DEFAULT_COLUMN_WIDTH,
1004
+ parseHTML: (element) => element.style.width.replace(/['"]+/g, "") || DEFAULT_COLUMN_WIDTH,
1005
+ renderHTML: (attributes) => {
1006
+ if (!attributes.width || attributes.width === DEFAULT_COLUMN_WIDTH) {
1007
+ return {};
1008
+ }
1009
+ return {
1010
+ style: `width: ${attributes.width}%;max-width:${attributes.width}%`
1011
+ };
1012
+ }
1013
+ },
1014
+ verticalAlign: {
1015
+ default: DEFAULT_COLUMN_VERTICAL_ALIGN,
1016
+ parseHTML: (element) => {
1017
+ var _a;
1018
+ return ((_a = element == null ? void 0 : element.style) == null ? void 0 : _a.verticalAlign) || "top";
1019
+ },
1020
+ renderHTML: (attributes) => {
1021
+ const { verticalAlign } = attributes;
1022
+ if (!verticalAlign || verticalAlign === DEFAULT_COLUMN_VERTICAL_ALIGN) {
1023
+ return {};
1024
+ }
1025
+ if (verticalAlign === "middle") {
1026
+ return {
1027
+ style: `display: flex;flex-direction: column;justify-content: center;`
1028
+ };
1029
+ } else if (verticalAlign === "bottom") {
1030
+ return {
1031
+ style: `display: flex;flex-direction: column;justify-content: flex-end;`
1032
+ };
1033
+ }
1034
+ }
1035
+ }
1036
+ };
1037
+ },
1038
+ addCommands() {
1039
+ return {
1040
+ updateColumn: (attrs) => updateAttributes(this.name, attrs)
1041
+ };
1042
+ },
1043
+ renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
1044
+ return [
1045
+ "div",
1046
+ (0, import_core6.mergeAttributes)(HTMLAttributes2, {
1047
+ "data-type": "column",
1048
+ class: "hide-scrollbars"
1049
+ }),
1050
+ 0
1051
+ ];
1052
+ },
1053
+ parseHTML() {
1054
+ return [
1055
+ {
1056
+ tag: 'div[data-type="column"]'
1057
+ }
1058
+ ];
1059
+ }
1060
+ });
1061
+
1062
+ // src/editor/utils/columns.ts
1063
+ function getClosestNodeByName(editor, name) {
1064
+ const { state } = editor.view;
1065
+ return (0, import_core7.findParentNode)((node) => node.type.name === name)(state.selection);
1066
+ }
1067
+ function goToColumn(editor, type) {
1068
+ const columnsNode = getClosestNodeByName(editor, "columns");
1069
+ const columnNode = getClosestNodeByName(editor, "column");
1070
+ if (!columnsNode || !columnNode) {
1071
+ return false;
1072
+ }
1073
+ const { state, dispatch } = editor.view;
1074
+ const cols = columnsNode.node;
1075
+ let currColumnIndex = 0;
1076
+ cols.content.forEach((child, _, index) => {
1077
+ var _a, _b, _c;
1078
+ if (child.eq(columnNode.node) && ((_a = child == null ? void 0 : child.attrs) == null ? void 0 : _a.columnId) === ((_c = (_b = columnNode.node) == null ? void 0 : _b.attrs) == null ? void 0 : _c.columnId)) {
1079
+ currColumnIndex = index;
1080
+ }
1081
+ });
1082
+ const nextColumnIndex = type === "next" ? currColumnIndex + 1 : currColumnIndex - 1;
1083
+ if (nextColumnIndex < 0 || nextColumnIndex >= cols.childCount) {
1084
+ return false;
1085
+ }
1086
+ let nextColumnPos = columnsNode.pos;
1087
+ cols.content.forEach((child, _, index) => {
1088
+ if (index < nextColumnIndex) {
1089
+ nextColumnPos += child.nodeSize;
1090
+ }
1091
+ });
1092
+ const tr = state.tr.setTime(Date.now());
1093
+ const textSelection = import_state.TextSelection.near(tr.doc.resolve(nextColumnPos));
1094
+ tr.setSelection(textSelection);
1095
+ dispatch(tr);
1096
+ return true;
1097
+ }
1098
+
1099
+ // src/editor/nodes/columns/columns.ts
1100
+ var import_core8 = require("@tiptap/core");
1101
+ var import_core9 = require("@tiptap/core");
1102
+ var import_uuid3 = require("uuid");
1103
+ var DEFAULT_COLUMNS_GAP = 8;
1104
+ var ColumnsExtension = import_core9.Node.create({
1105
+ name: "columns",
1106
+ group: "columns",
1107
+ content: "column+",
1108
+ defining: true,
1109
+ isolating: true,
1110
+ addAttributes() {
1111
+ return {
1112
+ showIfKey: {
1113
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
1114
+ parseHTML: (element) => {
1115
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
1116
+ },
1117
+ renderHTML(attributes) {
1118
+ if (!attributes.showIfKey) {
1119
+ return {};
1120
+ }
1121
+ return {
1122
+ "data-show-if-key": attributes.showIfKey
1123
+ };
1124
+ }
1125
+ },
1126
+ gap: {
1127
+ default: DEFAULT_COLUMNS_GAP,
1128
+ parseHTML: (element) => {
1129
+ return Number(element.style.gap) || DEFAULT_COLUMNS_GAP;
1130
+ },
1131
+ renderHTML(attributes) {
1132
+ if (!attributes.gap) {
1133
+ return {};
1134
+ }
1135
+ return {
1136
+ style: `gap: ${attributes.gap}px`
1137
+ };
1138
+ }
1139
+ }
1140
+ };
1141
+ },
1142
+ addCommands() {
1143
+ return {
1144
+ setColumns: () => ({ commands }) => {
1145
+ return commands.insertContent({
1146
+ type: this.name,
1147
+ attrs: {},
1148
+ content: [
1149
+ {
1150
+ type: "column",
1151
+ attrs: {
1152
+ columnId: (0, import_uuid3.v4)()
1153
+ },
1154
+ content: [
1155
+ {
1156
+ type: "paragraph"
1157
+ }
1158
+ ]
1159
+ },
1160
+ {
1161
+ type: "column",
1162
+ attrs: {
1163
+ columnId: (0, import_uuid3.v4)()
1164
+ },
1165
+ content: [
1166
+ {
1167
+ type: "paragraph"
1168
+ }
1169
+ ]
1170
+ }
1171
+ ]
1172
+ });
1173
+ },
1174
+ updateColumns: (attrs) => updateAttributes(this.name, attrs)
1175
+ };
1176
+ },
1177
+ renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
1178
+ return [
1179
+ "div",
1180
+ (0, import_core8.mergeAttributes)(HTMLAttributes2, {
1181
+ "data-type": "columns",
1182
+ class: "mly-relative"
1183
+ }),
1184
+ 0
1185
+ ];
1186
+ },
1187
+ parseHTML() {
1188
+ return [
1189
+ {
1190
+ tag: 'div[data-type="columns"]'
1191
+ }
1192
+ ];
1193
+ },
1194
+ addKeyboardShortcuts() {
1195
+ return {
1196
+ Tab: () => {
1197
+ return goToColumn(this.editor, "next");
1198
+ },
1199
+ "Shift-Tab": () => {
1200
+ return goToColumn(this.editor, "previous");
1201
+ }
1202
+ };
1203
+ }
1204
+ });
1205
+
1206
+ // src/editor/nodes/for/for.ts
1207
+ var import_core10 = require("@tiptap/core");
1208
+ var import_react4 = require("@tiptap/react");
1209
+
1210
+ // src/editor/nodes/for/for-view.tsx
1211
+ var import_react3 = require("@tiptap/react");
1212
+ var import_lucide_react = require("lucide-react");
1213
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1214
+ function ForView(props) {
1215
+ const { editor, getPos } = props;
1216
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1217
+ import_react3.NodeViewWrapper,
1218
+ {
1219
+ draggable: editor.isEditable,
1220
+ "data-drag-handle": editor.isEditable,
1221
+ "data-type": "for",
1222
+ className: "mly-relative",
1223
+ children: [
1224
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react3.NodeViewContent, { className: "is-editable" }),
1225
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1226
+ "div",
1227
+ {
1228
+ role: "button",
1229
+ "data-repeat-indicator": "",
1230
+ className: "mly-absolute mly-inset-y-0 mly-right-0 mly-flex mly-translate-x-full mly-cursor-pointer mly-flex-col mly-items-center mly-gap-1 mly-opacity-60",
1231
+ contentEditable: false,
1232
+ onClick: () => {
1233
+ editor.commands.setNodeSelection(getPos());
1234
+ },
1235
+ children: [
1236
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react.Repeat2, { className: "mly-size-3 mly-stroke-[2.5] mly-text-midnight-gray" }),
1237
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mly-w-[1.5px] mly-grow mly-rounded-full mly-bg-rose-300" })
1238
+ ]
1239
+ }
1240
+ )
1241
+ ]
1242
+ }
1243
+ );
1244
+ }
1245
+
1246
+ // src/editor/nodes/for/for.ts
1247
+ var ForExtension = import_core10.Node.create({
1248
+ name: "for",
1249
+ group: "block",
1250
+ content: "(block|columns)+",
1251
+ draggable: true,
1252
+ isolating: true,
1253
+ addAttributes() {
1254
+ return {
1255
+ each: {
1256
+ default: "items",
1257
+ parseHTML: (element) => {
1258
+ return element.getAttribute("each") || "";
1259
+ },
1260
+ renderHTML: (attributes) => {
1261
+ if (!attributes.each) {
1262
+ return {};
1263
+ }
1264
+ return {
1265
+ each: attributes.each
1266
+ };
1267
+ }
1268
+ },
1269
+ isUpdatingKey: {
1270
+ default: false
1271
+ },
1272
+ showIfKey: {
1273
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
1274
+ parseHTML: (element) => {
1275
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
1276
+ },
1277
+ renderHTML(attributes) {
1278
+ if (!attributes.showIfKey) {
1279
+ return {};
1280
+ }
1281
+ return {
1282
+ "data-show-if-key": attributes.showIfKey
1283
+ };
1284
+ }
1285
+ }
1286
+ };
1287
+ },
1288
+ parseHTML() {
1289
+ return [
1290
+ {
1291
+ tag: `div[data-type="${this.name}"]`
1292
+ }
1293
+ ];
1294
+ },
1295
+ renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
1296
+ return [
1297
+ "div",
1298
+ (0, import_core10.mergeAttributes)(HTMLAttributes2, {
1299
+ "data-type": this.name
1300
+ }),
1301
+ 0
1302
+ ];
1303
+ },
1304
+ addCommands() {
1305
+ return {
1306
+ setFor: () => ({ commands }) => {
1307
+ return commands.insertContent({
1308
+ type: this.name,
1309
+ attrs: {},
1310
+ content: [
1311
+ {
1312
+ type: "paragraph"
1313
+ }
1314
+ ]
1315
+ });
1316
+ },
1317
+ updateFor: (attrs) => updateAttributes(this.name, attrs)
1318
+ };
1319
+ },
1320
+ addNodeView() {
1321
+ return (0, import_react4.ReactNodeViewRenderer)(ForView, {
1322
+ contentDOMElementTag: "div",
1323
+ className: "mly-relative"
1324
+ });
1325
+ }
1326
+ });
1327
+
1328
+ // src/editor/nodes/button/button.tsx
1329
+ var import_core11 = require("@tiptap/core");
1330
+ var import_react22 = require("@tiptap/react");
1331
+
1332
+ // src/editor/components/alignment-switch.tsx
1333
+ var import_lucide_react2 = require("lucide-react");
1334
+
1335
+ // src/editor/components/base-button.tsx
1336
+ var React4 = __toESM(require("react"));
1337
+ var import_react_slot = require("@radix-ui/react-slot");
1338
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1339
+ var BaseButton = React4.forwardRef(
1340
+ (_a, ref) => {
1341
+ var _b = _a, {
1342
+ className,
1343
+ variant = "default",
1344
+ size = "default",
1345
+ asChild = false
1346
+ } = _b, props = __objRest(_b, [
1347
+ "className",
1348
+ "variant",
1349
+ "size",
1350
+ "asChild"
1351
+ ]);
1352
+ const Comp = asChild ? import_react_slot.Slot : "button";
1353
+ const baseClass = "mly-inline-flex mly-items-center mly-justify-center mly-rounded-md mly-text-sm mly-font-medium mly-ring-offset-white mly-transition-colors focus-visible:mly-outline-none focus-visible:mly-ring-2 focus-visible:mly-ring-gray-400 focus-visible:mly-ring-offset-2 focus-visible:mly-relative focus-visible:mly-z-10 disabled:mly-opacity-50 ";
1354
+ const variantClasses = {
1355
+ default: "mly-bg-gray-900 mly-text-gray-50 hover:mly-bg-soft-gray",
1356
+ destructive: "mly-bg-red-500 mly-text-gray-50 hover:mly-bg-red-500/90",
1357
+ outline: "mly-border mly-border-gray-200 mly-bg-white hover:mly-bg-gray-100 hover:mly-text-gray-900",
1358
+ secondary: "mly-bg-gray-100 mly-text-gray-900 hover:mly-bg-gray-100/80",
1359
+ ghost: "hover:mly-bg-soft-gray bg-transparent hover:mly-text-gray-900 data-[state=true]:mly-bg-soft-gray data-[state=true]:mly-text-gray-900",
1360
+ link: "mly-text-gray-900 mly-underline-offset-4 hover:mly-underline"
1361
+ };
1362
+ const sizeClasses = {
1363
+ default: "mly-h-10 mly-px-4 mly-py-2",
1364
+ sm: "mly-h-9 mly-rounded-md mly-px-3",
1365
+ lg: "mly-h-11 mly-rounded-md mly-px-8",
1366
+ icon: "mly-h-10 mly-w-10"
1367
+ };
1368
+ const classes = cn(
1369
+ "mly-editor",
1370
+ baseClass,
1371
+ variantClasses[variant],
1372
+ sizeClasses[size],
1373
+ className
1374
+ );
1375
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Comp, __spreadValues({ className: classes, ref }, props));
1376
+ }
1377
+ );
1378
+ BaseButton.displayName = "BaseButton";
1379
+
1380
+ // src/editor/components/ui/tooltip.tsx
1381
+ var React5 = __toESM(require("react"));
1382
+ var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"));
1383
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1384
+ var TooltipProvider = TooltipPrimitive.Provider;
1385
+ var Tooltip = TooltipPrimitive.Root;
1386
+ var TooltipTrigger = TooltipPrimitive.Trigger;
1387
+ var TooltipContent = React5.forwardRef((_a, ref) => {
1388
+ var _b = _a, { className, sideOffset = 4 } = _b, props = __objRest(_b, ["className", "sideOffset"]);
1389
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1390
+ TooltipPrimitive.Content,
1391
+ __spreadValues({
1392
+ ref,
1393
+ sideOffset,
1394
+ className: cn(
1395
+ "mly-z-50 mly-overflow-hidden mly-rounded-md mly-border mly-bg-white mly-px-2 mly-py-1 mly-text-xs mly-animate-in mly-fade-in-0 mly-zoom-in-95",
1396
+ className
1397
+ )
1398
+ }, props)
1399
+ );
1400
+ });
1401
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
1402
+
1403
+ // src/editor/components/bubble-menu-button.tsx
1404
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1405
+ function BubbleMenuButton(item) {
1406
+ var _a;
1407
+ const { tooltip } = item;
1408
+ const content = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1409
+ BaseButton,
1410
+ __spreadProps(__spreadValues({
1411
+ variant: "ghost",
1412
+ size: "sm"
1413
+ }, item.command ? { onClick: item.command } : {}), {
1414
+ "data-state": (_a = item == null ? void 0 : item.isActive) == null ? void 0 : _a.call(item),
1415
+ className: cn(
1416
+ "!mly-size-7 mly-px-2.5 disabled:mly-cursor-not-allowed",
1417
+ item == null ? void 0 : item.className
1418
+ ),
1419
+ type: "button",
1420
+ disabled: item.disbabled,
1421
+ children: item.icon ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1422
+ item.icon,
1423
+ {
1424
+ className: cn(
1425
+ "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5]",
1426
+ item == null ? void 0 : item.iconClassName
1427
+ )
1428
+ }
1429
+ ) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1430
+ "span",
1431
+ {
1432
+ className: cn(
1433
+ "mly-text-sm mly-font-medium mly-text-slate-600",
1434
+ item == null ? void 0 : item.nameClassName
1435
+ ),
1436
+ children: item.name
1437
+ }
1438
+ )
1439
+ })
1440
+ );
1441
+ if (tooltip) {
1442
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Tooltip, { children: [
1443
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipTrigger, { asChild: true, children: content }),
1444
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipContent, { sideOffset: 8, children: tooltip })
1445
+ ] });
1446
+ }
1447
+ return content;
1448
+ }
1449
+
1450
+ // src/editor/components/alignment-switch.tsx
1451
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1452
+ function AlignmentSwitch(props) {
1453
+ const { alignment = "left", onAlignmentChange } = props;
1454
+ const activeAlignment = {
1455
+ left: {
1456
+ icon: import_lucide_react2.AlignLeft,
1457
+ tooltip: "Align Left",
1458
+ onClick: () => {
1459
+ onAlignmentChange("center");
1460
+ }
1461
+ },
1462
+ center: {
1463
+ icon: import_lucide_react2.AlignCenter,
1464
+ tooltip: "Align Center",
1465
+ onClick: () => {
1466
+ onAlignmentChange("right");
1467
+ }
1468
+ },
1469
+ right: {
1470
+ icon: import_lucide_react2.AlignRight,
1471
+ tooltip: "Align Right",
1472
+ onClick: () => {
1473
+ onAlignmentChange("left");
1474
+ }
1475
+ }
1476
+ }[alignment];
1477
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1478
+ BubbleMenuButton,
1479
+ {
1480
+ icon: activeAlignment.icon,
1481
+ tooltip: activeAlignment.tooltip,
1482
+ command: activeAlignment.onClick
1483
+ }
1484
+ );
1485
+ }
1486
+
1487
+ // src/editor/components/ui/color-picker.tsx
1488
+ var import_react_colorful = require("react-colorful");
1489
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1490
+ function ColorPicker(props) {
1491
+ const {
1492
+ color,
1493
+ onColorChange,
1494
+ borderColor,
1495
+ backgroundColor,
1496
+ tooltip,
1497
+ className,
1498
+ children,
1499
+ onClose,
1500
+ suggestedColors = []
1501
+ } = props;
1502
+ const handleColorChange = (color2) => {
1503
+ queueMicrotask(() => {
1504
+ onColorChange(color2);
1505
+ });
1506
+ };
1507
+ const popoverButton = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PopoverTrigger, { asChild: true, children: children || /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1508
+ BaseButton,
1509
+ {
1510
+ variant: "ghost",
1511
+ className: "!mly-size-7 mly-shrink-0",
1512
+ size: "sm",
1513
+ type: "button",
1514
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1515
+ "div",
1516
+ {
1517
+ className: cn(
1518
+ "mly-h-4 mly-w-4 mly-shrink-0 mly-rounded mly-border-2 mly-border-gray-700",
1519
+ className
1520
+ ),
1521
+ style: __spreadProps(__spreadValues({}, borderColor ? { borderColor } : {}), {
1522
+ backgroundColor: backgroundColor || "transparent"
1523
+ })
1524
+ }
1525
+ )
1526
+ }
1527
+ ) });
1528
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1529
+ Popover,
1530
+ {
1531
+ onOpenChange: (open) => {
1532
+ if (!open) {
1533
+ onClose == null ? void 0 : onClose(color);
1534
+ }
1535
+ },
1536
+ children: [
1537
+ tooltip ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Tooltip, { children: [
1538
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipTrigger, { asChild: true, children: popoverButton }),
1539
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipContent, { sideOffset: 8, children: tooltip })
1540
+ ] }) : popoverButton,
1541
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1542
+ PopoverContent,
1543
+ {
1544
+ className: "mly-w-full mly-rounded-none mly-border-0 !mly-bg-transparent !mly-p-0 mly-shadow-none mly-drop-shadow-md",
1545
+ sideOffset: 8,
1546
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "mly-min-w-[260px] mly-rounded-xl mly-border mly-bg-white mly-p-4", children: [
1547
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1548
+ import_react_colorful.HexColorPicker,
1549
+ {
1550
+ color,
1551
+ onChange: handleColorChange,
1552
+ className: "mly-flex !mly-w-full mly-flex-col mly-gap-4"
1553
+ }
1554
+ ),
1555
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1556
+ import_react_colorful.HexColorInput,
1557
+ {
1558
+ alpha: true,
1559
+ color,
1560
+ onChange: handleColorChange,
1561
+ className: "mly-mt-4 mly-w-full mly-min-w-0 mly-rounded-lg mly-border mly-px-2 mly-py-1.5 mly-text-sm mly-uppercase focus-visible:mly-border-gray-400 focus-visible:mly-outline-none",
1562
+ prefixed: true
1563
+ }
1564
+ ),
1565
+ suggestedColors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
1566
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "-mly-mx-4 mly-my-4 mly-h-px mly-bg-gray-200" }),
1567
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { className: "mly-text-xs mly-text-gray-500", children: "Recently used" }),
1568
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mly-mt-2 mly-flex mly-flex-wrap mly-gap-0.5", children: suggestedColors.map((suggestedColor) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1569
+ BaseButton,
1570
+ {
1571
+ variant: "ghost",
1572
+ size: "sm",
1573
+ className: "!mly-size-7 mly-shrink-0",
1574
+ type: "button",
1575
+ onClick: () => handleColorChange(suggestedColor),
1576
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1577
+ "div",
1578
+ {
1579
+ className: "mly-h-4 mly-w-4 mly-shrink-0 mly-rounded",
1580
+ style: {
1581
+ backgroundColor: suggestedColor
1582
+ }
1583
+ }
1584
+ )
1585
+ },
1586
+ suggestedColor
1587
+ )) })
1588
+ ] })
1589
+ ] })
1590
+ }
1591
+ )
1592
+ ]
1593
+ }
1594
+ );
1595
+ }
1596
+
1597
+ // src/editor/components/ui/divider.tsx
1598
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1599
+ function Divider(props) {
1600
+ const { type = "vertical", className } = props;
1601
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1602
+ "div",
1603
+ {
1604
+ className: cn(
1605
+ "mly-shrink-0 mly-bg-gray-200",
1606
+ type === "vertical" ? "mly-mx-0.5 mly-w-px" : "mly-my-0.5 mly-h-px",
1607
+ className
1608
+ )
1609
+ }
1610
+ );
1611
+ }
1612
+
1613
+ // src/editor/components/ui/link-input-popover.tsx
1614
+ var import_lucide_react11 = require("lucide-react");
1615
+ var import_react11 = require("react");
1616
+
1617
+ // src/editor/provider.tsx
1618
+ var import_react6 = require("react");
1619
+
1620
+ // src/blocks/button.tsx
1621
+ var import_lucide_react3 = require("lucide-react");
1622
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1623
+ var button = {
1624
+ title: "Button",
1625
+ description: "Add a call to action button to email.",
1626
+ searchTerms: ["link", "button", "cta"],
1627
+ icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.MousePointer, { className: "mly-h-4 mly-w-4" }),
1628
+ command: ({ editor, range }) => {
1629
+ editor.chain().focus().deleteRange(range).setButton().run();
1630
+ }
1631
+ };
1632
+ var linkCard = {
1633
+ title: "Link Card",
1634
+ description: "Add a link card to email.",
1635
+ searchTerms: ["link", "button", "image"],
1636
+ icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.ArrowUpRightSquare, { className: "mly-h-4 mly-w-4" }),
1637
+ command: ({ editor, range }) => {
1638
+ editor.chain().focus().deleteRange(range).setLinkCard().run();
1639
+ },
1640
+ shouldBeHidden: (editor) => {
1641
+ return editor.extensionManager.extensions.findIndex(
1642
+ (ext) => ext.name === "linkCard"
1643
+ ) === -1;
1644
+ }
1645
+ };
1646
+
1647
+ // src/blocks/image.tsx
1648
+ var import_lucide_react4 = require("lucide-react");
1649
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1650
+ var image = {
1651
+ title: "Image",
1652
+ description: "Full width image",
1653
+ searchTerms: ["image"],
1654
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.ImageIcon, { className: "mly-h-4 mly-w-4" }),
1655
+ command: ({ editor, range }) => {
1656
+ editor.chain().focus().deleteRange(range).setImage({ src: "" }).run();
1657
+ }
1658
+ };
1659
+ var logo = {
1660
+ title: "Logo",
1661
+ description: "Add your brand logo",
1662
+ searchTerms: ["image", "logo"],
1663
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.ImageIcon, { className: "mly-h-4 mly-w-4" }),
1664
+ command: ({ editor, range }) => {
1665
+ editor.chain().focus().deleteRange(range).setLogoImage({ src: "" }).run();
1666
+ }
1667
+ };
1668
+
1669
+ // src/blocks/layout.tsx
1670
+ var import_lucide_react5 = require("lucide-react");
1671
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1672
+ var columns = {
1673
+ title: "Columns",
1674
+ description: "Add columns to email.",
1675
+ searchTerms: ["layout", "columns"],
1676
+ icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.ColumnsIcon, { className: "mly-h-4 mly-w-4" }),
1677
+ shouldBeHidden: (editor) => {
1678
+ return editor.isActive("columns");
1679
+ },
1680
+ command: ({ editor, range }) => {
1681
+ editor.chain().focus().deleteRange(range).setColumns().focus(editor.state.selection.head - 2).run();
1682
+ }
1683
+ };
1684
+ var section = {
1685
+ title: "Section",
1686
+ description: "Add a section to email.",
1687
+ searchTerms: ["layout", "section"],
1688
+ icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.RectangleHorizontal, { className: "mly-h-4 mly-w-4" }),
1689
+ command: ({ editor, range }) => {
1690
+ editor.chain().focus().deleteRange(range).setSection().run();
1691
+ }
1692
+ };
1693
+ var forLoop = {
1694
+ title: "For",
1695
+ description: "Loop over an array of items.",
1696
+ searchTerms: ["for", "loop"],
1697
+ icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.Repeat2, { className: "mly-h-4 mly-w-4" }),
1698
+ shouldBeHidden: (editor) => {
1699
+ return editor.isActive("for");
1700
+ },
1701
+ command: ({ editor, range }) => {
1702
+ editor.chain().focus().deleteRange(range).setFor().run();
1703
+ }
1704
+ };
1705
+ var spacer = {
1706
+ title: "Spacer",
1707
+ description: "Add space between blocks.",
1708
+ searchTerms: ["space", "gap", "divider"],
1709
+ icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.MoveVertical, { className: "mly-h-4 mly-w-4" }),
1710
+ command: ({ editor, range }) => {
1711
+ editor.chain().focus().deleteRange(range).setSpacer({ height: "sm" }).run();
1712
+ }
1713
+ };
1714
+ var divider = {
1715
+ title: "Divider",
1716
+ description: "Add a horizontal divider.",
1717
+ searchTerms: ["divider", "line"],
1718
+ icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.Minus, { className: "mly-h-4 mly-w-4" }),
1719
+ command: ({ editor, range }) => {
1720
+ editor.chain().focus().deleteRange(range).setHorizontalRule().run();
1721
+ }
1722
+ };
1723
+
1724
+ // src/blocks/list.tsx
1725
+ var import_lucide_react6 = require("lucide-react");
1726
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1727
+ var bulletList = {
1728
+ title: "Bullet List",
1729
+ description: "Create a simple bullet list.",
1730
+ searchTerms: ["unordered", "point"],
1731
+ icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react6.List, { className: "mly-h-4 mly-w-4" }),
1732
+ command: ({ editor, range }) => {
1733
+ editor.chain().focus().deleteRange(range).toggleBulletList().run();
1734
+ }
1735
+ };
1736
+ var orderedList = {
1737
+ title: "Numbered List",
1738
+ description: "Create a list with numbering.",
1739
+ searchTerms: ["ordered"],
1740
+ icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react6.ListOrdered, { className: "mly-h-4 mly-w-4" }),
1741
+ command: ({ editor, range }) => {
1742
+ editor.chain().focus().deleteRange(range).toggleOrderedList().run();
1743
+ }
1744
+ };
1745
+
1746
+ // src/blocks/typography.tsx
1747
+ var import_lucide_react7 = require("lucide-react");
1748
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1749
+ var text = {
1750
+ title: "Text",
1751
+ description: "Just start typing with plain text.",
1752
+ searchTerms: ["p", "paragraph"],
1753
+ icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.Text, { className: "mly-h-4 mly-w-4" }),
1754
+ command: ({ editor, range }) => {
1755
+ editor.chain().focus().deleteRange(range).toggleNode("paragraph", "paragraph").run();
1756
+ }
1757
+ };
1758
+ var heading1 = {
1759
+ title: "Heading 1",
1760
+ description: "Big heading.",
1761
+ searchTerms: ["title", "big", "large"],
1762
+ icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.Heading1, { className: "mly-h-4 mly-w-4" }),
1763
+ command: ({ editor, range }) => {
1764
+ editor.chain().focus().deleteRange(range).setNode("heading", { level: 1 }).run();
1765
+ }
1766
+ };
1767
+ var heading2 = {
1768
+ title: "Heading 2",
1769
+ description: "Medium heading.",
1770
+ searchTerms: ["subtitle", "medium"],
1771
+ icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.Heading2, { className: "mly-h-4 mly-w-4" }),
1772
+ command: ({ editor, range }) => {
1773
+ editor.chain().focus().deleteRange(range).setNode("heading", { level: 2 }).run();
1774
+ }
1775
+ };
1776
+ var heading3 = {
1777
+ title: "Heading 3",
1778
+ description: "Small heading.",
1779
+ searchTerms: ["subtitle", "small"],
1780
+ icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.Heading3, { className: "mly-h-4 mly-w-4" }),
1781
+ command: ({ editor, range }) => {
1782
+ editor.chain().focus().deleteRange(range).setNode("heading", { level: 3 }).run();
1783
+ }
1784
+ };
1785
+ var hardBreak = {
1786
+ title: "Hard Break",
1787
+ description: "Add a break between lines.",
1788
+ searchTerms: ["break", "line"],
1789
+ icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.DivideIcon, { className: "mly-h-4 mly-w-4" }),
1790
+ command: ({ editor, range }) => {
1791
+ editor.chain().focus().deleteRange(range).setHardBreak().run();
1792
+ }
1793
+ };
1794
+ var blockquote = {
1795
+ title: "Blockquote",
1796
+ description: "Add blockquote.",
1797
+ searchTerms: ["quote", "blockquote"],
1798
+ icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.TextQuote, { className: "mly-h-4 mly-w-4" }),
1799
+ command: ({ editor, range }) => {
1800
+ editor.chain().focus().deleteRange(range).toggleBlockquote().run();
1801
+ }
1802
+ };
1803
+ var footer = {
1804
+ title: "Footer",
1805
+ description: "Add a footer text to email.",
1806
+ searchTerms: ["footer", "text"],
1807
+ icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.FootprintsIcon, { className: "mly-h-4 mly-w-4" }),
1808
+ command: ({ editor, range }) => {
1809
+ editor.chain().focus().deleteRange(range).setFooter().run();
1810
+ }
1811
+ };
1812
+ var clearLine = {
1813
+ title: "Clear Line",
1814
+ description: "Clear the current line.",
1815
+ searchTerms: ["clear", "line"],
1816
+ icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.EraserIcon, { className: "mly-h-4 mly-w-4" }),
1817
+ command: ({ editor, range }) => {
1818
+ editor.chain().focus().selectParentNode().deleteSelection().run();
1819
+ }
1820
+ };
1821
+
1822
+ // src/editor/extensions/slash-command/default-slash-commands.ts
1823
+ var DEFAULT_SLASH_COMMANDS = [
1824
+ text,
1825
+ heading1,
1826
+ heading2,
1827
+ heading3,
1828
+ bulletList,
1829
+ orderedList,
1830
+ image,
1831
+ logo,
1832
+ columns,
1833
+ section,
1834
+ forLoop,
1835
+ divider,
1836
+ spacer,
1837
+ button,
1838
+ linkCard,
1839
+ hardBreak,
1840
+ blockquote,
1841
+ footer,
1842
+ clearLine
1843
+ ];
1844
+
1845
+ // src/editor/nodes/variable/variable-view.tsx
1846
+ var import_react5 = require("@tiptap/react");
1847
+ var import_lucide_react8 = require("lucide-react");
1848
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1849
+ function VariableView(props) {
1850
+ const { node, updateAttributes: updateAttributes2, editor } = props;
1851
+ const { id, fallback, required } = node.attrs;
1852
+ const { renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION } = useMailyContext();
1853
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1854
+ import_react5.NodeViewWrapper,
1855
+ {
1856
+ className: "react-component mly-inline-block mly-leading-none",
1857
+ draggable: "false",
1858
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Popover, { children: [
1859
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1860
+ PopoverTrigger,
1861
+ {
1862
+ onClick: (e) => {
1863
+ if (!editor.isEditable) {
1864
+ e.preventDefault();
1865
+ return;
1866
+ }
1867
+ },
1868
+ children: renderVariable({
1869
+ variable: { name: id, required, valid: true },
1870
+ fallback,
1871
+ editor,
1872
+ from: "content-variable"
1873
+ })
1874
+ }
1875
+ ),
1876
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1877
+ PopoverContent,
1878
+ {
1879
+ align: "start",
1880
+ side: "bottom",
1881
+ className: "mly-w-max mly-rounded-lg !mly-p-0.5",
1882
+ sideOffset: 8,
1883
+ onOpenAutoFocus: (e) => e.preventDefault(),
1884
+ onCloseAutoFocus: (e) => e.preventDefault(),
1885
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "mly-flex mly-items-stretch mly-text-midnight-gray", children: [
1886
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "mly-relative", children: [
1887
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "mly-inline-block mly-px-2 mly-text-xs mly-text-midnight-gray", children: "Variable" }),
1888
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1889
+ "input",
1890
+ __spreadProps(__spreadValues({}, AUTOCOMPLETE_PASSWORD_MANAGERS_OFF), {
1891
+ value: id != null ? id : "",
1892
+ onChange: (e) => {
1893
+ updateAttributes2({
1894
+ id: e.target.value
1895
+ });
1896
+ },
1897
+ placeholder: "ie. name...",
1898
+ className: "mly-h-7 mly-w-36 mly-rounded-md mly-bg-soft-gray mly-px-2 mly-text-sm mly-text-midnight-gray focus:mly-bg-soft-gray focus:mly-outline-none"
1899
+ })
1900
+ )
1901
+ ] }),
1902
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Divider, { className: "mly-mx-1.5" }),
1903
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "mly-relative", children: [
1904
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "mly-inline-block mly-px-2 mly-pl-1 mly-text-xs mly-text-midnight-gray", children: "Default" }),
1905
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1906
+ "input",
1907
+ __spreadProps(__spreadValues({}, AUTOCOMPLETE_PASSWORD_MANAGERS_OFF), {
1908
+ value: fallback != null ? fallback : "",
1909
+ onChange: (e) => {
1910
+ updateAttributes2({
1911
+ fallback: e.target.value
1912
+ });
1913
+ },
1914
+ placeholder: "ie. John Doe...",
1915
+ className: "mly-h-7 mly-w-32 mly-rounded-md mly-bg-soft-gray mly-px-2 mly-pr-6 mly-text-sm mly-text-midnight-gray focus:mly-bg-soft-gray focus:mly-outline-none"
1916
+ })
1917
+ ),
1918
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "mly-absolute mly-inset-y-0 mly-right-1 mly-flex mly-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react8.Pencil, { className: "mly-h-3 mly-w-3 mly-stroke-[2.5] mly-text-midnight-gray" }) })
1919
+ ] })
1920
+ ] }) })
1921
+ }
1922
+ )
1923
+ ] })
1924
+ }
1925
+ );
1926
+ }
1927
+ var DefaultRenderVariable = (props) => {
1928
+ const { variable, fallback, from } = props;
1929
+ const { name, required, valid } = variable;
1930
+ if (from === "button-variable") {
1931
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "mly-inline-grid mly-h-7 mly-max-w-xs mly-grid-cols-[12px_1fr] mly-items-center mly-gap-1.5 mly-rounded-md mly-border mly-border-[var(--button-var-border-color)] mly-px-2 mly-font-mono mly-text-sm", children: [
1932
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react8.Braces, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5]" }),
1933
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "mly-min-w-0 mly-truncate mly-text-left", children: name })
1934
+ ] });
1935
+ }
1936
+ if (from === "bubble-variable") {
1937
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1938
+ "div",
1939
+ {
1940
+ className: cn(
1941
+ "mly-inline-grid mly-h-7 mly-min-w-28 mly-max-w-xs mly-grid-cols-[12px_1fr] mly-items-center mly-gap-1.5 mly-rounded-md mly-border mly-px-2 mly-font-mono mly-text-sm hover:mly-bg-soft-gray",
1942
+ !valid && "mly-border-rose-400 mly-bg-rose-50 mly-text-rose-600 hover:mly-bg-rose-100"
1943
+ ),
1944
+ children: [
1945
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react8.Braces, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-rose-600" }),
1946
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "mly-min-w-0 mly-truncate mly-text-left", children: name })
1947
+ ]
1948
+ }
1949
+ );
1950
+ }
1951
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1952
+ "span",
1953
+ {
1954
+ tabIndex: -1,
1955
+ className: "mly-inline-flex mly-items-center mly-gap-[var(--variable-icon-gap)] mly-rounded-full mly-border mly-px-1.5 mly-py-0.5 mly-leading-none",
1956
+ children: [
1957
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react8.Braces, { className: "mly-size-[var(--variable-icon-size)] mly-shrink-0 mly-stroke-[2.5] mly-text-rose-600" }),
1958
+ name,
1959
+ required && !fallback && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react8.AlertTriangle, { className: "mly-size-[var(--variable-icon-size)] mly-shrink-0 mly-stroke-[2.5]" })
1960
+ ]
1961
+ }
1962
+ );
1963
+ };
1964
+
1965
+ // src/editor/provider.tsx
1966
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1967
+ var DEFAULT_PLACEHOLDER_URL = "maily.to/";
1968
+ var DEFAULT_VARIABLE_TRIGGER_CHAR = "@";
1969
+ var DEFAULT_VARIABLES = [];
1970
+ var DEFAULT_RENDER_VARIABLE_FUNCTION = DefaultRenderVariable;
1971
+ var MailyContext = (0, import_react6.createContext)({
1972
+ placeholderUrl: DEFAULT_PLACEHOLDER_URL,
1973
+ variableTriggerCharacter: DEFAULT_VARIABLE_TRIGGER_CHAR,
1974
+ variables: DEFAULT_VARIABLES,
1975
+ blocks: DEFAULT_SLASH_COMMANDS,
1976
+ renderVariable: DEFAULT_RENDER_VARIABLE_FUNCTION
1977
+ });
1978
+ function useMailyContext() {
1979
+ const values = (0, import_react6.useContext)(MailyContext);
1980
+ if (!values) {
1981
+ throw new Error("Missing MailyContext.Provider in the component tree");
1982
+ }
1983
+ return values;
1984
+ }
1985
+
1986
+ // src/editor/nodes/variable/variable-popover.tsx
1987
+ var import_lucide_react9 = require("lucide-react");
1988
+ var import_react7 = require("react");
1989
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1990
+ var VariablePopover = (0, import_react7.forwardRef)((props, ref) => {
1991
+ const { items, onSelectItem } = props;
1992
+ const [selectedIndex, setSelectedIndex] = (0, import_react7.useState)(0);
1993
+ const scrollContainerRef = (0, import_react7.useRef)(null);
1994
+ const itemRefs = (0, import_react7.useRef)([]);
1995
+ const scrollSelectedIntoView = (index) => {
1996
+ const container = scrollContainerRef.current;
1997
+ const selectedItem = itemRefs.current[index];
1998
+ if (!container || !selectedItem) {
1999
+ return;
2000
+ }
2001
+ const containerRect = container.getBoundingClientRect();
2002
+ const itemRect = selectedItem.getBoundingClientRect();
2003
+ const padding = 4;
2004
+ if (itemRect.bottom > containerRect.bottom) {
2005
+ container.scrollTop += itemRect.bottom - containerRect.bottom + padding;
2006
+ } else if (itemRect.top < containerRect.top) {
2007
+ container.scrollTop += itemRect.top - containerRect.top - padding;
2008
+ }
2009
+ };
2010
+ (0, import_react7.useEffect)(() => {
2011
+ setSelectedIndex(0);
2012
+ if (scrollContainerRef.current) {
2013
+ scrollContainerRef.current.scrollTop = 0;
2014
+ }
2015
+ itemRefs.current = items.map(() => null);
2016
+ }, [items]);
2017
+ (0, import_react7.useEffect)(() => {
2018
+ scrollSelectedIntoView(selectedIndex);
2019
+ }, [selectedIndex]);
2020
+ (0, import_react7.useImperativeHandle)(ref, () => ({
2021
+ moveUp: () => {
2022
+ setSelectedIndex((selectedIndex + items.length - 1) % items.length);
2023
+ },
2024
+ moveDown: () => {
2025
+ setSelectedIndex((selectedIndex + 1) % items.length);
2026
+ },
2027
+ select: () => {
2028
+ const item = items[selectedIndex];
2029
+ if (!item) {
2030
+ return;
2031
+ }
2032
+ onSelectItem(item);
2033
+ }
2034
+ }));
2035
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "mly-z-50 mly-w-64 mly-rounded-lg mly-border mly-border-gray-200 mly-bg-white mly-shadow-md mly-transition-all", children: [
2036
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "mly-flex mly-items-center mly-justify-between mly-gap-2 mly-border-b mly-border-gray-200 mly-bg-soft-gray/40 mly-px-1 mly-py-1.5 mly-text-gray-500", children: [
2037
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "mly-text-xs mly-uppercase", children: "Variables" }),
2038
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(VariableIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react9.Braces, { className: "mly-size-3 mly-stroke-[2.5]" }) })
2039
+ ] }),
2040
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2041
+ "div",
2042
+ {
2043
+ ref: scrollContainerRef,
2044
+ className: "mly-max-h-52 mly-overflow-y-auto mly-scrollbar-thin mly-scrollbar-track-transparent mly-scrollbar-thumb-gray-200",
2045
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "mly-flex mly-w-fit mly-min-w-full mly-flex-col mly-gap-0.5 mly-p-1", children: (items == null ? void 0 : items.length) ? items == null ? void 0 : items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
2046
+ "button",
2047
+ {
2048
+ ref: (el) => itemRefs.current[index] = el,
2049
+ onClick: () => onSelectItem(item),
2050
+ className: cn(
2051
+ "mly-flex mly-w-fit mly-min-w-full mly-items-center mly-gap-2 mly-rounded-md mly-px-2 mly-py-1 mly-text-left mly-font-mono mly-text-sm mly-text-gray-900 hover:mly-bg-soft-gray",
2052
+ index === selectedIndex ? "mly-bg-soft-gray" : "mly-bg-white"
2053
+ ),
2054
+ children: [
2055
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react9.Braces, { className: "mly-size-3 mly-stroke-[2.5] mly-text-rose-600" }),
2056
+ item.name
2057
+ ]
2058
+ },
2059
+ index
2060
+ )) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "mly-flex mly-h-7 mly-w-full mly-items-center mly-gap-2 mly-rounded-md mly-px-2 mly-py-1 mly-text-left mly-font-mono mly-text-[13px] mly-text-gray-900 hover:mly-bg-soft-gray", children: "No result" }) })
2061
+ }
2062
+ ),
2063
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "mly-flex mly-items-center mly-justify-between mly-gap-2 mly-border-t mly-border-gray-200 mly-px-1 mly-py-1.5 mly-text-gray-500", children: [
2064
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "mly-flex mly-items-center mly-gap-1", children: [
2065
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(VariableIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react9.ArrowDownIcon, { className: "mly-size-3 mly-stroke-[2.5]" }) }),
2066
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(VariableIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react9.ArrowUpIcon, { className: "mly-size-3 mly-stroke-[2.5]" }) }),
2067
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "mly-text-xs mly-text-gray-500", children: "Navigate" })
2068
+ ] }),
2069
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(VariableIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react9.CornerDownLeftIcon, { className: "mly-size-3 mly-stroke-[2.5]" }) })
2070
+ ] })
2071
+ ] });
2072
+ });
2073
+ function VariableIcon(props) {
2074
+ const { className, children } = props;
2075
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2076
+ "div",
2077
+ {
2078
+ className: cn(
2079
+ "mly-flex mly-size-5 mly-items-center mly-justify-center mly-rounded-md mly-border",
2080
+ className
2081
+ ),
2082
+ children
2083
+ }
2084
+ );
2085
+ }
2086
+
2087
+ // src/editor/utils/use-outside-click.ts
2088
+ var import_react8 = require("react");
2089
+ var import_react9 = require("react");
2090
+ function useOutsideClick(ref, callback) {
2091
+ const handleClick = (0, import_react8.useCallback)(
2092
+ (e) => {
2093
+ if (ref.current && !ref.current.contains(e.target)) {
2094
+ callback();
2095
+ }
2096
+ },
2097
+ [ref, callback]
2098
+ );
2099
+ (0, import_react9.useEffect)(() => {
2100
+ document.addEventListener("mousedown", handleClick);
2101
+ document.addEventListener("touchstart", handleClick);
2102
+ return () => {
2103
+ document.removeEventListener("mousedown", handleClick);
2104
+ document.removeEventListener("touchstart", handleClick);
2105
+ };
2106
+ }, [handleClick]);
2107
+ }
2108
+
2109
+ // src/editor/components/ui/input-autocomplete.tsx
2110
+ var import_lucide_react10 = require("lucide-react");
2111
+ var import_react10 = require("react");
2112
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2113
+ var InputAutocomplete = (0, import_react10.forwardRef)((props, ref) => {
2114
+ const _a = props, {
2115
+ value = "",
2116
+ onValueChange,
2117
+ className,
2118
+ onOutsideClick,
2119
+ onSelectOption,
2120
+ autoCompleteOptions = [],
2121
+ triggerChar = ""
2122
+ } = _a, inputProps = __objRest(_a, [
2123
+ "value",
2124
+ "onValueChange",
2125
+ "className",
2126
+ "onOutsideClick",
2127
+ "onSelectOption",
2128
+ "autoCompleteOptions",
2129
+ "triggerChar"
2130
+ ]);
2131
+ const containerRef = (0, import_react10.useRef)(null);
2132
+ const popoverRef = (0, import_react10.useRef)(null);
2133
+ useOutsideClick(containerRef, () => {
2134
+ onOutsideClick == null ? void 0 : onOutsideClick();
2135
+ });
2136
+ const isTriggeringVariable = value.startsWith(triggerChar);
2137
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: cn("mly-relative"), ref: containerRef, children: [
2138
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "mly-relative", children: [
2139
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2140
+ "input",
2141
+ __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, AUTOCOMPLETE_PASSWORD_MANAGERS_OFF), {
2142
+ placeholder: "e.g. items",
2143
+ type: "text"
2144
+ }), inputProps), {
2145
+ ref,
2146
+ value,
2147
+ onChange: (e) => {
2148
+ onValueChange(e.target.value);
2149
+ },
2150
+ className: cn(
2151
+ "mly-h-7 mly-w-40 mly-rounded-md mly-px-2 mly-pr-6 mly-text-sm mly-text-midnight-gray hover:mly-bg-soft-gray focus:mly-bg-soft-gray focus:mly-outline-none",
2152
+ className
2153
+ ),
2154
+ onKeyDown: (e) => {
2155
+ if (!popoverRef.current || !isTriggeringVariable) {
2156
+ return;
2157
+ }
2158
+ const { moveUp, moveDown, select } = popoverRef.current;
2159
+ if (e.key === "ArrowDown") {
2160
+ e.preventDefault();
2161
+ moveDown();
2162
+ } else if (e.key === "ArrowUp") {
2163
+ e.preventDefault();
2164
+ moveUp();
2165
+ } else if (e.key === "Enter") {
2166
+ e.preventDefault();
2167
+ select();
2168
+ }
2169
+ },
2170
+ spellCheck: false
2171
+ })
2172
+ ),
2173
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mly-absolute mly-inset-y-0 mly-right-1 mly-flex mly-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_lucide_react10.CornerDownLeft, { className: "mly-h-3 mly-w-3 mly-stroke-[2.5] mly-text-midnight-gray" }) })
2174
+ ] }),
2175
+ isTriggeringVariable && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mly-absolute mly-left-0 mly-top-8", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2176
+ VariablePopover,
2177
+ {
2178
+ items: autoCompleteOptions.map((option) => {
2179
+ return {
2180
+ name: option
2181
+ };
2182
+ }),
2183
+ onSelectItem: (item) => {
2184
+ onSelectOption == null ? void 0 : onSelectOption(item.name);
2185
+ },
2186
+ ref: popoverRef
2187
+ }
2188
+ ) })
2189
+ ] });
2190
+ });
2191
+ InputAutocomplete.displayName = "InputAutocomplete";
2192
+
2193
+ // src/editor/utils/variable.ts
2194
+ function processVariables(variables, options) {
2195
+ const { query } = options;
2196
+ const queryLower = query.toLowerCase();
2197
+ let filteredVariables = [];
2198
+ if (Array.isArray(variables)) {
2199
+ filteredVariables = variables.filter(
2200
+ (variable) => variable.name.toLowerCase().startsWith(queryLower)
2201
+ );
2202
+ if (query.length > 0 && !filteredVariables.some((variable) => variable.name === query)) {
2203
+ filteredVariables.push({ name: query, required: true });
2204
+ }
2205
+ return filteredVariables;
2206
+ } else if (typeof variables === "function") {
2207
+ return variables(options);
2208
+ } else {
2209
+ throw new Error(`Invalid variables type. Expected 'Array' or 'Function', but received '${typeof variables}'.
2210
+
2211
+ You can check out the documentation for more information: https://github.com/arikchakma/maily.to/blob/main/packages/core/readme.md`);
2212
+ }
2213
+ }
2214
+
2215
+ // src/editor/components/ui/link-input-popover.tsx
2216
+ var import_react12 = require("react");
2217
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2218
+ var LINK_PROTOCOL_REGEX = /https?:\/\//;
2219
+ function LinkInputPopover(props) {
2220
+ var _a;
2221
+ const {
2222
+ defaultValue = "",
2223
+ onValueChange,
2224
+ tooltip,
2225
+ icon: Icon = import_lucide_react11.Link,
2226
+ editor,
2227
+ isVariable
2228
+ } = props;
2229
+ const defaultProtocol = (_a = defaultValue.match(LINK_PROTOCOL_REGEX)) == null ? void 0 : _a[0];
2230
+ const defaultUrlWithoutProtocol = defaultValue.replace(
2231
+ LINK_PROTOCOL_REGEX,
2232
+ ""
2233
+ );
2234
+ const [isOpen, setIsOpen] = (0, import_react11.useState)(false);
2235
+ const [protocol, setProtocol] = (0, import_react11.useState)(defaultProtocol || "https://");
2236
+ const [isEditing, setIsEditing] = (0, import_react11.useState)(!isVariable);
2237
+ const linkInputRef = (0, import_react11.useRef)(null);
2238
+ const {
2239
+ variables = [],
2240
+ variableTriggerCharacter = DEFAULT_VARIABLE_TRIGGER_CHAR,
2241
+ renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION,
2242
+ placeholderUrl = DEFAULT_PLACEHOLDER_URL
2243
+ } = useMailyContext();
2244
+ const autoCompleteOptions = (0, import_react12.useMemo)(() => {
2245
+ const withoutTrigger = defaultUrlWithoutProtocol.replace(
2246
+ new RegExp(variableTriggerCharacter, "g"),
2247
+ ""
2248
+ );
2249
+ return processVariables(variables, {
2250
+ query: withoutTrigger || "",
2251
+ from: "bubble-variable",
2252
+ editor
2253
+ }).map((variable) => variable.name);
2254
+ }, [variables, defaultUrlWithoutProtocol, editor]);
2255
+ const popoverButton = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2256
+ BaseButton,
2257
+ {
2258
+ variant: "ghost",
2259
+ size: "sm",
2260
+ type: "button",
2261
+ className: "mly-size-7",
2262
+ "data-state": !!defaultUrlWithoutProtocol,
2263
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Icon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-midnight-gray" })
2264
+ }
2265
+ ) });
2266
+ const normalizeProtocol = (value, p = protocol) => {
2267
+ value = value == null ? void 0 : value.replace(LINK_PROTOCOL_REGEX, "");
2268
+ return p + value;
2269
+ };
2270
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [
2271
+ tooltip ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Tooltip, { children: [
2272
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TooltipTrigger, { asChild: true, children: popoverButton }),
2273
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(TooltipContent, { sideOffset: 8, children: tooltip })
2274
+ ] }) : popoverButton,
2275
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2276
+ PopoverContent,
2277
+ {
2278
+ align: "end",
2279
+ side: "top",
2280
+ className: "mly-w-max mly-rounded-none mly-border-none mly-bg-transparent !mly-p-0 mly-shadow-none",
2281
+ sideOffset: 8,
2282
+ onCloseAutoFocus: (e) => e.preventDefault(),
2283
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2284
+ "form",
2285
+ {
2286
+ onSubmit: (e) => {
2287
+ e.preventDefault();
2288
+ const input = linkInputRef.current;
2289
+ if (!input) {
2290
+ return;
2291
+ }
2292
+ let value = normalizeProtocol(input.value);
2293
+ onValueChange == null ? void 0 : onValueChange(value);
2294
+ setIsOpen(false);
2295
+ },
2296
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "mly-isolate mly-flex mly-rounded-lg", children: [
2297
+ !isEditing && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "mly-flex mly-h-8 mly-items-center mly-rounded-lg mly-border mly-border-gray-300 mly-bg-white mly-px-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2298
+ "button",
2299
+ {
2300
+ onClick: () => {
2301
+ setIsEditing(true);
2302
+ setTimeout(() => {
2303
+ var _a2;
2304
+ (_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
2305
+ }, 0);
2306
+ },
2307
+ children: renderVariable({
2308
+ variable: {
2309
+ name: defaultUrlWithoutProtocol,
2310
+ valid: true
2311
+ },
2312
+ fallback: "",
2313
+ from: "bubble-variable",
2314
+ editor
2315
+ })
2316
+ }
2317
+ ) }),
2318
+ isEditing && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
2319
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "mly-relative", children: [
2320
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2321
+ "select",
2322
+ {
2323
+ className: "hover:text-accent-foreground mly-peer mly-inline-flex mly-h-full mly-appearance-none mly-items-center mly-rounded-none mly-rounded-s-lg mly-border mly-border-gray-300 mly-bg-gray-50 mly-pe-8 mly-ps-3 mly-text-sm mly-text-gray-700 mly-transition-shadow hover:mly-bg-gray-100 focus:mly-z-10 focus-visible:mly-outline-none disabled:mly-pointer-events-none disabled:mly-cursor-not-allowed disabled:mly-opacity-50",
2324
+ "aria-label": "Protocol",
2325
+ value: protocol,
2326
+ onChange: (e) => {
2327
+ var _a2;
2328
+ const protocol2 = e.target.value;
2329
+ setProtocol(protocol2);
2330
+ const newValue = normalizeProtocol(
2331
+ ((_a2 = linkInputRef.current) == null ? void 0 : _a2.value) || "",
2332
+ protocol2
2333
+ );
2334
+ onValueChange == null ? void 0 : onValueChange(newValue);
2335
+ },
2336
+ children: [
2337
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "https://", children: "https://" }),
2338
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "http://", children: "http://" })
2339
+ ]
2340
+ }
2341
+ ),
2342
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "mly-pointer-events-none mly-absolute mly-inset-y-0 mly-right-0 mly-z-10 mly-flex mly-h-full mly-w-9 mly-items-center mly-justify-center mly-text-gray-600 peer-disabled:mly-opacity-50", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2343
+ import_lucide_react11.ChevronDownIcon,
2344
+ {
2345
+ size: 16,
2346
+ strokeWidth: 2,
2347
+ "aria-hidden": "true",
2348
+ role: "img"
2349
+ }
2350
+ ) })
2351
+ ] }),
2352
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2353
+ InputAutocomplete,
2354
+ {
2355
+ value: defaultUrlWithoutProtocol,
2356
+ onValueChange: (value) => {
2357
+ let newValue = normalizeProtocol(value);
2358
+ onValueChange == null ? void 0 : onValueChange(newValue);
2359
+ },
2360
+ autoCompleteOptions,
2361
+ ref: linkInputRef,
2362
+ placeholder: placeholderUrl,
2363
+ className: "-mly-ms-px mly-block mly-h-8 mly-w-52 mly-rounded-lg mly-rounded-s-none mly-border mly-border-gray-300 mly-px-2 mly-py-1.5 mly-pr-6 mly-text-sm mly-shadow-sm mly-outline-none placeholder:mly-text-gray-400",
2364
+ triggerChar: variableTriggerCharacter,
2365
+ onSelectOption: (value) => {
2366
+ var _a2;
2367
+ const isVariable2 = (_a2 = autoCompleteOptions.includes(value)) != null ? _a2 : false;
2368
+ if (isVariable2) {
2369
+ setIsEditing(false);
2370
+ } else {
2371
+ value = normalizeProtocol(value);
2372
+ }
2373
+ onValueChange == null ? void 0 : onValueChange(value, isVariable2);
2374
+ setIsOpen(false);
2375
+ }
2376
+ }
2377
+ )
2378
+ ] })
2379
+ ] })
2380
+ }
2381
+ )
2382
+ }
2383
+ )
2384
+ ] });
2385
+ }
2386
+
2387
+ // src/editor/components/ui/select.tsx
2388
+ var import_react13 = require("react");
2389
+ var import_lucide_react12 = require("lucide-react");
2390
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2391
+ function Select(props) {
2392
+ const {
2393
+ label,
2394
+ options,
2395
+ value,
2396
+ onValueChange,
2397
+ tooltip,
2398
+ className,
2399
+ icon: Icon,
2400
+ iconClassName
2401
+ } = props;
2402
+ const selectId = `mly${(0, import_react13.useId)()}`;
2403
+ const content = /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "relative", children: [
2404
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("label", { htmlFor: selectId, className: "sr-only", children: label }),
2405
+ Icon && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "mly-pointer-events-none mly-absolute mly-inset-y-0 mly-left-2 mly-z-20 mly-flex mly-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Icon, { className: cn("mly-size-3", iconClassName) }) }),
2406
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2407
+ "select",
2408
+ {
2409
+ id: selectId,
2410
+ className: cn(
2411
+ "mly-flex mly-min-h-7 mly-max-w-max mly-appearance-none mly-items-center mly-rounded-md mly-px-1.5 mly-py-0.5 mly-pr-7 mly-text-sm mly-text-midnight-gray mly-ring-offset-white mly-transition-colors hover:mly-bg-soft-gray focus-visible:mly-relative focus-visible:mly-z-10 focus-visible:mly-outline-none focus-visible:mly-ring-2 focus-visible:mly-ring-gray-400 focus-visible:mly-ring-offset-2 active:mly-bg-soft-gray",
2412
+ !!Icon && "mly-pl-7",
2413
+ className
2414
+ ),
2415
+ value,
2416
+ onChange: (event) => onValueChange(event.target.value),
2417
+ children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: option.value, children: option.label }, option.value))
2418
+ }
2419
+ ),
2420
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "mly-pointer-events-none mly-absolute mly-inset-y-0 mly-right-0 mly-z-10 mly-flex mly-h-full mly-w-7 mly-items-center mly-justify-center mly-text-gray-600 peer-disabled:mly-opacity-50", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2421
+ import_lucide_react12.ChevronDownIcon,
2422
+ {
2423
+ size: 16,
2424
+ strokeWidth: 2,
2425
+ "aria-hidden": "true",
2426
+ role: "img"
2427
+ }
2428
+ ) })
2429
+ ] });
2430
+ if (!tooltip) {
2431
+ return content;
2432
+ }
2433
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Tooltip, { children: [
2434
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TooltipTrigger, { asChild: true, children: content }),
2435
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(TooltipContent, { sideOffset: 8, children: tooltip })
2436
+ ] });
2437
+ }
2438
+
2439
+ // src/editor/nodes/button/button-view.tsx
2440
+ var import_react20 = require("@tiptap/react");
2441
+
2442
+ // src/editor/components/show-popover.tsx
2443
+ var import_lucide_react13 = require("lucide-react");
2444
+ var import_react14 = require("react");
2445
+ var import_react15 = require("react");
2446
+ var import_react16 = require("react");
2447
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2448
+ function _ShowPopover(props) {
2449
+ const { showIfKey = "", onShowIfKeyValueChange, editor } = props;
2450
+ const { variables = [], renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION } = useMailyContext();
2451
+ const [isUpdatingKey, setIsUpdatingKey] = (0, import_react14.useState)(false);
2452
+ const inputRef = (0, import_react14.useRef)(null);
2453
+ const autoCompleteOptions = (0, import_react15.useMemo)(() => {
2454
+ return processVariables(variables, {
2455
+ query: showIfKey || "",
2456
+ from: "bubble-variable",
2457
+ editor
2458
+ }).map((variable) => variable.name);
2459
+ }, [variables, showIfKey, editor]);
2460
+ const isValidWhenKey = showIfKey || autoCompleteOptions.includes(showIfKey);
2461
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2462
+ Popover,
2463
+ {
2464
+ onOpenChange: (open) => {
2465
+ if (open) {
2466
+ return;
2467
+ }
2468
+ setIsUpdatingKey(false);
2469
+ },
2470
+ children: [
2471
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Tooltip, { children: [
2472
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2473
+ PopoverTrigger,
2474
+ {
2475
+ className: cn(
2476
+ "mly-flex mly-items-center mly-gap-1 mly-rounded-md mly-px-1.5 mly-text-sm data-[state=open]:mly-bg-soft-gray hover:mly-bg-soft-gray focus-visible:mly-relative focus-visible:mly-z-10 focus-visible:mly-outline-none focus-visible:mly-ring-2 focus-visible:mly-ring-gray-400 focus-visible:mly-ring-offset-2",
2477
+ showIfKey && "mly-bg-rose-100 mly-text-rose-800 data-[state=open]:mly-bg-rose-100 hover:mly-bg-rose-100"
2478
+ ),
2479
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react13.Eye, { className: "mly-h-4 mly-w-4 mly-stroke-[2.5]" })
2480
+ }
2481
+ ) }),
2482
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TooltipContent, { sideOffset: 8, children: "Show block conditionally" })
2483
+ ] }),
2484
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2485
+ PopoverContent,
2486
+ {
2487
+ className: "mly-flex mly-w-max mly-rounded-lg !mly-p-0.5",
2488
+ side: "top",
2489
+ sideOffset: 8,
2490
+ align: "end",
2491
+ onOpenAutoFocus: (e) => {
2492
+ e.preventDefault();
2493
+ },
2494
+ onCloseAutoFocus: (e) => {
2495
+ e.preventDefault();
2496
+ },
2497
+ children: [
2498
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "mly-flex mly-items-center mly-px-1.5 mly-text-sm mly-leading-none", children: "Show if" }),
2499
+ !isUpdatingKey && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2500
+ "button",
2501
+ {
2502
+ onClick: () => {
2503
+ setIsUpdatingKey(true);
2504
+ setTimeout(() => {
2505
+ var _a;
2506
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
2507
+ }, 0);
2508
+ },
2509
+ children: renderVariable({
2510
+ variable: {
2511
+ name: showIfKey,
2512
+ valid: !!isValidWhenKey
2513
+ },
2514
+ fallback: "",
2515
+ from: "bubble-variable",
2516
+ editor
2517
+ })
2518
+ }
2519
+ ),
2520
+ isUpdatingKey && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2521
+ "form",
2522
+ {
2523
+ onSubmit: (e) => {
2524
+ e.preventDefault();
2525
+ setIsUpdatingKey(false);
2526
+ },
2527
+ onKeyDown: (e) => {
2528
+ if (e.key === "Escape") {
2529
+ setIsUpdatingKey(false);
2530
+ }
2531
+ },
2532
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2533
+ InputAutocomplete,
2534
+ {
2535
+ value: showIfKey || "",
2536
+ onValueChange: (value) => {
2537
+ onShowIfKeyValueChange == null ? void 0 : onShowIfKeyValueChange(value);
2538
+ },
2539
+ onOutsideClick: () => {
2540
+ setIsUpdatingKey(false);
2541
+ },
2542
+ onSelectOption: (value) => {
2543
+ onShowIfKeyValueChange == null ? void 0 : onShowIfKeyValueChange(value);
2544
+ setIsUpdatingKey(false);
2545
+ },
2546
+ autoCompleteOptions,
2547
+ ref: inputRef
2548
+ }
2549
+ )
2550
+ }
2551
+ )
2552
+ ]
2553
+ }
2554
+ )
2555
+ ]
2556
+ }
2557
+ );
2558
+ }
2559
+ var ShowPopover = (0, import_react16.memo)(_ShowPopover);
2560
+
2561
+ // src/editor/nodes/button/button-label-input.tsx
2562
+ var import_react17 = require("react");
2563
+ var import_react18 = require("react");
2564
+ var import_react19 = require("react");
2565
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2566
+ function ButtonLabelInput(props) {
2567
+ const { value, onValueChange, isVariable, editor } = props;
2568
+ const linkInputRef = (0, import_react19.useRef)(null);
2569
+ const [isEditing, setIsEditing] = (0, import_react18.useState)(!isVariable);
2570
+ const {
2571
+ variables = [],
2572
+ variableTriggerCharacter = DEFAULT_VARIABLE_TRIGGER_CHAR,
2573
+ renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION,
2574
+ placeholderUrl = DEFAULT_PLACEHOLDER_URL
2575
+ } = useMailyContext();
2576
+ const autoCompleteOptions = (0, import_react17.useMemo)(() => {
2577
+ const withoutTrigger = value.replace(
2578
+ new RegExp(variableTriggerCharacter, "g"),
2579
+ ""
2580
+ );
2581
+ return processVariables(variables, {
2582
+ query: withoutTrigger || "",
2583
+ from: "bubble-variable",
2584
+ editor
2585
+ }).map((variable) => variable.name);
2586
+ }, [variables, value, editor]);
2587
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "mly-isolate mly-flex mly-rounded-lg", children: [
2588
+ !isEditing && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2589
+ "button",
2590
+ {
2591
+ onClick: () => {
2592
+ setIsEditing(true);
2593
+ setTimeout(() => {
2594
+ var _a;
2595
+ (_a = linkInputRef.current) == null ? void 0 : _a.focus();
2596
+ }, 0);
2597
+ },
2598
+ children: renderVariable({
2599
+ variable: {
2600
+ name: value,
2601
+ valid: true
2602
+ },
2603
+ fallback: "",
2604
+ from: "bubble-variable",
2605
+ editor
2606
+ })
2607
+ }
2608
+ ),
2609
+ isEditing && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2610
+ InputAutocomplete,
2611
+ {
2612
+ value,
2613
+ onValueChange: (value2) => {
2614
+ onValueChange == null ? void 0 : onValueChange(value2);
2615
+ },
2616
+ autoCompleteOptions,
2617
+ ref: linkInputRef,
2618
+ placeholder: placeholderUrl,
2619
+ className: "mly-h-7 mly-w-40 mly-rounded-md mly-px-2 mly-pr-6 mly-text-sm mly-text-midnight-gray hover:mly-bg-soft-gray focus:mly-bg-soft-gray focus:mly-outline-none",
2620
+ triggerChar: variableTriggerCharacter,
2621
+ onSelectOption: (value2) => {
2622
+ var _a;
2623
+ const isVariable2 = (_a = autoCompleteOptions.includes(value2)) != null ? _a : false;
2624
+ if (isVariable2) {
2625
+ setIsEditing(false);
2626
+ }
2627
+ onValueChange == null ? void 0 : onValueChange(value2, isVariable2);
2628
+ }
2629
+ }
2630
+ )
2631
+ ] });
2632
+ }
2633
+
2634
+ // src/editor/nodes/button/button-view.tsx
2635
+ var import_react21 = require("react");
2636
+ var import_jsx_runtime25 = require("react/jsx-runtime");
2637
+ function ButtonView(props) {
2638
+ const { node, editor, getPos, updateAttributes: updateAttributes2 } = props;
2639
+ const {
2640
+ text: text2,
2641
+ isTextVariable,
2642
+ alignment,
2643
+ variant,
2644
+ borderRadius: _radius,
2645
+ buttonColor,
2646
+ textColor,
2647
+ url: externalLink,
2648
+ showIfKey = "",
2649
+ isUrlVariable,
2650
+ paddingTop,
2651
+ paddingRight,
2652
+ paddingBottom,
2653
+ paddingLeft
2654
+ } = node.attrs;
2655
+ const { renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION } = useMailyContext();
2656
+ const sizes = (0, import_react21.useMemo)(
2657
+ () => ({
2658
+ small: {
2659
+ paddingX: 24,
2660
+ paddingY: 6
2661
+ },
2662
+ medium: {
2663
+ paddingX: 32,
2664
+ paddingY: 10
2665
+ },
2666
+ large: {
2667
+ paddingX: 40,
2668
+ paddingY: 14
2669
+ }
2670
+ }),
2671
+ []
2672
+ );
2673
+ const size = (0, import_react21.useMemo)(() => {
2674
+ var _a;
2675
+ return (_a = Object.entries(sizes).find(
2676
+ ([, { paddingX, paddingY }]) => paddingRight === paddingX && paddingTop === paddingY
2677
+ )) == null ? void 0 : _a[0];
2678
+ }, [paddingRight, paddingTop, sizes]);
2679
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2680
+ import_react20.NodeViewWrapper,
2681
+ {
2682
+ draggable: editor.isEditable,
2683
+ "data-drag-handle": editor.isEditable,
2684
+ "data-type": "button",
2685
+ style: {
2686
+ textAlign: alignment
2687
+ },
2688
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Popover, { open: props.selected && editor.isEditable, children: [
2689
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2690
+ "button",
2691
+ {
2692
+ className: cn(
2693
+ "mly-inline-flex mly-items-center mly-justify-center mly-rounded-md mly-text-sm mly-font-medium mly-ring-offset-white mly-transition-colors disabled:mly-pointer-events-none disabled:mly-opacity-50",
2694
+ "mly-font-semibold mly-no-underline",
2695
+ {
2696
+ "!mly-rounded-full": _radius === "round",
2697
+ "!mly-rounded-md": _radius === "smooth",
2698
+ "!mly-rounded-none": _radius === "sharp"
2699
+ }
2700
+ ),
2701
+ tabIndex: -1,
2702
+ style: {
2703
+ backgroundColor: variant === "filled" ? buttonColor : "transparent",
2704
+ color: textColor,
2705
+ borderWidth: 2,
2706
+ borderStyle: "solid",
2707
+ borderColor: buttonColor,
2708
+ // decrease the border color opacity to 80%
2709
+ // so that it's not too prominent
2710
+ "--button-var-border-color": `${textColor}80`,
2711
+ paddingTop,
2712
+ paddingRight,
2713
+ paddingBottom,
2714
+ paddingLeft
2715
+ },
2716
+ onClick: (e) => {
2717
+ e.preventDefault();
2718
+ if (!editor.isEditable) {
2719
+ return;
2720
+ }
2721
+ const pos = getPos();
2722
+ editor.commands.setNodeSelection(pos);
2723
+ },
2724
+ children: isTextVariable ? renderVariable({
2725
+ variable: { name: text2, valid: true },
2726
+ fallback: text2,
2727
+ from: "button-variable",
2728
+ editor
2729
+ }) : text2
2730
+ }
2731
+ ) }) }),
2732
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2733
+ PopoverContent,
2734
+ {
2735
+ align: "end",
2736
+ side: "top",
2737
+ className: "mly-w-max mly-rounded-lg !mly-p-0.5",
2738
+ sideOffset: 8,
2739
+ onOpenAutoFocus: (e) => e.preventDefault(),
2740
+ onCloseAutoFocus: (e) => e.preventDefault(),
2741
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mly-flex mly-items-stretch mly-text-midnight-gray", children: [
2742
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2743
+ ButtonLabelInput,
2744
+ {
2745
+ value: text2,
2746
+ onValueChange: (value, isVariable) => {
2747
+ updateAttributes2({
2748
+ text: value,
2749
+ isTextVariable: isVariable != null ? isVariable : false
2750
+ });
2751
+ },
2752
+ isVariable: isTextVariable,
2753
+ editor
2754
+ }
2755
+ ),
2756
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Divider, {}),
2757
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mly-flex mly-space-x-0.5", children: [
2758
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2759
+ Select,
2760
+ {
2761
+ label: "Border Radius",
2762
+ value: _radius,
2763
+ options: allowedButtonBorderRadius.map((value) => ({
2764
+ value,
2765
+ label: value
2766
+ })),
2767
+ onValueChange: (value) => {
2768
+ updateAttributes2({
2769
+ borderRadius: value
2770
+ });
2771
+ },
2772
+ tooltip: "Border Radius",
2773
+ className: "mly-capitalize"
2774
+ }
2775
+ ),
2776
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2777
+ Select,
2778
+ {
2779
+ label: "Style",
2780
+ value: variant,
2781
+ options: allowedButtonVariant.map((value) => ({
2782
+ value,
2783
+ label: value
2784
+ })),
2785
+ onValueChange: (value) => {
2786
+ updateAttributes2({
2787
+ variant: value
2788
+ });
2789
+ },
2790
+ tooltip: "Style",
2791
+ className: "mly-capitalize"
2792
+ }
2793
+ ),
2794
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2795
+ Select,
2796
+ {
2797
+ label: "Size",
2798
+ value: size,
2799
+ options: [
2800
+ { value: "small", label: "Small" },
2801
+ { value: "medium", label: "Medium" },
2802
+ { value: "large", label: "Large" }
2803
+ ],
2804
+ onValueChange: (value) => {
2805
+ const { paddingX, paddingY } = sizes[value];
2806
+ updateAttributes2({
2807
+ paddingTop: paddingY,
2808
+ paddingRight: paddingX,
2809
+ paddingBottom: paddingY,
2810
+ paddingLeft: paddingX
2811
+ });
2812
+ },
2813
+ tooltip: "Size"
2814
+ }
2815
+ )
2816
+ ] }),
2817
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Divider, {}),
2818
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mly-flex mly-space-x-0.5", children: [
2819
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2820
+ AlignmentSwitch,
2821
+ {
2822
+ alignment,
2823
+ onAlignmentChange: (alignment2) => {
2824
+ updateAttributes2({
2825
+ alignment: alignment2
2826
+ });
2827
+ }
2828
+ }
2829
+ ),
2830
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2831
+ LinkInputPopover,
2832
+ {
2833
+ defaultValue: externalLink || "",
2834
+ onValueChange: (value, isVariable) => {
2835
+ updateAttributes2({
2836
+ url: value,
2837
+ isUrlVariable: isVariable != null ? isVariable : false
2838
+ });
2839
+ },
2840
+ tooltip: "Update External Link",
2841
+ editor,
2842
+ isVariable: isUrlVariable
2843
+ }
2844
+ )
2845
+ ] }),
2846
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Divider, {}),
2847
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mly-flex mly-space-x-0.5", children: [
2848
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2849
+ BackgroundColorPickerPopup,
2850
+ {
2851
+ variant,
2852
+ color: buttonColor,
2853
+ onChange: (color) => {
2854
+ updateAttributes2({
2855
+ buttonColor: color
2856
+ });
2857
+ }
2858
+ }
2859
+ ),
2860
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2861
+ TextColorPickerPopup,
2862
+ {
2863
+ color: textColor,
2864
+ onChange: (color) => {
2865
+ updateAttributes2({
2866
+ textColor: color
2867
+ });
2868
+ }
2869
+ }
2870
+ )
2871
+ ] }),
2872
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Divider, {}),
2873
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2874
+ ShowPopover,
2875
+ {
2876
+ showIfKey,
2877
+ onShowIfKeyValueChange: (value) => {
2878
+ updateAttributes2({
2879
+ showIfKey: value
2880
+ });
2881
+ },
2882
+ editor
2883
+ }
2884
+ )
2885
+ ] }) })
2886
+ }
2887
+ )
2888
+ ] })
2889
+ }
2890
+ );
2891
+ }
2892
+ function BackgroundColorPickerPopup(props) {
2893
+ const { color, onChange, variant } = props;
2894
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2895
+ ColorPicker,
2896
+ {
2897
+ color,
2898
+ onColorChange: onChange,
2899
+ tooltip: "Background Color",
2900
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2901
+ BaseButton,
2902
+ {
2903
+ variant: "ghost",
2904
+ size: "sm",
2905
+ type: "button",
2906
+ className: "mly-size-7",
2907
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2908
+ "div",
2909
+ {
2910
+ className: "mly-h-4 mly-w-4 mly-shrink-0 mly-rounded-full mly-shadow",
2911
+ style: {
2912
+ backgroundColor: variant === "filled" ? color : "transparent",
2913
+ borderStyle: "solid",
2914
+ borderWidth: 2,
2915
+ borderColor: variant === "filled" ? "white" : color
2916
+ }
2917
+ }
2918
+ )
2919
+ }
2920
+ )
2921
+ }
2922
+ );
2923
+ }
2924
+ function TextColorPickerPopup(props) {
2925
+ const { color, onChange } = props;
2926
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ColorPicker, { color, onColorChange: onChange, tooltip: "Text Color", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2927
+ BaseButton,
2928
+ {
2929
+ variant: "ghost",
2930
+ size: "sm",
2931
+ type: "button",
2932
+ className: "mly-size-7",
2933
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mly-flex mly-flex-col mly-items-center mly-justify-center mly-gap-[1px]", children: [
2934
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "mly-font-bolder mly-font-mono mly-text-xs mly-text-midnight-gray", children: "A" }),
2935
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2936
+ "div",
2937
+ {
2938
+ className: "mly-h-[2px] mly-w-3 mly-shrink-0 mly-rounded-md mly-shadow",
2939
+ style: { backgroundColor: color }
2940
+ }
2941
+ )
2942
+ ] })
2943
+ }
2944
+ ) });
2945
+ }
2946
+
2947
+ // src/editor/nodes/button/button.tsx
2948
+ var DEFAULT_BUTTON_ALIGNMENT = "left";
2949
+ var DEFAULT_BUTTON_VARIANT = "filled";
2950
+ var DEFAULT_BUTTON_BORDER_RADIUS = "smooth";
2951
+ var DEFAULT_BUTTON_BACKGROUND_COLOR = "#000000";
2952
+ var DEFAULT_BUTTON_TEXT_COLOR = "#ffffff";
2953
+ var DEFAULT_BUTTON_PADDING_TOP = 10;
2954
+ var DEFAULT_BUTTON_PADDING_RIGHT = 32;
2955
+ var DEFAULT_BUTTON_PADDING_BOTTOM = 10;
2956
+ var DEFAULT_BUTTON_PADDING_LEFT = 32;
2957
+ var allowedButtonVariant = ["filled", "outline"];
2958
+ var allowedButtonBorderRadius = ["sharp", "smooth", "round"];
2959
+ var ButtonExtension = import_core11.Node.create({
2960
+ name: "button",
2961
+ group: "block",
2962
+ atom: true,
2963
+ draggable: true,
2964
+ addAttributes() {
2965
+ return {
2966
+ text: {
2967
+ default: "Button",
2968
+ parseHTML: (element) => {
2969
+ return element.getAttribute("data-text") || "";
2970
+ },
2971
+ renderHTML: (attributes) => {
2972
+ return {
2973
+ "data-text": attributes.text
2974
+ };
2975
+ }
2976
+ },
2977
+ isTextVariable: {
2978
+ default: false,
2979
+ parseHTML: (element) => {
2980
+ return element.getAttribute("data-is-text-variable") === "true";
2981
+ },
2982
+ renderHTML: (attributes) => {
2983
+ if (!attributes.isTextVariable) {
2984
+ return {};
2985
+ }
2986
+ return {
2987
+ "data-is-text-variable": "true"
2988
+ };
2989
+ }
2990
+ },
2991
+ url: {
2992
+ default: "",
2993
+ parseHTML: (element) => {
2994
+ return element.getAttribute("data-url") || "";
2995
+ },
2996
+ renderHTML: (attributes) => {
2997
+ return {
2998
+ "data-url": attributes.url
2999
+ };
3000
+ }
3001
+ },
3002
+ // Later we will remove this attribute
3003
+ // and use the `url` attribute instead when implement
3004
+ // the URL variable feature
3005
+ isUrlVariable: {
3006
+ default: false,
3007
+ parseHTML: (element) => {
3008
+ return element.getAttribute("data-is-url-variable") === "true";
3009
+ },
3010
+ renderHTML: (attributes) => {
3011
+ if (!attributes.isUrlVariable) {
3012
+ return {};
3013
+ }
3014
+ return {
3015
+ "data-is-url-variable": "true"
3016
+ };
3017
+ }
3018
+ },
3019
+ alignment: {
3020
+ default: DEFAULT_BUTTON_ALIGNMENT,
3021
+ parseHTML: (element) => {
3022
+ return element.getAttribute("data-alignment") || DEFAULT_BUTTON_ALIGNMENT;
3023
+ },
3024
+ renderHTML: (attributes) => {
3025
+ return {
3026
+ "data-alignment": attributes.alignment
3027
+ };
3028
+ }
3029
+ },
3030
+ variant: {
3031
+ default: DEFAULT_BUTTON_VARIANT,
3032
+ parseHTML: (element) => {
3033
+ return element.getAttribute("data-variant") || DEFAULT_BUTTON_VARIANT;
3034
+ },
3035
+ renderHTML: (attributes) => {
3036
+ return {
3037
+ "data-variant": attributes.variant
3038
+ };
3039
+ }
3040
+ },
3041
+ borderRadius: {
3042
+ default: DEFAULT_BUTTON_BORDER_RADIUS,
3043
+ parseHTML: (element) => {
3044
+ return element.getAttribute("data-border-radius") || DEFAULT_BUTTON_BORDER_RADIUS;
3045
+ },
3046
+ renderHTML: (attributes) => {
3047
+ return {
3048
+ "data-border-radius": attributes.borderRadius
3049
+ };
3050
+ }
3051
+ },
3052
+ buttonColor: {
3053
+ default: DEFAULT_BUTTON_BACKGROUND_COLOR,
3054
+ parseHTML: (element) => {
3055
+ return element.getAttribute("data-button-color") || DEFAULT_BUTTON_BACKGROUND_COLOR;
3056
+ },
3057
+ renderHTML: (attributes) => {
3058
+ return {
3059
+ "data-button-color": attributes.buttonColor
3060
+ };
3061
+ }
3062
+ },
3063
+ textColor: {
3064
+ default: DEFAULT_BUTTON_TEXT_COLOR,
3065
+ parseHTML: (element) => {
3066
+ return element.getAttribute("data-text-color") || DEFAULT_BUTTON_TEXT_COLOR;
3067
+ },
3068
+ renderHTML: (attributes) => {
3069
+ return {
3070
+ "data-text-color": attributes.textColor
3071
+ };
3072
+ }
3073
+ },
3074
+ showIfKey: {
3075
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
3076
+ parseHTML: (element) => {
3077
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
3078
+ },
3079
+ renderHTML(attributes) {
3080
+ if (!attributes.showIfKey) {
3081
+ return {};
3082
+ }
3083
+ return {
3084
+ "data-show-if-key": attributes.showIfKey
3085
+ };
3086
+ }
3087
+ },
3088
+ paddingTop: {
3089
+ default: DEFAULT_BUTTON_PADDING_TOP,
3090
+ parseHTML: (element) => {
3091
+ return parseInt(
3092
+ element.getAttribute("data-padding-top") || DEFAULT_BUTTON_PADDING_TOP.toString(),
3093
+ 10
3094
+ );
3095
+ },
3096
+ renderHTML: (attributes) => {
3097
+ return {
3098
+ "data-padding-top": attributes.paddingTop
3099
+ };
3100
+ }
3101
+ },
3102
+ paddingRight: {
3103
+ default: DEFAULT_BUTTON_PADDING_RIGHT,
3104
+ parseHTML: (element) => {
3105
+ return parseInt(
3106
+ element.getAttribute("data-padding-right") || DEFAULT_BUTTON_PADDING_RIGHT.toString(),
3107
+ 10
3108
+ );
3109
+ },
3110
+ renderHTML: (attributes) => {
3111
+ return {
3112
+ "data-padding-right": attributes.paddingRight
3113
+ };
3114
+ }
3115
+ },
3116
+ paddingBottom: {
3117
+ default: DEFAULT_BUTTON_PADDING_BOTTOM,
3118
+ parseHTML: (element) => {
3119
+ return parseInt(
3120
+ element.getAttribute("data-padding-bottom") || DEFAULT_BUTTON_PADDING_BOTTOM.toString(),
3121
+ 10
3122
+ );
3123
+ },
3124
+ renderHTML: (attributes) => {
3125
+ return {
3126
+ "data-padding-bottom": attributes.paddingBottom
3127
+ };
3128
+ }
3129
+ },
3130
+ paddingLeft: {
3131
+ default: DEFAULT_BUTTON_PADDING_LEFT,
3132
+ parseHTML: (element) => {
3133
+ return parseInt(
3134
+ element.getAttribute("data-padding-left") || DEFAULT_BUTTON_PADDING_LEFT.toString(),
3135
+ 10
3136
+ );
3137
+ },
3138
+ renderHTML: (attributes) => {
3139
+ return {
3140
+ "data-padding-left": attributes.paddingLeft
3141
+ };
3142
+ }
3143
+ }
3144
+ };
3145
+ },
3146
+ parseHTML() {
3147
+ return [
3148
+ {
3149
+ tag: `div[data-type="${this.name}"]`
3150
+ }
3151
+ ];
3152
+ },
3153
+ renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
3154
+ return [
3155
+ "div",
3156
+ (0, import_core11.mergeAttributes)(HTMLAttributes2, {
3157
+ "data-type": this.name
3158
+ })
3159
+ ];
3160
+ },
3161
+ addCommands() {
3162
+ return {
3163
+ setButton: () => ({ commands }) => {
3164
+ return commands.insertContent({
3165
+ type: this.name,
3166
+ attrs: {},
3167
+ content: []
3168
+ });
3169
+ },
3170
+ updateButton: (attrs) => updateAttributes(this.name, attrs)
3171
+ };
3172
+ },
3173
+ addNodeView() {
3174
+ return (0, import_react22.ReactNodeViewRenderer)(ButtonView, {
3175
+ contentDOMElementTag: "div",
3176
+ className: "mly-relative"
3177
+ });
3178
+ }
3179
+ });
3180
+
3181
+ // src/editor/nodes/logo/logo.ts
3182
+ var import_extension_image = __toESM(require("@tiptap/extension-image"));
3183
+ var import_react29 = require("@tiptap/react");
3184
+
3185
+ // src/editor/nodes/logo/logo-view.tsx
3186
+ var import_react26 = require("@tiptap/react");
3187
+ var import_react27 = require("react");
3188
+ var import_react28 = require("react");
3189
+
3190
+ // src/editor/utils/use-event.ts
3191
+ var import_react23 = require("react");
3192
+ var useEvent = (handler) => {
3193
+ const handlerRef = (0, import_react23.useRef)(null);
3194
+ (0, import_react23.useLayoutEffect)(() => {
3195
+ handlerRef.current = handler;
3196
+ }, [handler]);
3197
+ return (0, import_react23.useCallback)((...args) => {
3198
+ if (handlerRef.current === null) {
3199
+ throw new Error("Handler is not assigned");
3200
+ }
3201
+ return handlerRef.current(...args);
3202
+ }, []);
3203
+ };
3204
+
3205
+ // src/editor/nodes/image/image-view.tsx
3206
+ var import_react24 = require("@tiptap/react");
3207
+ var import_lucide_react14 = require("lucide-react");
3208
+ var import_react25 = require("react");
3209
+ var import_jsx_runtime26 = require("react/jsx-runtime");
3210
+ var MIN_WIDTH = 20;
3211
+ var MAX_WIDTH = 600;
3212
+ function ImageView(props) {
3213
+ const { node, updateAttributes: updateAttributes2, selected, editor } = props;
3214
+ const [status, setStatus] = (0, import_react25.useState)("idle");
3215
+ const wrapperRef = (0, import_react25.useRef)(null);
3216
+ const imgRef = (0, import_react25.useRef)(null);
3217
+ const [resizingStyle, setResizingStyle] = (0, import_react25.useState)();
3218
+ const handleMouseDown = useEvent(
3219
+ (event) => {
3220
+ const imageParent = document.querySelector(
3221
+ ".ProseMirror-selectednode"
3222
+ );
3223
+ if (!imgRef.current || !imageParent || !selected) {
3224
+ return;
3225
+ }
3226
+ const imageParentWidth = Math.max(imageParent.offsetWidth, MAX_WIDTH);
3227
+ event.preventDefault();
3228
+ const direction = event.currentTarget.dataset.direction || "--";
3229
+ const initialXPosition = event.clientX;
3230
+ const currentWidth = imgRef.current.width;
3231
+ const currentHeight = imgRef.current.height;
3232
+ let newWidth = currentWidth;
3233
+ let newHeight = currentHeight;
3234
+ const transform = direction[1] === "w" ? -1 : 1;
3235
+ const removeListeners = () => {
3236
+ window.removeEventListener("mousemove", mouseMoveHandler);
3237
+ window.removeEventListener("mouseup", removeListeners);
3238
+ updateAttributes2({ width: newWidth, height: newHeight });
3239
+ setResizingStyle(void 0);
3240
+ };
3241
+ const mouseMoveHandler = (event2) => {
3242
+ newWidth = Math.max(
3243
+ currentWidth + transform * (event2.clientX - initialXPosition),
3244
+ MIN_WIDTH
3245
+ );
3246
+ if (newWidth > imageParentWidth) {
3247
+ newWidth = imageParentWidth;
3248
+ }
3249
+ newHeight = newWidth / currentWidth * currentHeight;
3250
+ setResizingStyle({ width: newWidth, height: newHeight });
3251
+ if (!event2.buttons) {
3252
+ return removeListeners();
3253
+ }
3254
+ };
3255
+ window.addEventListener("mousemove", mouseMoveHandler);
3256
+ window.addEventListener("mouseup", removeListeners);
3257
+ }
3258
+ );
3259
+ function dragCornerButton(direction) {
3260
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3261
+ "div",
3262
+ {
3263
+ role: "button",
3264
+ tabIndex: 0,
3265
+ onMouseDown: handleMouseDown,
3266
+ "data-direction": direction,
3267
+ className: "mly-bg-rose-500",
3268
+ style: __spreadProps(__spreadValues(__spreadValues({
3269
+ position: "absolute",
3270
+ height: "10px",
3271
+ width: "10px"
3272
+ }, { n: { top: 0 }, s: { bottom: 0 } }[direction[0]]), { w: { left: 0 }, e: { right: 0 } }[direction[1]]), {
3273
+ cursor: `${direction}-resize`
3274
+ })
3275
+ }
3276
+ );
3277
+ }
3278
+ let { alignment = "center", width, height, src } = node.attrs || {};
3279
+ const _a = node.attrs || {}, {
3280
+ externalLink,
3281
+ isExternalLinkVariable,
3282
+ isSrcVariable,
3283
+ showIfKey
3284
+ } = _a, attrs = __objRest(_a, [
3285
+ "externalLink",
3286
+ "isExternalLinkVariable",
3287
+ "isSrcVariable",
3288
+ "showIfKey"
3289
+ ]);
3290
+ const hasImageSrc = !!attrs.src;
3291
+ (0, import_react25.useEffect)(() => {
3292
+ if (!src) {
3293
+ return;
3294
+ }
3295
+ setStatus("loading");
3296
+ const img = new Image();
3297
+ img.src = src;
3298
+ img.onload = () => {
3299
+ setStatus("loaded");
3300
+ const { naturalWidth, naturalHeight } = img;
3301
+ const wrapper = wrapperRef == null ? void 0 : wrapperRef.current;
3302
+ if (!wrapper || width !== "auto" || !naturalWidth) {
3303
+ return;
3304
+ }
3305
+ const wrapperWidth = wrapper.offsetWidth;
3306
+ const aspectRatio = naturalWidth / naturalHeight;
3307
+ const calculatedHeight = Math.min(
3308
+ wrapperWidth / aspectRatio,
3309
+ naturalHeight
3310
+ );
3311
+ updateAttributes2({
3312
+ width: Math.min(wrapperWidth, naturalWidth),
3313
+ height: Math.min(calculatedHeight, naturalHeight)
3314
+ });
3315
+ };
3316
+ img.onerror = () => {
3317
+ setStatus("error");
3318
+ };
3319
+ return () => {
3320
+ img.src = "";
3321
+ img.onload = null;
3322
+ img.onerror = null;
3323
+ };
3324
+ }, [src]);
3325
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3326
+ import_react24.NodeViewWrapper,
3327
+ {
3328
+ as: "div",
3329
+ draggable: editor.isEditable,
3330
+ "data-drag-handle": editor.isEditable,
3331
+ style: __spreadValues(__spreadProps(__spreadValues({}, hasImageSrc && status === "loaded" ? __spreadValues({
3332
+ width: `${width}px`,
3333
+ height: `${height}px`
3334
+ }, resizingStyle) : {}), {
3335
+ overflow: "hidden",
3336
+ position: "relative",
3337
+ // Weird! Basically tiptap/prose wraps this in a span and the line height causes an annoying buffer.
3338
+ lineHeight: "0px",
3339
+ display: "block"
3340
+ }), {
3341
+ center: { marginLeft: "auto", marginRight: "auto" },
3342
+ left: { marginRight: "auto" },
3343
+ right: { marginLeft: "auto" }
3344
+ }[alignment] || {}),
3345
+ ref: wrapperRef,
3346
+ children: [
3347
+ !hasImageSrc && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ImageStatusLabel, { status: "idle" }),
3348
+ hasImageSrc && isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ImageStatusLabel, { status: "variable" }),
3349
+ hasImageSrc && status === "loading" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ImageStatusLabel, { status: "loading" }),
3350
+ hasImageSrc && status === "error" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ImageStatusLabel, { status: "error" }),
3351
+ hasImageSrc && status === "loaded" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
3352
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3353
+ "img",
3354
+ __spreadProps(__spreadValues({}, attrs), {
3355
+ ref: imgRef,
3356
+ style: __spreadProps(__spreadValues({}, resizingStyle), {
3357
+ cursor: "default",
3358
+ marginBottom: 0
3359
+ }),
3360
+ draggable: editor.isEditable
3361
+ })
3362
+ ),
3363
+ selected && editor.isEditable && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
3364
+ [
3365
+ { left: 0, top: 0, height: "100%", width: "1px" },
3366
+ { right: 0, top: 0, height: "100%", width: "1px" },
3367
+ { top: 0, left: 0, width: "100%", height: "1px" },
3368
+ { bottom: 0, left: 0, width: "100%", height: "1px" }
3369
+ ].map((style, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3370
+ "div",
3371
+ {
3372
+ className: "mly-bg-rose-500",
3373
+ style: __spreadValues({
3374
+ position: "absolute"
3375
+ }, style)
3376
+ },
3377
+ i
3378
+ )),
3379
+ dragCornerButton("nw"),
3380
+ dragCornerButton("ne"),
3381
+ dragCornerButton("sw"),
3382
+ dragCornerButton("se")
3383
+ ] })
3384
+ ] })
3385
+ ]
3386
+ }
3387
+ );
3388
+ }
3389
+ function ImageStatusLabel(props) {
3390
+ const { status } = props;
3391
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3392
+ "div",
3393
+ {
3394
+ className: cn(
3395
+ "mly-flex mly-items-center mly-gap-2 mly-rounded-lg mly-bg-soft-gray mly-p-4 mly-text-sm mly-font-medium",
3396
+ {
3397
+ "mly-text-gray-500 hover:mly-bg-soft-gray/60": status === "loading",
3398
+ "mly-text-red-500 hover:mly-bg-soft-gray/60": status === "error"
3399
+ }
3400
+ ),
3401
+ children: [
3402
+ status === "idle" && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
3403
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react14.ImageOffIcon, { className: "mly-size-4 mly-stroke-[2.5]" }),
3404
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: "No image selected" })
3405
+ ] }),
3406
+ status === "loading" && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
3407
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react14.Loader2, { className: "mly-size-4 mly-animate-spin mly-stroke-[2.5]" }),
3408
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: "Loading image..." })
3409
+ ] }),
3410
+ status === "error" && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
3411
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react14.Ban, { className: "mly-size-4 mly-stroke-[2.5]" }),
3412
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: "Error loading image" })
3413
+ ] }),
3414
+ status === "variable" && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
3415
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react14.BracesIcon, { className: "mly-size-4 mly-stroke-[2.5]" }),
3416
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: "Variable Image URL" })
3417
+ ] })
3418
+ ]
3419
+ }
3420
+ );
3421
+ }
3422
+
3423
+ // src/editor/nodes/logo/logo-view.tsx
3424
+ var import_jsx_runtime27 = require("react/jsx-runtime");
3425
+ function LogoView(props) {
3426
+ const { node, editor } = props;
3427
+ const [status, setStatus] = (0, import_react28.useState)("idle");
3428
+ let {
3429
+ alignment = "center",
3430
+ src: logoSrc,
3431
+ isSrcVariable,
3432
+ size = "sm"
3433
+ } = node.attrs || {};
3434
+ const hasImageSrc = !!logoSrc;
3435
+ (0, import_react27.useEffect)(() => {
3436
+ if (!logoSrc) {
3437
+ return;
3438
+ }
3439
+ setStatus("loading");
3440
+ const img = new Image();
3441
+ img.src = logoSrc;
3442
+ img.onload = () => {
3443
+ setStatus("loaded");
3444
+ };
3445
+ img.onerror = () => {
3446
+ setStatus("error");
3447
+ };
3448
+ return () => {
3449
+ img.src = "";
3450
+ img.onload = null;
3451
+ img.onerror = null;
3452
+ };
3453
+ }, [logoSrc]);
3454
+ const logoSize = logoSizes[size];
3455
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
3456
+ import_react26.NodeViewWrapper,
3457
+ {
3458
+ as: "div",
3459
+ draggable: editor.isEditable,
3460
+ "data-drag-handle": editor.isEditable,
3461
+ style: {
3462
+ overflow: "hidden",
3463
+ position: "relative",
3464
+ // Weird! Basically tiptap/prose wraps this in a span and the line height causes an annoying buffer.
3465
+ lineHeight: "0px",
3466
+ display: "block"
3467
+ },
3468
+ children: [
3469
+ !hasImageSrc && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ImageStatusLabel, { status: "idle" }),
3470
+ hasImageSrc && isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ImageStatusLabel, { status: "variable" }),
3471
+ hasImageSrc && status === "loading" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ImageStatusLabel, { status: "loading" }),
3472
+ hasImageSrc && status === "error" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ImageStatusLabel, { status: "error" }),
3473
+ hasImageSrc && status === "loaded" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3474
+ "img",
3475
+ {
3476
+ src: logoSrc,
3477
+ alt: "Logo",
3478
+ style: __spreadValues({
3479
+ height: logoSize,
3480
+ width: logoSize,
3481
+ cursor: "default",
3482
+ marginBottom: 0
3483
+ }, {
3484
+ center: { marginLeft: "auto", marginRight: "auto" },
3485
+ left: { marginRight: "auto" },
3486
+ right: { marginLeft: "auto" }
3487
+ }[alignment] || {}),
3488
+ draggable: editor.isEditable
3489
+ }
3490
+ )
3491
+ ]
3492
+ }
3493
+ );
3494
+ }
3495
+
3496
+ // src/editor/nodes/logo/logo.ts
3497
+ var allowedLogoSize = ["sm", "md", "lg"];
3498
+ var allowedLogoAlignment = ["left", "center", "right"];
3499
+ var DEFAULT_ALIGNMENT = "left";
3500
+ var DEFAULT_LOGO_SIZE = "sm";
3501
+ var logoSizes = {
3502
+ sm: "40px",
3503
+ md: "48px",
3504
+ lg: "64px"
3505
+ };
3506
+ var LogoExtension = import_extension_image.default.extend({
3507
+ name: "logo",
3508
+ priority: 1e3,
3509
+ addAttributes() {
3510
+ var _a;
3511
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
3512
+ "maily-component": {
3513
+ default: "logo",
3514
+ renderHTML: (attributes) => {
3515
+ return {
3516
+ "data-maily-component": attributes["maily-component"]
3517
+ };
3518
+ },
3519
+ parseHTML: (element) => element.getAttribute("data-maily-component")
3520
+ },
3521
+ size: {
3522
+ default: DEFAULT_LOGO_SIZE,
3523
+ parseHTML: (element) => element.getAttribute("data-size"),
3524
+ renderHTML: (attributes) => {
3525
+ return {
3526
+ "data-size": attributes.size
3527
+ };
3528
+ }
3529
+ },
3530
+ alignment: {
3531
+ default: DEFAULT_ALIGNMENT,
3532
+ parseHTML: (element) => element.getAttribute("data-alignment"),
3533
+ renderHTML: (attributes) => {
3534
+ return {
3535
+ "data-alignment": attributes.alignment
3536
+ };
3537
+ }
3538
+ },
3539
+ showIfKey: {
3540
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
3541
+ parseHTML: (element) => {
3542
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
3543
+ },
3544
+ renderHTML(attributes) {
3545
+ if (!attributes.showIfKey) {
3546
+ return {};
3547
+ }
3548
+ return {
3549
+ "data-show-if-key": attributes.showIfKey
3550
+ };
3551
+ }
3552
+ },
3553
+ // Later we will remove this attribute
3554
+ // and use the `src` attribute instead when implement
3555
+ // the URL variable feature
3556
+ isSrcVariable: {
3557
+ default: false,
3558
+ parseHTML: (element) => {
3559
+ return element.getAttribute("data-is-src-variable") === "true";
3560
+ },
3561
+ renderHTML: (attributes) => {
3562
+ if (!attributes.isSrcVariable) {
3563
+ return {};
3564
+ }
3565
+ return {
3566
+ "data-is-src-variable": "true"
3567
+ };
3568
+ }
3569
+ }
3570
+ });
3571
+ },
3572
+ addCommands() {
3573
+ return {
3574
+ setLogoImage: (options) => ({ commands }) => {
3575
+ return commands.insertContent({
3576
+ type: this.name,
3577
+ attrs: options
3578
+ });
3579
+ },
3580
+ setLogoAttributes: (attributes) => ({ commands }) => {
3581
+ return commands.updateAttributes("logo", attributes);
3582
+ }
3583
+ };
3584
+ },
3585
+ parseHTML() {
3586
+ return [
3587
+ {
3588
+ tag: `img[data-maily-component="${this.name}"]`
3589
+ }
3590
+ ];
3591
+ },
3592
+ addNodeView() {
3593
+ return (0, import_react29.ReactNodeViewRenderer)(LogoView, {
3594
+ className: "mly-relative"
3595
+ });
3596
+ }
3597
+ });
3598
+
3599
+ // src/editor/nodes/image/image.ts
3600
+ var import_extension_image2 = __toESM(require("@tiptap/extension-image"));
3601
+ var import_react30 = require("@tiptap/react");
3602
+ var ImageExtension = import_extension_image2.default.extend({
3603
+ addAttributes() {
3604
+ var _a;
3605
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
3606
+ width: {
3607
+ default: "auto",
3608
+ parseHTML: (element) => {
3609
+ const width = element.style.width;
3610
+ return width ? { width } : null;
3611
+ },
3612
+ renderHTML: ({ width }) => ({ style: `width: ${width}` })
3613
+ },
3614
+ height: {
3615
+ default: "auto",
3616
+ parseHTML: (element) => {
3617
+ const height = element.style.height;
3618
+ return height ? { height } : null;
3619
+ },
3620
+ renderHTML: ({ height }) => ({ style: `height: ${height}` })
3621
+ },
3622
+ alignment: {
3623
+ default: "center",
3624
+ renderHTML: ({ alignment }) => ({ "data-alignment": alignment }),
3625
+ parseHTML: (element) => element.getAttribute("data-alignment") || "center"
3626
+ },
3627
+ externalLink: {
3628
+ default: null,
3629
+ renderHTML: ({ externalLink }) => {
3630
+ if (!externalLink) {
3631
+ return {};
3632
+ }
3633
+ return {
3634
+ "data-external-link": externalLink
3635
+ };
3636
+ },
3637
+ parseHTML: (element) => {
3638
+ const externalLink = element.getAttribute("data-external-link");
3639
+ return externalLink ? { externalLink } : null;
3640
+ }
3641
+ },
3642
+ // Later we will remove this attribute
3643
+ // and use the `externalLink` attribute instead
3644
+ // when implement the URL variable feature
3645
+ isExternalLinkVariable: {
3646
+ default: false,
3647
+ parseHTML: (element) => {
3648
+ return element.getAttribute("data-is-external-link-variable") === "true";
3649
+ },
3650
+ renderHTML: (attributes) => {
3651
+ if (!attributes.isExternalLinkVariable) {
3652
+ return {};
3653
+ }
3654
+ return {
3655
+ "data-is-external-link-variable": "true"
3656
+ };
3657
+ }
3658
+ },
3659
+ // Later we will remove this attribute
3660
+ // and use the `src` attribute instead when implement
3661
+ // the URL variable feature
3662
+ isSrcVariable: {
3663
+ default: false,
3664
+ parseHTML: (element) => {
3665
+ return element.getAttribute("data-is-src-variable") === "true";
3666
+ },
3667
+ renderHTML: (attributes) => {
3668
+ if (!attributes.isSrcVariable) {
3669
+ return {};
3670
+ }
3671
+ return {
3672
+ "data-is-src-variable": "true"
3673
+ };
3674
+ }
3675
+ },
3676
+ showIfKey: {
3677
+ default: DEFAULT_SECTION_SHOW_IF_KEY,
3678
+ parseHTML: (element) => {
3679
+ return element.getAttribute("data-show-if-key") || DEFAULT_SECTION_SHOW_IF_KEY;
3680
+ },
3681
+ renderHTML(attributes) {
3682
+ if (!attributes.showIfKey) {
3683
+ return {};
3684
+ }
3685
+ return {
3686
+ "data-show-if-key": attributes.showIfKey
3687
+ };
3688
+ }
3689
+ }
3690
+ });
3691
+ },
3692
+ addNodeView() {
3693
+ return (0, import_react30.ReactNodeViewRenderer)(ImageView, {
3694
+ className: "mly-relative"
3695
+ });
3696
+ }
3697
+ });
3698
+
3699
+ // src/editor/nodes/link.ts
3700
+ var import_extension_link = __toESM(require("@tiptap/extension-link"));
3701
+ var LinkExtension = import_extension_link.default.extend({
3702
+ addAttributes() {
3703
+ var _a;
3704
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
3705
+ isUrlVariable: {
3706
+ default: false
3707
+ }
3708
+ });
3709
+ },
3710
+ addCommands() {
3711
+ var _a;
3712
+ return __spreadProps(__spreadValues({}, (_a = this.parent) == null ? void 0 : _a.call(this)), {
3713
+ setIsUrlVariable: (isUrlVariable) => ({ chain }) => {
3714
+ return chain().setMark("link", { isUrlVariable }).run();
3715
+ }
3716
+ });
3717
+ }
3718
+ });
3719
+
3720
+ // src/editor/extensions/maily-kit.tsx
3721
+ var MailyKit = import_core12.Extension.create({
3722
+ name: "maily-kit",
3723
+ addOptions() {
3724
+ return {
3725
+ link: {
3726
+ HTMLAttributes: {
3727
+ target: "_blank",
3728
+ rel: "noopener noreferrer nofollow",
3729
+ class: "mly-no-underline"
3730
+ },
3731
+ openOnClick: false
3732
+ }
3733
+ };
3734
+ },
3735
+ addExtensions() {
3736
+ const extensions = [
3737
+ import_extension_document.default.extend({
3738
+ content: "(block|columns)+"
3739
+ }),
3740
+ import_starter_kit.default.configure({
3741
+ heading: {
3742
+ levels: [1, 2, 3],
3743
+ HTMLAttributes: {
3744
+ class: "mly-relative"
3745
+ }
3746
+ },
3747
+ code: {
3748
+ HTMLAttributes: {
3749
+ class: "mly-px-1 mly-relative mly-py-0.5 mly-bg-[#efefef] mly-text-sm mly-rounded-md mly-tracking-normal mly-font-normal"
3750
+ }
3751
+ },
3752
+ blockquote: {
3753
+ HTMLAttributes: {
3754
+ class: "mly-not-prose mly-border-l-4 mly-border-gray-300 mly-pl-4 mly-mt-4 mly-mb-4 mly-relative"
3755
+ }
3756
+ },
3757
+ paragraph: {
3758
+ HTMLAttributes: {
3759
+ class: "mly-relative"
3760
+ }
3761
+ },
3762
+ bulletList: {
3763
+ HTMLAttributes: {
3764
+ class: "mly-relative"
3765
+ }
3766
+ },
3767
+ orderedList: {
3768
+ HTMLAttributes: {
3769
+ class: "mly-relative"
3770
+ }
3771
+ },
3772
+ horizontalRule: false,
3773
+ dropcursor: false,
3774
+ document: false
3775
+ }),
3776
+ import_extension_underline.default,
3777
+ Color.configure({ types: [import_extension_text_style.default.name, import_extension_list_item.default.name] }),
3778
+ import_extension_text_style.default.configure(),
3779
+ import_extension_text_align.default.configure({
3780
+ types: [import_extension_paragraph.default.name, import_extension_heading.default.name, Footer.name]
3781
+ }),
3782
+ HorizontalRule,
3783
+ import_extension_placeholder.default.configure({
3784
+ placeholder: ({ node }) => {
3785
+ if (node.type.name === "heading") {
3786
+ return `Heading ${node.attrs.level}`;
3787
+ } else if ([
3788
+ "columns",
3789
+ "column",
3790
+ "section",
3791
+ "for",
3792
+ "show",
3793
+ "blockquote"
3794
+ ].includes(node.type.name)) {
3795
+ return "";
3796
+ }
3797
+ return "Write something or / to see commands";
3798
+ },
3799
+ includeChildren: true
3800
+ }),
3801
+ Footer,
3802
+ import_extension_focus.default,
3803
+ import_extension_dropcursor.default.configure({
3804
+ color: "#555",
3805
+ width: 3,
3806
+ class: "ProseMirror-dropcursor"
3807
+ })
3808
+ ];
3809
+ if (this.options.linkCard !== false) {
3810
+ extensions.push(LinkCardExtension.configure(this.options.linkCard));
3811
+ }
3812
+ if (this.options.for !== false) {
3813
+ extensions.push(ForExtension);
3814
+ }
3815
+ if (this.options.section !== false) {
3816
+ extensions.push(SectionExtension);
3817
+ }
3818
+ if (this.options.columns !== false) {
3819
+ extensions.push(ColumnsExtension);
3820
+ }
3821
+ if (this.options.column !== false) {
3822
+ extensions.push(ColumnExtension);
3823
+ }
3824
+ if (this.options.button !== false) {
3825
+ extensions.push(ButtonExtension);
3826
+ }
3827
+ if (this.options.spacer !== false) {
3828
+ extensions.push(Spacer);
3829
+ }
3830
+ if (this.options.logo !== false) {
3831
+ extensions.push(LogoExtension);
3832
+ }
3833
+ if (this.options.image !== false) {
3834
+ extensions.push(ImageExtension);
3835
+ }
3836
+ if (this.options.link !== false) {
3837
+ extensions.push(LinkExtension.configure(this.options.link));
3838
+ }
3839
+ return extensions;
3840
+ }
3841
+ });
3842
+
3843
+ // src/editor/extensions/slash-command/slash-command.ts
3844
+ var import_core13 = require("@tiptap/core");
3845
+ var import_suggestion = __toESM(require("@tiptap/suggestion"));
3846
+ var SlashCommandExtension = import_core13.Extension.create({
3847
+ name: "slash-command",
3848
+ addOptions() {
3849
+ return {
3850
+ suggestion: {
3851
+ char: "/",
3852
+ command: ({ editor, range, props }) => {
3853
+ props.command({ editor, range });
3854
+ }
3855
+ }
3856
+ };
3857
+ },
3858
+ addProseMirrorPlugins() {
3859
+ return [
3860
+ (0, import_suggestion.default)(__spreadValues({
3861
+ editor: this.editor
3862
+ }, this.options.suggestion))
3863
+ ];
3864
+ }
3865
+ });
3866
+
3867
+ // src/editor/utils/update-scroll-view.ts
3868
+ var updateScrollView = (container, item) => {
3869
+ const containerHeight = container.offsetHeight;
3870
+ const itemHeight = item ? item.offsetHeight : 0;
3871
+ const top = item.offsetTop;
3872
+ const bottom = top + itemHeight;
3873
+ if (top < container.scrollTop) {
3874
+ container.scrollTop -= container.scrollTop - top + 5;
3875
+ } else if (bottom > containerHeight + container.scrollTop) {
3876
+ container.scrollTop += bottom - containerHeight - container.scrollTop + 5;
3877
+ }
3878
+ };
3879
+
3880
+ // src/editor/extensions/slash-command/slash-command-view.tsx
3881
+ var import_react31 = require("@tiptap/react");
3882
+ var import_react32 = require("react");
3883
+ var import_tippy = __toESM(require("tippy.js"));
3884
+ var import_jsx_runtime28 = require("react/jsx-runtime");
3885
+ function CommandList(props) {
3886
+ const { items, command, editor } = props;
3887
+ const [selectedIndex, setSelectedIndex] = (0, import_react32.useState)(0);
3888
+ const selectItem = (0, import_react32.useCallback)(
3889
+ (index) => {
3890
+ const item = items[index];
3891
+ if (item) {
3892
+ command(item);
3893
+ }
3894
+ },
3895
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3896
+ [command, editor, items]
3897
+ );
3898
+ (0, import_react32.useEffect)(() => {
3899
+ const navigationKeys = ["ArrowUp", "ArrowDown", "Enter"];
3900
+ const onKeyDown = (e) => {
3901
+ if (navigationKeys.includes(e.key)) {
3902
+ e.preventDefault();
3903
+ if (e.key === "ArrowUp") {
3904
+ setSelectedIndex((selectedIndex + items.length - 1) % items.length);
3905
+ return true;
3906
+ }
3907
+ if (e.key === "ArrowDown") {
3908
+ setSelectedIndex((selectedIndex + 1) % items.length);
3909
+ return true;
3910
+ }
3911
+ if (e.key === "Enter") {
3912
+ selectItem(selectedIndex);
3913
+ return true;
3914
+ }
3915
+ return false;
3916
+ }
3917
+ };
3918
+ document.addEventListener("keydown", onKeyDown);
3919
+ return () => {
3920
+ document.removeEventListener("keydown", onKeyDown);
3921
+ };
3922
+ }, [items, selectedIndex, setSelectedIndex, selectItem]);
3923
+ (0, import_react32.useEffect)(() => {
3924
+ setSelectedIndex(0);
3925
+ }, [items]);
3926
+ const commandListContainer = (0, import_react32.useRef)(null);
3927
+ (0, import_react32.useLayoutEffect)(() => {
3928
+ const container = commandListContainer == null ? void 0 : commandListContainer.current;
3929
+ const item = container == null ? void 0 : container.children[selectedIndex];
3930
+ if (item && container) {
3931
+ updateScrollView(container, item);
3932
+ }
3933
+ }, [selectedIndex]);
3934
+ return items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-z-50 mly-w-72 mly-rounded-md mly-border mly-border-gray-200 mly-bg-white mly-shadow-md mly-transition-all", children: [
3935
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3936
+ "div",
3937
+ {
3938
+ id: "slash-command",
3939
+ ref: commandListContainer,
3940
+ className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto mly-scroll-smooth mly-p-1",
3941
+ children: items.map((item, index) => {
3942
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3943
+ "button",
3944
+ {
3945
+ className: cn(
3946
+ "mly-flex mly-w-full mly-items-center mly-space-x-2 mly-rounded-md mly-px-2 mly-py-1 mly-text-left mly-text-sm mly-text-gray-900 hover:mly-bg-gray-100 hover:mly-text-gray-900",
3947
+ index === selectedIndex ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
3948
+ ),
3949
+ onClick: () => selectItem(index),
3950
+ type: "button",
3951
+ children: [
3952
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "mly-flex mly-h-6 mly-w-6 mly-shrink-0 mly-items-center mly-justify-center", children: item.icon }),
3953
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { children: [
3954
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "mly-font-medium", children: item.title }),
3955
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
3956
+ ] })
3957
+ ]
3958
+ },
3959
+ index
3960
+ );
3961
+ })
3962
+ }
3963
+ ),
3964
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "mly-border-t mly-border-gray-200 mly-px-1 mly-py-3 mly-pl-4", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-flex mly-items-center", children: [
3965
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
3966
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("kbd", { className: "mly-rounded mly-border mly-p-1 mly-px-2 mly-font-medium", children: "\u2191" }),
3967
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("kbd", { className: "mly-ml-1 mly-rounded mly-border mly-p-1 mly-px-2 mly-font-medium", children: "\u2193" }),
3968
+ " ",
3969
+ "to navigate"
3970
+ ] }),
3971
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": "true", className: "mly-select-none mly-px-1", children: "\xB7" }),
3972
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
3973
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("kbd", { className: "mly-rounded mly-border mly-p-1 mly-px-1.5 mly-font-medium", children: "Enter" }),
3974
+ " ",
3975
+ "to select"
3976
+ ] })
3977
+ ] }) })
3978
+ ] }) : null;
3979
+ }
3980
+ function getSlashCommandSuggestions(commands = DEFAULT_SLASH_COMMANDS) {
3981
+ return {
3982
+ items: ({ query, editor }) => {
3983
+ return commands.filter((item) => {
3984
+ var _a;
3985
+ if (typeof query === "string" && query.length > 0) {
3986
+ const search = query.toLowerCase();
3987
+ if ((_a = item == null ? void 0 : item.shouldBeHidden) == null ? void 0 : _a.call(item, editor)) {
3988
+ return false;
3989
+ }
3990
+ return item.title.toLowerCase().includes(search) || item.description.toLowerCase().includes(search) || item.searchTerms && item.searchTerms.some((term) => term.includes(search));
3991
+ }
3992
+ return true;
3993
+ });
3994
+ },
3995
+ render: () => {
3996
+ let component;
3997
+ let popup = null;
3998
+ return {
3999
+ onStart: (props) => {
4000
+ component = new import_react31.ReactRenderer(CommandList, {
4001
+ props,
4002
+ editor: props.editor
4003
+ });
4004
+ popup = (0, import_tippy.default)("body", {
4005
+ getReferenceClientRect: props.clientRect,
4006
+ appendTo: () => document.body,
4007
+ content: component.element,
4008
+ showOnCreate: true,
4009
+ interactive: true,
4010
+ trigger: "manual"
4011
+ });
4012
+ },
4013
+ onUpdate: (props) => {
4014
+ component == null ? void 0 : component.updateProps(props);
4015
+ popup && popup[0].setProps({
4016
+ getReferenceClientRect: props.clientRect
4017
+ });
4018
+ },
4019
+ onKeyDown: (props) => {
4020
+ var _a;
4021
+ if (props.event.key === "Escape") {
4022
+ popup == null ? void 0 : popup[0].hide();
4023
+ return true;
4024
+ }
4025
+ return (_a = component == null ? void 0 : component.ref) == null ? void 0 : _a.onKeyDown(props);
4026
+ },
4027
+ onExit: () => {
4028
+ if (!popup || !(popup == null ? void 0 : popup[0]) || !component) {
4029
+ return;
4030
+ }
4031
+ popup == null ? void 0 : popup[0].destroy();
4032
+ component == null ? void 0 : component.destroy();
4033
+ }
4034
+ };
4035
+ }
4036
+ };
4037
+ }
4038
+
4039
+ // src/editor/nodes/variable/variable.ts
4040
+ var import_core14 = require("@tiptap/core");
4041
+ var import_state2 = require("@tiptap/pm/state");
4042
+ var import_react33 = require("@tiptap/react");
4043
+ var import_suggestion2 = __toESM(require("@tiptap/suggestion"));
4044
+ var VariablePluginKey = new import_state2.PluginKey("variable");
4045
+ var VariableExtension = import_core14.Node.create({
4046
+ name: "variable",
4047
+ group: "inline",
4048
+ inline: true,
4049
+ selectable: true,
4050
+ atom: true,
4051
+ addOptions() {
4052
+ return {
4053
+ variables: [],
4054
+ triggerChar: "@",
4055
+ renderLabel({ options, node }) {
4056
+ var _a;
4057
+ return `${(_a = node.attrs.label) != null ? _a : node.attrs.id}`;
4058
+ },
4059
+ suggestion: {
4060
+ char: "@",
4061
+ pluginKey: VariablePluginKey,
4062
+ command: ({ editor, range, props }) => {
4063
+ var _a, _b;
4064
+ const nodeAfter = editor.view.state.selection.$to.nodeAfter;
4065
+ const overrideSpace = (_a = nodeAfter == null ? void 0 : nodeAfter.text) == null ? void 0 : _a.startsWith(" ");
4066
+ if (overrideSpace) {
4067
+ range.to += 1;
4068
+ }
4069
+ editor.chain().focus().insertContentAt(range, [
4070
+ {
4071
+ type: this.name,
4072
+ attrs: props
4073
+ },
4074
+ {
4075
+ type: "text",
4076
+ text: " "
4077
+ }
4078
+ ]).run();
4079
+ (_b = window.getSelection()) == null ? void 0 : _b.collapseToEnd();
4080
+ },
4081
+ allow: ({ state, range }) => {
4082
+ const $from = state.doc.resolve(range.from);
4083
+ const type = state.schema.nodes[this.name];
4084
+ const allow = !!$from.parent.type.contentMatch.matchType(type);
4085
+ return allow;
4086
+ }
4087
+ }
4088
+ };
4089
+ },
4090
+ addAttributes() {
4091
+ return {
4092
+ id: {
4093
+ default: null,
4094
+ parseHTML: (element) => element.getAttribute("data-id"),
4095
+ renderHTML: (attributes) => {
4096
+ if (!attributes.id) {
4097
+ return {};
4098
+ }
4099
+ return {
4100
+ "data-id": attributes.id
4101
+ };
4102
+ }
4103
+ },
4104
+ label: {
4105
+ default: null,
4106
+ parseHTML: (element) => element.getAttribute("data-label"),
4107
+ renderHTML: (attributes) => {
4108
+ if (!attributes.label) {
4109
+ return {};
4110
+ }
4111
+ return {
4112
+ "data-label": attributes.label
4113
+ };
4114
+ }
4115
+ },
4116
+ fallback: {
4117
+ default: null,
4118
+ parseHTML: (element) => element.getAttribute("data-fallback"),
4119
+ renderHTML: (attributes) => {
4120
+ if (!attributes.fallback) {
4121
+ return {};
4122
+ }
4123
+ return {
4124
+ "data-fallback": attributes.fallback
4125
+ };
4126
+ }
4127
+ },
4128
+ required: {
4129
+ default: true,
4130
+ parseHTML: (element) => element.hasAttribute("data-required"),
4131
+ renderHTML: (attributes) => {
4132
+ var _a;
4133
+ return {
4134
+ "data-required": (_a = attributes == null ? void 0 : attributes.required) != null ? _a : true
4135
+ };
4136
+ }
4137
+ }
4138
+ };
4139
+ },
4140
+ parseHTML() {
4141
+ return [
4142
+ {
4143
+ tag: `div[data-type="${this.name}"]`
4144
+ }
4145
+ ];
4146
+ },
4147
+ renderHTML({ node, HTMLAttributes: HTMLAttributes2 }) {
4148
+ return [
4149
+ "div",
4150
+ (0, import_core14.mergeAttributes)({ "data-type": this.name }, HTMLAttributes2),
4151
+ this.options.renderLabel({
4152
+ options: this.options,
4153
+ node
4154
+ })
4155
+ ];
4156
+ },
4157
+ renderText({ node }) {
4158
+ return this.options.renderLabel({
4159
+ options: this.options,
4160
+ node
4161
+ });
4162
+ },
4163
+ addKeyboardShortcuts() {
4164
+ return {
4165
+ Backspace: () => this.editor.commands.command(({ tr, state }) => {
4166
+ let isMention = false;
4167
+ const { selection } = state;
4168
+ const { empty, anchor } = selection;
4169
+ if (!empty) {
4170
+ return false;
4171
+ }
4172
+ state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
4173
+ if (node.type.name === this.name) {
4174
+ isMention = true;
4175
+ tr.insertText(
4176
+ this.options.suggestion.char || "",
4177
+ pos,
4178
+ pos + node.nodeSize
4179
+ );
4180
+ return false;
4181
+ }
4182
+ });
4183
+ return isMention;
4184
+ })
4185
+ };
4186
+ },
4187
+ addProseMirrorPlugins() {
4188
+ return [
4189
+ (0, import_suggestion2.default)(__spreadValues({
4190
+ editor: this.editor
4191
+ }, this.options.suggestion))
4192
+ ];
4193
+ },
4194
+ addNodeView() {
4195
+ return (0, import_react33.ReactNodeViewRenderer)(VariableView, {
4196
+ className: "mly-relative mly-inline-block",
4197
+ as: "div"
4198
+ });
4199
+ }
4200
+ });
4201
+
4202
+ // src/editor/nodes/variable/variable-suggestions.tsx
4203
+ var import_react34 = require("@tiptap/react");
4204
+ var import_react35 = require("react");
4205
+ var import_tippy2 = __toESM(require("tippy.js"));
4206
+ var import_react36 = require("react");
4207
+ var import_jsx_runtime29 = require("react/jsx-runtime");
4208
+ var VariableList = (0, import_react35.forwardRef)((props, ref) => {
4209
+ const { items = [] } = props;
4210
+ const popoverRef = (0, import_react36.useRef)(null);
4211
+ (0, import_react35.useImperativeHandle)(ref, () => ({
4212
+ onKeyDown: ({ event }) => {
4213
+ if (!popoverRef.current) {
4214
+ return false;
4215
+ }
4216
+ const { moveUp, moveDown, select } = popoverRef.current || {};
4217
+ if (event.key === "ArrowUp") {
4218
+ event.preventDefault();
4219
+ moveUp();
4220
+ return true;
4221
+ }
4222
+ if (event.key === "ArrowDown") {
4223
+ event.preventDefault();
4224
+ moveDown();
4225
+ return true;
4226
+ }
4227
+ if (event.key === "Enter") {
4228
+ select();
4229
+ return true;
4230
+ }
4231
+ return false;
4232
+ }
4233
+ }));
4234
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4235
+ VariablePopover,
4236
+ {
4237
+ items,
4238
+ onSelectItem: (value) => {
4239
+ var _a;
4240
+ props.command({
4241
+ id: value.name,
4242
+ required: (_a = value.required) != null ? _a : true
4243
+ });
4244
+ },
4245
+ ref: popoverRef
4246
+ }
4247
+ );
4248
+ });
4249
+ VariableList.displayName = "VariableList";
4250
+ function getVariableSuggestions(variables = DEFAULT_VARIABLES, char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
4251
+ return {
4252
+ char,
4253
+ items: ({ query, editor }) => {
4254
+ return processVariables(variables, {
4255
+ query,
4256
+ editor,
4257
+ from: "content-variable"
4258
+ });
4259
+ },
4260
+ render: () => {
4261
+ let component;
4262
+ let popup = null;
4263
+ return {
4264
+ onStart: (props) => {
4265
+ component = new import_react34.ReactRenderer(VariableList, {
4266
+ props,
4267
+ editor: props.editor
4268
+ });
4269
+ if (!props.clientRect) {
4270
+ return;
4271
+ }
4272
+ popup = (0, import_tippy2.default)("body", {
4273
+ getReferenceClientRect: props.clientRect,
4274
+ appendTo: () => document.body,
4275
+ content: component.element,
4276
+ showOnCreate: true,
4277
+ interactive: true,
4278
+ trigger: "manual",
4279
+ placement: "bottom-start"
4280
+ });
4281
+ },
4282
+ onUpdate(props) {
4283
+ var _a;
4284
+ component.updateProps(props);
4285
+ if (!props.clientRect) {
4286
+ return;
4287
+ }
4288
+ (_a = popup == null ? void 0 : popup[0]) == null ? void 0 : _a.setProps({
4289
+ getReferenceClientRect: props.clientRect
4290
+ });
4291
+ },
4292
+ onKeyDown(props) {
4293
+ var _a;
4294
+ if (props.event.key === "Escape") {
4295
+ popup == null ? void 0 : popup[0].hide();
4296
+ return true;
4297
+ }
4298
+ return (_a = component.ref) == null ? void 0 : _a.onKeyDown(props);
4299
+ },
4300
+ onExit() {
4301
+ if (!popup || !(popup == null ? void 0 : popup[0]) || !component) {
4302
+ return;
4303
+ }
4304
+ popup == null ? void 0 : popup[0].destroy();
4305
+ component.destroy();
4306
+ }
4307
+ };
4308
+ }
4309
+ };
4310
+ }
4311
+ // Annotate the CommonJS export names for ESM import in node:
4312
+ 0 && (module.exports = {
4313
+ ButtonExtension,
4314
+ Color,
4315
+ ColumnExtension,
4316
+ ColumnsExtension,
4317
+ DEFAULT_BUTTON_ALIGNMENT,
4318
+ DEFAULT_BUTTON_BACKGROUND_COLOR,
4319
+ DEFAULT_BUTTON_BORDER_RADIUS,
4320
+ DEFAULT_BUTTON_PADDING_BOTTOM,
4321
+ DEFAULT_BUTTON_PADDING_LEFT,
4322
+ DEFAULT_BUTTON_PADDING_RIGHT,
4323
+ DEFAULT_BUTTON_PADDING_TOP,
4324
+ DEFAULT_BUTTON_TEXT_COLOR,
4325
+ DEFAULT_BUTTON_VARIANT,
4326
+ DEFAULT_COLUMNS_GAP,
4327
+ DEFAULT_COLUMN_VERTICAL_ALIGN,
4328
+ DEFAULT_COLUMN_WIDTH,
4329
+ DEFAULT_LOGO_SIZE,
4330
+ DEFAULT_SECTION_ALIGN,
4331
+ DEFAULT_SECTION_BACKGROUND_COLOR,
4332
+ DEFAULT_SECTION_BORDER_COLOR,
4333
+ DEFAULT_SECTION_BORDER_RADIUS,
4334
+ DEFAULT_SECTION_BORDER_WIDTH,
4335
+ DEFAULT_SECTION_MARGIN_BOTTOM,
4336
+ DEFAULT_SECTION_MARGIN_LEFT,
4337
+ DEFAULT_SECTION_MARGIN_RIGHT,
4338
+ DEFAULT_SECTION_MARGIN_TOP,
4339
+ DEFAULT_SECTION_PADDING_BOTTOM,
4340
+ DEFAULT_SECTION_PADDING_LEFT,
4341
+ DEFAULT_SECTION_PADDING_RIGHT,
4342
+ DEFAULT_SECTION_PADDING_TOP,
4343
+ DEFAULT_SECTION_SHOW_IF_KEY,
4344
+ Footer,
4345
+ ForExtension,
4346
+ HorizontalRule,
4347
+ ImageExtension,
4348
+ LinkExtension,
4349
+ LogoExtension,
4350
+ MailyKit,
4351
+ SectionExtension,
4352
+ SlashCommandExtension,
4353
+ Spacer,
4354
+ VariableExtension,
4355
+ VariableList,
4356
+ VariablePluginKey,
4357
+ allowedButtonBorderRadius,
4358
+ allowedButtonVariant,
4359
+ allowedLogoAlignment,
4360
+ allowedLogoSize,
4361
+ allowedSpacerSize,
4362
+ getSlashCommandSuggestions,
4363
+ getVariableSuggestions,
4364
+ logoSizes
4365
+ });
4366
+ //# sourceMappingURL=index.js.map