@maily-to/core 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocks/index.d.mts +3 -1
- package/dist/blocks/index.d.ts +3 -1
- package/dist/blocks/index.js +41 -26
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/index.mjs +36 -22
- package/dist/blocks/index.mjs.map +1 -1
- package/dist/extensions/index.d.mts +203 -141
- package/dist/extensions/index.d.ts +203 -141
- package/dist/extensions/index.js +1454 -1029
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/index.mjs +1292 -872
- package/dist/extensions/index.mjs.map +1 -1
- package/dist/index.d.mts +0 -22
- package/dist/index.d.ts +0 -22
- package/dist/index.js +4863 -4471
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4883 -4489
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/readme.md +86 -30
package/dist/extensions/index.js
CHANGED
|
@@ -55,6 +55,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
55
55
|
mod
|
|
56
56
|
));
|
|
57
57
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
+
var __async = (__this, __arguments, generator) => {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
var fulfilled = (value) => {
|
|
61
|
+
try {
|
|
62
|
+
step(generator.next(value));
|
|
63
|
+
} catch (e) {
|
|
64
|
+
reject(e);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var rejected = (value) => {
|
|
68
|
+
try {
|
|
69
|
+
step(generator.throw(value));
|
|
70
|
+
} catch (e) {
|
|
71
|
+
reject(e);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
75
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
76
|
+
});
|
|
77
|
+
};
|
|
58
78
|
|
|
59
79
|
// src/extensions.ts
|
|
60
80
|
var extensions_exports = {};
|
|
@@ -76,6 +96,7 @@ __export(extensions_exports, {
|
|
|
76
96
|
DEFAULT_COLUMN_VERTICAL_ALIGN: () => DEFAULT_COLUMN_VERTICAL_ALIGN,
|
|
77
97
|
DEFAULT_COLUMN_WIDTH: () => DEFAULT_COLUMN_WIDTH,
|
|
78
98
|
DEFAULT_LOGO_SIZE: () => DEFAULT_LOGO_SIZE,
|
|
99
|
+
DEFAULT_RENDER_VARIABLE_FUNCTION: () => DEFAULT_RENDER_VARIABLE_FUNCTION,
|
|
79
100
|
DEFAULT_SECTION_ALIGN: () => DEFAULT_SECTION_ALIGN,
|
|
80
101
|
DEFAULT_SECTION_BACKGROUND_COLOR: () => DEFAULT_SECTION_BACKGROUND_COLOR,
|
|
81
102
|
DEFAULT_SECTION_BORDER_COLOR: () => DEFAULT_SECTION_BORDER_COLOR,
|
|
@@ -91,9 +112,14 @@ __export(extensions_exports, {
|
|
|
91
112
|
DEFAULT_SECTION_PADDING_TOP: () => DEFAULT_SECTION_PADDING_TOP,
|
|
92
113
|
DEFAULT_SECTION_SHOW_IF_KEY: () => DEFAULT_SECTION_SHOW_IF_KEY,
|
|
93
114
|
DEFAULT_SPACER_HEIGHT: () => DEFAULT_SPACER_HEIGHT,
|
|
115
|
+
DEFAULT_VARIABLES: () => DEFAULT_VARIABLES,
|
|
116
|
+
DEFAULT_VARIABLE_SUGGESTION_POPOVER: () => DEFAULT_VARIABLE_SUGGESTION_POPOVER,
|
|
117
|
+
DEFAULT_VARIABLE_TRIGGER_CHAR: () => DEFAULT_VARIABLE_TRIGGER_CHAR,
|
|
94
118
|
Footer: () => Footer,
|
|
95
119
|
HorizontalRule: () => HorizontalRule,
|
|
96
120
|
ImageExtension: () => ImageExtension,
|
|
121
|
+
ImageUploadExtension: () => ImageUploadExtension,
|
|
122
|
+
ImageUploadPlugin: () => ImageUploadPlugin,
|
|
97
123
|
LinkExtension: () => LinkExtension,
|
|
98
124
|
LogoExtension: () => LogoExtension,
|
|
99
125
|
MailyKit: () => MailyKit,
|
|
@@ -111,23 +137,11 @@ __export(extensions_exports, {
|
|
|
111
137
|
allowedLogoSize: () => allowedLogoSize,
|
|
112
138
|
getSlashCommandSuggestions: () => getSlashCommandSuggestions,
|
|
113
139
|
getVariableSuggestions: () => getVariableSuggestions,
|
|
114
|
-
logoSizes: () => logoSizes
|
|
140
|
+
logoSizes: () => logoSizes,
|
|
141
|
+
useImageUploadOptions: () => useImageUploadOptions
|
|
115
142
|
});
|
|
116
143
|
module.exports = __toCommonJS(extensions_exports);
|
|
117
144
|
|
|
118
|
-
// src/editor/extensions/maily-kit.tsx
|
|
119
|
-
var import_core12 = require("@tiptap/core");
|
|
120
|
-
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
121
|
-
var import_extension_list_item = __toESM(require("@tiptap/extension-list-item"));
|
|
122
|
-
var import_extension_paragraph2 = __toESM(require("@tiptap/extension-paragraph"));
|
|
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_heading2 = __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
145
|
// src/editor/extensions/color.ts
|
|
132
146
|
var import_extension_color = __toESM(require("@tiptap/extension-color"));
|
|
133
147
|
var Color = import_extension_color.default.extend({
|
|
@@ -168,9 +182,157 @@ var HorizontalRule = import_extension_horizontal_rule.HorizontalRule.extend({
|
|
|
168
182
|
}
|
|
169
183
|
});
|
|
170
184
|
|
|
171
|
-
// src/editor/
|
|
185
|
+
// src/editor/plugins/image-upload/image-upload-plugin.ts
|
|
186
|
+
var import_state = require("@tiptap/pm/state");
|
|
187
|
+
function ImageUploadPlugin(options) {
|
|
188
|
+
const { editor, onImageUpload, allowedMimeTypes } = options;
|
|
189
|
+
function handleImageUpload(view, file, pos) {
|
|
190
|
+
var _a, _b, _c;
|
|
191
|
+
const placeholderSrc = URL.createObjectURL(file);
|
|
192
|
+
const { tr, schema } = view.state;
|
|
193
|
+
const imageNode = schema.nodes.image.create({
|
|
194
|
+
src: placeholderSrc,
|
|
195
|
+
isSrcVariable: false,
|
|
196
|
+
alt: file.name,
|
|
197
|
+
externalLink: "",
|
|
198
|
+
isExternalLinkVariable: false
|
|
199
|
+
});
|
|
200
|
+
(_c = (_b = (_a = editor == null ? void 0 : editor.extensionStorage) == null ? void 0 : _a.imageUpload) == null ? void 0 : _b.placeholderImages) == null ? void 0 : _c.add(
|
|
201
|
+
placeholderSrc
|
|
202
|
+
);
|
|
203
|
+
const resolvedPos = pos !== void 0 ? view.state.doc.resolve(pos) : view.state.selection.$head;
|
|
204
|
+
const transaction = tr.insert(resolvedPos.pos, imageNode);
|
|
205
|
+
view.dispatch(transaction);
|
|
206
|
+
onImageUpload == null ? void 0 : onImageUpload(file).then((uploadedSrc) => {
|
|
207
|
+
const updateTr = view.state.tr;
|
|
208
|
+
const predicate = (node) => node.type.name === "image" && node.attrs.src === placeholderSrc;
|
|
209
|
+
view.state.doc.descendants((node, pos2) => {
|
|
210
|
+
if (predicate(node)) {
|
|
211
|
+
updateTr.setNodeMarkup(pos2, void 0, __spreadProps(__spreadValues({}, node.attrs), {
|
|
212
|
+
src: uploadedSrc
|
|
213
|
+
}));
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
view.dispatch(updateTr);
|
|
218
|
+
}).catch((error) => {
|
|
219
|
+
console.error("Image upload failed", error);
|
|
220
|
+
}).finally(() => {
|
|
221
|
+
editor.extensionStorage.imageUpload.placeholderImages.delete(
|
|
222
|
+
placeholderSrc
|
|
223
|
+
);
|
|
224
|
+
URL.revokeObjectURL(placeholderSrc);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return new import_state.Plugin({
|
|
228
|
+
key: new import_state.PluginKey("imageUpload"),
|
|
229
|
+
props: {
|
|
230
|
+
handleDrop: (view, event) => {
|
|
231
|
+
var _a, _b;
|
|
232
|
+
if (!onImageUpload || // we'll handle drops in the ImageView component
|
|
233
|
+
// this is just for dropping images in empty areas
|
|
234
|
+
!((_b = (_a = event.dataTransfer) == null ? void 0 : _a.files) == null ? void 0 : _b.length)) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
const images = Array.from(event.dataTransfer.files).filter(
|
|
238
|
+
(file) => allowedMimeTypes == null ? void 0 : allowedMimeTypes.includes(file.type)
|
|
239
|
+
);
|
|
240
|
+
if (images.length === 0) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
const pos = view.posAtCoords({
|
|
244
|
+
left: event.clientX,
|
|
245
|
+
top: event.clientY
|
|
246
|
+
});
|
|
247
|
+
if (!pos) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
event.preventDefault();
|
|
251
|
+
event.stopPropagation();
|
|
252
|
+
images.forEach((file) => handleImageUpload(view, file, pos.pos));
|
|
253
|
+
return true;
|
|
254
|
+
},
|
|
255
|
+
handlePaste: (view, event) => {
|
|
256
|
+
var _a, _b;
|
|
257
|
+
if (!onImageUpload || !((_b = (_a = event.clipboardData) == null ? void 0 : _a.files) == null ? void 0 : _b.length)) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
const images = Array.from(event.clipboardData.files).filter(
|
|
261
|
+
(file) => allowedMimeTypes == null ? void 0 : allowedMimeTypes.includes(file.type)
|
|
262
|
+
);
|
|
263
|
+
if (images.length === 0) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
event.preventDefault();
|
|
267
|
+
event.stopPropagation();
|
|
268
|
+
images.forEach((file) => handleImageUpload(view, file));
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// src/editor/extensions/image-upload/image-upload.ts
|
|
172
276
|
var import_core2 = require("@tiptap/core");
|
|
173
|
-
var
|
|
277
|
+
var import_react = require("react");
|
|
278
|
+
var ImageUploadExtension = import_core2.Extension.create({
|
|
279
|
+
name: "imageUpload",
|
|
280
|
+
addOptions() {
|
|
281
|
+
return {
|
|
282
|
+
allowedMimeTypes: [
|
|
283
|
+
"image/jpeg",
|
|
284
|
+
"image/png",
|
|
285
|
+
"image/gif",
|
|
286
|
+
"image/webp",
|
|
287
|
+
"image/svg+xml"
|
|
288
|
+
],
|
|
289
|
+
onImageUpload: void 0
|
|
290
|
+
};
|
|
291
|
+
},
|
|
292
|
+
addStorage() {
|
|
293
|
+
return {
|
|
294
|
+
placeholderImages: /* @__PURE__ */ new Set()
|
|
295
|
+
};
|
|
296
|
+
},
|
|
297
|
+
addProseMirrorPlugins() {
|
|
298
|
+
const { onImageUpload } = this.options;
|
|
299
|
+
if (!onImageUpload) {
|
|
300
|
+
return [];
|
|
301
|
+
}
|
|
302
|
+
return [
|
|
303
|
+
ImageUploadPlugin({
|
|
304
|
+
editor: this.editor,
|
|
305
|
+
allowedMimeTypes: this.options.allowedMimeTypes,
|
|
306
|
+
onImageUpload: this.options.onImageUpload
|
|
307
|
+
})
|
|
308
|
+
];
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
function useImageUploadOptions(editor) {
|
|
312
|
+
return (0, import_react.useMemo)(() => {
|
|
313
|
+
const node = editor.extensionManager.extensions.find(
|
|
314
|
+
(extension) => extension.name === "imageUpload"
|
|
315
|
+
);
|
|
316
|
+
return (node == null ? void 0 : node.options) || {};
|
|
317
|
+
}, [editor]);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// src/editor/extensions/maily-kit.tsx
|
|
321
|
+
var import_core14 = require("@tiptap/core");
|
|
322
|
+
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
323
|
+
var import_extension_list_item = __toESM(require("@tiptap/extension-list-item"));
|
|
324
|
+
var import_extension_paragraph2 = __toESM(require("@tiptap/extension-paragraph"));
|
|
325
|
+
var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"));
|
|
326
|
+
var import_extension_text_style = __toESM(require("@tiptap/extension-text-style"));
|
|
327
|
+
var import_extension_heading2 = __toESM(require("@tiptap/extension-heading"));
|
|
328
|
+
var import_extension_underline = __toESM(require("@tiptap/extension-underline"));
|
|
329
|
+
var import_extension_document = __toESM(require("@tiptap/extension-document"));
|
|
330
|
+
var import_extension_focus = __toESM(require("@tiptap/extension-focus"));
|
|
331
|
+
var import_extension_dropcursor = __toESM(require("@tiptap/extension-dropcursor"));
|
|
332
|
+
|
|
333
|
+
// src/editor/nodes/footer.ts
|
|
334
|
+
var import_core3 = require("@tiptap/core");
|
|
335
|
+
var Footer = import_core3.Node.create({
|
|
174
336
|
name: "footer",
|
|
175
337
|
group: "block",
|
|
176
338
|
content: "inline*",
|
|
@@ -200,7 +362,7 @@ var Footer = import_core2.Node.create({
|
|
|
200
362
|
renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
|
|
201
363
|
return [
|
|
202
364
|
"small",
|
|
203
|
-
(0,
|
|
365
|
+
(0, import_core3.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes2, {
|
|
204
366
|
class: "footer mly-block mly-text-[13px] mly-text-slate-500 mly-relative"
|
|
205
367
|
}),
|
|
206
368
|
0
|
|
@@ -209,7 +371,7 @@ var Footer = import_core2.Node.create({
|
|
|
209
371
|
});
|
|
210
372
|
|
|
211
373
|
// src/editor/nodes/spacer.ts
|
|
212
|
-
var
|
|
374
|
+
var import_core5 = require("@tiptap/core");
|
|
213
375
|
|
|
214
376
|
// src/editor/utils/update-attribute.ts
|
|
215
377
|
function updateAttributes(type, attrs) {
|
|
@@ -246,7 +408,7 @@ function updateAttributes(type, attrs) {
|
|
|
246
408
|
}
|
|
247
409
|
|
|
248
410
|
// src/editor/nodes/section/section.ts
|
|
249
|
-
var
|
|
411
|
+
var import_core4 = require("@tiptap/core");
|
|
250
412
|
var DEFAULT_SECTION_BACKGROUND_COLOR = "#f7f7f7";
|
|
251
413
|
var DEFAULT_SECTION_ALIGN = "left";
|
|
252
414
|
var DEFAULT_SECTION_BORDER_WIDTH = 2;
|
|
@@ -261,7 +423,7 @@ var DEFAULT_SECTION_PADDING_RIGHT = 5;
|
|
|
261
423
|
var DEFAULT_SECTION_PADDING_BOTTOM = 5;
|
|
262
424
|
var DEFAULT_SECTION_PADDING_LEFT = 5;
|
|
263
425
|
var DEFAULT_SECTION_SHOW_IF_KEY = null;
|
|
264
|
-
var SectionExtension =
|
|
426
|
+
var SectionExtension = import_core4.Node.create({
|
|
265
427
|
name: "section",
|
|
266
428
|
group: "block",
|
|
267
429
|
content: "(block|columns)+",
|
|
@@ -524,7 +686,7 @@ var SectionExtension = import_core3.Node.create({
|
|
|
524
686
|
},
|
|
525
687
|
[
|
|
526
688
|
"td",
|
|
527
|
-
(0,
|
|
689
|
+
(0, import_core4.mergeAttributes)(HTMLAttributes2, {
|
|
528
690
|
"data-type": "section-cell",
|
|
529
691
|
style: "border-style: solid",
|
|
530
692
|
class: "mly-w-full [text-align:revert-layer]"
|
|
@@ -546,7 +708,7 @@ var SectionExtension = import_core3.Node.create({
|
|
|
546
708
|
|
|
547
709
|
// src/editor/nodes/spacer.ts
|
|
548
710
|
var DEFAULT_SPACER_HEIGHT = 8;
|
|
549
|
-
var Spacer =
|
|
711
|
+
var Spacer = import_core5.Node.create({
|
|
550
712
|
name: "spacer",
|
|
551
713
|
priority: 1e3,
|
|
552
714
|
group: "block",
|
|
@@ -603,7 +765,7 @@ var Spacer = import_core4.Node.create({
|
|
|
603
765
|
const { height } = node.attrs;
|
|
604
766
|
return [
|
|
605
767
|
"div",
|
|
606
|
-
(0,
|
|
768
|
+
(0, import_core5.mergeAttributes)(
|
|
607
769
|
{
|
|
608
770
|
"data-maily-component": this.name
|
|
609
771
|
},
|
|
@@ -623,11 +785,11 @@ var Spacer = import_core4.Node.create({
|
|
|
623
785
|
});
|
|
624
786
|
|
|
625
787
|
// src/editor/extensions/link-card.ts
|
|
626
|
-
var
|
|
627
|
-
var
|
|
788
|
+
var import_core6 = require("@tiptap/core");
|
|
789
|
+
var import_react3 = require("@tiptap/react");
|
|
628
790
|
|
|
629
791
|
// src/editor/nodes/link-card.tsx
|
|
630
|
-
var
|
|
792
|
+
var import_react2 = require("@tiptap/react");
|
|
631
793
|
|
|
632
794
|
// src/editor/components/input.tsx
|
|
633
795
|
var React = __toESM(require("react"));
|
|
@@ -721,7 +883,7 @@ function LinkCardComponent(props) {
|
|
|
721
883
|
const { title, description, link, linkTitle, image: image2, badgeText, subTitle } = props.node.attrs;
|
|
722
884
|
const { getPos, editor } = props;
|
|
723
885
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
724
|
-
|
|
886
|
+
import_react2.NodeViewWrapper,
|
|
725
887
|
{
|
|
726
888
|
className: `react-component ${props.selected && "ProseMirror-selectednode"}`,
|
|
727
889
|
draggable: editor.isEditable,
|
|
@@ -890,7 +1052,7 @@ function LinkCardComponent(props) {
|
|
|
890
1052
|
}
|
|
891
1053
|
|
|
892
1054
|
// src/editor/extensions/link-card.ts
|
|
893
|
-
var LinkCardExtension =
|
|
1055
|
+
var LinkCardExtension = import_core6.Node.create({
|
|
894
1056
|
name: "linkCard",
|
|
895
1057
|
group: "block",
|
|
896
1058
|
atom: true,
|
|
@@ -933,7 +1095,7 @@ var LinkCardExtension = import_core5.Node.create({
|
|
|
933
1095
|
renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
|
|
934
1096
|
return [
|
|
935
1097
|
"div",
|
|
936
|
-
(0,
|
|
1098
|
+
(0, import_core6.mergeAttributes)(
|
|
937
1099
|
{
|
|
938
1100
|
"data-maily-component": this.name
|
|
939
1101
|
},
|
|
@@ -954,7 +1116,7 @@ var LinkCardExtension = import_core5.Node.create({
|
|
|
954
1116
|
};
|
|
955
1117
|
},
|
|
956
1118
|
addNodeView() {
|
|
957
|
-
return (0,
|
|
1119
|
+
return (0, import_react3.ReactNodeViewRenderer)(LinkCardComponent, {
|
|
958
1120
|
className: "mly-relative"
|
|
959
1121
|
});
|
|
960
1122
|
}
|
|
@@ -962,16 +1124,16 @@ var LinkCardExtension = import_core5.Node.create({
|
|
|
962
1124
|
|
|
963
1125
|
// src/editor/utils/columns.ts
|
|
964
1126
|
var import_model = require("@tiptap/pm/model");
|
|
965
|
-
var
|
|
1127
|
+
var import_state2 = require("@tiptap/pm/state");
|
|
966
1128
|
var import_uuid2 = require("uuid");
|
|
967
|
-
var
|
|
1129
|
+
var import_core8 = require("@tiptap/core");
|
|
968
1130
|
|
|
969
1131
|
// src/editor/nodes/columns/column.ts
|
|
970
|
-
var
|
|
1132
|
+
var import_core7 = require("@tiptap/core");
|
|
971
1133
|
var import_uuid = require("uuid");
|
|
972
1134
|
var DEFAULT_COLUMN_WIDTH = "auto";
|
|
973
1135
|
var DEFAULT_COLUMN_VERTICAL_ALIGN = "top";
|
|
974
|
-
var ColumnExtension =
|
|
1136
|
+
var ColumnExtension = import_core7.Node.create({
|
|
975
1137
|
name: "column",
|
|
976
1138
|
content: "block+",
|
|
977
1139
|
isolating: true,
|
|
@@ -1035,7 +1197,7 @@ var ColumnExtension = import_core6.Node.create({
|
|
|
1035
1197
|
renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
|
|
1036
1198
|
return [
|
|
1037
1199
|
"div",
|
|
1038
|
-
(0,
|
|
1200
|
+
(0, import_core7.mergeAttributes)(HTMLAttributes2, {
|
|
1039
1201
|
"data-type": "column",
|
|
1040
1202
|
class: "hide-scrollbars"
|
|
1041
1203
|
}),
|
|
@@ -1054,7 +1216,7 @@ var ColumnExtension = import_core6.Node.create({
|
|
|
1054
1216
|
// src/editor/utils/columns.ts
|
|
1055
1217
|
function getClosestNodeByName(editor, name) {
|
|
1056
1218
|
const { state } = editor.view;
|
|
1057
|
-
return (0,
|
|
1219
|
+
return (0, import_core8.findParentNode)((node) => node.type.name === name)(state.selection);
|
|
1058
1220
|
}
|
|
1059
1221
|
function goToColumn(editor, type) {
|
|
1060
1222
|
const columnsNode = getClosestNodeByName(editor, "columns");
|
|
@@ -1082,18 +1244,18 @@ function goToColumn(editor, type) {
|
|
|
1082
1244
|
}
|
|
1083
1245
|
});
|
|
1084
1246
|
const tr = state.tr.setTime(Date.now());
|
|
1085
|
-
const textSelection =
|
|
1247
|
+
const textSelection = import_state2.TextSelection.near(tr.doc.resolve(nextColumnPos));
|
|
1086
1248
|
tr.setSelection(textSelection);
|
|
1087
1249
|
dispatch(tr);
|
|
1088
1250
|
return true;
|
|
1089
1251
|
}
|
|
1090
1252
|
|
|
1091
1253
|
// src/editor/nodes/columns/columns.ts
|
|
1092
|
-
var import_core8 = require("@tiptap/core");
|
|
1093
1254
|
var import_core9 = require("@tiptap/core");
|
|
1255
|
+
var import_core10 = require("@tiptap/core");
|
|
1094
1256
|
var import_uuid3 = require("uuid");
|
|
1095
1257
|
var DEFAULT_COLUMNS_GAP = 8;
|
|
1096
|
-
var ColumnsExtension =
|
|
1258
|
+
var ColumnsExtension = import_core10.Node.create({
|
|
1097
1259
|
name: "columns",
|
|
1098
1260
|
group: "columns",
|
|
1099
1261
|
content: "column+",
|
|
@@ -1169,7 +1331,7 @@ var ColumnsExtension = import_core9.Node.create({
|
|
|
1169
1331
|
renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
|
|
1170
1332
|
return [
|
|
1171
1333
|
"div",
|
|
1172
|
-
(0,
|
|
1334
|
+
(0, import_core9.mergeAttributes)(HTMLAttributes2, {
|
|
1173
1335
|
"data-type": "columns",
|
|
1174
1336
|
class: "mly-relative"
|
|
1175
1337
|
}),
|
|
@@ -1196,8 +1358,8 @@ var ColumnsExtension = import_core9.Node.create({
|
|
|
1196
1358
|
});
|
|
1197
1359
|
|
|
1198
1360
|
// src/editor/nodes/button/button.tsx
|
|
1199
|
-
var
|
|
1200
|
-
var
|
|
1361
|
+
var import_core12 = require("@tiptap/core");
|
|
1362
|
+
var import_react20 = require("@tiptap/react");
|
|
1201
1363
|
|
|
1202
1364
|
// src/editor/components/alignment-switch.tsx
|
|
1203
1365
|
var import_lucide_react = require("lucide-react");
|
|
@@ -1388,150 +1550,443 @@ function AlignmentSwitch(props) {
|
|
|
1388
1550
|
] });
|
|
1389
1551
|
}
|
|
1390
1552
|
|
|
1391
|
-
// src/editor/components/
|
|
1392
|
-
var
|
|
1393
|
-
var
|
|
1394
|
-
function ColorPicker(props) {
|
|
1395
|
-
const {
|
|
1396
|
-
color,
|
|
1397
|
-
onColorChange,
|
|
1398
|
-
borderColor,
|
|
1399
|
-
backgroundColor,
|
|
1400
|
-
tooltip,
|
|
1401
|
-
className,
|
|
1402
|
-
children,
|
|
1403
|
-
onClose,
|
|
1404
|
-
suggestedColors = []
|
|
1405
|
-
} = props;
|
|
1406
|
-
const handleColorChange = (color2) => {
|
|
1407
|
-
queueMicrotask(() => {
|
|
1408
|
-
onColorChange(color2);
|
|
1409
|
-
});
|
|
1410
|
-
};
|
|
1411
|
-
const popoverButton = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PopoverTrigger, { asChild: true, children: children || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1412
|
-
BaseButton,
|
|
1413
|
-
{
|
|
1414
|
-
variant: "ghost",
|
|
1415
|
-
className: "!mly-size-7 mly-shrink-0",
|
|
1416
|
-
size: "sm",
|
|
1417
|
-
type: "button",
|
|
1418
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1419
|
-
"div",
|
|
1420
|
-
{
|
|
1421
|
-
className: cn(
|
|
1422
|
-
"mly-h-4 mly-w-4 mly-shrink-0 mly-rounded mly-border-2 mly-border-gray-700",
|
|
1423
|
-
className
|
|
1424
|
-
),
|
|
1425
|
-
style: __spreadProps(__spreadValues({}, borderColor ? { borderColor } : {}), {
|
|
1426
|
-
backgroundColor: backgroundColor || "transparent"
|
|
1427
|
-
})
|
|
1428
|
-
}
|
|
1429
|
-
)
|
|
1430
|
-
}
|
|
1431
|
-
) });
|
|
1432
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1433
|
-
Popover,
|
|
1434
|
-
{
|
|
1435
|
-
onOpenChange: (open) => {
|
|
1436
|
-
if (!open) {
|
|
1437
|
-
onClose == null ? void 0 : onClose(color);
|
|
1438
|
-
}
|
|
1439
|
-
},
|
|
1440
|
-
children: [
|
|
1441
|
-
tooltip ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Tooltip, { children: [
|
|
1442
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipTrigger, { asChild: true, children: popoverButton }),
|
|
1443
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipContent, { sideOffset: 8, children: tooltip })
|
|
1444
|
-
] }) : popoverButton,
|
|
1445
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1446
|
-
PopoverContent,
|
|
1447
|
-
{
|
|
1448
|
-
className: "mly-w-full mly-rounded-none mly-border-0 !mly-bg-transparent !mly-p-0 mly-shadow-none mly-drop-shadow-md",
|
|
1449
|
-
sideOffset: 8,
|
|
1450
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mly-min-w-[260px] mly-rounded-xl mly-border mly-border-gray-200 mly-bg-white mly-p-4", children: [
|
|
1451
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1452
|
-
import_react_colorful.HexColorPicker,
|
|
1453
|
-
{
|
|
1454
|
-
color,
|
|
1455
|
-
onChange: handleColorChange,
|
|
1456
|
-
className: "mly-flex !mly-w-full mly-flex-col mly-gap-4"
|
|
1457
|
-
}
|
|
1458
|
-
),
|
|
1459
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1460
|
-
import_react_colorful.HexColorInput,
|
|
1461
|
-
{
|
|
1462
|
-
alpha: true,
|
|
1463
|
-
color,
|
|
1464
|
-
onChange: handleColorChange,
|
|
1465
|
-
className: "mly-mt-4 mly-w-full mly-min-w-0 mly-rounded-lg mly-border mly-border-gray-200 mly-px-2 mly-py-1.5 mly-text-sm mly-uppercase focus-visible:mly-border-gray-400 focus-visible:mly-outline-none",
|
|
1466
|
-
prefixed: true
|
|
1467
|
-
}
|
|
1468
|
-
),
|
|
1469
|
-
suggestedColors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
|
|
1470
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "-mly-mx-4 mly-my-4 mly-h-px mly-bg-gray-200" }),
|
|
1471
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { className: "mly-text-xs mly-text-gray-500", children: "Recently used" }),
|
|
1472
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mly-mt-2 mly-flex mly-flex-wrap mly-gap-0.5", children: suggestedColors.map((suggestedColor) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1473
|
-
BaseButton,
|
|
1474
|
-
{
|
|
1475
|
-
variant: "ghost",
|
|
1476
|
-
size: "sm",
|
|
1477
|
-
className: "!mly-size-7 mly-shrink-0",
|
|
1478
|
-
type: "button",
|
|
1479
|
-
onClick: () => handleColorChange(suggestedColor),
|
|
1480
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1481
|
-
"div",
|
|
1482
|
-
{
|
|
1483
|
-
className: "mly-h-4 mly-w-4 mly-shrink-0 mly-rounded",
|
|
1484
|
-
style: {
|
|
1485
|
-
backgroundColor: suggestedColor
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
)
|
|
1489
|
-
},
|
|
1490
|
-
suggestedColor
|
|
1491
|
-
)) })
|
|
1492
|
-
] })
|
|
1493
|
-
] })
|
|
1494
|
-
}
|
|
1495
|
-
)
|
|
1496
|
-
]
|
|
1497
|
-
}
|
|
1498
|
-
);
|
|
1499
|
-
}
|
|
1553
|
+
// src/editor/components/show-popover.tsx
|
|
1554
|
+
var import_lucide_react3 = require("lucide-react");
|
|
1555
|
+
var import_react8 = require("react");
|
|
1500
1556
|
|
|
1501
|
-
// src/editor/
|
|
1502
|
-
var
|
|
1503
|
-
function
|
|
1504
|
-
const
|
|
1505
|
-
|
|
1506
|
-
"div",
|
|
1507
|
-
{
|
|
1508
|
-
className: cn(
|
|
1509
|
-
"mly-shrink-0 mly-bg-gray-200",
|
|
1510
|
-
type === "vertical" ? "mly-mx-0.5 mly-w-px" : "mly-my-0.5 mly-h-px",
|
|
1511
|
-
className
|
|
1512
|
-
)
|
|
1513
|
-
}
|
|
1557
|
+
// src/editor/utils/node-options.ts
|
|
1558
|
+
var import_react4 = require("react");
|
|
1559
|
+
function getNodeOptions(editor, name) {
|
|
1560
|
+
const node = editor.extensionManager.extensions.find(
|
|
1561
|
+
(extension) => extension.name === name
|
|
1514
1562
|
);
|
|
1563
|
+
if (!node) {
|
|
1564
|
+
throw new Error(`Node ${name} not found`);
|
|
1565
|
+
}
|
|
1566
|
+
return node.options;
|
|
1567
|
+
}
|
|
1568
|
+
function getVariableOptions(editor) {
|
|
1569
|
+
return getNodeOptions(editor, "variable");
|
|
1570
|
+
}
|
|
1571
|
+
function useVariableOptions(editor) {
|
|
1572
|
+
return (0, import_react4.useMemo)(() => {
|
|
1573
|
+
return getVariableOptions(editor);
|
|
1574
|
+
}, [editor]);
|
|
1515
1575
|
}
|
|
1516
1576
|
|
|
1517
|
-
// src/editor/
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1577
|
+
// src/editor/utils/variable.ts
|
|
1578
|
+
function processVariables(variables, options) {
|
|
1579
|
+
const { query } = options;
|
|
1580
|
+
const queryLower = query.toLowerCase();
|
|
1581
|
+
let filteredVariables = [];
|
|
1582
|
+
if (Array.isArray(variables)) {
|
|
1583
|
+
filteredVariables = variables.filter(
|
|
1584
|
+
(variable) => variable.name.toLowerCase().startsWith(queryLower)
|
|
1585
|
+
);
|
|
1586
|
+
if (query.length > 0 && !filteredVariables.some((variable) => variable.name === query)) {
|
|
1587
|
+
filteredVariables.push({ name: query, required: true });
|
|
1588
|
+
}
|
|
1589
|
+
return filteredVariables;
|
|
1590
|
+
} else if (typeof variables === "function") {
|
|
1591
|
+
return variables(options);
|
|
1592
|
+
} else {
|
|
1593
|
+
throw new Error(`Invalid variables type. Expected 'Array' or 'Function', but received '${typeof variables}'.
|
|
1523
1594
|
|
|
1524
|
-
|
|
1525
|
-
|
|
1595
|
+
You can check out the documentation for more information: https://github.com/arikchakma/maily.to/blob/main/packages/core/readme.md`);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1526
1598
|
|
|
1527
|
-
// src/
|
|
1528
|
-
var
|
|
1529
|
-
var
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1599
|
+
// src/editor/utils/use-outside-click.ts
|
|
1600
|
+
var import_react5 = require("react");
|
|
1601
|
+
var import_react6 = require("react");
|
|
1602
|
+
function useOutsideClick(ref, callback) {
|
|
1603
|
+
const handleClick = (0, import_react5.useCallback)(
|
|
1604
|
+
(e) => {
|
|
1605
|
+
if (ref.current && !ref.current.contains(e.target)) {
|
|
1606
|
+
callback();
|
|
1607
|
+
}
|
|
1608
|
+
},
|
|
1609
|
+
[ref, callback]
|
|
1610
|
+
);
|
|
1611
|
+
(0, import_react6.useEffect)(() => {
|
|
1612
|
+
document.addEventListener("mousedown", handleClick);
|
|
1613
|
+
document.addEventListener("touchstart", handleClick);
|
|
1614
|
+
return () => {
|
|
1615
|
+
document.removeEventListener("mousedown", handleClick);
|
|
1616
|
+
document.removeEventListener("touchstart", handleClick);
|
|
1617
|
+
};
|
|
1618
|
+
}, [handleClick]);
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
// src/editor/components/ui/input-autocomplete.tsx
|
|
1622
|
+
var import_lucide_react2 = require("lucide-react");
|
|
1623
|
+
var import_react7 = require("react");
|
|
1624
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1625
|
+
var InputAutocomplete = (0, import_react7.forwardRef)((props, ref) => {
|
|
1626
|
+
var _b;
|
|
1627
|
+
const _a = props, {
|
|
1628
|
+
value = "",
|
|
1629
|
+
onValueChange,
|
|
1630
|
+
className,
|
|
1631
|
+
onOutsideClick,
|
|
1632
|
+
onSelectOption,
|
|
1633
|
+
autoCompleteOptions = [],
|
|
1634
|
+
triggerChar = "",
|
|
1635
|
+
editor
|
|
1636
|
+
} = _a, inputProps = __objRest(_a, [
|
|
1637
|
+
"value",
|
|
1638
|
+
"onValueChange",
|
|
1639
|
+
"className",
|
|
1640
|
+
"onOutsideClick",
|
|
1641
|
+
"onSelectOption",
|
|
1642
|
+
"autoCompleteOptions",
|
|
1643
|
+
"triggerChar",
|
|
1644
|
+
"editor"
|
|
1645
|
+
]);
|
|
1646
|
+
const containerRef = (0, import_react7.useRef)(null);
|
|
1647
|
+
const popoverRef = (0, import_react7.useRef)(null);
|
|
1648
|
+
const VariableSuggestionPopoverComponent = (_b = useVariableOptions(editor)) == null ? void 0 : _b.variableSuggestionsPopover;
|
|
1649
|
+
useOutsideClick(containerRef, () => {
|
|
1650
|
+
onOutsideClick == null ? void 0 : onOutsideClick();
|
|
1651
|
+
});
|
|
1652
|
+
const isTriggeringVariable = value.startsWith(triggerChar);
|
|
1653
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: cn("mly-relative"), ref: containerRef, children: [
|
|
1654
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "mly-relative", children: [
|
|
1655
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1656
|
+
"input",
|
|
1657
|
+
__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, AUTOCOMPLETE_PASSWORD_MANAGERS_OFF), {
|
|
1658
|
+
placeholder: "e.g. items",
|
|
1659
|
+
type: "text"
|
|
1660
|
+
}), inputProps), {
|
|
1661
|
+
ref,
|
|
1662
|
+
value,
|
|
1663
|
+
onChange: (e) => {
|
|
1664
|
+
onValueChange(e.target.value);
|
|
1665
|
+
},
|
|
1666
|
+
className: cn(
|
|
1667
|
+
"mly-h-7 mly-w-40 mly-rounded-md mly-bg-white 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",
|
|
1668
|
+
className
|
|
1669
|
+
),
|
|
1670
|
+
onKeyDown: (e) => {
|
|
1671
|
+
if (!popoverRef.current || !isTriggeringVariable) {
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
const { moveUp, moveDown, select } = popoverRef.current;
|
|
1675
|
+
if (e.key === "ArrowDown") {
|
|
1676
|
+
e.preventDefault();
|
|
1677
|
+
moveDown();
|
|
1678
|
+
} else if (e.key === "ArrowUp") {
|
|
1679
|
+
e.preventDefault();
|
|
1680
|
+
moveUp();
|
|
1681
|
+
} else if (e.key === "Enter") {
|
|
1682
|
+
e.preventDefault();
|
|
1683
|
+
select();
|
|
1684
|
+
}
|
|
1685
|
+
},
|
|
1686
|
+
spellCheck: false
|
|
1687
|
+
})
|
|
1688
|
+
),
|
|
1689
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mly-absolute mly-inset-y-0 mly-right-1 mly-flex mly-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react2.CornerDownLeft, { className: "mly-h-3 mly-w-3 mly-stroke-[2.5] mly-text-midnight-gray" }) })
|
|
1690
|
+
] }),
|
|
1691
|
+
isTriggeringVariable && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mly-absolute mly-left-0 mly-top-8", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1692
|
+
VariableSuggestionPopoverComponent,
|
|
1693
|
+
{
|
|
1694
|
+
items: autoCompleteOptions.map((option) => {
|
|
1695
|
+
return {
|
|
1696
|
+
name: option
|
|
1697
|
+
};
|
|
1698
|
+
}),
|
|
1699
|
+
onSelectItem: (item) => {
|
|
1700
|
+
onSelectOption == null ? void 0 : onSelectOption(item.name);
|
|
1701
|
+
},
|
|
1702
|
+
ref: popoverRef
|
|
1703
|
+
}
|
|
1704
|
+
) })
|
|
1705
|
+
] });
|
|
1706
|
+
});
|
|
1707
|
+
InputAutocomplete.displayName = "InputAutocomplete";
|
|
1708
|
+
|
|
1709
|
+
// src/editor/components/show-popover.tsx
|
|
1710
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1711
|
+
function _ShowPopover(props) {
|
|
1712
|
+
const { showIfKey = "", onShowIfKeyValueChange, editor } = props;
|
|
1713
|
+
const opts = useVariableOptions(editor);
|
|
1714
|
+
const variables = opts == null ? void 0 : opts.variables;
|
|
1715
|
+
const renderVariable = opts == null ? void 0 : opts.renderVariable;
|
|
1716
|
+
const [isUpdatingKey, setIsUpdatingKey] = (0, import_react8.useState)(false);
|
|
1717
|
+
const inputRef = (0, import_react8.useRef)(null);
|
|
1718
|
+
const autoCompleteOptions = (0, import_react8.useMemo)(() => {
|
|
1719
|
+
return processVariables(variables, {
|
|
1720
|
+
query: showIfKey || "",
|
|
1721
|
+
from: "bubble-variable",
|
|
1722
|
+
editor
|
|
1723
|
+
}).map((variable) => variable.name);
|
|
1724
|
+
}, [variables, showIfKey, editor]);
|
|
1725
|
+
const isValidWhenKey = showIfKey || autoCompleteOptions.includes(showIfKey);
|
|
1726
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1727
|
+
Popover,
|
|
1728
|
+
{
|
|
1729
|
+
onOpenChange: (open) => {
|
|
1730
|
+
if (open) {
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
setIsUpdatingKey(false);
|
|
1734
|
+
},
|
|
1735
|
+
children: [
|
|
1736
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Tooltip, { children: [
|
|
1737
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1738
|
+
PopoverTrigger,
|
|
1739
|
+
{
|
|
1740
|
+
className: cn(
|
|
1741
|
+
"mly-flex mly-size-7 mly-items-center mly-justify-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",
|
|
1742
|
+
showIfKey && "mly-bg-rose-100 mly-text-rose-800 data-[state=open]:mly-bg-rose-100 hover:mly-bg-rose-100"
|
|
1743
|
+
),
|
|
1744
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react3.Eye, { className: "mly-h-3 mly-w-3 mly-stroke-[2.5]" })
|
|
1745
|
+
}
|
|
1746
|
+
) }),
|
|
1747
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipContent, { sideOffset: 8, children: "Show block conditionally" })
|
|
1748
|
+
] }),
|
|
1749
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1750
|
+
PopoverContent,
|
|
1751
|
+
{
|
|
1752
|
+
className: "mly-flex mly-w-max mly-rounded-lg !mly-p-0.5",
|
|
1753
|
+
side: "top",
|
|
1754
|
+
sideOffset: 8,
|
|
1755
|
+
align: "end",
|
|
1756
|
+
onOpenAutoFocus: (e) => {
|
|
1757
|
+
e.preventDefault();
|
|
1758
|
+
},
|
|
1759
|
+
onCloseAutoFocus: (e) => {
|
|
1760
|
+
e.preventDefault();
|
|
1761
|
+
},
|
|
1762
|
+
children: [
|
|
1763
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "mly-flex mly-items-center mly-gap-1.5 mly-px-1.5 mly-text-sm mly-leading-none", children: [
|
|
1764
|
+
"Show if",
|
|
1765
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Tooltip, { children: [
|
|
1766
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1767
|
+
import_lucide_react3.InfoIcon,
|
|
1768
|
+
{
|
|
1769
|
+
className: cn("mly-size-3 mly-stroke-[2.5] mly-text-gray-500")
|
|
1770
|
+
}
|
|
1771
|
+
) }),
|
|
1772
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1773
|
+
TooltipContent,
|
|
1774
|
+
{
|
|
1775
|
+
sideOffset: 14,
|
|
1776
|
+
className: "mly-max-w-[285px]",
|
|
1777
|
+
align: "start",
|
|
1778
|
+
children: "Show the block if the selected variable is true."
|
|
1779
|
+
}
|
|
1780
|
+
)
|
|
1781
|
+
] })
|
|
1782
|
+
] }),
|
|
1783
|
+
!isUpdatingKey && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1784
|
+
"button",
|
|
1785
|
+
{
|
|
1786
|
+
onClick: () => {
|
|
1787
|
+
setIsUpdatingKey(true);
|
|
1788
|
+
setTimeout(() => {
|
|
1789
|
+
var _a;
|
|
1790
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
1791
|
+
}, 0);
|
|
1792
|
+
},
|
|
1793
|
+
children: renderVariable({
|
|
1794
|
+
variable: {
|
|
1795
|
+
name: showIfKey,
|
|
1796
|
+
valid: !!isValidWhenKey
|
|
1797
|
+
},
|
|
1798
|
+
fallback: "",
|
|
1799
|
+
from: "bubble-variable",
|
|
1800
|
+
editor
|
|
1801
|
+
})
|
|
1802
|
+
}
|
|
1803
|
+
),
|
|
1804
|
+
isUpdatingKey && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1805
|
+
"form",
|
|
1806
|
+
{
|
|
1807
|
+
onSubmit: (e) => {
|
|
1808
|
+
e.preventDefault();
|
|
1809
|
+
setIsUpdatingKey(false);
|
|
1810
|
+
},
|
|
1811
|
+
onKeyDown: (e) => {
|
|
1812
|
+
if (e.key === "Escape") {
|
|
1813
|
+
setIsUpdatingKey(false);
|
|
1814
|
+
}
|
|
1815
|
+
},
|
|
1816
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1817
|
+
InputAutocomplete,
|
|
1818
|
+
{
|
|
1819
|
+
editor,
|
|
1820
|
+
value: showIfKey || "",
|
|
1821
|
+
onValueChange: (value) => {
|
|
1822
|
+
onShowIfKeyValueChange == null ? void 0 : onShowIfKeyValueChange(value);
|
|
1823
|
+
},
|
|
1824
|
+
onOutsideClick: () => {
|
|
1825
|
+
setIsUpdatingKey(false);
|
|
1826
|
+
},
|
|
1827
|
+
onSelectOption: (value) => {
|
|
1828
|
+
onShowIfKeyValueChange == null ? void 0 : onShowIfKeyValueChange(value);
|
|
1829
|
+
setIsUpdatingKey(false);
|
|
1830
|
+
},
|
|
1831
|
+
autoCompleteOptions,
|
|
1832
|
+
ref: inputRef
|
|
1833
|
+
}
|
|
1834
|
+
)
|
|
1835
|
+
}
|
|
1836
|
+
)
|
|
1837
|
+
]
|
|
1838
|
+
}
|
|
1839
|
+
)
|
|
1840
|
+
]
|
|
1841
|
+
}
|
|
1842
|
+
);
|
|
1843
|
+
}
|
|
1844
|
+
var ShowPopover = (0, import_react8.memo)(_ShowPopover);
|
|
1845
|
+
|
|
1846
|
+
// src/editor/components/ui/color-picker.tsx
|
|
1847
|
+
var import_react_colorful = require("react-colorful");
|
|
1848
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1849
|
+
function ColorPicker(props) {
|
|
1850
|
+
const {
|
|
1851
|
+
color,
|
|
1852
|
+
onColorChange,
|
|
1853
|
+
borderColor,
|
|
1854
|
+
backgroundColor,
|
|
1855
|
+
tooltip,
|
|
1856
|
+
className,
|
|
1857
|
+
children,
|
|
1858
|
+
onClose,
|
|
1859
|
+
suggestedColors = []
|
|
1860
|
+
} = props;
|
|
1861
|
+
const handleColorChange = (color2) => {
|
|
1862
|
+
queueMicrotask(() => {
|
|
1863
|
+
onColorChange(color2);
|
|
1864
|
+
});
|
|
1865
|
+
};
|
|
1866
|
+
const popoverButton = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PopoverTrigger, { asChild: true, children: children || /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1867
|
+
BaseButton,
|
|
1868
|
+
{
|
|
1869
|
+
variant: "ghost",
|
|
1870
|
+
className: "!mly-size-7 mly-shrink-0",
|
|
1871
|
+
size: "sm",
|
|
1872
|
+
type: "button",
|
|
1873
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1874
|
+
"div",
|
|
1875
|
+
{
|
|
1876
|
+
className: cn(
|
|
1877
|
+
"mly-h-4 mly-w-4 mly-shrink-0 mly-rounded mly-border-2 mly-border-gray-700",
|
|
1878
|
+
className
|
|
1879
|
+
),
|
|
1880
|
+
style: __spreadProps(__spreadValues({}, borderColor ? { borderColor } : {}), {
|
|
1881
|
+
backgroundColor: backgroundColor || "transparent"
|
|
1882
|
+
})
|
|
1883
|
+
}
|
|
1884
|
+
)
|
|
1885
|
+
}
|
|
1886
|
+
) });
|
|
1887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1888
|
+
Popover,
|
|
1889
|
+
{
|
|
1890
|
+
onOpenChange: (open) => {
|
|
1891
|
+
if (!open) {
|
|
1892
|
+
onClose == null ? void 0 : onClose(color);
|
|
1893
|
+
}
|
|
1894
|
+
},
|
|
1895
|
+
children: [
|
|
1896
|
+
tooltip ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Tooltip, { children: [
|
|
1897
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipTrigger, { asChild: true, children: popoverButton }),
|
|
1898
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TooltipContent, { sideOffset: 8, children: tooltip })
|
|
1899
|
+
] }) : popoverButton,
|
|
1900
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1901
|
+
PopoverContent,
|
|
1902
|
+
{
|
|
1903
|
+
className: "mly-w-full mly-rounded-none mly-border-0 !mly-bg-transparent !mly-p-0 mly-shadow-none mly-drop-shadow-md",
|
|
1904
|
+
sideOffset: 8,
|
|
1905
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "mly-min-w-[260px] mly-rounded-xl mly-border mly-border-gray-200 mly-bg-white mly-p-4", children: [
|
|
1906
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1907
|
+
import_react_colorful.HexColorPicker,
|
|
1908
|
+
{
|
|
1909
|
+
color,
|
|
1910
|
+
onChange: handleColorChange,
|
|
1911
|
+
className: "mly-flex !mly-w-full mly-flex-col mly-gap-4"
|
|
1912
|
+
}
|
|
1913
|
+
),
|
|
1914
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1915
|
+
import_react_colorful.HexColorInput,
|
|
1916
|
+
{
|
|
1917
|
+
alpha: true,
|
|
1918
|
+
color,
|
|
1919
|
+
onChange: handleColorChange,
|
|
1920
|
+
className: "mly-mt-4 mly-w-full mly-min-w-0 mly-rounded-lg mly-border mly-border-gray-200 mly-px-2 mly-py-1.5 mly-text-sm mly-uppercase focus-visible:mly-border-gray-400 focus-visible:mly-outline-none",
|
|
1921
|
+
prefixed: true
|
|
1922
|
+
}
|
|
1923
|
+
),
|
|
1924
|
+
suggestedColors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { children: [
|
|
1925
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "-mly-mx-4 mly-my-4 mly-h-px mly-bg-gray-200" }),
|
|
1926
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { className: "mly-text-xs mly-text-gray-500", children: "Recently used" }),
|
|
1927
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "mly-mt-2 mly-flex mly-flex-wrap mly-gap-0.5", children: suggestedColors.map((suggestedColor) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1928
|
+
BaseButton,
|
|
1929
|
+
{
|
|
1930
|
+
variant: "ghost",
|
|
1931
|
+
size: "sm",
|
|
1932
|
+
className: "!mly-size-7 mly-shrink-0",
|
|
1933
|
+
type: "button",
|
|
1934
|
+
onClick: () => handleColorChange(suggestedColor),
|
|
1935
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1936
|
+
"div",
|
|
1937
|
+
{
|
|
1938
|
+
className: "mly-h-4 mly-w-4 mly-shrink-0 mly-rounded",
|
|
1939
|
+
style: {
|
|
1940
|
+
backgroundColor: suggestedColor
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
)
|
|
1944
|
+
},
|
|
1945
|
+
suggestedColor
|
|
1946
|
+
)) })
|
|
1947
|
+
] })
|
|
1948
|
+
] })
|
|
1949
|
+
}
|
|
1950
|
+
)
|
|
1951
|
+
]
|
|
1952
|
+
}
|
|
1953
|
+
);
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
// src/editor/components/ui/divider.tsx
|
|
1957
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1958
|
+
function Divider(props) {
|
|
1959
|
+
const { type = "vertical", className } = props;
|
|
1960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1961
|
+
"div",
|
|
1962
|
+
{
|
|
1963
|
+
className: cn(
|
|
1964
|
+
"mly-shrink-0 mly-bg-gray-200",
|
|
1965
|
+
type === "vertical" ? "mly-mx-0.5 mly-w-px" : "mly-my-0.5 mly-h-px",
|
|
1966
|
+
className
|
|
1967
|
+
)
|
|
1968
|
+
}
|
|
1969
|
+
);
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
// src/editor/components/ui/link-input-popover.tsx
|
|
1973
|
+
var import_lucide_react14 = require("lucide-react");
|
|
1974
|
+
var import_react14 = require("react");
|
|
1975
|
+
|
|
1976
|
+
// src/editor/provider.tsx
|
|
1977
|
+
var import_react9 = require("react");
|
|
1978
|
+
|
|
1979
|
+
// src/editor/extensions/slash-command/default-slash-commands.tsx
|
|
1980
|
+
var import_lucide_react11 = require("lucide-react");
|
|
1981
|
+
|
|
1982
|
+
// src/blocks/button.tsx
|
|
1983
|
+
var import_lucide_react4 = require("lucide-react");
|
|
1984
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1985
|
+
var button = {
|
|
1986
|
+
title: "Button",
|
|
1987
|
+
description: "Add a call to action button to email.",
|
|
1533
1988
|
searchTerms: ["link", "button", "cta"],
|
|
1534
|
-
icon: /* @__PURE__ */ (0,
|
|
1989
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.MousePointer, { className: "mly-h-4 mly-w-4" }),
|
|
1535
1990
|
command: ({ editor, range }) => {
|
|
1536
1991
|
editor.chain().focus().deleteRange(range).setButton().run();
|
|
1537
1992
|
}
|
|
@@ -1540,7 +1995,7 @@ var linkCard = {
|
|
|
1540
1995
|
title: "Link Card",
|
|
1541
1996
|
description: "Add a link card to email.",
|
|
1542
1997
|
searchTerms: ["link", "button", "image"],
|
|
1543
|
-
icon: /* @__PURE__ */ (0,
|
|
1998
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.ArrowUpRightSquare, { className: "mly-h-4 mly-w-4" }),
|
|
1544
1999
|
command: ({ editor, range }) => {
|
|
1545
2000
|
editor.chain().focus().deleteRange(range).setLinkCard().run();
|
|
1546
2001
|
},
|
|
@@ -1552,27 +2007,27 @@ var linkCard = {
|
|
|
1552
2007
|
};
|
|
1553
2008
|
|
|
1554
2009
|
// src/blocks/code.tsx
|
|
1555
|
-
var
|
|
1556
|
-
var
|
|
2010
|
+
var import_lucide_react5 = require("lucide-react");
|
|
2011
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1557
2012
|
var htmlCodeBlock = {
|
|
1558
2013
|
title: "Custom HTML",
|
|
1559
2014
|
description: "Insert a custom HTML block",
|
|
1560
2015
|
searchTerms: ["html", "code", "custom"],
|
|
1561
|
-
icon: /* @__PURE__ */ (0,
|
|
2016
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react5.CodeXmlIcon, { className: "mly-h-4 mly-w-4" }),
|
|
1562
2017
|
command: ({ editor, range }) => {
|
|
1563
2018
|
editor.chain().focus().deleteRange(range).setHtmlCodeBlock({ language: "html" }).run();
|
|
1564
2019
|
}
|
|
1565
2020
|
};
|
|
1566
2021
|
|
|
1567
2022
|
// src/blocks/image.tsx
|
|
1568
|
-
var
|
|
1569
|
-
var
|
|
1570
|
-
var
|
|
2023
|
+
var import_state3 = require("@tiptap/pm/state");
|
|
2024
|
+
var import_lucide_react6 = require("lucide-react");
|
|
2025
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1571
2026
|
var image = {
|
|
1572
2027
|
title: "Image",
|
|
1573
2028
|
description: "Full width image",
|
|
1574
2029
|
searchTerms: ["image"],
|
|
1575
|
-
icon: /* @__PURE__ */ (0,
|
|
2030
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react6.ImageIcon, { className: "mly-h-4 mly-w-4" }),
|
|
1576
2031
|
command: ({ editor, range }) => {
|
|
1577
2032
|
editor.chain().focus().deleteRange(range).setImage({ src: "" }).run();
|
|
1578
2033
|
}
|
|
@@ -1581,7 +2036,7 @@ var logo = {
|
|
|
1581
2036
|
title: "Logo",
|
|
1582
2037
|
description: "Add your brand logo",
|
|
1583
2038
|
searchTerms: ["image", "logo"],
|
|
1584
|
-
icon: /* @__PURE__ */ (0,
|
|
2039
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react6.ImageIcon, { className: "mly-h-4 mly-w-4" }),
|
|
1585
2040
|
command: ({ editor, range }) => {
|
|
1586
2041
|
editor.chain().focus().deleteRange(range).setLogoImage({ src: "" }).run();
|
|
1587
2042
|
}
|
|
@@ -1590,7 +2045,7 @@ var inlineImage = {
|
|
|
1590
2045
|
title: "Inline Image",
|
|
1591
2046
|
description: "Inline image",
|
|
1592
2047
|
searchTerms: ["image", "inline"],
|
|
1593
|
-
icon: /* @__PURE__ */ (0,
|
|
2048
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react6.ImageIcon, { className: "mly-h-4 mly-w-4" }),
|
|
1594
2049
|
command: ({ editor, range }) => {
|
|
1595
2050
|
editor.chain().focus().deleteRange(range).setInlineImage({
|
|
1596
2051
|
src: ""
|
|
@@ -1601,7 +2056,7 @@ var inlineImage = {
|
|
|
1601
2056
|
if (!node) {
|
|
1602
2057
|
return false;
|
|
1603
2058
|
}
|
|
1604
|
-
const selection =
|
|
2059
|
+
const selection = import_state3.TextSelection.create(
|
|
1605
2060
|
tr.doc,
|
|
1606
2061
|
from,
|
|
1607
2062
|
from + node.nodeSize
|
|
@@ -1613,13 +2068,13 @@ var inlineImage = {
|
|
|
1613
2068
|
};
|
|
1614
2069
|
|
|
1615
2070
|
// src/blocks/layout.tsx
|
|
1616
|
-
var
|
|
1617
|
-
var
|
|
2071
|
+
var import_lucide_react7 = require("lucide-react");
|
|
2072
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1618
2073
|
var columns = {
|
|
1619
2074
|
title: "Columns",
|
|
1620
2075
|
description: "Add columns to email.",
|
|
1621
2076
|
searchTerms: ["layout", "columns"],
|
|
1622
|
-
icon: /* @__PURE__ */ (0,
|
|
2077
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.ColumnsIcon, { className: "mly-h-4 mly-w-4" }),
|
|
1623
2078
|
command: ({ editor, range }) => {
|
|
1624
2079
|
editor.chain().focus().deleteRange(range).setColumns().focus(editor.state.selection.head - 2).run();
|
|
1625
2080
|
}
|
|
@@ -1628,7 +2083,7 @@ var section = {
|
|
|
1628
2083
|
title: "Section",
|
|
1629
2084
|
description: "Add a section to email.",
|
|
1630
2085
|
searchTerms: ["layout", "section"],
|
|
1631
|
-
icon: /* @__PURE__ */ (0,
|
|
2086
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.RectangleHorizontal, { className: "mly-h-4 mly-w-4" }),
|
|
1632
2087
|
command: ({ editor, range }) => {
|
|
1633
2088
|
editor.chain().focus().deleteRange(range).setSection().run();
|
|
1634
2089
|
}
|
|
@@ -1637,7 +2092,7 @@ var repeat = {
|
|
|
1637
2092
|
title: "Repeat",
|
|
1638
2093
|
description: "Loop over an array of items.",
|
|
1639
2094
|
searchTerms: ["repeat", "for", "loop"],
|
|
1640
|
-
icon: /* @__PURE__ */ (0,
|
|
2095
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.Repeat2, { className: "mly-h-4 mly-w-4" }),
|
|
1641
2096
|
command: ({ editor, range }) => {
|
|
1642
2097
|
editor.chain().focus().deleteRange(range).setRepeat().run();
|
|
1643
2098
|
}
|
|
@@ -1646,7 +2101,7 @@ var spacer = {
|
|
|
1646
2101
|
title: "Spacer",
|
|
1647
2102
|
description: "Add space between blocks.",
|
|
1648
2103
|
searchTerms: ["space", "gap", "divider"],
|
|
1649
|
-
icon: /* @__PURE__ */ (0,
|
|
2104
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.MoveVertical, { className: "mly-h-4 mly-w-4" }),
|
|
1650
2105
|
command: ({ editor, range }) => {
|
|
1651
2106
|
editor.chain().focus().deleteRange(range).setSpacer({ height: "sm" }).run();
|
|
1652
2107
|
}
|
|
@@ -1655,20 +2110,20 @@ var divider = {
|
|
|
1655
2110
|
title: "Divider",
|
|
1656
2111
|
description: "Add a horizontal divider.",
|
|
1657
2112
|
searchTerms: ["divider", "line"],
|
|
1658
|
-
icon: /* @__PURE__ */ (0,
|
|
2113
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react7.Minus, { className: "mly-h-4 mly-w-4" }),
|
|
1659
2114
|
command: ({ editor, range }) => {
|
|
1660
2115
|
editor.chain().focus().deleteRange(range).setHorizontalRule().run();
|
|
1661
2116
|
}
|
|
1662
2117
|
};
|
|
1663
2118
|
|
|
1664
2119
|
// src/blocks/list.tsx
|
|
1665
|
-
var
|
|
1666
|
-
var
|
|
2120
|
+
var import_lucide_react8 = require("lucide-react");
|
|
2121
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1667
2122
|
var bulletList = {
|
|
1668
2123
|
title: "Bullet List",
|
|
1669
2124
|
description: "Create a simple bullet list.",
|
|
1670
2125
|
searchTerms: ["unordered", "point"],
|
|
1671
|
-
icon: /* @__PURE__ */ (0,
|
|
2126
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react8.List, { className: "mly-h-4 mly-w-4" }),
|
|
1672
2127
|
command: ({ editor, range }) => {
|
|
1673
2128
|
editor.chain().focus().deleteRange(range).toggleBulletList().run();
|
|
1674
2129
|
}
|
|
@@ -1677,20 +2132,20 @@ var orderedList = {
|
|
|
1677
2132
|
title: "Numbered List",
|
|
1678
2133
|
description: "Create a list with numbering.",
|
|
1679
2134
|
searchTerms: ["ordered"],
|
|
1680
|
-
icon: /* @__PURE__ */ (0,
|
|
2135
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react8.ListOrdered, { className: "mly-h-4 mly-w-4" }),
|
|
1681
2136
|
command: ({ editor, range }) => {
|
|
1682
2137
|
editor.chain().focus().deleteRange(range).toggleOrderedList().run();
|
|
1683
2138
|
}
|
|
1684
2139
|
};
|
|
1685
2140
|
|
|
1686
2141
|
// src/blocks/typography.tsx
|
|
1687
|
-
var
|
|
1688
|
-
var
|
|
2142
|
+
var import_lucide_react9 = require("lucide-react");
|
|
2143
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1689
2144
|
var text = {
|
|
1690
2145
|
title: "Text",
|
|
1691
2146
|
description: "Just start typing with plain text.",
|
|
1692
2147
|
searchTerms: ["p", "paragraph"],
|
|
1693
|
-
icon: /* @__PURE__ */ (0,
|
|
2148
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react9.Text, { className: "mly-h-4 mly-w-4" }),
|
|
1694
2149
|
command: ({ editor, range }) => {
|
|
1695
2150
|
editor.chain().focus().deleteRange(range).toggleNode("paragraph", "paragraph").run();
|
|
1696
2151
|
}
|
|
@@ -1699,7 +2154,7 @@ var heading1 = {
|
|
|
1699
2154
|
title: "Heading 1",
|
|
1700
2155
|
description: "Big heading.",
|
|
1701
2156
|
searchTerms: ["h1", "title", "big", "large"],
|
|
1702
|
-
icon: /* @__PURE__ */ (0,
|
|
2157
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react9.Heading1, { className: "mly-h-4 mly-w-4" }),
|
|
1703
2158
|
command: ({ editor, range }) => {
|
|
1704
2159
|
editor.chain().focus().deleteRange(range).setNode("heading", { level: 1 }).run();
|
|
1705
2160
|
}
|
|
@@ -1708,7 +2163,7 @@ var heading2 = {
|
|
|
1708
2163
|
title: "Heading 2",
|
|
1709
2164
|
description: "Medium heading.",
|
|
1710
2165
|
searchTerms: ["h2", "subtitle", "medium"],
|
|
1711
|
-
icon: /* @__PURE__ */ (0,
|
|
2166
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react9.Heading2, { className: "mly-h-4 mly-w-4" }),
|
|
1712
2167
|
command: ({ editor, range }) => {
|
|
1713
2168
|
editor.chain().focus().deleteRange(range).setNode("heading", { level: 2 }).run();
|
|
1714
2169
|
}
|
|
@@ -1717,7 +2172,7 @@ var heading3 = {
|
|
|
1717
2172
|
title: "Heading 3",
|
|
1718
2173
|
description: "Small heading.",
|
|
1719
2174
|
searchTerms: ["h3", "subtitle", "small"],
|
|
1720
|
-
icon: /* @__PURE__ */ (0,
|
|
2175
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react9.Heading3, { className: "mly-h-4 mly-w-4" }),
|
|
1721
2176
|
command: ({ editor, range }) => {
|
|
1722
2177
|
editor.chain().focus().deleteRange(range).setNode("heading", { level: 3 }).run();
|
|
1723
2178
|
}
|
|
@@ -1726,7 +2181,7 @@ var hardBreak = {
|
|
|
1726
2181
|
title: "Hard Break",
|
|
1727
2182
|
description: "Add a break between lines.",
|
|
1728
2183
|
searchTerms: ["break", "line"],
|
|
1729
|
-
icon: /* @__PURE__ */ (0,
|
|
2184
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react9.DivideIcon, { className: "mly-h-4 mly-w-4" }),
|
|
1730
2185
|
command: ({ editor, range }) => {
|
|
1731
2186
|
editor.chain().focus().deleteRange(range).setHardBreak().run();
|
|
1732
2187
|
}
|
|
@@ -1735,7 +2190,7 @@ var blockquote = {
|
|
|
1735
2190
|
title: "Blockquote",
|
|
1736
2191
|
description: "Add blockquote.",
|
|
1737
2192
|
searchTerms: ["quote", "blockquote"],
|
|
1738
|
-
icon: /* @__PURE__ */ (0,
|
|
2193
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react9.TextQuote, { className: "mly-h-4 mly-w-4" }),
|
|
1739
2194
|
command: ({ editor, range }) => {
|
|
1740
2195
|
editor.chain().focus().deleteRange(range).toggleBlockquote().run();
|
|
1741
2196
|
}
|
|
@@ -1744,7 +2199,7 @@ var footer = {
|
|
|
1744
2199
|
title: "Footer",
|
|
1745
2200
|
description: "Add a footer text to email.",
|
|
1746
2201
|
searchTerms: ["footer", "text"],
|
|
1747
|
-
icon: /* @__PURE__ */ (0,
|
|
2202
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react9.FootprintsIcon, { className: "mly-h-4 mly-w-4" }),
|
|
1748
2203
|
command: ({ editor, range }) => {
|
|
1749
2204
|
editor.chain().focus().deleteRange(range).setFooter().run();
|
|
1750
2205
|
}
|
|
@@ -1753,16 +2208,16 @@ var clearLine = {
|
|
|
1753
2208
|
title: "Clear Line",
|
|
1754
2209
|
description: "Clear the current line.",
|
|
1755
2210
|
searchTerms: ["clear", "line"],
|
|
1756
|
-
icon: /* @__PURE__ */ (0,
|
|
2211
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react9.EraserIcon, { className: "mly-h-4 mly-w-4" }),
|
|
1757
2212
|
command: ({ editor, range }) => {
|
|
1758
2213
|
editor.chain().focus().selectParentNode().deleteSelection().run();
|
|
1759
2214
|
}
|
|
1760
2215
|
};
|
|
1761
2216
|
|
|
1762
2217
|
// src/editor/components/icons/logo-with-cover-image.tsx
|
|
1763
|
-
var
|
|
2218
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1764
2219
|
function LogoWithCoverImageIcon(props) {
|
|
1765
|
-
return /* @__PURE__ */ (0,
|
|
2220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1766
2221
|
"svg",
|
|
1767
2222
|
__spreadProps(__spreadValues({
|
|
1768
2223
|
width: "14",
|
|
@@ -1772,7 +2227,7 @@ function LogoWithCoverImageIcon(props) {
|
|
|
1772
2227
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1773
2228
|
}, props), {
|
|
1774
2229
|
children: [
|
|
1775
|
-
/* @__PURE__ */ (0,
|
|
2230
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1776
2231
|
"path",
|
|
1777
2232
|
{
|
|
1778
2233
|
fillRule: "evenodd",
|
|
@@ -1781,7 +2236,7 @@ function LogoWithCoverImageIcon(props) {
|
|
|
1781
2236
|
fill: "currentColor"
|
|
1782
2237
|
}
|
|
1783
2238
|
),
|
|
1784
|
-
/* @__PURE__ */ (0,
|
|
2239
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1785
2240
|
"path",
|
|
1786
2241
|
{
|
|
1787
2242
|
fillRule: "evenodd",
|
|
@@ -1790,7 +2245,7 @@ function LogoWithCoverImageIcon(props) {
|
|
|
1790
2245
|
fill: "currentColor"
|
|
1791
2246
|
}
|
|
1792
2247
|
),
|
|
1793
|
-
/* @__PURE__ */ (0,
|
|
2248
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1794
2249
|
"path",
|
|
1795
2250
|
{
|
|
1796
2251
|
fillRule: "evenodd",
|
|
@@ -1799,8 +2254,8 @@ function LogoWithCoverImageIcon(props) {
|
|
|
1799
2254
|
fill: "currentColor"
|
|
1800
2255
|
}
|
|
1801
2256
|
),
|
|
1802
|
-
/* @__PURE__ */ (0,
|
|
1803
|
-
/* @__PURE__ */ (0,
|
|
2257
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("mask", { id: "path-4-inside-1_1046_19527", fill: "white", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("rect", { x: "3", y: "4", width: "8", height: "3", rx: "0.5" }) }),
|
|
2258
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1804
2259
|
"rect",
|
|
1805
2260
|
{
|
|
1806
2261
|
x: "3",
|
|
@@ -1813,7 +2268,7 @@ function LogoWithCoverImageIcon(props) {
|
|
|
1813
2268
|
mask: "url(#path-4-inside-1_1046_19527)"
|
|
1814
2269
|
}
|
|
1815
2270
|
),
|
|
1816
|
-
/* @__PURE__ */ (0,
|
|
2271
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1817
2272
|
"rect",
|
|
1818
2273
|
{
|
|
1819
2274
|
x: "6.25",
|
|
@@ -1825,16 +2280,16 @@ function LogoWithCoverImageIcon(props) {
|
|
|
1825
2280
|
strokeWidth: "0.5"
|
|
1826
2281
|
}
|
|
1827
2282
|
),
|
|
1828
|
-
/* @__PURE__ */ (0,
|
|
2283
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("rect", { x: "3", y: "8", width: "2", height: "1", rx: "0.5", fill: "currentColor" })
|
|
1829
2284
|
]
|
|
1830
2285
|
})
|
|
1831
2286
|
);
|
|
1832
2287
|
}
|
|
1833
2288
|
|
|
1834
2289
|
// src/editor/components/icons/logo-with-text-horizon.tsx
|
|
1835
|
-
var
|
|
2290
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1836
2291
|
function LogoWithTextHorizonIcon(props) {
|
|
1837
|
-
return /* @__PURE__ */ (0,
|
|
2292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1838
2293
|
"svg",
|
|
1839
2294
|
__spreadProps(__spreadValues({
|
|
1840
2295
|
width: "14",
|
|
@@ -1844,7 +2299,7 @@ function LogoWithTextHorizonIcon(props) {
|
|
|
1844
2299
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1845
2300
|
}, props), {
|
|
1846
2301
|
children: [
|
|
1847
|
-
/* @__PURE__ */ (0,
|
|
2302
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1848
2303
|
"path",
|
|
1849
2304
|
{
|
|
1850
2305
|
fillRule: "evenodd",
|
|
@@ -1853,7 +2308,7 @@ function LogoWithTextHorizonIcon(props) {
|
|
|
1853
2308
|
fill: "currentColor"
|
|
1854
2309
|
}
|
|
1855
2310
|
),
|
|
1856
|
-
/* @__PURE__ */ (0,
|
|
2311
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1857
2312
|
"rect",
|
|
1858
2313
|
{
|
|
1859
2314
|
x: "6.25",
|
|
@@ -1865,8 +2320,8 @@ function LogoWithTextHorizonIcon(props) {
|
|
|
1865
2320
|
strokeWidth: "0.5"
|
|
1866
2321
|
}
|
|
1867
2322
|
),
|
|
1868
|
-
/* @__PURE__ */ (0,
|
|
1869
|
-
/* @__PURE__ */ (0,
|
|
2323
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("rect", { x: "3", y: "6.5", width: "2", height: "1", rx: "0.5", fill: "currentColor" }),
|
|
2324
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1870
2325
|
"path",
|
|
1871
2326
|
{
|
|
1872
2327
|
fillRule: "evenodd",
|
|
@@ -1875,7 +2330,7 @@ function LogoWithTextHorizonIcon(props) {
|
|
|
1875
2330
|
fill: "currentColor"
|
|
1876
2331
|
}
|
|
1877
2332
|
),
|
|
1878
|
-
/* @__PURE__ */ (0,
|
|
2333
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1879
2334
|
"path",
|
|
1880
2335
|
{
|
|
1881
2336
|
fillRule: "evenodd",
|
|
@@ -1890,9 +2345,9 @@ function LogoWithTextHorizonIcon(props) {
|
|
|
1890
2345
|
}
|
|
1891
2346
|
|
|
1892
2347
|
// src/editor/components/icons/logo-with-text-vertical.tsx
|
|
1893
|
-
var
|
|
2348
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1894
2349
|
function LogoWithTextVerticalIcon(props) {
|
|
1895
|
-
return /* @__PURE__ */ (0,
|
|
2350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
1896
2351
|
"svg",
|
|
1897
2352
|
__spreadProps(__spreadValues({
|
|
1898
2353
|
width: "14",
|
|
@@ -1902,7 +2357,7 @@ function LogoWithTextVerticalIcon(props) {
|
|
|
1902
2357
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1903
2358
|
}, props), {
|
|
1904
2359
|
children: [
|
|
1905
|
-
/* @__PURE__ */ (0,
|
|
2360
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1906
2361
|
"path",
|
|
1907
2362
|
{
|
|
1908
2363
|
fillRule: "evenodd",
|
|
@@ -1911,7 +2366,7 @@ function LogoWithTextVerticalIcon(props) {
|
|
|
1911
2366
|
fill: "currentColor"
|
|
1912
2367
|
}
|
|
1913
2368
|
),
|
|
1914
|
-
/* @__PURE__ */ (0,
|
|
2369
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1915
2370
|
"rect",
|
|
1916
2371
|
{
|
|
1917
2372
|
x: "4.25",
|
|
@@ -1923,8 +2378,8 @@ function LogoWithTextVerticalIcon(props) {
|
|
|
1923
2378
|
strokeWidth: "0.5"
|
|
1924
2379
|
}
|
|
1925
2380
|
),
|
|
1926
|
-
/* @__PURE__ */ (0,
|
|
1927
|
-
/* @__PURE__ */ (0,
|
|
2381
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("rect", { x: "6", y: "6", width: "2", height: "1", rx: "0.5", fill: "currentColor" }),
|
|
2382
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1928
2383
|
"path",
|
|
1929
2384
|
{
|
|
1930
2385
|
fillRule: "evenodd",
|
|
@@ -1933,7 +2388,7 @@ function LogoWithTextVerticalIcon(props) {
|
|
|
1933
2388
|
fill: "currentColor"
|
|
1934
2389
|
}
|
|
1935
2390
|
),
|
|
1936
|
-
/* @__PURE__ */ (0,
|
|
2391
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1937
2392
|
"path",
|
|
1938
2393
|
{
|
|
1939
2394
|
fillRule: "evenodd",
|
|
@@ -1948,12 +2403,12 @@ function LogoWithTextVerticalIcon(props) {
|
|
|
1948
2403
|
}
|
|
1949
2404
|
|
|
1950
2405
|
// src/blocks/headers.tsx
|
|
1951
|
-
var
|
|
2406
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1952
2407
|
var headerLogoWithTextHorizontal = {
|
|
1953
2408
|
title: "Logo with Text (Horizontal)",
|
|
1954
2409
|
description: "Logo and a text horizontally",
|
|
1955
2410
|
searchTerms: ["logo", "text"],
|
|
1956
|
-
icon: /* @__PURE__ */ (0,
|
|
2411
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(LogoWithTextHorizonIcon, { className: "mly-h-4 mly-w-4" }),
|
|
1957
2412
|
command: ({ editor, range }) => {
|
|
1958
2413
|
editor.chain().deleteRange(range).insertContent({
|
|
1959
2414
|
type: "columns",
|
|
@@ -2017,7 +2472,7 @@ var headerLogoWithTextVertical = {
|
|
|
2017
2472
|
title: "Logo with Text (Vertical)",
|
|
2018
2473
|
description: "Logo and a text vertically",
|
|
2019
2474
|
searchTerms: ["logo", "text"],
|
|
2020
|
-
icon: /* @__PURE__ */ (0,
|
|
2475
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(LogoWithTextVerticalIcon, { className: "mly-h-4 mly-w-4" }),
|
|
2021
2476
|
command: ({ editor, range }) => {
|
|
2022
2477
|
editor.chain().deleteRange(range).insertContent([
|
|
2023
2478
|
{
|
|
@@ -2048,7 +2503,7 @@ var headerLogoWithCoverImage = {
|
|
|
2048
2503
|
title: "Logo with Cover Image",
|
|
2049
2504
|
description: "Logo and a cover image",
|
|
2050
2505
|
searchTerms: ["logo", "cover", "image"],
|
|
2051
|
-
icon: /* @__PURE__ */ (0,
|
|
2506
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(LogoWithCoverImageIcon, { className: "mly-h-4 mly-w-4" }),
|
|
2052
2507
|
command: ({ editor, range }) => {
|
|
2053
2508
|
const todayFormatted = (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
|
|
2054
2509
|
year: "numeric",
|
|
@@ -2136,13 +2591,13 @@ var headerLogoWithCoverImage = {
|
|
|
2136
2591
|
};
|
|
2137
2592
|
|
|
2138
2593
|
// src/blocks/footers.tsx
|
|
2139
|
-
var
|
|
2140
|
-
var
|
|
2594
|
+
var import_lucide_react10 = require("lucide-react");
|
|
2595
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2141
2596
|
var footerCopyrightText = {
|
|
2142
2597
|
title: "Footer Copyright",
|
|
2143
2598
|
description: "Copyright text for the footer.",
|
|
2144
2599
|
searchTerms: ["footer", "copyright"],
|
|
2145
|
-
icon: /* @__PURE__ */ (0,
|
|
2600
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react10.CopyrightIcon, { className: "mly-h-4 mly-w-4" }),
|
|
2146
2601
|
command: ({ editor, range }) => {
|
|
2147
2602
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
2148
2603
|
editor.chain().focus().deleteRange(range).insertContent({
|
|
@@ -2162,7 +2617,7 @@ var footerCommunityFeedbackCta = {
|
|
|
2162
2617
|
title: "Footer Community Feedback CTA",
|
|
2163
2618
|
description: "Community feedback CTA for the footer.",
|
|
2164
2619
|
searchTerms: ["footer", "community", "feedback", "cta"],
|
|
2165
|
-
icon: /* @__PURE__ */ (0,
|
|
2620
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react10.RectangleHorizontalIcon, { className: "mly-h-4 mly-w-4" }),
|
|
2166
2621
|
command: ({ editor, range }) => {
|
|
2167
2622
|
editor.chain().focus().deleteRange(range).insertContent([
|
|
2168
2623
|
{
|
|
@@ -2205,7 +2660,7 @@ var footerCompanySignature = {
|
|
|
2205
2660
|
title: "Footer Company Signature",
|
|
2206
2661
|
description: "Company signature for the footer.",
|
|
2207
2662
|
searchTerms: ["footer", "company", "signature"],
|
|
2208
|
-
icon: /* @__PURE__ */ (0,
|
|
2663
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react10.LayoutTemplateIcon, { className: "mly-h-4 mly-w-4" }),
|
|
2209
2664
|
command: ({ editor, range }) => {
|
|
2210
2665
|
editor.chain().focus().deleteRange(range).insertContent([
|
|
2211
2666
|
{ type: "horizontalRule" },
|
|
@@ -2359,7 +2814,7 @@ var footerCompanySignature = {
|
|
|
2359
2814
|
};
|
|
2360
2815
|
|
|
2361
2816
|
// src/editor/extensions/slash-command/default-slash-commands.tsx
|
|
2362
|
-
var
|
|
2817
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2363
2818
|
var DEFAULT_SLASH_COMMANDS = [
|
|
2364
2819
|
{
|
|
2365
2820
|
title: "Blocks",
|
|
@@ -2394,7 +2849,7 @@ var DEFAULT_SLASH_COMMANDS = [
|
|
|
2394
2849
|
title: "Headers",
|
|
2395
2850
|
description: "Add pre-designed headers block",
|
|
2396
2851
|
searchTerms: ["header", "headers"],
|
|
2397
|
-
icon: /* @__PURE__ */ (0,
|
|
2852
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.Heading1, { className: "mly-h-4 mly-w-4" }),
|
|
2398
2853
|
preview: "https://cdn.usemaily.com/previews/header-preview-xyz.png",
|
|
2399
2854
|
commands: [
|
|
2400
2855
|
headerLogoWithTextVertical,
|
|
@@ -2407,7 +2862,7 @@ var DEFAULT_SLASH_COMMANDS = [
|
|
|
2407
2862
|
title: "Footers",
|
|
2408
2863
|
description: "Add pre-designed footers block",
|
|
2409
2864
|
searchTerms: ["footers"],
|
|
2410
|
-
icon: /* @__PURE__ */ (0,
|
|
2865
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react11.FootprintsIcon, { className: "mly-h-4 mly-w-4" }),
|
|
2411
2866
|
commands: [
|
|
2412
2867
|
footerCopyrightText,
|
|
2413
2868
|
footerCommunityFeedbackCta,
|
|
@@ -2419,33 +2874,163 @@ var DEFAULT_SLASH_COMMANDS = [
|
|
|
2419
2874
|
}
|
|
2420
2875
|
];
|
|
2421
2876
|
|
|
2877
|
+
// src/editor/provider.tsx
|
|
2878
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2879
|
+
var DEFAULT_PLACEHOLDER_URL = "maily.to/";
|
|
2880
|
+
var MailyContext = (0, import_react9.createContext)({
|
|
2881
|
+
placeholderUrl: DEFAULT_PLACEHOLDER_URL,
|
|
2882
|
+
blocks: DEFAULT_SLASH_COMMANDS
|
|
2883
|
+
});
|
|
2884
|
+
function useMailyContext() {
|
|
2885
|
+
const values = (0, import_react9.useContext)(MailyContext);
|
|
2886
|
+
if (!values) {
|
|
2887
|
+
throw new Error("Missing MailyContext.Provider in the component tree");
|
|
2888
|
+
}
|
|
2889
|
+
return values;
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
// src/editor/components/ui/link-input-popover.tsx
|
|
2893
|
+
var import_react15 = require("react");
|
|
2894
|
+
|
|
2895
|
+
// src/editor/nodes/variable/variable.ts
|
|
2896
|
+
var import_core11 = require("@tiptap/core");
|
|
2897
|
+
var import_state4 = require("@tiptap/pm/state");
|
|
2898
|
+
var import_react13 = require("@tiptap/react");
|
|
2899
|
+
var import_suggestion = __toESM(require("@tiptap/suggestion"));
|
|
2900
|
+
|
|
2901
|
+
// src/editor/nodes/variable/variable-suggestions-popover.tsx
|
|
2902
|
+
var import_lucide_react12 = require("lucide-react");
|
|
2903
|
+
var import_react10 = require("react");
|
|
2904
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2905
|
+
var VariableSuggestionsPopover = (0, import_react10.forwardRef)((props, ref) => {
|
|
2906
|
+
const { items, onSelectItem } = props;
|
|
2907
|
+
const [selectedIndex, setSelectedIndex] = (0, import_react10.useState)(0);
|
|
2908
|
+
const scrollContainerRef = (0, import_react10.useRef)(null);
|
|
2909
|
+
const itemRefs = (0, import_react10.useRef)([]);
|
|
2910
|
+
const scrollSelectedIntoView = (index) => {
|
|
2911
|
+
const container = scrollContainerRef.current;
|
|
2912
|
+
const selectedItem = itemRefs.current[index];
|
|
2913
|
+
if (!container || !selectedItem) {
|
|
2914
|
+
return;
|
|
2915
|
+
}
|
|
2916
|
+
const containerRect = container.getBoundingClientRect();
|
|
2917
|
+
const itemRect = selectedItem.getBoundingClientRect();
|
|
2918
|
+
const padding = 4;
|
|
2919
|
+
if (itemRect.bottom > containerRect.bottom) {
|
|
2920
|
+
container.scrollTop += itemRect.bottom - containerRect.bottom + padding;
|
|
2921
|
+
} else if (itemRect.top < containerRect.top) {
|
|
2922
|
+
container.scrollTop += itemRect.top - containerRect.top - padding;
|
|
2923
|
+
}
|
|
2924
|
+
};
|
|
2925
|
+
(0, import_react10.useEffect)(() => {
|
|
2926
|
+
setSelectedIndex(0);
|
|
2927
|
+
if (scrollContainerRef.current) {
|
|
2928
|
+
scrollContainerRef.current.scrollTop = 0;
|
|
2929
|
+
}
|
|
2930
|
+
itemRefs.current = items.map(() => null);
|
|
2931
|
+
}, [items]);
|
|
2932
|
+
(0, import_react10.useEffect)(() => {
|
|
2933
|
+
scrollSelectedIntoView(selectedIndex);
|
|
2934
|
+
}, [selectedIndex]);
|
|
2935
|
+
(0, import_react10.useImperativeHandle)(ref, () => ({
|
|
2936
|
+
moveUp: () => {
|
|
2937
|
+
setSelectedIndex((selectedIndex + items.length - 1) % items.length);
|
|
2938
|
+
},
|
|
2939
|
+
moveDown: () => {
|
|
2940
|
+
setSelectedIndex((selectedIndex + 1) % items.length);
|
|
2941
|
+
},
|
|
2942
|
+
select: () => {
|
|
2943
|
+
const item = items[selectedIndex];
|
|
2944
|
+
if (!item) {
|
|
2945
|
+
return;
|
|
2946
|
+
}
|
|
2947
|
+
onSelectItem(item);
|
|
2948
|
+
}
|
|
2949
|
+
}));
|
|
2950
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.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: [
|
|
2951
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.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: [
|
|
2952
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "mly-text-xs mly-uppercase", children: "Variables" }),
|
|
2953
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(VariableIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react12.Braces, { className: "mly-size-3 mly-stroke-[2.5]" }) })
|
|
2954
|
+
] }),
|
|
2955
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2956
|
+
"div",
|
|
2957
|
+
{
|
|
2958
|
+
ref: scrollContainerRef,
|
|
2959
|
+
className: "mly-max-h-52 mly-overflow-y-auto mly-scrollbar-thin mly-scrollbar-track-transparent mly-scrollbar-thumb-gray-200",
|
|
2960
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.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_runtime26.jsxs)(
|
|
2961
|
+
"button",
|
|
2962
|
+
{
|
|
2963
|
+
ref: (el) => itemRefs.current[index] = el,
|
|
2964
|
+
onClick: () => onSelectItem(item),
|
|
2965
|
+
className: cn(
|
|
2966
|
+
"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",
|
|
2967
|
+
index === selectedIndex ? "mly-bg-soft-gray" : "mly-bg-white"
|
|
2968
|
+
),
|
|
2969
|
+
children: [
|
|
2970
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react12.Braces, { className: "mly-size-3 mly-stroke-[2.5] mly-text-rose-600" }),
|
|
2971
|
+
item.name
|
|
2972
|
+
]
|
|
2973
|
+
},
|
|
2974
|
+
index
|
|
2975
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime26.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" }) })
|
|
2976
|
+
}
|
|
2977
|
+
),
|
|
2978
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.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: [
|
|
2979
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "mly-flex mly-items-center mly-gap-1", children: [
|
|
2980
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(VariableIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react12.ArrowDownIcon, { className: "mly-size-3 mly-stroke-[2.5]" }) }),
|
|
2981
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(VariableIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react12.ArrowUpIcon, { className: "mly-size-3 mly-stroke-[2.5]" }) }),
|
|
2982
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "mly-text-xs mly-text-gray-500", children: "Navigate" })
|
|
2983
|
+
] }),
|
|
2984
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(VariableIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react12.CornerDownLeftIcon, { className: "mly-size-3 mly-stroke-[2.5]" }) })
|
|
2985
|
+
] })
|
|
2986
|
+
] });
|
|
2987
|
+
});
|
|
2988
|
+
function VariableIcon(props) {
|
|
2989
|
+
const { className, children } = props;
|
|
2990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2991
|
+
"div",
|
|
2992
|
+
{
|
|
2993
|
+
className: cn(
|
|
2994
|
+
"mly-flex mly-size-5 mly-items-center mly-justify-center mly-rounded-md mly-border",
|
|
2995
|
+
className
|
|
2996
|
+
),
|
|
2997
|
+
children
|
|
2998
|
+
}
|
|
2999
|
+
);
|
|
3000
|
+
}
|
|
3001
|
+
|
|
2422
3002
|
// src/editor/nodes/variable/variable-view.tsx
|
|
2423
|
-
var
|
|
2424
|
-
var
|
|
2425
|
-
var
|
|
3003
|
+
var import_react11 = require("@tiptap/react");
|
|
3004
|
+
var import_lucide_react13 = require("lucide-react");
|
|
3005
|
+
var import_react12 = require("react");
|
|
3006
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2426
3007
|
function VariableView(props) {
|
|
2427
3008
|
const { node, updateAttributes: updateAttributes2, editor } = props;
|
|
2428
3009
|
const { id, fallback, required } = node.attrs;
|
|
2429
|
-
const
|
|
2430
|
-
|
|
2431
|
-
|
|
3010
|
+
const renderVariable = (0, import_react12.useMemo)(() => {
|
|
3011
|
+
var _a, _b;
|
|
3012
|
+
const variableRender = (_b = (_a = getNodeOptions(editor, "variable")) == null ? void 0 : _a.renderVariable) != null ? _b : DEFAULT_RENDER_VARIABLE_FUNCTION;
|
|
3013
|
+
return variableRender;
|
|
3014
|
+
}, [editor]);
|
|
3015
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3016
|
+
import_react11.NodeViewWrapper,
|
|
2432
3017
|
{
|
|
2433
3018
|
className: "react-component mly-inline-block mly-leading-none",
|
|
2434
3019
|
draggable: "false",
|
|
2435
|
-
children: /* @__PURE__ */ (0,
|
|
3020
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2436
3021
|
Popover,
|
|
2437
3022
|
{
|
|
2438
3023
|
onOpenChange: (open) => {
|
|
2439
3024
|
editor.storage.variable.popover = open;
|
|
2440
3025
|
},
|
|
2441
3026
|
children: [
|
|
2442
|
-
/* @__PURE__ */ (0,
|
|
3027
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(PopoverTrigger, { children: renderVariable({
|
|
2443
3028
|
variable: { name: id, required, valid: true },
|
|
2444
3029
|
fallback,
|
|
2445
3030
|
editor,
|
|
2446
3031
|
from: "content-variable"
|
|
2447
3032
|
}) }),
|
|
2448
|
-
/* @__PURE__ */ (0,
|
|
3033
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2449
3034
|
PopoverContent,
|
|
2450
3035
|
{
|
|
2451
3036
|
align: "start",
|
|
@@ -2454,10 +3039,10 @@ function VariableView(props) {
|
|
|
2454
3039
|
sideOffset: 8,
|
|
2455
3040
|
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
2456
3041
|
onCloseAutoFocus: (e) => e.preventDefault(),
|
|
2457
|
-
children: /* @__PURE__ */ (0,
|
|
2458
|
-
/* @__PURE__ */ (0,
|
|
2459
|
-
/* @__PURE__ */ (0,
|
|
2460
|
-
/* @__PURE__ */ (0,
|
|
3042
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "mly-flex mly-items-stretch mly-text-midnight-gray", children: [
|
|
3043
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("label", { className: "mly-relative", children: [
|
|
3044
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "mly-inline-block mly-px-2 mly-text-xs mly-text-midnight-gray", children: "Variable" }),
|
|
3045
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2461
3046
|
"input",
|
|
2462
3047
|
__spreadProps(__spreadValues({}, AUTOCOMPLETE_PASSWORD_MANAGERS_OFF), {
|
|
2463
3048
|
value: id != null ? id : "",
|
|
@@ -2471,10 +3056,10 @@ function VariableView(props) {
|
|
|
2471
3056
|
})
|
|
2472
3057
|
)
|
|
2473
3058
|
] }),
|
|
2474
|
-
/* @__PURE__ */ (0,
|
|
2475
|
-
/* @__PURE__ */ (0,
|
|
2476
|
-
/* @__PURE__ */ (0,
|
|
2477
|
-
/* @__PURE__ */ (0,
|
|
3059
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Divider, { className: "mly-mx-1.5" }),
|
|
3060
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("label", { className: "mly-relative", children: [
|
|
3061
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "mly-inline-block mly-px-2 mly-pl-1 mly-text-xs mly-text-midnight-gray", children: "Default" }),
|
|
3062
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2478
3063
|
"input",
|
|
2479
3064
|
__spreadProps(__spreadValues({}, AUTOCOMPLETE_PASSWORD_MANAGERS_OFF), {
|
|
2480
3065
|
value: fallback != null ? fallback : "",
|
|
@@ -2487,7 +3072,7 @@ function VariableView(props) {
|
|
|
2487
3072
|
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"
|
|
2488
3073
|
})
|
|
2489
3074
|
),
|
|
2490
|
-
/* @__PURE__ */ (0,
|
|
3075
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "mly-absolute mly-inset-y-0 mly-right-1 mly-flex mly-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react13.Pencil, { className: "mly-h-3 mly-w-3 mly-stroke-[2.5] mly-text-midnight-gray" }) })
|
|
2491
3076
|
] })
|
|
2492
3077
|
] }) })
|
|
2493
3078
|
}
|
|
@@ -2499,304 +3084,223 @@ function VariableView(props) {
|
|
|
2499
3084
|
);
|
|
2500
3085
|
}
|
|
2501
3086
|
var DefaultRenderVariable = (props) => {
|
|
2502
|
-
const { variable, fallback, from } = props;
|
|
2503
|
-
const { name, required, valid } = variable;
|
|
2504
|
-
if (from === "button-variable") {
|
|
2505
|
-
return /* @__PURE__ */ (0,
|
|
2506
|
-
/* @__PURE__ */ (0,
|
|
2507
|
-
/* @__PURE__ */ (0,
|
|
2508
|
-
] });
|
|
2509
|
-
}
|
|
2510
|
-
if (from === "bubble-variable") {
|
|
2511
|
-
return /* @__PURE__ */ (0,
|
|
2512
|
-
"div",
|
|
2513
|
-
{
|
|
2514
|
-
className: cn(
|
|
2515
|
-
"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",
|
|
2516
|
-
!valid && "mly-border-rose-400 mly-bg-rose-50 mly-text-rose-600 hover:mly-bg-rose-100"
|
|
2517
|
-
),
|
|
2518
|
-
children: [
|
|
2519
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react10.Braces, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-rose-600" }),
|
|
2520
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "mly-min-w-0 mly-truncate mly-text-left", children: name })
|
|
2521
|
-
]
|
|
2522
|
-
}
|
|
2523
|
-
);
|
|
2524
|
-
}
|
|
2525
|
-
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2526
|
-
"span",
|
|
2527
|
-
{
|
|
2528
|
-
tabIndex: -1,
|
|
2529
|
-
className: "mly-inline-flex mly-items-center mly-gap-[var(--variable-icon-gap)] mly-rounded-full mly-border mly-border-gray-200 mly-px-1.5 mly-py-0.5 mly-leading-none",
|
|
2530
|
-
children: [
|
|
2531
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react10.Braces, { className: "mly-size-[var(--variable-icon-size)] mly-shrink-0 mly-stroke-[2.5] mly-text-rose-600" }),
|
|
2532
|
-
name,
|
|
2533
|
-
required && !fallback && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react10.AlertTriangle, { className: "mly-size-[var(--variable-icon-size)] mly-shrink-0 mly-stroke-[2.5]" })
|
|
2534
|
-
]
|
|
2535
|
-
}
|
|
2536
|
-
);
|
|
2537
|
-
};
|
|
2538
|
-
|
|
2539
|
-
// src/editor/provider.tsx
|
|
2540
|
-
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2541
|
-
var DEFAULT_PLACEHOLDER_URL = "maily.to/";
|
|
2542
|
-
var DEFAULT_VARIABLE_TRIGGER_CHAR = "@";
|
|
2543
|
-
var DEFAULT_VARIABLES = [];
|
|
2544
|
-
var DEFAULT_RENDER_VARIABLE_FUNCTION = DefaultRenderVariable;
|
|
2545
|
-
var MailyContext = (0, import_react4.createContext)({
|
|
2546
|
-
placeholderUrl: DEFAULT_PLACEHOLDER_URL,
|
|
2547
|
-
variableTriggerCharacter: DEFAULT_VARIABLE_TRIGGER_CHAR,
|
|
2548
|
-
variables: DEFAULT_VARIABLES,
|
|
2549
|
-
blocks: DEFAULT_SLASH_COMMANDS,
|
|
2550
|
-
renderVariable: DEFAULT_RENDER_VARIABLE_FUNCTION
|
|
2551
|
-
});
|
|
2552
|
-
function useMailyContext() {
|
|
2553
|
-
const values = (0, import_react4.useContext)(MailyContext);
|
|
2554
|
-
if (!values) {
|
|
2555
|
-
throw new Error("Missing MailyContext.Provider in the component tree");
|
|
2556
|
-
}
|
|
2557
|
-
return values;
|
|
2558
|
-
}
|
|
2559
|
-
|
|
2560
|
-
// src/editor/nodes/variable/variable-popover.tsx
|
|
2561
|
-
var import_lucide_react11 = require("lucide-react");
|
|
2562
|
-
var import_react5 = require("react");
|
|
2563
|
-
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2564
|
-
var VariablePopover = (0, import_react5.forwardRef)((props, ref) => {
|
|
2565
|
-
const { items, onSelectItem } = props;
|
|
2566
|
-
const [selectedIndex, setSelectedIndex] = (0, import_react5.useState)(0);
|
|
2567
|
-
const scrollContainerRef = (0, import_react5.useRef)(null);
|
|
2568
|
-
const itemRefs = (0, import_react5.useRef)([]);
|
|
2569
|
-
const scrollSelectedIntoView = (index) => {
|
|
2570
|
-
const container = scrollContainerRef.current;
|
|
2571
|
-
const selectedItem = itemRefs.current[index];
|
|
2572
|
-
if (!container || !selectedItem) {
|
|
2573
|
-
return;
|
|
2574
|
-
}
|
|
2575
|
-
const containerRect = container.getBoundingClientRect();
|
|
2576
|
-
const itemRect = selectedItem.getBoundingClientRect();
|
|
2577
|
-
const padding = 4;
|
|
2578
|
-
if (itemRect.bottom > containerRect.bottom) {
|
|
2579
|
-
container.scrollTop += itemRect.bottom - containerRect.bottom + padding;
|
|
2580
|
-
} else if (itemRect.top < containerRect.top) {
|
|
2581
|
-
container.scrollTop += itemRect.top - containerRect.top - padding;
|
|
2582
|
-
}
|
|
2583
|
-
};
|
|
2584
|
-
(0, import_react5.useEffect)(() => {
|
|
2585
|
-
setSelectedIndex(0);
|
|
2586
|
-
if (scrollContainerRef.current) {
|
|
2587
|
-
scrollContainerRef.current.scrollTop = 0;
|
|
2588
|
-
}
|
|
2589
|
-
itemRefs.current = items.map(() => null);
|
|
2590
|
-
}, [items]);
|
|
2591
|
-
(0, import_react5.useEffect)(() => {
|
|
2592
|
-
scrollSelectedIntoView(selectedIndex);
|
|
2593
|
-
}, [selectedIndex]);
|
|
2594
|
-
(0, import_react5.useImperativeHandle)(ref, () => ({
|
|
2595
|
-
moveUp: () => {
|
|
2596
|
-
setSelectedIndex((selectedIndex + items.length - 1) % items.length);
|
|
2597
|
-
},
|
|
2598
|
-
moveDown: () => {
|
|
2599
|
-
setSelectedIndex((selectedIndex + 1) % items.length);
|
|
2600
|
-
},
|
|
2601
|
-
select: () => {
|
|
2602
|
-
const item = items[selectedIndex];
|
|
2603
|
-
if (!item) {
|
|
2604
|
-
return;
|
|
2605
|
-
}
|
|
2606
|
-
onSelectItem(item);
|
|
2607
|
-
}
|
|
2608
|
-
}));
|
|
2609
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.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: [
|
|
2610
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.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: [
|
|
2611
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "mly-text-xs mly-uppercase", children: "Variables" }),
|
|
2612
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(VariableIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react11.Braces, { className: "mly-size-3 mly-stroke-[2.5]" }) })
|
|
2613
|
-
] }),
|
|
2614
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3087
|
+
const { variable, fallback, from } = props;
|
|
3088
|
+
const { name, required, valid } = variable;
|
|
3089
|
+
if (from === "button-variable") {
|
|
3090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.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: [
|
|
3091
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react13.Braces, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5]" }),
|
|
3092
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "mly-min-w-0 mly-truncate mly-text-left", children: name })
|
|
3093
|
+
] });
|
|
3094
|
+
}
|
|
3095
|
+
if (from === "bubble-variable") {
|
|
3096
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2615
3097
|
"div",
|
|
2616
3098
|
{
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
"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",
|
|
2626
|
-
index === selectedIndex ? "mly-bg-soft-gray" : "mly-bg-white"
|
|
2627
|
-
),
|
|
2628
|
-
children: [
|
|
2629
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react11.Braces, { className: "mly-size-3 mly-stroke-[2.5] mly-text-rose-600" }),
|
|
2630
|
-
item.name
|
|
2631
|
-
]
|
|
2632
|
-
},
|
|
2633
|
-
index
|
|
2634
|
-
)) : /* @__PURE__ */ (0, import_jsx_runtime25.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" }) })
|
|
3099
|
+
className: cn(
|
|
3100
|
+
"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",
|
|
3101
|
+
!valid && "mly-border-rose-400 mly-bg-rose-50 mly-text-rose-600 hover:mly-bg-rose-100"
|
|
3102
|
+
),
|
|
3103
|
+
children: [
|
|
3104
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react13.Braces, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-rose-600" }),
|
|
3105
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "mly-min-w-0 mly-truncate mly-text-left", children: name })
|
|
3106
|
+
]
|
|
2635
3107
|
}
|
|
2636
|
-
)
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(VariableIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react11.ArrowUpIcon, { className: "mly-size-3 mly-stroke-[2.5]" }) }),
|
|
2641
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "mly-text-xs mly-text-gray-500", children: "Navigate" })
|
|
2642
|
-
] }),
|
|
2643
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(VariableIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react11.CornerDownLeftIcon, { className: "mly-size-3 mly-stroke-[2.5]" }) })
|
|
2644
|
-
] })
|
|
2645
|
-
] });
|
|
2646
|
-
});
|
|
2647
|
-
function VariableIcon(props) {
|
|
2648
|
-
const { className, children } = props;
|
|
2649
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2650
|
-
"div",
|
|
3108
|
+
);
|
|
3109
|
+
}
|
|
3110
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3111
|
+
"span",
|
|
2651
3112
|
{
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
3113
|
+
tabIndex: -1,
|
|
3114
|
+
className: "mly-inline-flex mly-items-center mly-gap-[var(--variable-icon-gap)] mly-rounded-full mly-border mly-border-gray-200 mly-px-1.5 mly-py-0.5 mly-leading-none",
|
|
3115
|
+
children: [
|
|
3116
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react13.Braces, { className: "mly-size-[var(--variable-icon-size)] mly-shrink-0 mly-stroke-[2.5] mly-text-rose-600" }),
|
|
3117
|
+
name,
|
|
3118
|
+
required && !fallback && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react13.AlertTriangle, { className: "mly-size-[var(--variable-icon-size)] mly-shrink-0 mly-stroke-[2.5]" })
|
|
3119
|
+
]
|
|
2657
3120
|
}
|
|
2658
3121
|
);
|
|
2659
|
-
}
|
|
3122
|
+
};
|
|
2660
3123
|
|
|
2661
|
-
// src/editor/
|
|
2662
|
-
var
|
|
2663
|
-
var
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
(
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
return () => {
|
|
2677
|
-
document.removeEventListener("mousedown", handleClick);
|
|
2678
|
-
document.removeEventListener("touchstart", handleClick);
|
|
3124
|
+
// src/editor/nodes/variable/variable.ts
|
|
3125
|
+
var DEFAULT_VARIABLE_TRIGGER_CHAR = "@";
|
|
3126
|
+
var DEFAULT_VARIABLES = [];
|
|
3127
|
+
var DEFAULT_RENDER_VARIABLE_FUNCTION = DefaultRenderVariable;
|
|
3128
|
+
var DEFAULT_VARIABLE_SUGGESTION_POPOVER = VariableSuggestionsPopover;
|
|
3129
|
+
var VariablePluginKey = new import_state4.PluginKey("variable");
|
|
3130
|
+
var VariableExtension = import_core11.Node.create({
|
|
3131
|
+
name: "variable",
|
|
3132
|
+
group: "inline",
|
|
3133
|
+
inline: true,
|
|
3134
|
+
selectable: true,
|
|
3135
|
+
atom: true,
|
|
3136
|
+
addStorage() {
|
|
3137
|
+
return {
|
|
3138
|
+
popover: false
|
|
2679
3139
|
};
|
|
2680
|
-
},
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
var
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
});
|
|
2710
|
-
const isTriggeringVariable = value.startsWith(triggerChar);
|
|
2711
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: cn("mly-relative"), ref: containerRef, children: [
|
|
2712
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "mly-relative", children: [
|
|
2713
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2714
|
-
"input",
|
|
2715
|
-
__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, AUTOCOMPLETE_PASSWORD_MANAGERS_OFF), {
|
|
2716
|
-
placeholder: "e.g. items",
|
|
2717
|
-
type: "text"
|
|
2718
|
-
}), inputProps), {
|
|
2719
|
-
ref,
|
|
2720
|
-
value,
|
|
2721
|
-
onChange: (e) => {
|
|
2722
|
-
onValueChange(e.target.value);
|
|
2723
|
-
},
|
|
2724
|
-
className: cn(
|
|
2725
|
-
"mly-h-7 mly-w-40 mly-rounded-md mly-bg-white 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",
|
|
2726
|
-
className
|
|
2727
|
-
),
|
|
2728
|
-
onKeyDown: (e) => {
|
|
2729
|
-
if (!popoverRef.current || !isTriggeringVariable) {
|
|
2730
|
-
return;
|
|
2731
|
-
}
|
|
2732
|
-
const { moveUp, moveDown, select } = popoverRef.current;
|
|
2733
|
-
if (e.key === "ArrowDown") {
|
|
2734
|
-
e.preventDefault();
|
|
2735
|
-
moveDown();
|
|
2736
|
-
} else if (e.key === "ArrowUp") {
|
|
2737
|
-
e.preventDefault();
|
|
2738
|
-
moveUp();
|
|
2739
|
-
} else if (e.key === "Enter") {
|
|
2740
|
-
e.preventDefault();
|
|
2741
|
-
select();
|
|
3140
|
+
},
|
|
3141
|
+
addOptions() {
|
|
3142
|
+
return {
|
|
3143
|
+
variables: DEFAULT_VARIABLES,
|
|
3144
|
+
variableSuggestionsPopover: DEFAULT_VARIABLE_SUGGESTION_POPOVER,
|
|
3145
|
+
renderVariable: DEFAULT_RENDER_VARIABLE_FUNCTION,
|
|
3146
|
+
renderLabel(props) {
|
|
3147
|
+
var _a;
|
|
3148
|
+
const { node } = props;
|
|
3149
|
+
return `${(_a = node.attrs.label) != null ? _a : node.attrs.id}`;
|
|
3150
|
+
},
|
|
3151
|
+
suggestion: {
|
|
3152
|
+
char: "@",
|
|
3153
|
+
pluginKey: VariablePluginKey,
|
|
3154
|
+
command: ({ editor, range, props }) => {
|
|
3155
|
+
var _a, _b;
|
|
3156
|
+
const nodeAfter = editor.view.state.selection.$to.nodeAfter;
|
|
3157
|
+
const overrideSpace = (_a = nodeAfter == null ? void 0 : nodeAfter.text) == null ? void 0 : _a.startsWith(" ");
|
|
3158
|
+
if (overrideSpace) {
|
|
3159
|
+
range.to += 1;
|
|
3160
|
+
}
|
|
3161
|
+
editor.chain().focus().insertContentAt(range, [
|
|
3162
|
+
{
|
|
3163
|
+
type: this.name,
|
|
3164
|
+
attrs: props
|
|
3165
|
+
},
|
|
3166
|
+
{
|
|
3167
|
+
type: "text",
|
|
3168
|
+
text: " "
|
|
2742
3169
|
}
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
}
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
3170
|
+
]).run();
|
|
3171
|
+
(_b = window.getSelection()) == null ? void 0 : _b.collapseToEnd();
|
|
3172
|
+
},
|
|
3173
|
+
allow: ({ state, range }) => {
|
|
3174
|
+
const $from = state.doc.resolve(range.from);
|
|
3175
|
+
const type = state.schema.nodes[this.name];
|
|
3176
|
+
const allow = !!$from.parent.type.contentMatch.matchType(type);
|
|
3177
|
+
return allow;
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
};
|
|
3181
|
+
},
|
|
3182
|
+
addAttributes() {
|
|
3183
|
+
return {
|
|
3184
|
+
id: {
|
|
3185
|
+
default: null,
|
|
3186
|
+
parseHTML: (element) => element.getAttribute("data-id"),
|
|
3187
|
+
renderHTML: (attributes) => {
|
|
3188
|
+
if (!attributes.id) {
|
|
3189
|
+
return {};
|
|
3190
|
+
}
|
|
2753
3191
|
return {
|
|
2754
|
-
|
|
3192
|
+
"data-id": attributes.id
|
|
2755
3193
|
};
|
|
2756
|
-
}
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
3194
|
+
}
|
|
3195
|
+
},
|
|
3196
|
+
label: {
|
|
3197
|
+
default: null,
|
|
3198
|
+
parseHTML: (element) => element.getAttribute("data-label"),
|
|
3199
|
+
renderHTML: (attributes) => {
|
|
3200
|
+
if (!attributes.label) {
|
|
3201
|
+
return {};
|
|
3202
|
+
}
|
|
3203
|
+
return {
|
|
3204
|
+
"data-label": attributes.label
|
|
3205
|
+
};
|
|
3206
|
+
}
|
|
3207
|
+
},
|
|
3208
|
+
fallback: {
|
|
3209
|
+
default: null,
|
|
3210
|
+
parseHTML: (element) => element.getAttribute("data-fallback"),
|
|
3211
|
+
renderHTML: (attributes) => {
|
|
3212
|
+
if (!attributes.fallback) {
|
|
3213
|
+
return {};
|
|
3214
|
+
}
|
|
3215
|
+
return {
|
|
3216
|
+
"data-fallback": attributes.fallback
|
|
3217
|
+
};
|
|
3218
|
+
}
|
|
3219
|
+
},
|
|
3220
|
+
required: {
|
|
3221
|
+
default: true,
|
|
3222
|
+
parseHTML: (element) => element.hasAttribute("data-required"),
|
|
3223
|
+
renderHTML: (attributes) => {
|
|
3224
|
+
var _a;
|
|
3225
|
+
return {
|
|
3226
|
+
"data-required": (_a = attributes == null ? void 0 : attributes.required) != null ? _a : true
|
|
3227
|
+
};
|
|
3228
|
+
}
|
|
2761
3229
|
}
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
(
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
}
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
3230
|
+
};
|
|
3231
|
+
},
|
|
3232
|
+
parseHTML() {
|
|
3233
|
+
return [
|
|
3234
|
+
{
|
|
3235
|
+
tag: `div[data-type="${this.name}"]`
|
|
3236
|
+
}
|
|
3237
|
+
];
|
|
3238
|
+
},
|
|
3239
|
+
renderHTML({ node, HTMLAttributes: HTMLAttributes2 }) {
|
|
3240
|
+
return [
|
|
3241
|
+
"div",
|
|
3242
|
+
(0, import_core11.mergeAttributes)({ "data-type": this.name }, HTMLAttributes2),
|
|
3243
|
+
this.options.renderLabel({
|
|
3244
|
+
options: this.options,
|
|
3245
|
+
node
|
|
3246
|
+
})
|
|
3247
|
+
];
|
|
3248
|
+
},
|
|
3249
|
+
renderText({ node }) {
|
|
3250
|
+
return this.options.renderLabel({
|
|
3251
|
+
options: this.options,
|
|
3252
|
+
node
|
|
3253
|
+
});
|
|
3254
|
+
},
|
|
3255
|
+
addKeyboardShortcuts() {
|
|
3256
|
+
return {
|
|
3257
|
+
Backspace: () => this.editor.commands.command(({ tr, state }) => {
|
|
3258
|
+
let isMention = false;
|
|
3259
|
+
const { selection } = state;
|
|
3260
|
+
const { empty, anchor } = selection;
|
|
3261
|
+
if (!empty) {
|
|
3262
|
+
return false;
|
|
3263
|
+
}
|
|
3264
|
+
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
3265
|
+
if (node.type.name === this.name) {
|
|
3266
|
+
isMention = true;
|
|
3267
|
+
tr.insertText(
|
|
3268
|
+
this.options.suggestion.char || "",
|
|
3269
|
+
pos,
|
|
3270
|
+
pos + node.nodeSize
|
|
3271
|
+
);
|
|
3272
|
+
return false;
|
|
3273
|
+
}
|
|
3274
|
+
});
|
|
3275
|
+
return isMention;
|
|
3276
|
+
})
|
|
3277
|
+
};
|
|
3278
|
+
},
|
|
3279
|
+
addProseMirrorPlugins() {
|
|
3280
|
+
return [
|
|
3281
|
+
(0, import_suggestion.default)(__spreadValues({
|
|
3282
|
+
editor: this.editor
|
|
3283
|
+
}, this.options.suggestion))
|
|
3284
|
+
];
|
|
3285
|
+
},
|
|
3286
|
+
addNodeView() {
|
|
3287
|
+
return (0, import_react13.ReactNodeViewRenderer)(VariableView, {
|
|
3288
|
+
className: "mly-relative mly-inline-block",
|
|
3289
|
+
as: "div"
|
|
3290
|
+
});
|
|
2786
3291
|
}
|
|
2787
|
-
}
|
|
3292
|
+
});
|
|
2788
3293
|
|
|
2789
3294
|
// src/editor/components/ui/link-input-popover.tsx
|
|
2790
|
-
var
|
|
2791
|
-
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3295
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2792
3296
|
var LINK_PROTOCOL_REGEX = /https?:\/\//;
|
|
2793
3297
|
function LinkInputPopover(props) {
|
|
2794
|
-
var _a;
|
|
3298
|
+
var _a, _b, _c;
|
|
2795
3299
|
const {
|
|
2796
3300
|
defaultValue = "",
|
|
2797
3301
|
onValueChange,
|
|
2798
3302
|
tooltip,
|
|
2799
|
-
icon: Icon =
|
|
3303
|
+
icon: Icon = import_lucide_react14.Link,
|
|
2800
3304
|
editor,
|
|
2801
3305
|
isVariable
|
|
2802
3306
|
} = props;
|
|
@@ -2805,17 +3309,16 @@ function LinkInputPopover(props) {
|
|
|
2805
3309
|
LINK_PROTOCOL_REGEX,
|
|
2806
3310
|
""
|
|
2807
3311
|
);
|
|
2808
|
-
const [isOpen, setIsOpen] = (0,
|
|
2809
|
-
const [protocol, setProtocol] = (0,
|
|
2810
|
-
const [isEditing, setIsEditing] = (0,
|
|
2811
|
-
const linkInputRef = (0,
|
|
2812
|
-
const {
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
const autoCompleteOptions = (0, import_react10.useMemo)(() => {
|
|
3312
|
+
const [isOpen, setIsOpen] = (0, import_react14.useState)(false);
|
|
3313
|
+
const [protocol, setProtocol] = (0, import_react14.useState)(defaultProtocol || "https://");
|
|
3314
|
+
const [isEditing, setIsEditing] = (0, import_react14.useState)(!isVariable);
|
|
3315
|
+
const linkInputRef = (0, import_react14.useRef)(null);
|
|
3316
|
+
const { placeholderUrl = DEFAULT_PLACEHOLDER_URL } = useMailyContext();
|
|
3317
|
+
const options = useVariableOptions(editor);
|
|
3318
|
+
const renderVariable = options == null ? void 0 : options.renderVariable;
|
|
3319
|
+
const variables = options == null ? void 0 : options.variables;
|
|
3320
|
+
const variableTriggerCharacter = (_c = (_b = options == null ? void 0 : options.suggestion) == null ? void 0 : _b.char) != null ? _c : DEFAULT_VARIABLE_TRIGGER_CHAR;
|
|
3321
|
+
const autoCompleteOptions = (0, import_react15.useMemo)(() => {
|
|
2819
3322
|
const withoutTrigger = defaultUrlWithoutProtocol.replace(
|
|
2820
3323
|
new RegExp(variableTriggerCharacter, "g"),
|
|
2821
3324
|
""
|
|
@@ -2825,8 +3328,8 @@ function LinkInputPopover(props) {
|
|
|
2825
3328
|
from: "bubble-variable",
|
|
2826
3329
|
editor
|
|
2827
3330
|
}).map((variable) => variable.name);
|
|
2828
|
-
}, [variables, defaultUrlWithoutProtocol, editor]);
|
|
2829
|
-
const popoverButton = /* @__PURE__ */ (0,
|
|
3331
|
+
}, [variables, variableTriggerCharacter, defaultUrlWithoutProtocol, editor]);
|
|
3332
|
+
const popoverButton = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2830
3333
|
BaseButton,
|
|
2831
3334
|
{
|
|
2832
3335
|
variant: "ghost",
|
|
@@ -2834,19 +3337,19 @@ function LinkInputPopover(props) {
|
|
|
2834
3337
|
type: "button",
|
|
2835
3338
|
className: "mly-size-7",
|
|
2836
3339
|
"data-state": !!defaultUrlWithoutProtocol,
|
|
2837
|
-
children: /* @__PURE__ */ (0,
|
|
3340
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Icon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-midnight-gray" })
|
|
2838
3341
|
}
|
|
2839
3342
|
) });
|
|
2840
3343
|
const normalizeProtocol = (value, p = protocol) => {
|
|
2841
3344
|
value = value == null ? void 0 : value.replace(LINK_PROTOCOL_REGEX, "");
|
|
2842
3345
|
return p + value;
|
|
2843
3346
|
};
|
|
2844
|
-
return /* @__PURE__ */ (0,
|
|
2845
|
-
tooltip ? /* @__PURE__ */ (0,
|
|
2846
|
-
/* @__PURE__ */ (0,
|
|
2847
|
-
/* @__PURE__ */ (0,
|
|
3347
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [
|
|
3348
|
+
tooltip ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tooltip, { children: [
|
|
3349
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipTrigger, { asChild: true, children: popoverButton }),
|
|
3350
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipContent, { sideOffset: 8, children: tooltip })
|
|
2848
3351
|
] }) : popoverButton,
|
|
2849
|
-
/* @__PURE__ */ (0,
|
|
3352
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2850
3353
|
PopoverContent,
|
|
2851
3354
|
{
|
|
2852
3355
|
align: "end",
|
|
@@ -2854,7 +3357,7 @@ function LinkInputPopover(props) {
|
|
|
2854
3357
|
className: "mly-w-max mly-rounded-none mly-border-none mly-bg-transparent !mly-p-0 mly-shadow-none",
|
|
2855
3358
|
sideOffset: 8,
|
|
2856
3359
|
onCloseAutoFocus: (e) => e.preventDefault(),
|
|
2857
|
-
children: /* @__PURE__ */ (0,
|
|
3360
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2858
3361
|
"form",
|
|
2859
3362
|
{
|
|
2860
3363
|
onSubmit: (e) => {
|
|
@@ -2867,8 +3370,8 @@ function LinkInputPopover(props) {
|
|
|
2867
3370
|
onValueChange == null ? void 0 : onValueChange(value);
|
|
2868
3371
|
setIsOpen(false);
|
|
2869
3372
|
},
|
|
2870
|
-
children: /* @__PURE__ */ (0,
|
|
2871
|
-
!isEditing && /* @__PURE__ */ (0,
|
|
3373
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-isolate mly-flex mly-rounded-lg", children: [
|
|
3374
|
+
!isEditing && /* @__PURE__ */ (0, import_jsx_runtime28.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_runtime28.jsx)(
|
|
2872
3375
|
"button",
|
|
2873
3376
|
{
|
|
2874
3377
|
onClick: () => {
|
|
@@ -2889,9 +3392,9 @@ function LinkInputPopover(props) {
|
|
|
2889
3392
|
})
|
|
2890
3393
|
}
|
|
2891
3394
|
) }),
|
|
2892
|
-
isEditing && /* @__PURE__ */ (0,
|
|
2893
|
-
/* @__PURE__ */ (0,
|
|
2894
|
-
/* @__PURE__ */ (0,
|
|
3395
|
+
isEditing && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
|
|
3396
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-relative", children: [
|
|
3397
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
2895
3398
|
"select",
|
|
2896
3399
|
{
|
|
2897
3400
|
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",
|
|
@@ -2908,13 +3411,13 @@ function LinkInputPopover(props) {
|
|
|
2908
3411
|
onValueChange == null ? void 0 : onValueChange(newValue);
|
|
2909
3412
|
},
|
|
2910
3413
|
children: [
|
|
2911
|
-
/* @__PURE__ */ (0,
|
|
2912
|
-
/* @__PURE__ */ (0,
|
|
3414
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: "https://", children: "https://" }),
|
|
3415
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: "http://", children: "http://" })
|
|
2913
3416
|
]
|
|
2914
3417
|
}
|
|
2915
3418
|
),
|
|
2916
|
-
/* @__PURE__ */ (0,
|
|
2917
|
-
|
|
3419
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.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_runtime28.jsx)(
|
|
3420
|
+
import_lucide_react14.ChevronDownIcon,
|
|
2918
3421
|
{
|
|
2919
3422
|
size: 16,
|
|
2920
3423
|
strokeWidth: 2,
|
|
@@ -2923,9 +3426,10 @@ function LinkInputPopover(props) {
|
|
|
2923
3426
|
}
|
|
2924
3427
|
) })
|
|
2925
3428
|
] }),
|
|
2926
|
-
/* @__PURE__ */ (0,
|
|
3429
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2927
3430
|
InputAutocomplete,
|
|
2928
3431
|
{
|
|
3432
|
+
editor,
|
|
2929
3433
|
value: defaultUrlWithoutProtocol,
|
|
2930
3434
|
onValueChange: (value) => {
|
|
2931
3435
|
let newValue = normalizeProtocol(value);
|
|
@@ -2959,9 +3463,9 @@ function LinkInputPopover(props) {
|
|
|
2959
3463
|
}
|
|
2960
3464
|
|
|
2961
3465
|
// src/editor/components/ui/select.tsx
|
|
2962
|
-
var
|
|
2963
|
-
var
|
|
2964
|
-
var
|
|
3466
|
+
var import_react16 = require("react");
|
|
3467
|
+
var import_lucide_react15 = require("lucide-react");
|
|
3468
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2965
3469
|
function Select(props) {
|
|
2966
3470
|
const {
|
|
2967
3471
|
label,
|
|
@@ -2973,11 +3477,11 @@ function Select(props) {
|
|
|
2973
3477
|
icon: Icon,
|
|
2974
3478
|
iconClassName
|
|
2975
3479
|
} = props;
|
|
2976
|
-
const selectId = `mly${(0,
|
|
2977
|
-
const content = /* @__PURE__ */ (0,
|
|
2978
|
-
/* @__PURE__ */ (0,
|
|
2979
|
-
Icon && /* @__PURE__ */ (0,
|
|
2980
|
-
/* @__PURE__ */ (0,
|
|
3480
|
+
const selectId = `mly${(0, import_react16.useId)()}`;
|
|
3481
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "mly-relative", children: [
|
|
3482
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("label", { htmlFor: selectId, className: "mly-sr-only", children: label }),
|
|
3483
|
+
Icon && /* @__PURE__ */ (0, import_jsx_runtime29.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_runtime29.jsx)(Icon, { className: cn("mly-size-3", iconClassName) }) }),
|
|
3484
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2981
3485
|
"select",
|
|
2982
3486
|
{
|
|
2983
3487
|
id: selectId,
|
|
@@ -2988,11 +3492,11 @@ function Select(props) {
|
|
|
2988
3492
|
),
|
|
2989
3493
|
value,
|
|
2990
3494
|
onChange: (event) => onValueChange(event.target.value),
|
|
2991
|
-
children: options.map((option) => /* @__PURE__ */ (0,
|
|
3495
|
+
children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("option", { value: option.value, children: option.label }, option.value))
|
|
2992
3496
|
}
|
|
2993
3497
|
),
|
|
2994
|
-
/* @__PURE__ */ (0,
|
|
2995
|
-
|
|
3498
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.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_runtime29.jsx)(
|
|
3499
|
+
import_lucide_react15.ChevronDownIcon,
|
|
2996
3500
|
{
|
|
2997
3501
|
size: 16,
|
|
2998
3502
|
strokeWidth: 2,
|
|
@@ -3004,167 +3508,30 @@ function Select(props) {
|
|
|
3004
3508
|
if (!tooltip) {
|
|
3005
3509
|
return content;
|
|
3006
3510
|
}
|
|
3007
|
-
return /* @__PURE__ */ (0,
|
|
3008
|
-
/* @__PURE__ */ (0,
|
|
3009
|
-
/* @__PURE__ */ (0,
|
|
3511
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Tooltip, { children: [
|
|
3512
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TooltipTrigger, { asChild: true, children: content }),
|
|
3513
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TooltipContent, { sideOffset: 8, children: tooltip })
|
|
3010
3514
|
] });
|
|
3011
3515
|
}
|
|
3012
3516
|
|
|
3013
3517
|
// src/editor/nodes/button/button-view.tsx
|
|
3014
|
-
var
|
|
3015
|
-
|
|
3016
|
-
// src/editor/components/show-popover.tsx
|
|
3017
|
-
var import_lucide_react15 = require("lucide-react");
|
|
3018
|
-
var import_react12 = require("react");
|
|
3019
|
-
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3020
|
-
function _ShowPopover(props) {
|
|
3021
|
-
const { showIfKey = "", onShowIfKeyValueChange, editor } = props;
|
|
3022
|
-
const { variables = [], renderVariable = DEFAULT_RENDER_VARIABLE_FUNCTION } = useMailyContext();
|
|
3023
|
-
const [isUpdatingKey, setIsUpdatingKey] = (0, import_react12.useState)(false);
|
|
3024
|
-
const inputRef = (0, import_react12.useRef)(null);
|
|
3025
|
-
const autoCompleteOptions = (0, import_react12.useMemo)(() => {
|
|
3026
|
-
return processVariables(variables, {
|
|
3027
|
-
query: showIfKey || "",
|
|
3028
|
-
from: "bubble-variable",
|
|
3029
|
-
editor
|
|
3030
|
-
}).map((variable) => variable.name);
|
|
3031
|
-
}, [variables, showIfKey, editor]);
|
|
3032
|
-
const isValidWhenKey = showIfKey || autoCompleteOptions.includes(showIfKey);
|
|
3033
|
-
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3034
|
-
Popover,
|
|
3035
|
-
{
|
|
3036
|
-
onOpenChange: (open) => {
|
|
3037
|
-
if (open) {
|
|
3038
|
-
return;
|
|
3039
|
-
}
|
|
3040
|
-
setIsUpdatingKey(false);
|
|
3041
|
-
},
|
|
3042
|
-
children: [
|
|
3043
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Tooltip, { children: [
|
|
3044
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3045
|
-
PopoverTrigger,
|
|
3046
|
-
{
|
|
3047
|
-
className: cn(
|
|
3048
|
-
"mly-flex mly-size-7 mly-items-center mly-justify-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",
|
|
3049
|
-
showIfKey && "mly-bg-rose-100 mly-text-rose-800 data-[state=open]:mly-bg-rose-100 hover:mly-bg-rose-100"
|
|
3050
|
-
),
|
|
3051
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react15.Eye, { className: "mly-h-3 mly-w-3 mly-stroke-[2.5]" })
|
|
3052
|
-
}
|
|
3053
|
-
) }),
|
|
3054
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TooltipContent, { sideOffset: 8, children: "Show block conditionally" })
|
|
3055
|
-
] }),
|
|
3056
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3057
|
-
PopoverContent,
|
|
3058
|
-
{
|
|
3059
|
-
className: "mly-flex mly-w-max mly-rounded-lg !mly-p-0.5",
|
|
3060
|
-
side: "top",
|
|
3061
|
-
sideOffset: 8,
|
|
3062
|
-
align: "end",
|
|
3063
|
-
onOpenAutoFocus: (e) => {
|
|
3064
|
-
e.preventDefault();
|
|
3065
|
-
},
|
|
3066
|
-
onCloseAutoFocus: (e) => {
|
|
3067
|
-
e.preventDefault();
|
|
3068
|
-
},
|
|
3069
|
-
children: [
|
|
3070
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "mly-flex mly-items-center mly-gap-1.5 mly-px-1.5 mly-text-sm mly-leading-none", children: [
|
|
3071
|
-
"Show if",
|
|
3072
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Tooltip, { children: [
|
|
3073
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TooltipTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3074
|
-
import_lucide_react15.InfoIcon,
|
|
3075
|
-
{
|
|
3076
|
-
className: cn("mly-size-3 mly-stroke-[2.5] mly-text-gray-500")
|
|
3077
|
-
}
|
|
3078
|
-
) }),
|
|
3079
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3080
|
-
TooltipContent,
|
|
3081
|
-
{
|
|
3082
|
-
sideOffset: 14,
|
|
3083
|
-
className: "mly-max-w-[285px]",
|
|
3084
|
-
align: "start",
|
|
3085
|
-
children: "Show the block if the selected variable is true."
|
|
3086
|
-
}
|
|
3087
|
-
)
|
|
3088
|
-
] })
|
|
3089
|
-
] }),
|
|
3090
|
-
!isUpdatingKey && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3091
|
-
"button",
|
|
3092
|
-
{
|
|
3093
|
-
onClick: () => {
|
|
3094
|
-
setIsUpdatingKey(true);
|
|
3095
|
-
setTimeout(() => {
|
|
3096
|
-
var _a;
|
|
3097
|
-
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
3098
|
-
}, 0);
|
|
3099
|
-
},
|
|
3100
|
-
children: renderVariable({
|
|
3101
|
-
variable: {
|
|
3102
|
-
name: showIfKey,
|
|
3103
|
-
valid: !!isValidWhenKey
|
|
3104
|
-
},
|
|
3105
|
-
fallback: "",
|
|
3106
|
-
from: "bubble-variable",
|
|
3107
|
-
editor
|
|
3108
|
-
})
|
|
3109
|
-
}
|
|
3110
|
-
),
|
|
3111
|
-
isUpdatingKey && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3112
|
-
"form",
|
|
3113
|
-
{
|
|
3114
|
-
onSubmit: (e) => {
|
|
3115
|
-
e.preventDefault();
|
|
3116
|
-
setIsUpdatingKey(false);
|
|
3117
|
-
},
|
|
3118
|
-
onKeyDown: (e) => {
|
|
3119
|
-
if (e.key === "Escape") {
|
|
3120
|
-
setIsUpdatingKey(false);
|
|
3121
|
-
}
|
|
3122
|
-
},
|
|
3123
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3124
|
-
InputAutocomplete,
|
|
3125
|
-
{
|
|
3126
|
-
value: showIfKey || "",
|
|
3127
|
-
onValueChange: (value) => {
|
|
3128
|
-
onShowIfKeyValueChange == null ? void 0 : onShowIfKeyValueChange(value);
|
|
3129
|
-
},
|
|
3130
|
-
onOutsideClick: () => {
|
|
3131
|
-
setIsUpdatingKey(false);
|
|
3132
|
-
},
|
|
3133
|
-
onSelectOption: (value) => {
|
|
3134
|
-
onShowIfKeyValueChange == null ? void 0 : onShowIfKeyValueChange(value);
|
|
3135
|
-
setIsUpdatingKey(false);
|
|
3136
|
-
},
|
|
3137
|
-
autoCompleteOptions,
|
|
3138
|
-
ref: inputRef
|
|
3139
|
-
}
|
|
3140
|
-
)
|
|
3141
|
-
}
|
|
3142
|
-
)
|
|
3143
|
-
]
|
|
3144
|
-
}
|
|
3145
|
-
)
|
|
3146
|
-
]
|
|
3147
|
-
}
|
|
3148
|
-
);
|
|
3149
|
-
}
|
|
3150
|
-
var ShowPopover = (0, import_react12.memo)(_ShowPopover);
|
|
3518
|
+
var import_react18 = require("@tiptap/react");
|
|
3519
|
+
var import_react19 = require("react");
|
|
3151
3520
|
|
|
3152
3521
|
// src/editor/nodes/button/button-label-input.tsx
|
|
3153
|
-
var
|
|
3154
|
-
var import_react14 = require("react");
|
|
3155
|
-
var import_react15 = require("react");
|
|
3522
|
+
var import_react17 = require("react");
|
|
3156
3523
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3157
3524
|
function ButtonLabelInput(props) {
|
|
3525
|
+
var _a, _b;
|
|
3158
3526
|
const { value, onValueChange, isVariable, editor } = props;
|
|
3159
|
-
const linkInputRef = (0,
|
|
3160
|
-
const [isEditing, setIsEditing] = (0,
|
|
3161
|
-
const {
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
const autoCompleteOptions = (0, import_react13.useMemo)(() => {
|
|
3527
|
+
const linkInputRef = (0, import_react17.useRef)(null);
|
|
3528
|
+
const [isEditing, setIsEditing] = (0, import_react17.useState)(!isVariable);
|
|
3529
|
+
const { placeholderUrl = DEFAULT_PLACEHOLDER_URL } = useMailyContext();
|
|
3530
|
+
const otps = useVariableOptions(editor);
|
|
3531
|
+
const variables = otps == null ? void 0 : otps.variables;
|
|
3532
|
+
const variableTriggerCharacter = (_b = (_a = otps == null ? void 0 : otps.suggestion) == null ? void 0 : _a.char) != null ? _b : DEFAULT_VARIABLE_TRIGGER_CHAR;
|
|
3533
|
+
const renderVariable = otps == null ? void 0 : otps.renderVariable;
|
|
3534
|
+
const autoCompleteOptions = (0, import_react17.useMemo)(() => {
|
|
3168
3535
|
const withoutTrigger = value.replace(
|
|
3169
3536
|
new RegExp(variableTriggerCharacter, "g"),
|
|
3170
3537
|
""
|
|
@@ -3182,8 +3549,8 @@ function ButtonLabelInput(props) {
|
|
|
3182
3549
|
onClick: () => {
|
|
3183
3550
|
setIsEditing(true);
|
|
3184
3551
|
setTimeout(() => {
|
|
3185
|
-
var
|
|
3186
|
-
(
|
|
3552
|
+
var _a2;
|
|
3553
|
+
(_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
|
|
3187
3554
|
}, 0);
|
|
3188
3555
|
},
|
|
3189
3556
|
children: renderVariable({
|
|
@@ -3200,6 +3567,7 @@ function ButtonLabelInput(props) {
|
|
|
3200
3567
|
isEditing && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3201
3568
|
InputAutocomplete,
|
|
3202
3569
|
{
|
|
3570
|
+
editor,
|
|
3203
3571
|
value,
|
|
3204
3572
|
onValueChange: (value2) => {
|
|
3205
3573
|
onValueChange == null ? void 0 : onValueChange(value2);
|
|
@@ -3210,8 +3578,8 @@ function ButtonLabelInput(props) {
|
|
|
3210
3578
|
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",
|
|
3211
3579
|
triggerChar: variableTriggerCharacter,
|
|
3212
3580
|
onSelectOption: (value2) => {
|
|
3213
|
-
var
|
|
3214
|
-
const isVariable2 = (
|
|
3581
|
+
var _a2;
|
|
3582
|
+
const isVariable2 = (_a2 = autoCompleteOptions.includes(value2)) != null ? _a2 : false;
|
|
3215
3583
|
if (isVariable2) {
|
|
3216
3584
|
setIsEditing(false);
|
|
3217
3585
|
}
|
|
@@ -3223,7 +3591,6 @@ function ButtonLabelInput(props) {
|
|
|
3223
3591
|
}
|
|
3224
3592
|
|
|
3225
3593
|
// src/editor/nodes/button/button-view.tsx
|
|
3226
|
-
var import_react17 = require("react");
|
|
3227
3594
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3228
3595
|
function ButtonView(props) {
|
|
3229
3596
|
const { node, editor, getPos, updateAttributes: updateAttributes2 } = props;
|
|
@@ -3243,8 +3610,9 @@ function ButtonView(props) {
|
|
|
3243
3610
|
paddingBottom,
|
|
3244
3611
|
paddingLeft
|
|
3245
3612
|
} = node.attrs;
|
|
3246
|
-
const
|
|
3247
|
-
const
|
|
3613
|
+
const opts = useVariableOptions(editor);
|
|
3614
|
+
const renderVariable = opts == null ? void 0 : opts.renderVariable;
|
|
3615
|
+
const sizes = (0, import_react19.useMemo)(
|
|
3248
3616
|
() => ({
|
|
3249
3617
|
small: {
|
|
3250
3618
|
paddingX: 24,
|
|
@@ -3261,14 +3629,14 @@ function ButtonView(props) {
|
|
|
3261
3629
|
}),
|
|
3262
3630
|
[]
|
|
3263
3631
|
);
|
|
3264
|
-
const size = (0,
|
|
3632
|
+
const size = (0, import_react19.useMemo)(() => {
|
|
3265
3633
|
var _a;
|
|
3266
3634
|
return (_a = Object.entries(sizes).find(
|
|
3267
3635
|
([, { paddingX, paddingY }]) => paddingRight === paddingX && paddingTop === paddingY
|
|
3268
3636
|
)) == null ? void 0 : _a[0];
|
|
3269
3637
|
}, [paddingRight, paddingTop, sizes]);
|
|
3270
3638
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3271
|
-
|
|
3639
|
+
import_react18.NodeViewWrapper,
|
|
3272
3640
|
{
|
|
3273
3641
|
draggable: editor.isEditable,
|
|
3274
3642
|
"data-drag-handle": editor.isEditable,
|
|
@@ -3547,7 +3915,7 @@ var DEFAULT_BUTTON_PADDING_BOTTOM = 10;
|
|
|
3547
3915
|
var DEFAULT_BUTTON_PADDING_LEFT = 32;
|
|
3548
3916
|
var allowedButtonVariant = ["filled", "outline"];
|
|
3549
3917
|
var allowedButtonBorderRadius = ["sharp", "smooth", "round"];
|
|
3550
|
-
var ButtonExtension =
|
|
3918
|
+
var ButtonExtension = import_core12.Node.create({
|
|
3551
3919
|
name: "button",
|
|
3552
3920
|
group: "block",
|
|
3553
3921
|
atom: true,
|
|
@@ -3744,7 +4112,7 @@ var ButtonExtension = import_core10.Node.create({
|
|
|
3744
4112
|
renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
|
|
3745
4113
|
return [
|
|
3746
4114
|
"div",
|
|
3747
|
-
(0,
|
|
4115
|
+
(0, import_core12.mergeAttributes)(HTMLAttributes2, {
|
|
3748
4116
|
"data-type": this.name
|
|
3749
4117
|
})
|
|
3750
4118
|
];
|
|
@@ -3762,7 +4130,7 @@ var ButtonExtension = import_core10.Node.create({
|
|
|
3762
4130
|
};
|
|
3763
4131
|
},
|
|
3764
4132
|
addNodeView() {
|
|
3765
|
-
return (0,
|
|
4133
|
+
return (0, import_react20.ReactNodeViewRenderer)(ButtonView, {
|
|
3766
4134
|
contentDOMElementTag: "div",
|
|
3767
4135
|
className: "mly-relative"
|
|
3768
4136
|
});
|
|
@@ -3771,21 +4139,26 @@ var ButtonExtension = import_core10.Node.create({
|
|
|
3771
4139
|
|
|
3772
4140
|
// src/editor/nodes/logo/logo.ts
|
|
3773
4141
|
var import_extension_image = __toESM(require("@tiptap/extension-image"));
|
|
3774
|
-
var
|
|
4142
|
+
var import_react27 = require("@tiptap/react");
|
|
3775
4143
|
|
|
3776
4144
|
// src/editor/nodes/logo/logo-view.tsx
|
|
3777
|
-
var
|
|
3778
|
-
var
|
|
3779
|
-
var
|
|
4145
|
+
var import_react24 = require("@tiptap/react");
|
|
4146
|
+
var import_react25 = require("react");
|
|
4147
|
+
var import_react26 = require("react");
|
|
4148
|
+
|
|
4149
|
+
// src/editor/nodes/image/image-view.tsx
|
|
4150
|
+
var import_react22 = require("react");
|
|
4151
|
+
var import_react23 = require("@tiptap/react");
|
|
4152
|
+
var import_lucide_react16 = require("lucide-react");
|
|
3780
4153
|
|
|
3781
4154
|
// src/editor/utils/use-event.ts
|
|
3782
|
-
var
|
|
4155
|
+
var import_react21 = require("react");
|
|
3783
4156
|
var useEvent = (handler) => {
|
|
3784
|
-
const handlerRef = (0,
|
|
3785
|
-
(0,
|
|
4157
|
+
const handlerRef = (0, import_react21.useRef)(null);
|
|
4158
|
+
(0, import_react21.useLayoutEffect)(() => {
|
|
3786
4159
|
handlerRef.current = handler;
|
|
3787
4160
|
}, [handler]);
|
|
3788
|
-
return (0,
|
|
4161
|
+
return (0, import_react21.useCallback)((...args) => {
|
|
3789
4162
|
if (handlerRef.current === null) {
|
|
3790
4163
|
throw new Error("Handler is not assigned");
|
|
3791
4164
|
}
|
|
@@ -3794,18 +4167,18 @@ var useEvent = (handler) => {
|
|
|
3794
4167
|
};
|
|
3795
4168
|
|
|
3796
4169
|
// src/editor/nodes/image/image-view.tsx
|
|
3797
|
-
var import_react20 = require("@tiptap/react");
|
|
3798
|
-
var import_lucide_react16 = require("lucide-react");
|
|
3799
|
-
var import_react21 = require("react");
|
|
3800
4170
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3801
4171
|
var MIN_WIDTH = 20;
|
|
3802
4172
|
var MAX_WIDTH = 600;
|
|
3803
4173
|
function ImageView(props) {
|
|
3804
4174
|
const { node, updateAttributes: updateAttributes2, selected, editor } = props;
|
|
3805
|
-
const [status, setStatus] = (0,
|
|
3806
|
-
const
|
|
3807
|
-
const
|
|
3808
|
-
const
|
|
4175
|
+
const [status, setStatus] = (0, import_react22.useState)("idle");
|
|
4176
|
+
const [isPlaceholderImage, setIsPlaceholderImage] = (0, import_react22.useState)(false);
|
|
4177
|
+
const { onImageUpload, allowedMimeTypes = [] } = useImageUploadOptions(editor);
|
|
4178
|
+
const wrapperRef = (0, import_react22.useRef)(null);
|
|
4179
|
+
const imgRef = (0, import_react22.useRef)(null);
|
|
4180
|
+
const [resizingStyle, setResizingStyle] = (0, import_react22.useState)();
|
|
4181
|
+
const [isDraggingOver, setIsDraggingOver] = (0, import_react22.useState)(false);
|
|
3809
4182
|
const handleMouseDown = useEvent(
|
|
3810
4183
|
(event) => {
|
|
3811
4184
|
const imageParent = document.querySelector(
|
|
@@ -3847,25 +4220,31 @@ function ImageView(props) {
|
|
|
3847
4220
|
window.addEventListener("mouseup", removeListeners);
|
|
3848
4221
|
}
|
|
3849
4222
|
);
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
role: "button",
|
|
3855
|
-
tabIndex: 0,
|
|
3856
|
-
onMouseDown: handleMouseDown,
|
|
3857
|
-
"data-direction": direction,
|
|
3858
|
-
className: "mly-bg-rose-500",
|
|
3859
|
-
style: __spreadProps(__spreadValues(__spreadValues({
|
|
3860
|
-
position: "absolute",
|
|
3861
|
-
height: "10px",
|
|
3862
|
-
width: "10px"
|
|
3863
|
-
}, { n: { top: 0 }, s: { bottom: 0 } }[direction[0]]), { w: { left: 0 }, e: { right: 0 } }[direction[1]]), {
|
|
3864
|
-
cursor: `${direction}-resize`
|
|
3865
|
-
})
|
|
4223
|
+
const dragCornerButton = (0, import_react22.useCallback)(
|
|
4224
|
+
(direction) => {
|
|
4225
|
+
if (isPlaceholderImage) {
|
|
4226
|
+
return null;
|
|
3866
4227
|
}
|
|
3867
|
-
|
|
3868
|
-
|
|
4228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4229
|
+
"div",
|
|
4230
|
+
{
|
|
4231
|
+
role: "button",
|
|
4232
|
+
tabIndex: 0,
|
|
4233
|
+
onMouseDown: handleMouseDown,
|
|
4234
|
+
"data-direction": direction,
|
|
4235
|
+
className: "mly-bg-rose-500",
|
|
4236
|
+
style: __spreadProps(__spreadValues(__spreadValues({
|
|
4237
|
+
position: "absolute",
|
|
4238
|
+
height: "10px",
|
|
4239
|
+
width: "10px"
|
|
4240
|
+
}, { n: { top: 0 }, s: { bottom: 0 } }[direction[0]]), { w: { left: 0 }, e: { right: 0 } }[direction[1]]), {
|
|
4241
|
+
cursor: `${direction}-resize`
|
|
4242
|
+
})
|
|
4243
|
+
}
|
|
4244
|
+
);
|
|
4245
|
+
},
|
|
4246
|
+
[handleMouseDown, isPlaceholderImage]
|
|
4247
|
+
);
|
|
3869
4248
|
let { alignment = "center", width, height, src } = node.attrs || {};
|
|
3870
4249
|
const _a = node.attrs || {}, {
|
|
3871
4250
|
externalLink,
|
|
@@ -3879,11 +4258,40 @@ function ImageView(props) {
|
|
|
3879
4258
|
"showIfKey"
|
|
3880
4259
|
]);
|
|
3881
4260
|
const hasImageSrc = !!attrs.src;
|
|
3882
|
-
|
|
3883
|
-
|
|
4261
|
+
const isDroppable = !!onImageUpload && editor.isEditable && !hasImageSrc && !isSrcVariable && status === "idle";
|
|
4262
|
+
const handleFileChange = (e) => __async(this, null, function* () {
|
|
4263
|
+
if (!isDroppable || !e.target.files || e.target.files.length === 0) {
|
|
4264
|
+
return;
|
|
4265
|
+
}
|
|
4266
|
+
const file = e.target.files[0];
|
|
4267
|
+
yield handleImageUpload(file);
|
|
4268
|
+
});
|
|
4269
|
+
const handleImageUpload = (0, import_react22.useCallback)(
|
|
4270
|
+
(file) => __async(this, null, function* () {
|
|
4271
|
+
if (!isDroppable) {
|
|
4272
|
+
return;
|
|
4273
|
+
}
|
|
4274
|
+
try {
|
|
4275
|
+
setStatus("loading");
|
|
4276
|
+
const imageUrl = yield onImageUpload(file);
|
|
4277
|
+
updateAttributes2({ src: imageUrl });
|
|
4278
|
+
setIsPlaceholderImage(false);
|
|
4279
|
+
setStatus("loaded");
|
|
4280
|
+
} catch (error) {
|
|
4281
|
+
console.error("Error uploading image:", error);
|
|
4282
|
+
setStatus("error");
|
|
4283
|
+
}
|
|
4284
|
+
}),
|
|
4285
|
+
[onImageUpload, updateAttributes2]
|
|
4286
|
+
);
|
|
4287
|
+
(0, import_react22.useEffect)(() => {
|
|
4288
|
+
var _a2, _b, _c, _d;
|
|
4289
|
+
if (!src || isSrcVariable) {
|
|
3884
4290
|
return;
|
|
3885
4291
|
}
|
|
3886
4292
|
setStatus("loading");
|
|
4293
|
+
const isPlaceHolder = (_d = (_c = (_b = (_a2 = editor == null ? void 0 : editor.extensionStorage) == null ? void 0 : _a2.imageUpload) == null ? void 0 : _b.placeholderImages) == null ? void 0 : _c.has(src)) != null ? _d : false;
|
|
4294
|
+
setIsPlaceholderImage(isPlaceHolder);
|
|
3887
4295
|
const img = new Image();
|
|
3888
4296
|
img.src = src;
|
|
3889
4297
|
img.onload = () => {
|
|
@@ -3913,12 +4321,56 @@ function ImageView(props) {
|
|
|
3913
4321
|
img.onerror = null;
|
|
3914
4322
|
};
|
|
3915
4323
|
}, [src]);
|
|
4324
|
+
const handleDragOver = (0, import_react22.useCallback)(
|
|
4325
|
+
(e) => {
|
|
4326
|
+
if (!isDroppable) {
|
|
4327
|
+
return;
|
|
4328
|
+
}
|
|
4329
|
+
e.preventDefault();
|
|
4330
|
+
e.stopPropagation();
|
|
4331
|
+
setIsDraggingOver(true);
|
|
4332
|
+
},
|
|
4333
|
+
[onImageUpload]
|
|
4334
|
+
);
|
|
4335
|
+
const handleDragLeave = (0, import_react22.useCallback)(
|
|
4336
|
+
(e) => {
|
|
4337
|
+
if (!isDroppable) {
|
|
4338
|
+
return;
|
|
4339
|
+
}
|
|
4340
|
+
e.preventDefault();
|
|
4341
|
+
e.stopPropagation();
|
|
4342
|
+
setIsDraggingOver(false);
|
|
4343
|
+
},
|
|
4344
|
+
[onImageUpload]
|
|
4345
|
+
);
|
|
4346
|
+
const handleDrop = (0, import_react22.useCallback)(
|
|
4347
|
+
(e) => __async(this, null, function* () {
|
|
4348
|
+
var _a2;
|
|
4349
|
+
if (!isDroppable) {
|
|
4350
|
+
return;
|
|
4351
|
+
}
|
|
4352
|
+
e.preventDefault();
|
|
4353
|
+
e.stopPropagation();
|
|
4354
|
+
setIsDraggingOver(false);
|
|
4355
|
+
const files = (_a2 = e.dataTransfer) == null ? void 0 : _a2.files;
|
|
4356
|
+
if (!files || (files == null ? void 0 : files.length) === 0) {
|
|
4357
|
+
return;
|
|
4358
|
+
}
|
|
4359
|
+
const firstFile = files[0];
|
|
4360
|
+
if (!allowedMimeTypes.includes(firstFile.type)) {
|
|
4361
|
+
return;
|
|
4362
|
+
}
|
|
4363
|
+
yield handleImageUpload(firstFile);
|
|
4364
|
+
}),
|
|
4365
|
+
[handleImageUpload]
|
|
4366
|
+
);
|
|
3916
4367
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
3917
|
-
|
|
3918
|
-
{
|
|
4368
|
+
import_react23.NodeViewWrapper,
|
|
4369
|
+
__spreadProps(__spreadValues({
|
|
3919
4370
|
as: "div",
|
|
3920
4371
|
draggable: editor.isEditable,
|
|
3921
4372
|
"data-drag-handle": editor.isEditable,
|
|
4373
|
+
className: cn("mly-image-drop-zone", isDraggingOver && "mly-drag-over"),
|
|
3922
4374
|
style: __spreadValues(__spreadProps(__spreadValues({}, hasImageSrc && status === "loaded" ? __spreadValues({
|
|
3923
4375
|
width: width ? `${width}px` : void 0,
|
|
3924
4376
|
height: height ? `${height}px` : void 0
|
|
@@ -3933,12 +4385,35 @@ function ImageView(props) {
|
|
|
3933
4385
|
left: { marginRight: "auto" },
|
|
3934
4386
|
right: { marginLeft: "auto" }
|
|
3935
4387
|
}[alignment] || {}),
|
|
3936
|
-
ref: wrapperRef
|
|
4388
|
+
ref: wrapperRef
|
|
4389
|
+
}, isDroppable ? {
|
|
4390
|
+
onDragOver: handleDragOver,
|
|
4391
|
+
onDragLeave: handleDragLeave,
|
|
4392
|
+
onDrop: handleDrop
|
|
4393
|
+
} : {}), {
|
|
3937
4394
|
children: [
|
|
3938
|
-
!hasImageSrc && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4395
|
+
!hasImageSrc && status === "idle" && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4396
|
+
ImageStatusLabel,
|
|
4397
|
+
{
|
|
4398
|
+
status: "idle",
|
|
4399
|
+
minHeight: height,
|
|
4400
|
+
isDropZone: isDroppable
|
|
4401
|
+
}
|
|
4402
|
+
),
|
|
4403
|
+
!hasImageSrc && status === "loading" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ImageStatusLabel, { status: "loading", minHeight: height }),
|
|
3939
4404
|
hasImageSrc && isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ImageStatusLabel, { status: "variable", minHeight: height }),
|
|
3940
4405
|
hasImageSrc && status === "loading" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ImageStatusLabel, { status: "loading", minHeight: height }),
|
|
3941
4406
|
hasImageSrc && status === "error" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ImageStatusLabel, { status: "error", minHeight: height }),
|
|
4407
|
+
isDroppable && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4408
|
+
"input",
|
|
4409
|
+
{
|
|
4410
|
+
type: "file",
|
|
4411
|
+
accept: "image/*",
|
|
4412
|
+
onChange: handleFileChange,
|
|
4413
|
+
className: "mly-absolute mly-inset-0 mly-opacity-0",
|
|
4414
|
+
multiple: false
|
|
4415
|
+
}
|
|
4416
|
+
),
|
|
3942
4417
|
hasImageSrc && status === "loaded" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
3943
4418
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3944
4419
|
"img",
|
|
@@ -3948,10 +4423,13 @@ function ImageView(props) {
|
|
|
3948
4423
|
cursor: "default",
|
|
3949
4424
|
marginBottom: 0
|
|
3950
4425
|
}),
|
|
3951
|
-
draggable: editor.isEditable
|
|
4426
|
+
draggable: editor.isEditable,
|
|
4427
|
+
className: cn(
|
|
4428
|
+
isPlaceholderImage && "mly-animate-pulse mly-opacity-40"
|
|
4429
|
+
)
|
|
3952
4430
|
})
|
|
3953
4431
|
),
|
|
3954
|
-
selected && editor.isEditable && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
4432
|
+
selected && editor.isEditable && !isPlaceholderImage && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
3955
4433
|
[
|
|
3956
4434
|
{ left: 0, top: 0, height: "100%", width: "1px" },
|
|
3957
4435
|
{ right: 0, top: 0, height: "100%", width: "1px" },
|
|
@@ -3974,29 +4452,34 @@ function ImageView(props) {
|
|
|
3974
4452
|
] })
|
|
3975
4453
|
] })
|
|
3976
4454
|
]
|
|
3977
|
-
}
|
|
4455
|
+
})
|
|
3978
4456
|
);
|
|
3979
4457
|
}
|
|
3980
4458
|
function ImageStatusLabel(props) {
|
|
3981
|
-
const { status, minHeight } =
|
|
4459
|
+
const _a = props, { status, minHeight, className, style, isDropZone } = _a, rest = __objRest(_a, ["status", "minHeight", "className", "style", "isDropZone"]);
|
|
3982
4460
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
3983
4461
|
"div",
|
|
3984
|
-
{
|
|
4462
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
3985
4463
|
className: cn(
|
|
3986
4464
|
"mly-flex mly-items-center mly-justify-center mly-gap-2 mly-rounded-lg mly-bg-soft-gray mly-px-4 mly-py-2 mly-text-sm mly-font-medium",
|
|
3987
4465
|
{
|
|
3988
4466
|
"mly-text-gray-500 hover:mly-bg-soft-gray/60": status === "loading",
|
|
3989
4467
|
"mly-text-red-500 hover:mly-bg-soft-gray/60": status === "error"
|
|
3990
|
-
}
|
|
4468
|
+
},
|
|
4469
|
+
className
|
|
3991
4470
|
),
|
|
3992
|
-
style: __spreadValues({}, minHeight ? {
|
|
4471
|
+
style: __spreadValues(__spreadValues({}, minHeight ? {
|
|
3993
4472
|
minHeight
|
|
3994
|
-
} : {}),
|
|
4473
|
+
} : {}), style),
|
|
3995
4474
|
children: [
|
|
3996
|
-
status === "idle" && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
4475
|
+
status === "idle" && !isDropZone && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
3997
4476
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react16.ImageOffIcon, { className: "mly-size-4 mly-stroke-[2.5]" }),
|
|
3998
4477
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { children: "No image selected" })
|
|
3999
4478
|
] }),
|
|
4479
|
+
status === "idle" && isDropZone && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
4480
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react16.GrabIcon, { className: "mly-size-4 mly-stroke-[2.5]" }),
|
|
4481
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { children: "Click or Drop image here" })
|
|
4482
|
+
] }),
|
|
4000
4483
|
status === "loading" && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
4001
4484
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react16.Loader2, { className: "mly-size-4 mly-animate-spin mly-stroke-[2.5]" }),
|
|
4002
4485
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { children: "Loading image..." })
|
|
@@ -4010,15 +4493,18 @@ function ImageStatusLabel(props) {
|
|
|
4010
4493
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { children: "Variable Image URL" })
|
|
4011
4494
|
] })
|
|
4012
4495
|
]
|
|
4013
|
-
}
|
|
4496
|
+
})
|
|
4014
4497
|
);
|
|
4015
4498
|
}
|
|
4016
4499
|
|
|
4017
4500
|
// src/editor/nodes/logo/logo-view.tsx
|
|
4018
4501
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
4019
4502
|
function LogoView(props) {
|
|
4020
|
-
const { node, editor } = props;
|
|
4021
|
-
const [status, setStatus] = (0,
|
|
4503
|
+
const { node, editor, updateAttributes: updateAttributes2 } = props;
|
|
4504
|
+
const [status, setStatus] = (0, import_react26.useState)("idle");
|
|
4505
|
+
const [isPlaceholderImage, setIsPlaceholderImage] = (0, import_react26.useState)(false);
|
|
4506
|
+
const [isDraggingOver, setIsDraggingOver] = (0, import_react26.useState)(false);
|
|
4507
|
+
const { onImageUpload, allowedMimeTypes = [] } = useImageUploadOptions(editor);
|
|
4022
4508
|
let {
|
|
4023
4509
|
alignment = "center",
|
|
4024
4510
|
src: logoSrc,
|
|
@@ -4026,11 +4512,83 @@ function LogoView(props) {
|
|
|
4026
4512
|
size = "sm"
|
|
4027
4513
|
} = node.attrs || {};
|
|
4028
4514
|
const hasImageSrc = !!logoSrc;
|
|
4029
|
-
|
|
4515
|
+
const isDroppable = !!onImageUpload && editor.isEditable && !isSrcVariable && status === "idle";
|
|
4516
|
+
const handleFileChange = (e) => __async(this, null, function* () {
|
|
4517
|
+
if (!isDroppable || !e.target.files || e.target.files.length === 0) {
|
|
4518
|
+
return;
|
|
4519
|
+
}
|
|
4520
|
+
const file = e.target.files[0];
|
|
4521
|
+
yield handleImageUpload(file);
|
|
4522
|
+
});
|
|
4523
|
+
const handleImageUpload = (0, import_react25.useCallback)(
|
|
4524
|
+
(file) => __async(this, null, function* () {
|
|
4525
|
+
if (!isDroppable) {
|
|
4526
|
+
return;
|
|
4527
|
+
}
|
|
4528
|
+
try {
|
|
4529
|
+
setStatus("loading");
|
|
4530
|
+
const imageUrl = yield onImageUpload(file);
|
|
4531
|
+
updateAttributes2({ src: imageUrl });
|
|
4532
|
+
setIsPlaceholderImage(false);
|
|
4533
|
+
setStatus("loaded");
|
|
4534
|
+
} catch (error) {
|
|
4535
|
+
console.error("Error uploading image:", error);
|
|
4536
|
+
setStatus("error");
|
|
4537
|
+
}
|
|
4538
|
+
}),
|
|
4539
|
+
[onImageUpload, updateAttributes2]
|
|
4540
|
+
);
|
|
4541
|
+
const handleDragOver = (0, import_react25.useCallback)(
|
|
4542
|
+
(e) => {
|
|
4543
|
+
if (!isDroppable) {
|
|
4544
|
+
return;
|
|
4545
|
+
}
|
|
4546
|
+
e.preventDefault();
|
|
4547
|
+
e.stopPropagation();
|
|
4548
|
+
setIsDraggingOver(true);
|
|
4549
|
+
},
|
|
4550
|
+
[onImageUpload]
|
|
4551
|
+
);
|
|
4552
|
+
const handleDragLeave = (0, import_react25.useCallback)(
|
|
4553
|
+
(e) => {
|
|
4554
|
+
if (!isDroppable) {
|
|
4555
|
+
return;
|
|
4556
|
+
}
|
|
4557
|
+
e.preventDefault();
|
|
4558
|
+
e.stopPropagation();
|
|
4559
|
+
setIsDraggingOver(false);
|
|
4560
|
+
},
|
|
4561
|
+
[onImageUpload]
|
|
4562
|
+
);
|
|
4563
|
+
const handleDrop = (0, import_react25.useCallback)(
|
|
4564
|
+
(e) => __async(this, null, function* () {
|
|
4565
|
+
var _a;
|
|
4566
|
+
if (!isDroppable) {
|
|
4567
|
+
return;
|
|
4568
|
+
}
|
|
4569
|
+
e.preventDefault();
|
|
4570
|
+
e.stopPropagation();
|
|
4571
|
+
setIsDraggingOver(false);
|
|
4572
|
+
const files = (_a = e.dataTransfer) == null ? void 0 : _a.files;
|
|
4573
|
+
if (!files || (files == null ? void 0 : files.length) === 0) {
|
|
4574
|
+
return;
|
|
4575
|
+
}
|
|
4576
|
+
const firstFile = files[0];
|
|
4577
|
+
if (!allowedMimeTypes.includes(firstFile.type)) {
|
|
4578
|
+
return;
|
|
4579
|
+
}
|
|
4580
|
+
yield handleImageUpload(firstFile);
|
|
4581
|
+
}),
|
|
4582
|
+
[handleImageUpload]
|
|
4583
|
+
);
|
|
4584
|
+
(0, import_react25.useEffect)(() => {
|
|
4585
|
+
var _a, _b, _c, _d;
|
|
4030
4586
|
if (!logoSrc) {
|
|
4031
4587
|
return;
|
|
4032
4588
|
}
|
|
4033
4589
|
setStatus("loading");
|
|
4590
|
+
const isPlaceHolder = (_d = (_c = (_b = (_a = editor == null ? void 0 : editor.extensionStorage) == null ? void 0 : _a.imageUpload) == null ? void 0 : _b.placeholderImages) == null ? void 0 : _c.has(logoSrc)) != null ? _d : false;
|
|
4591
|
+
setIsPlaceholderImage(isPlaceHolder);
|
|
4034
4592
|
const img = new Image();
|
|
4035
4593
|
img.src = logoSrc;
|
|
4036
4594
|
img.onload = () => {
|
|
@@ -4047,8 +4605,8 @@ function LogoView(props) {
|
|
|
4047
4605
|
}, [logoSrc]);
|
|
4048
4606
|
const logoSize = logoSizes[size];
|
|
4049
4607
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
4050
|
-
|
|
4051
|
-
{
|
|
4608
|
+
import_react24.NodeViewWrapper,
|
|
4609
|
+
__spreadProps(__spreadValues({
|
|
4052
4610
|
as: "div",
|
|
4053
4611
|
draggable: editor.isEditable,
|
|
4054
4612
|
"data-drag-handle": editor.isEditable,
|
|
@@ -4059,11 +4617,35 @@ function LogoView(props) {
|
|
|
4059
4617
|
lineHeight: "0px",
|
|
4060
4618
|
display: "block"
|
|
4061
4619
|
},
|
|
4620
|
+
className: cn("mly-image-drop-zone", isDraggingOver && "mly-drag-over")
|
|
4621
|
+
}, isDroppable ? {
|
|
4622
|
+
onDragOver: handleDragOver,
|
|
4623
|
+
onDragLeave: handleDragLeave,
|
|
4624
|
+
onDrop: handleDrop
|
|
4625
|
+
} : {}), {
|
|
4062
4626
|
children: [
|
|
4063
|
-
!hasImageSrc && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4627
|
+
!hasImageSrc && status === "idle" && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4628
|
+
ImageStatusLabel,
|
|
4629
|
+
{
|
|
4630
|
+
status: "idle",
|
|
4631
|
+
minHeight: logoSize,
|
|
4632
|
+
isDropZone: isDroppable
|
|
4633
|
+
}
|
|
4634
|
+
),
|
|
4635
|
+
!hasImageSrc && status === "loading" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ImageStatusLabel, { status: "loading", minHeight: logoSize }),
|
|
4064
4636
|
hasImageSrc && isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ImageStatusLabel, { status: "variable", minHeight: logoSize }),
|
|
4065
4637
|
hasImageSrc && status === "loading" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ImageStatusLabel, { status: "loading", minHeight: logoSize }),
|
|
4066
4638
|
hasImageSrc && status === "error" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ImageStatusLabel, { status: "error", minHeight: logoSize }),
|
|
4639
|
+
isDroppable && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4640
|
+
"input",
|
|
4641
|
+
{
|
|
4642
|
+
type: "file",
|
|
4643
|
+
accept: "image/*",
|
|
4644
|
+
onChange: handleFileChange,
|
|
4645
|
+
className: "mly-absolute mly-inset-0 mly-opacity-0",
|
|
4646
|
+
multiple: false
|
|
4647
|
+
}
|
|
4648
|
+
),
|
|
4067
4649
|
hasImageSrc && status === "loaded" && !isSrcVariable && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4068
4650
|
"img",
|
|
4069
4651
|
{
|
|
@@ -4083,7 +4665,7 @@ function LogoView(props) {
|
|
|
4083
4665
|
}
|
|
4084
4666
|
)
|
|
4085
4667
|
]
|
|
4086
|
-
}
|
|
4668
|
+
})
|
|
4087
4669
|
);
|
|
4088
4670
|
}
|
|
4089
4671
|
|
|
@@ -4184,7 +4766,7 @@ var LogoExtension = import_extension_image.default.extend({
|
|
|
4184
4766
|
];
|
|
4185
4767
|
},
|
|
4186
4768
|
addNodeView() {
|
|
4187
|
-
return (0,
|
|
4769
|
+
return (0, import_react27.ReactNodeViewRenderer)(LogoView, {
|
|
4188
4770
|
className: "mly-relative"
|
|
4189
4771
|
});
|
|
4190
4772
|
}
|
|
@@ -4192,7 +4774,7 @@ var LogoExtension = import_extension_image.default.extend({
|
|
|
4192
4774
|
|
|
4193
4775
|
// src/editor/nodes/image/image.ts
|
|
4194
4776
|
var import_extension_image2 = __toESM(require("@tiptap/extension-image"));
|
|
4195
|
-
var
|
|
4777
|
+
var import_react28 = require("@tiptap/react");
|
|
4196
4778
|
var ImageExtension = import_extension_image2.default.extend({
|
|
4197
4779
|
addAttributes() {
|
|
4198
4780
|
var _a;
|
|
@@ -4290,7 +4872,7 @@ var ImageExtension = import_extension_image2.default.extend({
|
|
|
4290
4872
|
});
|
|
4291
4873
|
},
|
|
4292
4874
|
addNodeView() {
|
|
4293
|
-
return (0,
|
|
4875
|
+
return (0, import_react28.ReactNodeViewRenderer)(ImageView, {
|
|
4294
4876
|
className: "mly-relative"
|
|
4295
4877
|
});
|
|
4296
4878
|
}
|
|
@@ -4366,24 +4948,24 @@ var ParagraphExtension = import_extension_paragraph.default.extend({
|
|
|
4366
4948
|
});
|
|
4367
4949
|
|
|
4368
4950
|
// src/editor/nodes/repeat/repeat.ts
|
|
4369
|
-
var
|
|
4370
|
-
var
|
|
4951
|
+
var import_core13 = require("@tiptap/core");
|
|
4952
|
+
var import_react30 = require("@tiptap/react");
|
|
4371
4953
|
|
|
4372
4954
|
// src/editor/nodes/repeat/repeat-view.tsx
|
|
4373
|
-
var
|
|
4955
|
+
var import_react29 = require("@tiptap/react");
|
|
4374
4956
|
var import_lucide_react17 = require("lucide-react");
|
|
4375
4957
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4376
4958
|
function RepeatView(props) {
|
|
4377
4959
|
const { editor, getPos } = props;
|
|
4378
4960
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
4379
|
-
|
|
4961
|
+
import_react29.NodeViewWrapper,
|
|
4380
4962
|
{
|
|
4381
4963
|
"data-type": "repeat",
|
|
4382
4964
|
draggable: editor.isEditable,
|
|
4383
4965
|
"data-drag-handle": editor.isEditable,
|
|
4384
4966
|
className: "mly-relative",
|
|
4385
4967
|
children: [
|
|
4386
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4968
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react29.NodeViewContent, { className: "is-editable" }),
|
|
4387
4969
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
4388
4970
|
"div",
|
|
4389
4971
|
{
|
|
@@ -4406,7 +4988,7 @@ function RepeatView(props) {
|
|
|
4406
4988
|
}
|
|
4407
4989
|
|
|
4408
4990
|
// src/editor/nodes/repeat/repeat.ts
|
|
4409
|
-
var RepeatExtension =
|
|
4991
|
+
var RepeatExtension = import_core13.Node.create({
|
|
4410
4992
|
name: "repeat",
|
|
4411
4993
|
group: "block",
|
|
4412
4994
|
content: "(block|columns)+",
|
|
@@ -4457,7 +5039,7 @@ var RepeatExtension = import_core11.Node.create({
|
|
|
4457
5039
|
renderHTML({ HTMLAttributes: HTMLAttributes2 }) {
|
|
4458
5040
|
return [
|
|
4459
5041
|
"div",
|
|
4460
|
-
(0,
|
|
5042
|
+
(0, import_core13.mergeAttributes)(HTMLAttributes2, {
|
|
4461
5043
|
"data-type": this.name
|
|
4462
5044
|
}),
|
|
4463
5045
|
0
|
|
@@ -4480,7 +5062,7 @@ var RepeatExtension = import_core11.Node.create({
|
|
|
4480
5062
|
};
|
|
4481
5063
|
},
|
|
4482
5064
|
addNodeView() {
|
|
4483
|
-
return (0,
|
|
5065
|
+
return (0, import_react30.ReactNodeViewRenderer)(RepeatView, {
|
|
4484
5066
|
contentDOMElementTag: "div",
|
|
4485
5067
|
className: "mly-relative"
|
|
4486
5068
|
});
|
|
@@ -4488,7 +5070,7 @@ var RepeatExtension = import_core11.Node.create({
|
|
|
4488
5070
|
});
|
|
4489
5071
|
|
|
4490
5072
|
// src/editor/extensions/maily-kit.tsx
|
|
4491
|
-
var MailyKit =
|
|
5073
|
+
var MailyKit = import_core14.Extension.create({
|
|
4492
5074
|
name: "maily-kit",
|
|
4493
5075
|
addOptions() {
|
|
4494
5076
|
return {
|
|
@@ -4594,10 +5176,28 @@ var MailyKit = import_core12.Extension.create({
|
|
|
4594
5176
|
}
|
|
4595
5177
|
});
|
|
4596
5178
|
|
|
5179
|
+
// src/editor/extensions/placeholder.ts
|
|
5180
|
+
var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"));
|
|
5181
|
+
var PlaceholderExtension = import_extension_placeholder.default.configure({
|
|
5182
|
+
placeholder: ({ node }) => {
|
|
5183
|
+
if (node.type.name === "heading") {
|
|
5184
|
+
return `Heading ${node.attrs.level}`;
|
|
5185
|
+
} else if (node.type.name === "htmlCodeBlock") {
|
|
5186
|
+
return "Type your HTML code...";
|
|
5187
|
+
} else if (["columns", "column", "section", "repeat", "show", "blockquote"].includes(
|
|
5188
|
+
node.type.name
|
|
5189
|
+
)) {
|
|
5190
|
+
return "";
|
|
5191
|
+
}
|
|
5192
|
+
return "Write something or / to see commands";
|
|
5193
|
+
},
|
|
5194
|
+
includeChildren: true
|
|
5195
|
+
});
|
|
5196
|
+
|
|
4597
5197
|
// src/editor/extensions/slash-command/slash-command.ts
|
|
4598
|
-
var
|
|
4599
|
-
var
|
|
4600
|
-
var SlashCommandExtension =
|
|
5198
|
+
var import_core15 = require("@tiptap/core");
|
|
5199
|
+
var import_suggestion2 = __toESM(require("@tiptap/suggestion"));
|
|
5200
|
+
var SlashCommandExtension = import_core15.Extension.create({
|
|
4601
5201
|
name: "slash-command",
|
|
4602
5202
|
addOptions() {
|
|
4603
5203
|
return {
|
|
@@ -4611,7 +5211,7 @@ var SlashCommandExtension = import_core13.Extension.create({
|
|
|
4611
5211
|
},
|
|
4612
5212
|
addProseMirrorPlugins() {
|
|
4613
5213
|
return [
|
|
4614
|
-
(0,
|
|
5214
|
+
(0, import_suggestion2.default)(__spreadValues({
|
|
4615
5215
|
editor: this.editor
|
|
4616
5216
|
}, this.options.suggestion))
|
|
4617
5217
|
];
|
|
@@ -4619,16 +5219,16 @@ var SlashCommandExtension = import_core13.Extension.create({
|
|
|
4619
5219
|
});
|
|
4620
5220
|
|
|
4621
5221
|
// src/editor/extensions/slash-command/slash-command-view.tsx
|
|
4622
|
-
var
|
|
4623
|
-
var
|
|
5222
|
+
var import_react31 = require("@tiptap/react");
|
|
5223
|
+
var import_react32 = require("react");
|
|
4624
5224
|
var import_tippy = __toESM(require("tippy.js"));
|
|
4625
5225
|
var import_lucide_react18 = require("lucide-react");
|
|
4626
5226
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
4627
|
-
var CommandList = (0,
|
|
5227
|
+
var CommandList = (0, import_react32.forwardRef)(function CommandList2(props, ref) {
|
|
4628
5228
|
const { items: groups, command, editor } = props;
|
|
4629
|
-
const [selectedGroupIndex, setSelectedGroupIndex] = (0,
|
|
4630
|
-
const [selectedCommandIndex, setSelectedCommandIndex] = (0,
|
|
4631
|
-
const selectItem = (0,
|
|
5229
|
+
const [selectedGroupIndex, setSelectedGroupIndex] = (0, import_react32.useState)(0);
|
|
5230
|
+
const [selectedCommandIndex, setSelectedCommandIndex] = (0, import_react32.useState)(0);
|
|
5231
|
+
const selectItem = (0, import_react32.useCallback)(
|
|
4632
5232
|
(groupIndex, commandIndex) => {
|
|
4633
5233
|
const item = groups[groupIndex].commands[commandIndex];
|
|
4634
5234
|
if (!item) {
|
|
@@ -4638,7 +5238,7 @@ var CommandList = (0, import_react30.forwardRef)(function CommandList2(props, re
|
|
|
4638
5238
|
},
|
|
4639
5239
|
[command]
|
|
4640
5240
|
);
|
|
4641
|
-
(0,
|
|
5241
|
+
(0, import_react32.useImperativeHandle)(ref, () => ({
|
|
4642
5242
|
onKeyDown: ({ event }) => {
|
|
4643
5243
|
var _a, _b;
|
|
4644
5244
|
const navigationKeys = ["ArrowUp", "ArrowDown", "Enter"];
|
|
@@ -4690,13 +5290,13 @@ var CommandList = (0, import_react30.forwardRef)(function CommandList2(props, re
|
|
|
4690
5290
|
}
|
|
4691
5291
|
}
|
|
4692
5292
|
}));
|
|
4693
|
-
(0,
|
|
5293
|
+
(0, import_react32.useEffect)(() => {
|
|
4694
5294
|
setSelectedGroupIndex(0);
|
|
4695
5295
|
setSelectedCommandIndex(0);
|
|
4696
5296
|
}, [groups]);
|
|
4697
|
-
const commandListContainer = (0,
|
|
4698
|
-
const activeCommandRef = (0,
|
|
4699
|
-
(0,
|
|
5297
|
+
const commandListContainer = (0, import_react32.useRef)(null);
|
|
5298
|
+
const activeCommandRef = (0, import_react32.useRef)(null);
|
|
5299
|
+
(0, import_react32.useLayoutEffect)(() => {
|
|
4700
5300
|
const container = commandListContainer == null ? void 0 : commandListContainer.current;
|
|
4701
5301
|
const activeCommandContainer = activeCommandRef == null ? void 0 : activeCommandRef.current;
|
|
4702
5302
|
if (!container || !activeCommandContainer) {
|
|
@@ -4717,7 +5317,7 @@ var CommandList = (0, import_react30.forwardRef)(function CommandList2(props, re
|
|
|
4717
5317
|
id: "slash-command",
|
|
4718
5318
|
ref: commandListContainer,
|
|
4719
5319
|
className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto mly-scroll-smooth",
|
|
4720
|
-
children: groups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
5320
|
+
children: groups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_react32.Fragment, { children: [
|
|
4721
5321
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
4722
5322
|
"span",
|
|
4723
5323
|
{
|
|
@@ -4882,7 +5482,7 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
|
|
|
4882
5482
|
let popup = null;
|
|
4883
5483
|
return {
|
|
4884
5484
|
onStart: (props) => {
|
|
4885
|
-
component = new
|
|
5485
|
+
component = new import_react31.ReactRenderer(CommandList, {
|
|
4886
5486
|
props,
|
|
4887
5487
|
editor: props.editor
|
|
4888
5488
|
});
|
|
@@ -4921,183 +5521,17 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
|
|
|
4921
5521
|
};
|
|
4922
5522
|
}
|
|
4923
5523
|
|
|
4924
|
-
// src/editor/nodes/variable/variable.ts
|
|
4925
|
-
var import_core14 = require("@tiptap/core");
|
|
4926
|
-
var import_state3 = require("@tiptap/pm/state");
|
|
4927
|
-
var import_react31 = require("@tiptap/react");
|
|
4928
|
-
var import_suggestion2 = __toESM(require("@tiptap/suggestion"));
|
|
4929
|
-
var VariablePluginKey = new import_state3.PluginKey("variable");
|
|
4930
|
-
var VariableExtension = import_core14.Node.create({
|
|
4931
|
-
name: "variable",
|
|
4932
|
-
group: "inline",
|
|
4933
|
-
inline: true,
|
|
4934
|
-
selectable: true,
|
|
4935
|
-
atom: true,
|
|
4936
|
-
addStorage() {
|
|
4937
|
-
return {
|
|
4938
|
-
popover: false
|
|
4939
|
-
};
|
|
4940
|
-
},
|
|
4941
|
-
addOptions() {
|
|
4942
|
-
return {
|
|
4943
|
-
variables: [],
|
|
4944
|
-
triggerChar: "@",
|
|
4945
|
-
renderLabel({ options, node }) {
|
|
4946
|
-
var _a;
|
|
4947
|
-
return `${(_a = node.attrs.label) != null ? _a : node.attrs.id}`;
|
|
4948
|
-
},
|
|
4949
|
-
suggestion: {
|
|
4950
|
-
char: "@",
|
|
4951
|
-
pluginKey: VariablePluginKey,
|
|
4952
|
-
command: ({ editor, range, props }) => {
|
|
4953
|
-
var _a, _b;
|
|
4954
|
-
const nodeAfter = editor.view.state.selection.$to.nodeAfter;
|
|
4955
|
-
const overrideSpace = (_a = nodeAfter == null ? void 0 : nodeAfter.text) == null ? void 0 : _a.startsWith(" ");
|
|
4956
|
-
if (overrideSpace) {
|
|
4957
|
-
range.to += 1;
|
|
4958
|
-
}
|
|
4959
|
-
editor.chain().focus().insertContentAt(range, [
|
|
4960
|
-
{
|
|
4961
|
-
type: this.name,
|
|
4962
|
-
attrs: props
|
|
4963
|
-
},
|
|
4964
|
-
{
|
|
4965
|
-
type: "text",
|
|
4966
|
-
text: " "
|
|
4967
|
-
}
|
|
4968
|
-
]).run();
|
|
4969
|
-
(_b = window.getSelection()) == null ? void 0 : _b.collapseToEnd();
|
|
4970
|
-
},
|
|
4971
|
-
allow: ({ state, range }) => {
|
|
4972
|
-
const $from = state.doc.resolve(range.from);
|
|
4973
|
-
const type = state.schema.nodes[this.name];
|
|
4974
|
-
const allow = !!$from.parent.type.contentMatch.matchType(type);
|
|
4975
|
-
return allow;
|
|
4976
|
-
}
|
|
4977
|
-
}
|
|
4978
|
-
};
|
|
4979
|
-
},
|
|
4980
|
-
addAttributes() {
|
|
4981
|
-
return {
|
|
4982
|
-
id: {
|
|
4983
|
-
default: null,
|
|
4984
|
-
parseHTML: (element) => element.getAttribute("data-id"),
|
|
4985
|
-
renderHTML: (attributes) => {
|
|
4986
|
-
if (!attributes.id) {
|
|
4987
|
-
return {};
|
|
4988
|
-
}
|
|
4989
|
-
return {
|
|
4990
|
-
"data-id": attributes.id
|
|
4991
|
-
};
|
|
4992
|
-
}
|
|
4993
|
-
},
|
|
4994
|
-
label: {
|
|
4995
|
-
default: null,
|
|
4996
|
-
parseHTML: (element) => element.getAttribute("data-label"),
|
|
4997
|
-
renderHTML: (attributes) => {
|
|
4998
|
-
if (!attributes.label) {
|
|
4999
|
-
return {};
|
|
5000
|
-
}
|
|
5001
|
-
return {
|
|
5002
|
-
"data-label": attributes.label
|
|
5003
|
-
};
|
|
5004
|
-
}
|
|
5005
|
-
},
|
|
5006
|
-
fallback: {
|
|
5007
|
-
default: null,
|
|
5008
|
-
parseHTML: (element) => element.getAttribute("data-fallback"),
|
|
5009
|
-
renderHTML: (attributes) => {
|
|
5010
|
-
if (!attributes.fallback) {
|
|
5011
|
-
return {};
|
|
5012
|
-
}
|
|
5013
|
-
return {
|
|
5014
|
-
"data-fallback": attributes.fallback
|
|
5015
|
-
};
|
|
5016
|
-
}
|
|
5017
|
-
},
|
|
5018
|
-
required: {
|
|
5019
|
-
default: true,
|
|
5020
|
-
parseHTML: (element) => element.hasAttribute("data-required"),
|
|
5021
|
-
renderHTML: (attributes) => {
|
|
5022
|
-
var _a;
|
|
5023
|
-
return {
|
|
5024
|
-
"data-required": (_a = attributes == null ? void 0 : attributes.required) != null ? _a : true
|
|
5025
|
-
};
|
|
5026
|
-
}
|
|
5027
|
-
}
|
|
5028
|
-
};
|
|
5029
|
-
},
|
|
5030
|
-
parseHTML() {
|
|
5031
|
-
return [
|
|
5032
|
-
{
|
|
5033
|
-
tag: `div[data-type="${this.name}"]`
|
|
5034
|
-
}
|
|
5035
|
-
];
|
|
5036
|
-
},
|
|
5037
|
-
renderHTML({ node, HTMLAttributes: HTMLAttributes2 }) {
|
|
5038
|
-
return [
|
|
5039
|
-
"div",
|
|
5040
|
-
(0, import_core14.mergeAttributes)({ "data-type": this.name }, HTMLAttributes2),
|
|
5041
|
-
this.options.renderLabel({
|
|
5042
|
-
options: this.options,
|
|
5043
|
-
node
|
|
5044
|
-
})
|
|
5045
|
-
];
|
|
5046
|
-
},
|
|
5047
|
-
renderText({ node }) {
|
|
5048
|
-
return this.options.renderLabel({
|
|
5049
|
-
options: this.options,
|
|
5050
|
-
node
|
|
5051
|
-
});
|
|
5052
|
-
},
|
|
5053
|
-
addKeyboardShortcuts() {
|
|
5054
|
-
return {
|
|
5055
|
-
Backspace: () => this.editor.commands.command(({ tr, state }) => {
|
|
5056
|
-
let isMention = false;
|
|
5057
|
-
const { selection } = state;
|
|
5058
|
-
const { empty, anchor } = selection;
|
|
5059
|
-
if (!empty) {
|
|
5060
|
-
return false;
|
|
5061
|
-
}
|
|
5062
|
-
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
5063
|
-
if (node.type.name === this.name) {
|
|
5064
|
-
isMention = true;
|
|
5065
|
-
tr.insertText(
|
|
5066
|
-
this.options.suggestion.char || "",
|
|
5067
|
-
pos,
|
|
5068
|
-
pos + node.nodeSize
|
|
5069
|
-
);
|
|
5070
|
-
return false;
|
|
5071
|
-
}
|
|
5072
|
-
});
|
|
5073
|
-
return isMention;
|
|
5074
|
-
})
|
|
5075
|
-
};
|
|
5076
|
-
},
|
|
5077
|
-
addProseMirrorPlugins() {
|
|
5078
|
-
return [
|
|
5079
|
-
(0, import_suggestion2.default)(__spreadValues({
|
|
5080
|
-
editor: this.editor
|
|
5081
|
-
}, this.options.suggestion))
|
|
5082
|
-
];
|
|
5083
|
-
},
|
|
5084
|
-
addNodeView() {
|
|
5085
|
-
return (0, import_react31.ReactNodeViewRenderer)(VariableView, {
|
|
5086
|
-
className: "mly-relative mly-inline-block",
|
|
5087
|
-
as: "div"
|
|
5088
|
-
});
|
|
5089
|
-
}
|
|
5090
|
-
});
|
|
5091
|
-
|
|
5092
5524
|
// src/editor/nodes/variable/variable-suggestions.tsx
|
|
5093
|
-
var
|
|
5094
|
-
var
|
|
5525
|
+
var import_react33 = require("@tiptap/react");
|
|
5526
|
+
var import_react34 = require("react");
|
|
5095
5527
|
var import_tippy2 = __toESM(require("tippy.js"));
|
|
5096
5528
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
5097
|
-
var VariableList = (0,
|
|
5098
|
-
|
|
5099
|
-
const
|
|
5100
|
-
(0,
|
|
5529
|
+
var VariableList = (0, import_react34.forwardRef)((props, ref) => {
|
|
5530
|
+
var _a;
|
|
5531
|
+
const { items = [], editor } = props;
|
|
5532
|
+
const popoverRef = (0, import_react34.useRef)(null);
|
|
5533
|
+
const VariableSuggestionPopoverComponent = (_a = useVariableOptions(editor)) == null ? void 0 : _a.variableSuggestionsPopover;
|
|
5534
|
+
(0, import_react34.useImperativeHandle)(ref, () => ({
|
|
5101
5535
|
onKeyDown: ({ event }) => {
|
|
5102
5536
|
if (!popoverRef.current) {
|
|
5103
5537
|
return false;
|
|
@@ -5121,14 +5555,14 @@ var VariableList = (0, import_react33.forwardRef)((props, ref) => {
|
|
|
5121
5555
|
}
|
|
5122
5556
|
}));
|
|
5123
5557
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
5124
|
-
|
|
5558
|
+
VariableSuggestionPopoverComponent,
|
|
5125
5559
|
{
|
|
5126
5560
|
items,
|
|
5127
5561
|
onSelectItem: (value) => {
|
|
5128
|
-
var
|
|
5562
|
+
var _a2;
|
|
5129
5563
|
props.command({
|
|
5130
5564
|
id: value.name,
|
|
5131
|
-
required: (
|
|
5565
|
+
required: (_a2 = value.required) != null ? _a2 : true
|
|
5132
5566
|
});
|
|
5133
5567
|
},
|
|
5134
5568
|
ref: popoverRef
|
|
@@ -5136,10 +5570,12 @@ var VariableList = (0, import_react33.forwardRef)((props, ref) => {
|
|
|
5136
5570
|
);
|
|
5137
5571
|
});
|
|
5138
5572
|
VariableList.displayName = "VariableList";
|
|
5139
|
-
function getVariableSuggestions(
|
|
5573
|
+
function getVariableSuggestions(char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
|
|
5140
5574
|
return {
|
|
5141
5575
|
char,
|
|
5142
5576
|
items: ({ query, editor }) => {
|
|
5577
|
+
var _a;
|
|
5578
|
+
const variables = (_a = getVariableOptions(editor)) == null ? void 0 : _a.variables;
|
|
5143
5579
|
return processVariables(variables, {
|
|
5144
5580
|
query,
|
|
5145
5581
|
editor,
|
|
@@ -5151,7 +5587,7 @@ function getVariableSuggestions(variables = DEFAULT_VARIABLES, char = DEFAULT_VA
|
|
|
5151
5587
|
let popup = null;
|
|
5152
5588
|
return {
|
|
5153
5589
|
onStart: (props) => {
|
|
5154
|
-
component = new
|
|
5590
|
+
component = new import_react33.ReactRenderer(VariableList, {
|
|
5155
5591
|
props,
|
|
5156
5592
|
editor: props.editor
|
|
5157
5593
|
});
|
|
@@ -5197,24 +5633,6 @@ function getVariableSuggestions(variables = DEFAULT_VARIABLES, char = DEFAULT_VA
|
|
|
5197
5633
|
}
|
|
5198
5634
|
};
|
|
5199
5635
|
}
|
|
5200
|
-
|
|
5201
|
-
// src/editor/extensions/placeholder.ts
|
|
5202
|
-
var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"));
|
|
5203
|
-
var PlaceholderExtension = import_extension_placeholder.default.configure({
|
|
5204
|
-
placeholder: ({ node }) => {
|
|
5205
|
-
if (node.type.name === "heading") {
|
|
5206
|
-
return `Heading ${node.attrs.level}`;
|
|
5207
|
-
} else if (node.type.name === "htmlCodeBlock") {
|
|
5208
|
-
return "Type your HTML code...";
|
|
5209
|
-
} else if (["columns", "column", "section", "repeat", "show", "blockquote"].includes(
|
|
5210
|
-
node.type.name
|
|
5211
|
-
)) {
|
|
5212
|
-
return "";
|
|
5213
|
-
}
|
|
5214
|
-
return "Write something or / to see commands";
|
|
5215
|
-
},
|
|
5216
|
-
includeChildren: true
|
|
5217
|
-
});
|
|
5218
5636
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5219
5637
|
0 && (module.exports = {
|
|
5220
5638
|
ButtonExtension,
|
|
@@ -5234,6 +5652,7 @@ var PlaceholderExtension = import_extension_placeholder.default.configure({
|
|
|
5234
5652
|
DEFAULT_COLUMN_VERTICAL_ALIGN,
|
|
5235
5653
|
DEFAULT_COLUMN_WIDTH,
|
|
5236
5654
|
DEFAULT_LOGO_SIZE,
|
|
5655
|
+
DEFAULT_RENDER_VARIABLE_FUNCTION,
|
|
5237
5656
|
DEFAULT_SECTION_ALIGN,
|
|
5238
5657
|
DEFAULT_SECTION_BACKGROUND_COLOR,
|
|
5239
5658
|
DEFAULT_SECTION_BORDER_COLOR,
|
|
@@ -5249,9 +5668,14 @@ var PlaceholderExtension = import_extension_placeholder.default.configure({
|
|
|
5249
5668
|
DEFAULT_SECTION_PADDING_TOP,
|
|
5250
5669
|
DEFAULT_SECTION_SHOW_IF_KEY,
|
|
5251
5670
|
DEFAULT_SPACER_HEIGHT,
|
|
5671
|
+
DEFAULT_VARIABLES,
|
|
5672
|
+
DEFAULT_VARIABLE_SUGGESTION_POPOVER,
|
|
5673
|
+
DEFAULT_VARIABLE_TRIGGER_CHAR,
|
|
5252
5674
|
Footer,
|
|
5253
5675
|
HorizontalRule,
|
|
5254
5676
|
ImageExtension,
|
|
5677
|
+
ImageUploadExtension,
|
|
5678
|
+
ImageUploadPlugin,
|
|
5255
5679
|
LinkExtension,
|
|
5256
5680
|
LogoExtension,
|
|
5257
5681
|
MailyKit,
|
|
@@ -5269,6 +5693,7 @@ var PlaceholderExtension = import_extension_placeholder.default.configure({
|
|
|
5269
5693
|
allowedLogoSize,
|
|
5270
5694
|
getSlashCommandSuggestions,
|
|
5271
5695
|
getVariableSuggestions,
|
|
5272
|
-
logoSizes
|
|
5696
|
+
logoSizes,
|
|
5697
|
+
useImageUploadOptions
|
|
5273
5698
|
});
|
|
5274
5699
|
//# sourceMappingURL=index.js.map
|