@maily-to/core 0.3.7 → 2.0.0-beta.10

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.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/dist/blocks/index.cjs +29 -305
  3. package/dist/blocks/index.d.cts +1 -59
  4. package/dist/blocks/index.d.mts +46 -0
  5. package/dist/blocks/index.d.mts.map +1 -0
  6. package/dist/blocks/index.mjs +2 -273
  7. package/dist/extensions/index.cjs +354 -9100
  8. package/dist/extensions/index.d.cts +1 -448
  9. package/dist/extensions/index.d.mts +282 -0
  10. package/dist/extensions/index.d.mts.map +1 -0
  11. package/dist/extensions/index.mjs +322 -9052
  12. package/dist/index.cjs +10225 -12221
  13. package/dist/index.d.cts +1 -63
  14. package/dist/index.d.mts +743 -0
  15. package/dist/index.d.mts.map +1 -0
  16. package/dist/index.mjs +10103 -12273
  17. package/dist/slash-command-BrwA1bHs.d.mts +38 -0
  18. package/dist/slash-command-BrwA1bHs.d.mts.map +1 -0
  19. package/dist/theme-D1CI7_8s.d.mts +70 -0
  20. package/dist/theme-D1CI7_8s.d.mts.map +1 -0
  21. package/dist/typography-BdOKvXfQ.mjs +911 -0
  22. package/dist/typography-D-VnwOSw.cjs +970 -0
  23. package/dist/typography-DW7VApAR.cjs +1072 -0
  24. package/dist/use-maily-editor-Atvy2kSO.cjs +3993 -0
  25. package/dist/use-maily-editor-CByaDhmT.cjs +4955 -0
  26. package/dist/use-maily-editor-idL0RNsG.mjs +4504 -0
  27. package/package.json +115 -180
  28. package/readme.md +356 -195
  29. package/src/styles/index.css +2537 -0
  30. package/dist/blocks/index.cjs.map +0 -1
  31. package/dist/blocks/index.d.ts +0 -59
  32. package/dist/blocks/index.mjs.map +0 -1
  33. package/dist/extensions/index.cjs.map +0 -1
  34. package/dist/extensions/index.d.ts +0 -448
  35. package/dist/extensions/index.mjs.map +0 -1
  36. package/dist/index.cjs.map +0 -1
  37. package/dist/index.css +0 -2487
  38. package/dist/index.css.map +0 -1
  39. package/dist/index.d.ts +0 -63
  40. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,4955 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __exportAll = (all, no_symbols) => {
9
+ let target = {};
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
15
+ return target;
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
19
+ key = keys[i];
20
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
21
+ get: ((k) => from[k]).bind(null, key),
22
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
23
+ });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ //#endregion
32
+ const require_typography = require("./typography-DW7VApAR.cjs");
33
+ let react_compiler_runtime = require("react/compiler-runtime");
34
+ let react = require("react");
35
+ let _base_ui_utils_useIsoLayoutEffect = require("@base-ui/utils/useIsoLayoutEffect");
36
+ let _base_ui_utils_useRefWithInit = require("@base-ui/utils/useRefWithInit");
37
+ let react_jsx_runtime = require("react/jsx-runtime");
38
+ let lucide_react = require("lucide-react");
39
+ let _base_ui_react_tooltip = require("@base-ui/react/tooltip");
40
+ let _floating_ui_react = require("@floating-ui/react");
41
+ let _floating_ui_utils_dom = require("@floating-ui/utils/dom");
42
+ let _maily_to_shared = require("@maily-to/shared");
43
+ let _tiptap_react = require("@tiptap/react");
44
+ let zustand = require("zustand");
45
+ let _tiptap_pm_state = require("@tiptap/pm/state");
46
+ let _tiptap_extension_paragraph = require("@tiptap/extension-paragraph");
47
+ let _tiptap_extension_text = require("@tiptap/extension-text");
48
+ let _tiptap_extensions = require("@tiptap/extensions");
49
+ let _tiptap_extension_document = require("@tiptap/extension-document");
50
+ let _tiptap_core = require("@tiptap/core");
51
+ let _tiptap_suggestion = require("@tiptap/suggestion");
52
+ let _tiptap_extension_code = require("@tiptap/extension-code");
53
+ let _tiptap_extension_hard_break = require("@tiptap/extension-hard-break");
54
+ let _tiptap_extension_heading = require("@tiptap/extension-heading");
55
+ let _tiptap_extension_highlight = require("@tiptap/extension-highlight");
56
+ let _tiptap_extension_italic = require("@tiptap/extension-italic");
57
+ let _tiptap_extension_link = require("@tiptap/extension-link");
58
+ let _tiptap_extension_list = require("@tiptap/extension-list");
59
+ let _tiptap_extension_strike = require("@tiptap/extension-strike");
60
+ let _tiptap_extension_text_style = require("@tiptap/extension-text-style");
61
+ let _tiptap_extension_typography = require("@tiptap/extension-typography");
62
+ let _tiptap_extension_underline = require("@tiptap/extension-underline");
63
+ let _tiptap_extension_unique_id = require("@tiptap/extension-unique-id");
64
+ let _tiptap_extension_blockquote = require("@tiptap/extension-blockquote");
65
+ let _tiptap_extension_bold = require("@tiptap/extension-bold");
66
+ let _tiptap_extension_horizontal_rule = require("@tiptap/extension-horizontal-rule");
67
+ let _tiptap_extension_code_block_lowlight = require("@tiptap/extension-code-block-lowlight");
68
+ let highlight_js_lib_languages_xml = require("highlight.js/lib/languages/xml");
69
+ highlight_js_lib_languages_xml = __toESM(highlight_js_lib_languages_xml, 1);
70
+ let lowlight = require("lowlight");
71
+ let _tiptap_extension_file_handler = require("@tiptap/extension-file-handler");
72
+ let _tiptap_extension_image = require("@tiptap/extension-image");
73
+ let _tiptap_extension_table = require("@tiptap/extension-table");
74
+ let _tiptap_pm_history = require("@tiptap/pm/history");
75
+ let _tiptap_pm_model = require("@tiptap/pm/model");
76
+ //#region src/hooks/use-value-as-ref.ts
77
+ /**
78
+ * Untracks the provided value by turning it into a ref to remove its reactivity.
79
+ *
80
+ * Used to access the passed value inside `React.useEffect` without causing the effect to re-run when the value changes.
81
+ */
82
+ function useValueAsRef(value) {
83
+ const latest = (0, _base_ui_utils_useRefWithInit.useRefWithInit)(createLatestRef, value).current;
84
+ latest.next = value;
85
+ (0, _base_ui_utils_useIsoLayoutEffect.useIsoLayoutEffect)(latest.effect);
86
+ return latest;
87
+ }
88
+ function createLatestRef(value) {
89
+ const latest = {
90
+ current: value,
91
+ next: value,
92
+ effect: () => {
93
+ latest.current = latest.next;
94
+ }
95
+ };
96
+ return latest;
97
+ }
98
+ //#endregion
99
+ //#region src/components/icons/arrow-icon.tsx
100
+ function ArrowIcon(props) {
101
+ const $ = (0, react_compiler_runtime.c)(4);
102
+ let t0;
103
+ let t1;
104
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
105
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
106
+ d: "M9.66437 2.60207L4.80758 6.97318C4.07308 7.63423 3.11989 8 2.13172 8H0V10H20V8H18.5349C17.5468 8 16.5936 7.63423 15.8591 6.97318L11.0023 2.60207C10.622 2.2598 10.0447 2.25979 9.66437 2.60207Z",
107
+ "data-mly-arrow-fill": ""
108
+ });
109
+ t1 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
110
+ d: "M8.99542 1.85876C9.75604 1.17425 10.9106 1.17422 11.6713 1.85878L16.5281 6.22989C17.0789 6.72568 17.7938 7.00001 18.5349 7.00001L15.89 7L11.0023 2.60207C10.622 2.2598 10.0447 2.2598 9.66436 2.60207L4.77734 7L2.13171 7.00001C2.87284 7.00001 3.58774 6.72568 4.13861 6.22989L8.99542 1.85876Z",
111
+ "data-mly-arrow-border": ""
112
+ });
113
+ $[0] = t0;
114
+ $[1] = t1;
115
+ } else {
116
+ t0 = $[0];
117
+ t1 = $[1];
118
+ }
119
+ let t2;
120
+ if ($[2] !== props) {
121
+ t2 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
122
+ "data-mly-arrow-icon": "",
123
+ fill: "none",
124
+ height: "10",
125
+ viewBox: "0 0 20 10",
126
+ width: "20",
127
+ ...props,
128
+ children: [t0, t1]
129
+ });
130
+ $[2] = props;
131
+ $[3] = t2;
132
+ } else t2 = $[3];
133
+ return t2;
134
+ }
135
+ //#endregion
136
+ //#region src/hooks/use-editor-instance.ts
137
+ const EDITOR_INSTANCE_NOT_FOUND_ERROR = `Editor instance not found. Make sure to use the EditorContext.Provider or useEditor hook.
138
+
139
+ Please create an issue at ${_maily_to_shared.MAILY_BUG_REPORT_URL} if you think this is a bug.
140
+ `;
141
+ /**
142
+ * Returns the active Tiptap editor instance, preferring the explicitly
143
+ * passed editor over the one from EditorContext. Throws if neither exists.
144
+ */
145
+ function useEditorInstance(editor) {
146
+ const { editor: currentEditor } = (0, _tiptap_react.useCurrentEditor)();
147
+ const editorInstance = editor || currentEditor;
148
+ (0, _maily_to_shared.invariant)(editorInstance, EDITOR_INSTANCE_NOT_FOUND_ERROR);
149
+ return editorInstance;
150
+ }
151
+ //#endregion
152
+ //#region src/hooks/use-floating-store.ts
153
+ /**
154
+ * Global Zustand store that tracks FloatingUI contexts for all
155
+ * bubble menus. Menus register on mount and unregister on unmount
156
+ * so the editor can coordinate which menu is visible.
157
+ */
158
+ const useFloatingStore = (0, zustand.create)((set, get, store) => ({
159
+ contexts: [],
160
+ isDragContextOpen: false,
161
+ setDragContextOpen: (open) => {
162
+ set({ isDragContextOpen: open });
163
+ },
164
+ register: (id, context) => {
165
+ set((state) => {
166
+ if (state.contexts.find((item) => item.id === id)) return state;
167
+ return { contexts: [...state.contexts, {
168
+ id,
169
+ value: context
170
+ }] };
171
+ });
172
+ return () => {
173
+ get().unregister(id);
174
+ };
175
+ },
176
+ unregister: (id) => {
177
+ set((state) => ({ contexts: state.contexts.filter((item) => item.id !== id) }));
178
+ },
179
+ update: (id, context) => {
180
+ set((state) => ({ contexts: state.contexts.map((item) => item.id === id ? {
181
+ ...item,
182
+ value: context
183
+ } : item) }));
184
+ },
185
+ getContext: (id) => get().contexts.find((item) => item.id === id)?.value,
186
+ getAll: () => get().contexts,
187
+ reset: () => {
188
+ set(store.getInitialState());
189
+ }
190
+ }));
191
+ /** Registers a floating menu's context on mount and cleans up on unmount. */
192
+ function useRegisterFloatingContext(id, context) {
193
+ const $ = (0, react_compiler_runtime.c)(5);
194
+ const register = useFloatingStore(_temp$3);
195
+ let t0;
196
+ let t1;
197
+ if ($[0] !== context || $[1] !== id || $[2] !== register) {
198
+ t0 = () => register(id, context);
199
+ t1 = [
200
+ id,
201
+ context,
202
+ register
203
+ ];
204
+ $[0] = context;
205
+ $[1] = id;
206
+ $[2] = register;
207
+ $[3] = t0;
208
+ $[4] = t1;
209
+ } else {
210
+ t0 = $[3];
211
+ t1 = $[4];
212
+ }
213
+ (0, react.useEffect)(t0, t1);
214
+ }
215
+ function _temp$3(state) {
216
+ return state.register;
217
+ }
218
+ //#endregion
219
+ //#region src/hooks/use-on-selection-update.ts
220
+ function useOnSelectionUpdate(editor, onSelectionUpdate) {
221
+ const $ = (0, react_compiler_runtime.c)(4);
222
+ const callback = useValueAsRef(onSelectionUpdate);
223
+ let t0;
224
+ let t1;
225
+ if ($[0] !== callback || $[1] !== editor) {
226
+ t0 = () => {
227
+ const handler = () => {
228
+ callback.current();
229
+ };
230
+ handler();
231
+ editor.on("selectionUpdate", handler);
232
+ return () => {
233
+ editor.off("selectionUpdate", handler);
234
+ };
235
+ };
236
+ t1 = [callback, editor];
237
+ $[0] = callback;
238
+ $[1] = editor;
239
+ $[2] = t0;
240
+ $[3] = t1;
241
+ } else {
242
+ t0 = $[2];
243
+ t1 = $[3];
244
+ }
245
+ (0, react.useEffect)(t0, t1);
246
+ }
247
+ //#endregion
248
+ //#region src/types/floating-ui.ts
249
+ /**
250
+ * Stable IDs for each floating bubble menu. Used to register, look up,
251
+ * and coordinate visibility of menus through the floating store.
252
+ */
253
+ const FLOATING_ELEMENT_ATTRIBUTE = "data-mly-floating-element";
254
+ const FLOATING_ELEMENT_IDS = {
255
+ TEXT_BUBBLE_MENU: "text-bubble-menu",
256
+ VARIABLE_BUBBLE_MENU: "variable-bubble-menu",
257
+ SPACER_BUBBLE_MENU: "spacer-bubble-menu",
258
+ SECTION_BUBBLE_MENU: "section-bubble-menu",
259
+ COLUMNS_BUBBLE_MENU: "columns-bubble-menu",
260
+ INLINE_IMAGE_BUBBLE_MENU: "inline-image-bubble-menu",
261
+ IMAGE_BUBBLE_MENU: "image-bubble-menu",
262
+ BUTTON_BUBBLE_MENU: "button-bubble-menu",
263
+ HTML_CODE_BLOCK_BUBBLE_MENU: "html-code-block-bubble-menu",
264
+ REPEAT_BUBBLE_MENU: "repeat-bubble-menu",
265
+ LINK_CARD_BUBBLE_MENU: "link-card-bubble-menu"
266
+ };
267
+ /**
268
+ * Priority order for bubble menu visibility. When multiple menus
269
+ * could be active (e.g. text inside a button inside a section),
270
+ * the first matching menu in this list wins.
271
+ */
272
+ const FLOATING_ELEMENT_ORDER = [
273
+ FLOATING_ELEMENT_IDS.BUTTON_BUBBLE_MENU,
274
+ FLOATING_ELEMENT_IDS.HTML_CODE_BLOCK_BUBBLE_MENU,
275
+ FLOATING_ELEMENT_IDS.VARIABLE_BUBBLE_MENU,
276
+ FLOATING_ELEMENT_IDS.SPACER_BUBBLE_MENU,
277
+ FLOATING_ELEMENT_IDS.COLUMNS_BUBBLE_MENU,
278
+ FLOATING_ELEMENT_IDS.REPEAT_BUBBLE_MENU,
279
+ FLOATING_ELEMENT_IDS.SECTION_BUBBLE_MENU,
280
+ FLOATING_ELEMENT_IDS.INLINE_IMAGE_BUBBLE_MENU,
281
+ FLOATING_ELEMENT_IDS.IMAGE_BUBBLE_MENU,
282
+ FLOATING_ELEMENT_IDS.LINK_CARD_BUBBLE_MENU,
283
+ FLOATING_ELEMENT_IDS.TEXT_BUBBLE_MENU
284
+ ];
285
+ //#endregion
286
+ //#region src/utils/selection.ts
287
+ const CONTAINER_NODES = [
288
+ _maily_to_shared.MAILY_NODE_TYPES.COLUMNS,
289
+ _maily_to_shared.MAILY_NODE_TYPES.REPEAT,
290
+ _maily_to_shared.MAILY_NODE_TYPES.SECTION,
291
+ _maily_to_shared.MAILY_NODE_TYPES.BUTTON,
292
+ _maily_to_shared.MAILY_NODE_TYPES.HTML_CODE_BLOCK
293
+ ];
294
+ function clearInitialNodeSelection(editor) {
295
+ const { state } = editor;
296
+ if (!(state.selection instanceof _tiptap_pm_state.NodeSelection)) return;
297
+ const textSelection = _tiptap_pm_state.Selection.findFrom(state.doc.resolve(0), 1, true);
298
+ if (textSelection) editor.view.dispatch(state.tr.setSelection(textSelection));
299
+ editor.view.dom.blur();
300
+ }
301
+ function findNodeClientRect(editor, nodeType) {
302
+ const activeNode = (0, _tiptap_react.findParentNode)((node) => node.type.name === nodeType)(editor.state.selection);
303
+ if (!activeNode) return null;
304
+ const dom = editor.view.nodeDOM(activeNode.pos);
305
+ return dom instanceof HTMLElement ? dom.getBoundingClientRect() : null;
306
+ }
307
+ /**
308
+ * Returns a DOMRect for the current selection. For nodes inside a
309
+ * container (columns, repeat, section, button, html code block), returns the
310
+ * container's rect so the bubble menu stays anchored to the block rather than
311
+ * the inline selection.
312
+ */
313
+ function getCurrentSelectionRect(editor) {
314
+ const { selection } = editor.state;
315
+ const { ranges } = selection;
316
+ const from = Math.min(...ranges.map((range) => range.$from.pos));
317
+ const to = Math.max(...ranges.map((range) => range.$to.pos));
318
+ for (const nodeType of CONTAINER_NODES) if (editor.isActive(nodeType)) return findNodeClientRect(editor, nodeType) ?? (0, _tiptap_react.posToDOMRect)(editor.view, from, to);
319
+ if ((0, _tiptap_react.isNodeSelection)(selection)) {
320
+ const node = editor.view.nodeDOM(from);
321
+ if (node instanceof HTMLElement) return node.getBoundingClientRect();
322
+ }
323
+ return (0, _tiptap_react.posToDOMRect)(editor.view, from, to);
324
+ }
325
+ /**
326
+ * Returns true if the current selection is non-empty, non-collapsed,
327
+ * and not on a disallowed node type.
328
+ */
329
+ function isValidSelection(editor, notAllowedNodes = []) {
330
+ const { doc, selection } = editor.state;
331
+ const { empty, from, to } = selection;
332
+ const isEmptyTextBlock = !doc.textBetween(from, to).length && (0, _tiptap_react.isTextSelection)(selection);
333
+ const isNotAllowedNode = (0, _tiptap_react.isNodeSelection)(selection) && notAllowedNodes.includes(selection.node.type.name);
334
+ return !isEmptyTextBlock && !empty && !isNotAllowedNode;
335
+ }
336
+ /**
337
+ * Sets cursor position at mouse coordinates to prevent flicker
338
+ * when clicking outside the floating bubble menu. Only moves the
339
+ * cursor if the target position is inside an inline-content parent
340
+ * (skips block nodes like images and lists).
341
+ */
342
+ function moveCursorToCoords(editor, coords) {
343
+ const { state, view } = editor;
344
+ const position = view.posAtCoords(coords);
345
+ if (!position || position.pos <= 0) return;
346
+ const $pos = state.doc.resolve(position.pos);
347
+ if (!$pos.parent.inlineContent) return;
348
+ view.dispatch(state.tr.setSelection(_tiptap_pm_state.Selection.near($pos)));
349
+ }
350
+ //#endregion
351
+ //#region src/components/interface/floating-element.tsx
352
+ const FLOATING_ELEMENT_PADDING = 8;
353
+ const FLOATING_ELEMENT_HEIGHT = 28;
354
+ const NOT_ALLOWED_NODES = [
355
+ _maily_to_shared.MAILY_NODE_TYPES.IMAGE,
356
+ _maily_to_shared.MAILY_NODE_TYPES.INLINE_IMAGE,
357
+ _maily_to_shared.MAILY_NODE_TYPES.SPACER,
358
+ _maily_to_shared.MAILY_NODE_TYPES.HORIZONTAL_RULE
359
+ ];
360
+ const FloatingElement = (0, react.forwardRef)((props, ref) => {
361
+ const $ = (0, react_compiler_runtime.c)(60);
362
+ const { children, editor: defaultEditor, floatingId, onOpenChange, open: defaultOpen, placement: t0 } = props;
363
+ const placement = t0 === void 0 ? "top" : t0;
364
+ const editor = useEditorInstance(defaultEditor);
365
+ const isDragContextOpen = useFloatingStore(_temp$2);
366
+ const preventShowRef = (0, react.useRef)(false);
367
+ const [isOpen, setIsOpen] = (0, react.useState)(defaultOpen ?? false);
368
+ const openRef = useValueAsRef(isOpen);
369
+ const elementRef = (0, react.useRef)(null);
370
+ let t1;
371
+ if ($[0] !== editor.commands || $[1] !== onOpenChange || $[2] !== openRef) {
372
+ t1 = (open, _event, reason) => {
373
+ if (!open && reason === "escape-key" && elementRef.current?.contains(document.activeElement)) editor.commands.focus();
374
+ setIsOpen(open);
375
+ onOpenChange?.(open);
376
+ openRef.current = open;
377
+ };
378
+ $[0] = editor.commands;
379
+ $[1] = onOpenChange;
380
+ $[2] = openRef;
381
+ $[3] = t1;
382
+ } else t1 = $[3];
383
+ const handleOpenChange = t1;
384
+ let t2;
385
+ if ($[4] !== editor.view.dom) {
386
+ t2 = (event) => {
387
+ const target = event.target;
388
+ const editorWrapper = editor.view.dom.parentElement;
389
+ if (!(0, _floating_ui_utils_dom.isHTMLElement)(target) || !editorWrapper) return false;
390
+ if (target.closest(`[data-mly-floating-element]`)) return false;
391
+ return !editorWrapper.contains(target);
392
+ };
393
+ $[4] = editor.view.dom;
394
+ $[5] = t2;
395
+ } else t2 = $[5];
396
+ const handleOutsidePress = t2;
397
+ let t3;
398
+ if ($[6] !== floatingId) {
399
+ t3 = (state_0) => {
400
+ const { contexts } = useFloatingStore.getState();
401
+ const index = [...contexts.filter((context) => context.id !== floatingId && context.value.open && context.value.placement === state_0.placement).map(_temp2$2), floatingId].sort(_temp3$1).indexOf(floatingId);
402
+ if (index === 0) return 8;
403
+ return index * 36 + 8;
404
+ };
405
+ $[6] = floatingId;
406
+ $[7] = t3;
407
+ } else t3 = $[7];
408
+ const bubbleMenuOffset = t3;
409
+ let t4;
410
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
411
+ t4 = (0, _floating_ui_react.shift)({ padding: 8 });
412
+ $[8] = t4;
413
+ } else t4 = $[8];
414
+ let t5;
415
+ if ($[9] !== bubbleMenuOffset) {
416
+ t5 = (0, _floating_ui_react.offset)(bubbleMenuOffset);
417
+ $[9] = bubbleMenuOffset;
418
+ $[10] = t5;
419
+ } else t5 = $[10];
420
+ let t6;
421
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
422
+ t6 = (0, _floating_ui_react.flip)();
423
+ $[11] = t6;
424
+ } else t6 = $[11];
425
+ let t7;
426
+ if ($[12] !== t5) {
427
+ t7 = [
428
+ t4,
429
+ t5,
430
+ t6
431
+ ];
432
+ $[12] = t5;
433
+ $[13] = t7;
434
+ } else t7 = $[13];
435
+ let t8;
436
+ if ($[14] !== floatingId || $[15] !== handleOpenChange || $[16] !== isOpen || $[17] !== placement || $[18] !== t7) {
437
+ t8 = {
438
+ nodeId: floatingId,
439
+ open: isOpen,
440
+ onOpenChange: handleOpenChange,
441
+ whileElementsMounted: _floating_ui_react.autoUpdate,
442
+ placement,
443
+ middleware: t7
444
+ };
445
+ $[14] = floatingId;
446
+ $[15] = handleOpenChange;
447
+ $[16] = isOpen;
448
+ $[17] = placement;
449
+ $[18] = t7;
450
+ $[19] = t8;
451
+ } else t8 = $[19];
452
+ const { context: context_1, floatingStyles, placement: floatingPlacement, refs } = (0, _floating_ui_react.useFloating)(t8);
453
+ useRegisterFloatingContext(floatingId, context_1);
454
+ let t9;
455
+ if ($[20] !== handleOutsidePress) {
456
+ t9 = {
457
+ enabled: true,
458
+ escapeKey: true,
459
+ outsidePress: handleOutsidePress
460
+ };
461
+ $[20] = handleOutsidePress;
462
+ $[21] = t9;
463
+ } else t9 = $[21];
464
+ const dismiss = (0, _floating_ui_react.useDismiss)(context_1, t9);
465
+ let t10;
466
+ if ($[22] !== dismiss) {
467
+ t10 = [dismiss];
468
+ $[22] = dismiss;
469
+ $[23] = t10;
470
+ } else t10 = $[23];
471
+ const { getReferenceProps } = (0, _floating_ui_react.useInteractions)(t10);
472
+ let t11;
473
+ if ($[24] !== defaultOpen || $[25] !== editor || $[26] !== refs) {
474
+ t11 = () => {
475
+ const preventShow = preventShowRef.current;
476
+ const rect = getCurrentSelectionRect(editor);
477
+ if (rect && defaultOpen !== void 0 && !preventShow) {
478
+ setIsOpen(defaultOpen);
479
+ refs.setReference({ getBoundingClientRect: () => rect });
480
+ return;
481
+ }
482
+ if (!isValidSelection(editor, NOT_ALLOWED_NODES) || preventShow || !editor.isEditable) {
483
+ setIsOpen(false);
484
+ return;
485
+ }
486
+ setIsOpen(true);
487
+ refs.setReference({ getBoundingClientRect: () => rect });
488
+ };
489
+ $[24] = defaultOpen;
490
+ $[25] = editor;
491
+ $[26] = refs;
492
+ $[27] = t11;
493
+ } else t11 = $[27];
494
+ const handleSelectionChange = t11;
495
+ useOnSelectionUpdate(editor, handleSelectionChange);
496
+ let t12;
497
+ let t13;
498
+ if ($[28] !== editor || $[29] !== handleSelectionChange) {
499
+ t12 = () => {
500
+ const editorView = editor.view;
501
+ const handleMouseDown = (event_0) => {
502
+ if (event_0.button !== 0) return;
503
+ preventShowRef.current = true;
504
+ if (event_0.detail <= 1) moveCursorToCoords(editor, {
505
+ left: event_0.clientX,
506
+ top: event_0.clientY
507
+ });
508
+ };
509
+ const handleMouseUp = () => {
510
+ if (!preventShowRef.current) return;
511
+ preventShowRef.current = false;
512
+ handleSelectionChange();
513
+ };
514
+ editorView.dom.addEventListener("mousedown", handleMouseDown);
515
+ editorView.root.addEventListener("mouseup", handleMouseUp);
516
+ return () => {
517
+ editorView.dom.removeEventListener("mousedown", handleMouseDown);
518
+ editorView.root.removeEventListener("mouseup", handleMouseUp);
519
+ };
520
+ };
521
+ t13 = [editor, handleSelectionChange];
522
+ $[28] = editor;
523
+ $[29] = handleSelectionChange;
524
+ $[30] = t12;
525
+ $[31] = t13;
526
+ } else {
527
+ t12 = $[30];
528
+ t13 = $[31];
529
+ }
530
+ (0, react.useEffect)(t12, t13);
531
+ let t14;
532
+ let t15;
533
+ if ($[32] !== handleSelectionChange || $[33] !== openRef) {
534
+ t14 = () => {
535
+ const handleResize = () => {
536
+ if (!openRef.current) return;
537
+ handleSelectionChange();
538
+ };
539
+ window.addEventListener("resize", handleResize);
540
+ window.addEventListener("scroll", handleResize);
541
+ return () => {
542
+ window.removeEventListener("resize", handleResize);
543
+ window.removeEventListener("scroll", handleResize);
544
+ };
545
+ };
546
+ t15 = [handleSelectionChange, openRef];
547
+ $[32] = handleSelectionChange;
548
+ $[33] = openRef;
549
+ $[34] = t14;
550
+ $[35] = t15;
551
+ } else {
552
+ t14 = $[34];
553
+ t15 = $[35];
554
+ }
555
+ (0, react.useEffect)(t14, t15);
556
+ let t16;
557
+ if ($[36] !== editor.view.dom || $[37] !== handleOpenChange) {
558
+ t16 = () => {
559
+ const editorViewDom = editor.view.dom;
560
+ const handleDrag = () => {
561
+ handleOpenChange(false);
562
+ };
563
+ editorViewDom.addEventListener("dragstart", handleDrag);
564
+ editorViewDom.addEventListener("dragover", handleDrag);
565
+ return () => {
566
+ editorViewDom.removeEventListener("dragstart", handleDrag);
567
+ editorViewDom.removeEventListener("dragover", handleDrag);
568
+ };
569
+ };
570
+ $[36] = editor.view.dom;
571
+ $[37] = handleOpenChange;
572
+ $[38] = t16;
573
+ } else t16 = $[38];
574
+ let t17;
575
+ if ($[39] !== editor || $[40] !== handleOpenChange) {
576
+ t17 = [editor, handleOpenChange];
577
+ $[39] = editor;
578
+ $[40] = handleOpenChange;
579
+ $[41] = t17;
580
+ } else t17 = $[41];
581
+ (0, react.useEffect)(t16, t17);
582
+ let t18;
583
+ if ($[42] !== ref || $[43] !== refs.setFloating) {
584
+ t18 = [
585
+ refs.setFloating,
586
+ elementRef,
587
+ ref
588
+ ];
589
+ $[42] = ref;
590
+ $[43] = refs.setFloating;
591
+ $[44] = t18;
592
+ } else t18 = $[44];
593
+ const finalRef = (0, _floating_ui_react.useMergeRefs)(t18);
594
+ let t19;
595
+ if ($[45] !== floatingId) {
596
+ t19 = FLOATING_ELEMENT_ORDER.toReversed().indexOf(floatingId);
597
+ $[45] = floatingId;
598
+ $[46] = t19;
599
+ } else t19 = $[46];
600
+ const zIndex = 99 - t19 * (floatingPlacement === "top" ? 1 : -1);
601
+ if (!isOpen || isDragContextOpen) return null;
602
+ let t20;
603
+ if ($[47] !== getReferenceProps) {
604
+ t20 = getReferenceProps();
605
+ $[47] = getReferenceProps;
606
+ $[48] = t20;
607
+ } else t20 = $[48];
608
+ let t21;
609
+ if ($[49] !== floatingId) {
610
+ t21 = { [FLOATING_ELEMENT_ATTRIBUTE]: floatingId };
611
+ $[49] = floatingId;
612
+ $[50] = t21;
613
+ } else t21 = $[50];
614
+ let t22;
615
+ if ($[51] !== floatingStyles || $[52] !== zIndex) {
616
+ t22 = {
617
+ ...floatingStyles,
618
+ zIndex
619
+ };
620
+ $[51] = floatingStyles;
621
+ $[52] = zIndex;
622
+ $[53] = t22;
623
+ } else t22 = $[53];
624
+ let t23;
625
+ if ($[54] !== children || $[55] !== finalRef || $[56] !== t20 || $[57] !== t21 || $[58] !== t22) {
626
+ t23 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
627
+ ...t20,
628
+ ...t21,
629
+ ref: finalRef,
630
+ style: t22,
631
+ children
632
+ });
633
+ $[54] = children;
634
+ $[55] = finalRef;
635
+ $[56] = t20;
636
+ $[57] = t21;
637
+ $[58] = t22;
638
+ $[59] = t23;
639
+ } else t23 = $[59];
640
+ return t23;
641
+ });
642
+ FloatingElement.displayName = "FloatingElement";
643
+ function _temp$2(state) {
644
+ return state.isDragContextOpen;
645
+ }
646
+ function _temp2$2(context_0) {
647
+ return context_0.id;
648
+ }
649
+ function _temp3$1(a, b) {
650
+ return FLOATING_ELEMENT_ORDER.indexOf(a) - FLOATING_ELEMENT_ORDER.indexOf(b);
651
+ }
652
+ //#endregion
653
+ //#region src/components/interface/tooltip.tsx
654
+ const Tooltip = _base_ui_react_tooltip.Tooltip.Root;
655
+ const TooltipProvider = _base_ui_react_tooltip.Tooltip.Provider;
656
+ const TooltipTrigger = _base_ui_react_tooltip.Tooltip.Trigger;
657
+ function TooltipPositioner(props) {
658
+ const $ = (0, react_compiler_runtime.c)(10);
659
+ let container;
660
+ let rest;
661
+ let t0;
662
+ if ($[0] !== props) {
663
+ ({container, sideOffset: t0, ...rest} = props);
664
+ $[0] = props;
665
+ $[1] = container;
666
+ $[2] = rest;
667
+ $[3] = t0;
668
+ } else {
669
+ container = $[1];
670
+ rest = $[2];
671
+ t0 = $[3];
672
+ }
673
+ const sideOffset = t0 === void 0 ? 8 : t0;
674
+ let t1;
675
+ if ($[4] !== rest || $[5] !== sideOffset) {
676
+ t1 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_tooltip.Tooltip.Positioner, {
677
+ sideOffset,
678
+ ...rest
679
+ });
680
+ $[4] = rest;
681
+ $[5] = sideOffset;
682
+ $[6] = t1;
683
+ } else t1 = $[6];
684
+ let t2;
685
+ if ($[7] !== container || $[8] !== t1) {
686
+ t2 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_tooltip.Tooltip.Portal, {
687
+ container,
688
+ children: t1
689
+ });
690
+ $[7] = container;
691
+ $[8] = t1;
692
+ $[9] = t2;
693
+ } else t2 = $[9];
694
+ return t2;
695
+ }
696
+ function TooltipPopup(props) {
697
+ const $ = (0, react_compiler_runtime.c)(2);
698
+ let t0;
699
+ if ($[0] !== props) {
700
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_tooltip.Tooltip.Popup, {
701
+ "data-mly-tooltip": "",
702
+ ...props
703
+ });
704
+ $[0] = props;
705
+ $[1] = t0;
706
+ } else t0 = $[1];
707
+ return t0;
708
+ }
709
+ function TooltipArrow(props) {
710
+ const $ = (0, react_compiler_runtime.c)(3);
711
+ let t0;
712
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
713
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ArrowIcon, {});
714
+ $[0] = t0;
715
+ } else t0 = $[0];
716
+ let t1;
717
+ if ($[1] !== props) {
718
+ t1 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_tooltip.Tooltip.Arrow, {
719
+ "data-mly-tooltip-arrow": "",
720
+ ...props,
721
+ children: t0
722
+ });
723
+ $[1] = props;
724
+ $[2] = t1;
725
+ } else t1 = $[2];
726
+ return t1;
727
+ }
728
+ //#endregion
729
+ //#region src/utils/theme.ts
730
+ const HEADING_LEVEL_PATTERN = /^h[1-6]$/;
731
+ function getThemeSelector(type) {
732
+ const nodeType = HEADING_LEVEL_PATTERN.test(type) ? _maily_to_shared.MAILY_NODE_TYPES.HEADING : type;
733
+ return `${nodeType === type ? "" : type}[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${nodeType}"]`;
734
+ }
735
+ function getNodeTheme(editor) {
736
+ return editor.state.doc.attrs.theme ?? {};
737
+ }
738
+ function getMergedNodeTheme(options) {
739
+ const { theme, update } = options;
740
+ const merged = (0, _maily_to_shared.deepMerge)(theme, update);
741
+ const next = {};
742
+ for (const [type, declarations] of Object.entries(merged)) {
743
+ if (!declarations) continue;
744
+ const kept = {};
745
+ for (const [property, value] of Object.entries(declarations)) {
746
+ if (value === null || value === void 0 || value === "") continue;
747
+ kept[property] = value;
748
+ }
749
+ if (Object.keys(kept).length > 0) next[type] = kept;
750
+ }
751
+ return next;
752
+ }
753
+ function getNodeStyleState(options) {
754
+ const { editor, type } = options;
755
+ const attrs = editor.getAttributes(type);
756
+ const authored = (0, _maily_to_shared.parseInlineStyles)(attrs.style ?? "");
757
+ const theme = (0, _maily_to_shared.getThemeDeclarations)({
758
+ attrs,
759
+ theme: getNodeTheme(editor),
760
+ type
761
+ }) ?? {};
762
+ return {
763
+ authored,
764
+ resolved: (0, _maily_to_shared.mergeInlineStyles)(theme, authored)
765
+ };
766
+ }
767
+ function getTypeSelector(type) {
768
+ return `[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${type}"]`;
769
+ }
770
+ function getSuppressionRules(options) {
771
+ const { declarations, scope, selector } = options;
772
+ const outside = _maily_to_shared.BLOCK_CONTAINER_TYPES.map(getTypeSelector).join(",");
773
+ const rules = [];
774
+ if (declarations.marginTop && declarations.marginTop !== "0") {
775
+ const absorbers = _maily_to_shared.MARGIN_TOP_ABSORBER_TYPES.map((type) => {
776
+ return `${scope} ${getTypeSelector(type)}+${selector}`;
777
+ });
778
+ rules.push(`${[`${scope} ${selector}:first-child`, ...absorbers].join(",")}{margin-top:0}`);
779
+ }
780
+ if (declarations.marginBottom && declarations.marginBottom !== "0") {
781
+ const absorbers = _maily_to_shared.MARGIN_BOTTOM_ABSORBER_TYPES.map((type) => {
782
+ return `${scope} ${selector}:has(+${getTypeSelector(type)})`;
783
+ });
784
+ rules.push(`${[`${scope} ${selector}:last-child`, ...absorbers].join(",")}{margin-bottom:0}`);
785
+ }
786
+ if (rules.length > 0) rules.push(`${scope} :not(${outside})>${selector}{margin-top:0;margin-bottom:0}`);
787
+ return rules;
788
+ }
789
+ function getThemeCss(options) {
790
+ const { scope, theme } = options;
791
+ const rules = [];
792
+ for (const [type, declarations] of Object.entries(theme)) {
793
+ const selector = getThemeSelector(type);
794
+ const style = (0, _maily_to_shared.stringifyInlineStyles)(declarations);
795
+ if (style) {
796
+ rules.push(`${scope} ${selector}{${style}}`);
797
+ rules.push(...getSuppressionRules({
798
+ declarations,
799
+ scope,
800
+ selector
801
+ }));
802
+ }
803
+ }
804
+ return rules.join("");
805
+ }
806
+ function getChildEntries(options) {
807
+ const { offset, parent, type } = options;
808
+ const entries = [];
809
+ let position = offset;
810
+ parent.forEach((child) => {
811
+ if (child.type.name === type) entries.push({
812
+ node: child,
813
+ position
814
+ });
815
+ position += child.nodeSize;
816
+ });
817
+ return entries;
818
+ }
819
+ function getShellNodes(options) {
820
+ const { doc, type } = options;
821
+ const bodies = getChildEntries({
822
+ offset: 0,
823
+ parent: doc,
824
+ type: _maily_to_shared.MAILY_NODE_TYPES.BODY
825
+ });
826
+ if (type === _maily_to_shared.MAILY_NODE_TYPES.BODY) return bodies;
827
+ return bodies.flatMap((body) => {
828
+ return getChildEntries({
829
+ offset: body.position + 1,
830
+ parent: body.node,
831
+ type
832
+ });
833
+ });
834
+ }
835
+ //#endregion
836
+ //#region src/extensions/document/document.ts
837
+ const DOCUMENT_VERSION = 2;
838
+ const Document = _tiptap_extension_document.Document.extend({
839
+ content: _maily_to_shared.MAILY_NODE_TYPES.BODY,
840
+ addAttributes() {
841
+ return {
842
+ ...this.parent?.(),
843
+ version: { default: DOCUMENT_VERSION }
844
+ };
845
+ }
846
+ });
847
+ //#endregion
848
+ //#region ../extension-variable/dist/index.mjs
849
+ function getMarksAt(options) {
850
+ const { pos, state } = options;
851
+ return (state.storedMarks ?? state.doc.resolve(pos).marks()).map((mark) => {
852
+ return {
853
+ attrs: mark.attrs,
854
+ type: mark.type.name
855
+ };
856
+ });
857
+ }
858
+ /**
859
+ * Returns the suggestion options for a trigger of the Variable extension. These
860
+ * options are used to create a `Suggestion` ProseMirror plugin. Each plugin lets
861
+ * you define a different trigger that opens the variable menu. For example,
862
+ * you can define a `{{` trigger to insert variables and a `#` trigger to insert
863
+ * tags.
864
+ */
865
+ function getSuggestionOptions(options) {
866
+ const { addSpaceSuffix = true, char = _maily_to_shared.DEFAULT_VARIABLE_START_TRIGGER, editor: tiptapEditor, extensionName, overrideSuggestionOptions, shouldScrollIntoView = false } = options;
867
+ return {
868
+ editor: tiptapEditor,
869
+ char,
870
+ pluginKey: new _tiptap_pm_state.PluginKey(`variable-${char}`),
871
+ command: ({ editor, props, range }) => {
872
+ if (editor.view.state.selection.$to.nodeAfter?.text?.startsWith(" ")) range.to += 1;
873
+ const marks = getMarksAt({
874
+ pos: range.from,
875
+ state: editor.view.state
876
+ });
877
+ let chain = editor.chain().focus().insertContentAt(range, [{
878
+ type: extensionName,
879
+ attrs: {
880
+ ...props,
881
+ variableSuggestionChar: char
882
+ },
883
+ marks
884
+ }, ...addSpaceSuffix ? [{
885
+ type: "text",
886
+ text: " ",
887
+ marks
888
+ }] : []]);
889
+ if (shouldScrollIntoView) chain = chain.scrollIntoView();
890
+ chain.run();
891
+ editor.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd();
892
+ },
893
+ allow: ({ range, state }) => {
894
+ return !!state.doc.resolve(range.from).parent.type.contentMatch.matchType(state.schema.nodes[extensionName]);
895
+ },
896
+ ...overrideSuggestionOptions
897
+ };
898
+ }
899
+ function getSuggestions(options) {
900
+ return (options.options.suggestions.length ? options.options.suggestions : [options.options.suggestion]).map((suggestion) => getSuggestionOptions({
901
+ addSpaceSuffix: options.options.addSpaceSuffix,
902
+ char: suggestion.char,
903
+ editor: options.editor,
904
+ extensionName: options.name,
905
+ overrideSuggestionOptions: suggestion,
906
+ shouldScrollIntoView: options.options.shouldScrollIntoView
907
+ }));
908
+ }
909
+ function getSuggestionFromChar(options, char) {
910
+ const suggestions = getSuggestions(options);
911
+ return suggestions.find((item) => item.char === char) ?? suggestions[0] ?? null;
912
+ }
913
+ function getVariableLabel$1(node, suggestion) {
914
+ return `${suggestion?.char ?? _maily_to_shared.DEFAULT_VARIABLE_START_TRIGGER}${node.attrs.label ?? node.attrs.id}`;
915
+ }
916
+ const Variable = _tiptap_core.Node.create({
917
+ name: _maily_to_shared.MAILY_NODE_TYPES.VARIABLE,
918
+ priority: 101,
919
+ group: "inline",
920
+ inline: true,
921
+ selectable: true,
922
+ atom: true,
923
+ addOptions() {
924
+ return {
925
+ addSpaceSuffix: true,
926
+ deleteTriggerWithBackspace: false,
927
+ HTMLAttributes: {},
928
+ renderHTML({ node, options, suggestion }) {
929
+ return [
930
+ "span",
931
+ (0, _tiptap_core.mergeAttributes)(options.HTMLAttributes),
932
+ getVariableLabel$1(node, suggestion)
933
+ ];
934
+ },
935
+ renderText({ node, suggestion }) {
936
+ return getVariableLabel$1(node, suggestion);
937
+ },
938
+ shouldScrollIntoView: false,
939
+ suggestion: {},
940
+ suggestions: []
941
+ };
942
+ },
943
+ addAttributes() {
944
+ return {
945
+ id: {
946
+ parseHTML: (element) => element.getAttribute("data-id"),
947
+ renderHTML: (attributes) => attributes.id ? { "data-id": attributes.id } : {}
948
+ },
949
+ label: {
950
+ default: _maily_to_shared.DEFAULT_VARIABLE_ATTRIBUTES.label,
951
+ parseHTML: (element) => element.getAttribute("data-label"),
952
+ renderHTML: (attributes) => attributes.label ? { "data-label": attributes.label } : {}
953
+ },
954
+ variableSuggestionChar: {
955
+ default: _maily_to_shared.DEFAULT_VARIABLE_START_TRIGGER,
956
+ parseHTML: (element) => element.getAttribute("data-variable-suggestion-char") ?? _maily_to_shared.DEFAULT_VARIABLE_START_TRIGGER,
957
+ renderHTML: (attributes) => ({ "data-variable-suggestion-char": attributes.variableSuggestionChar })
958
+ },
959
+ fallback: {
960
+ default: _maily_to_shared.DEFAULT_VARIABLE_ATTRIBUTES.fallback,
961
+ parseHTML: (element) => element.getAttribute("data-fallback"),
962
+ renderHTML: (attributes) => attributes.fallback ? { "data-fallback": attributes.fallback } : {}
963
+ },
964
+ required: {
965
+ default: _maily_to_shared.DEFAULT_VARIABLE_ATTRIBUTES.required,
966
+ parseHTML: (element) => element.getAttribute("data-required") !== "false",
967
+ renderHTML: (attributes) => ({ "data-required": String(attributes.required) })
968
+ },
969
+ isDefaultEditable: {
970
+ default: _maily_to_shared.DEFAULT_VARIABLE_ATTRIBUTES.isDefaultEditable,
971
+ parseHTML: (element) => element.getAttribute("data-is-default-editable") !== "false" && element.getAttribute("data-hide-default-value") !== "true",
972
+ renderHTML: (attributes) => ({ "data-is-default-editable": String(attributes.isDefaultEditable) })
973
+ }
974
+ };
975
+ },
976
+ addCommands() {
977
+ return { insertVariable: (attrs) => ({ commands, state }) => commands.insertContent({
978
+ type: this.name,
979
+ attrs,
980
+ marks: getMarksAt({
981
+ pos: state.selection.from,
982
+ state
983
+ })
984
+ }) };
985
+ },
986
+ parseHTML() {
987
+ return [{ tag: `span[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${this.name}"]` }];
988
+ },
989
+ renderHTML({ HTMLAttributes, node }) {
990
+ const options = {
991
+ ...this.options,
992
+ HTMLAttributes: (0, _tiptap_core.mergeAttributes)({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: this.name }, this.options.HTMLAttributes, HTMLAttributes)
993
+ };
994
+ return this.options.renderHTML({
995
+ node,
996
+ options,
997
+ suggestion: getSuggestionFromChar(this, node.attrs.variableSuggestionChar)
998
+ });
999
+ },
1000
+ renderText({ node }) {
1001
+ return this.options.renderText({
1002
+ node,
1003
+ options: this.options,
1004
+ suggestion: getSuggestionFromChar(this, node.attrs.variableSuggestionChar)
1005
+ });
1006
+ },
1007
+ addKeyboardShortcuts() {
1008
+ return { Backspace: () => this.editor.commands.command(({ state, tr }) => {
1009
+ const { anchor, empty } = state.selection;
1010
+ if (!empty) return false;
1011
+ let matched = null;
1012
+ let matchedPos = 0;
1013
+ state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
1014
+ if (node.type.name === this.name) {
1015
+ matched = node;
1016
+ matchedPos = pos;
1017
+ return false;
1018
+ }
1019
+ return true;
1020
+ });
1021
+ if (!matched) return false;
1022
+ const variableNode = matched;
1023
+ tr.insertText(this.options.deleteTriggerWithBackspace ? "" : variableNode.attrs.variableSuggestionChar, matchedPos, matchedPos + variableNode.nodeSize);
1024
+ return true;
1025
+ }) };
1026
+ },
1027
+ addProseMirrorPlugins() {
1028
+ return getSuggestions(this).map(_tiptap_suggestion.Suggestion);
1029
+ }
1030
+ });
1031
+ //#endregion
1032
+ //#region src/utils/variable.ts
1033
+ const VARIABLE_SUGGESTION_POPOVER_ID = "mly-variable-suggestion-popover";
1034
+ function getVariableLabel(item) {
1035
+ return item.label ?? item.id ?? "";
1036
+ }
1037
+ /**
1038
+ * Filters the variable list by query prefix. If no exact match exists,
1039
+ * appends a dynamic entry so users can create variables on the fly.
1040
+ */
1041
+ function filterVariableSuggestions(variables = [], opts) {
1042
+ if (typeof variables === "function") return variables(opts);
1043
+ const query = opts.query.toLowerCase();
1044
+ const filtered = variables.filter((item) => getVariableLabel(item).toLowerCase().startsWith(query));
1045
+ if (!variables.some((item) => getVariableLabel(item).toLowerCase() === query) && query.length > 0) filtered.push({
1046
+ id: opts.query,
1047
+ label: opts.query,
1048
+ required: true,
1049
+ isDefaultEditable: true
1050
+ });
1051
+ return filtered;
1052
+ }
1053
+ //#endregion
1054
+ //#region src/components/interface/suggestion.tsx
1055
+ function SuggestionWrapper(props) {
1056
+ const $ = (0, react_compiler_runtime.c)(2);
1057
+ let t0;
1058
+ if ($[0] !== props) {
1059
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1060
+ ...props,
1061
+ "data-mly-suggestion": ""
1062
+ });
1063
+ $[0] = props;
1064
+ $[1] = t0;
1065
+ } else t0 = $[1];
1066
+ return t0;
1067
+ }
1068
+ function SuggestionHeader(props) {
1069
+ const $ = (0, react_compiler_runtime.c)(2);
1070
+ let t0;
1071
+ if ($[0] !== props) {
1072
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1073
+ ...props,
1074
+ "data-mly-suggestion-header": ""
1075
+ });
1076
+ $[0] = props;
1077
+ $[1] = t0;
1078
+ } else t0 = $[1];
1079
+ return t0;
1080
+ }
1081
+ function SuggestionKeyIcon(props) {
1082
+ const $ = (0, react_compiler_runtime.c)(2);
1083
+ let t0;
1084
+ if ($[0] !== props.children) {
1085
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1086
+ "data-mly-suggestion-key": "",
1087
+ children: props.children
1088
+ });
1089
+ $[0] = props.children;
1090
+ $[1] = t0;
1091
+ } else t0 = $[1];
1092
+ return t0;
1093
+ }
1094
+ function SuggestionFooter() {
1095
+ const $ = (0, react_compiler_runtime.c)(3);
1096
+ let t0;
1097
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1098
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SuggestionKeyIcon, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowDownIcon, { size: 12 }) });
1099
+ $[0] = t0;
1100
+ } else t0 = $[0];
1101
+ let t1;
1102
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
1103
+ t1 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1104
+ "data-mly-suggestion-hint": "",
1105
+ children: [
1106
+ t0,
1107
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SuggestionKeyIcon, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowUpIcon, { size: 12 }) }),
1108
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Navigate" })
1109
+ ]
1110
+ });
1111
+ $[1] = t1;
1112
+ } else t1 = $[1];
1113
+ let t2;
1114
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
1115
+ t2 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1116
+ "data-mly-suggestion-footer": "",
1117
+ children: [t1, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SuggestionKeyIcon, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CornerDownLeftIcon, { size: 12 }) })]
1118
+ });
1119
+ $[2] = t2;
1120
+ } else t2 = $[2];
1121
+ return t2;
1122
+ }
1123
+ //#endregion
1124
+ //#region src/hooks/use-scroll-into-view.ts
1125
+ function useScrollIntoView(deps = []) {
1126
+ const containerRef = (0, react.useRef)(null);
1127
+ const activeRef = (0, react.useRef)(null);
1128
+ (0, react.useLayoutEffect)(() => {
1129
+ const container = containerRef.current;
1130
+ const activeElement = activeRef.current;
1131
+ if (!container || !activeElement) return;
1132
+ const { offsetHeight, offsetTop } = activeElement;
1133
+ container.scrollTop = offsetTop - container.getBoundingClientRect().height / 2 + offsetHeight / 2;
1134
+ }, deps);
1135
+ return {
1136
+ activeRef,
1137
+ containerRef
1138
+ };
1139
+ }
1140
+ //#endregion
1141
+ //#region src/utils/composite.ts
1142
+ const ARROW_UP = "ArrowUp";
1143
+ const ARROW_DOWN = "ArrowDown";
1144
+ const HOME = "Home";
1145
+ const ENTER = "Enter";
1146
+ //#endregion
1147
+ //#region src/extensions/variable/variable-suggestions-popover.tsx
1148
+ const NAVIGATION_KEYS$1 = /* @__PURE__ */ new Set([
1149
+ ARROW_UP,
1150
+ ARROW_DOWN,
1151
+ ENTER,
1152
+ HOME,
1153
+ "End"
1154
+ ]);
1155
+ const VariableSuggestionsPopover = (0, react.forwardRef)((props, ref) => {
1156
+ const { items, onSelectItem } = props;
1157
+ const [selectedIndex, setSelectedIndex] = (0, react.useState)(0);
1158
+ const [prevItems, setPrevItems] = (0, react.useState)(items);
1159
+ const { activeRef: activeItemRef, containerRef: scrollContainerRef } = useScrollIntoView([selectedIndex]);
1160
+ if (prevItems !== items) {
1161
+ setPrevItems(items);
1162
+ setSelectedIndex(0);
1163
+ if (scrollContainerRef.current) scrollContainerRef.current.scrollTop = 0;
1164
+ }
1165
+ (0, react.useImperativeHandle)(ref, () => ({ onKeyDown: (event) => {
1166
+ if (!NAVIGATION_KEYS$1.has(event.key) || !items.length) return false;
1167
+ let newIndex = selectedIndex;
1168
+ let shouldSelect = false;
1169
+ switch (event.key) {
1170
+ case HOME:
1171
+ newIndex = 0;
1172
+ break;
1173
+ case "End":
1174
+ newIndex = items.length - 1;
1175
+ break;
1176
+ case ARROW_UP:
1177
+ newIndex = (selectedIndex + items.length - 1) % items.length;
1178
+ break;
1179
+ case ARROW_DOWN:
1180
+ newIndex = (selectedIndex + 1) % items.length;
1181
+ break;
1182
+ case ENTER:
1183
+ shouldSelect = true;
1184
+ break;
1185
+ default: return false;
1186
+ }
1187
+ event.preventDefault();
1188
+ if (shouldSelect) {
1189
+ const item = items[selectedIndex];
1190
+ if (item) onSelectItem(item);
1191
+ return true;
1192
+ }
1193
+ if (newIndex !== selectedIndex) setSelectedIndex(newIndex);
1194
+ return true;
1195
+ } }));
1196
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(SuggestionWrapper, { children: [
1197
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(SuggestionHeader, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Variables" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SuggestionKeyIcon, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.BracesIcon, { size: 12 }) })] }),
1198
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1199
+ "data-mly-suggestion-body": "",
1200
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1201
+ "data-axis": "y",
1202
+ "data-mly-scroll-fade": "",
1203
+ "data-mly-suggestion-scroll": "",
1204
+ ref: scrollContainerRef,
1205
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1206
+ "data-mly-suggestion-items": "",
1207
+ children: [items.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1208
+ "data-mly-suggestion-item": "",
1209
+ "data-selected": index === selectedIndex ? "" : void 0,
1210
+ onClick: () => onSelectItem(item),
1211
+ ref: index === selectedIndex ? activeItemRef : null,
1212
+ type: "button",
1213
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.BracesIcon, {
1214
+ "data-mly-suggestion-item-icon": "",
1215
+ size: 12
1216
+ }), item.label || item.id]
1217
+ }, item.id ?? index)), items.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1218
+ "data-mly-suggestion-empty": "",
1219
+ children: "No result"
1220
+ }) : null]
1221
+ })
1222
+ })
1223
+ }),
1224
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SuggestionFooter, {})
1225
+ ] });
1226
+ });
1227
+ VariableSuggestionsPopover.displayName = "VariableSuggestionsPopover";
1228
+ //#endregion
1229
+ //#region src/extensions/variable/variable-suggestion-list.tsx
1230
+ const VariableSuggestionList = (0, react.forwardRef)((props, ref) => {
1231
+ const $ = (0, react_compiler_runtime.c)(6);
1232
+ const { command: selectItem, items } = props;
1233
+ const popoverRef = (0, react.useRef)(null);
1234
+ let t0;
1235
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1236
+ t0 = () => ({ onKeyDown: (t1) => {
1237
+ const { event } = t1;
1238
+ return popoverRef.current?.onKeyDown(event) ?? false;
1239
+ } });
1240
+ $[0] = t0;
1241
+ } else t0 = $[0];
1242
+ (0, react.useImperativeHandle)(ref, t0);
1243
+ let t1;
1244
+ if ($[1] !== selectItem) {
1245
+ t1 = (value) => {
1246
+ selectItem({
1247
+ id: value.id,
1248
+ isDefaultEditable: value.isDefaultEditable ?? value.hideDefaultValue !== true,
1249
+ label: value.label,
1250
+ required: value.required ?? true
1251
+ });
1252
+ };
1253
+ $[1] = selectItem;
1254
+ $[2] = t1;
1255
+ } else t1 = $[2];
1256
+ let t2;
1257
+ if ($[3] !== items || $[4] !== t1) {
1258
+ t2 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VariableSuggestionsPopover, {
1259
+ items,
1260
+ onSelectItem: t1,
1261
+ ref: popoverRef
1262
+ });
1263
+ $[3] = items;
1264
+ $[4] = t1;
1265
+ $[5] = t2;
1266
+ } else t2 = $[5];
1267
+ return t2;
1268
+ });
1269
+ VariableSuggestionList.displayName = "VariableSuggestionList";
1270
+ //#endregion
1271
+ //#region src/extensions/variable/variable-suggestion.ts
1272
+ async function updatePosition$1(editor, element, range) {
1273
+ const position = await (0, _floating_ui_react.computePosition)({ getBoundingClientRect: () => (0, _tiptap_react.posToDOMRect)(editor.view, range.from, range.to) }, element, {
1274
+ placement: "bottom-start",
1275
+ strategy: "absolute",
1276
+ middleware: [
1277
+ (0, _floating_ui_react.shift)(),
1278
+ (0, _floating_ui_react.flip)(),
1279
+ (0, _floating_ui_react.offset)(8)
1280
+ ]
1281
+ });
1282
+ element.style.width = "max-content";
1283
+ element.style.position = position.strategy;
1284
+ element.style.left = `${position.x}px`;
1285
+ element.style.top = `${position.y}px`;
1286
+ element.style.zIndex = "9999";
1287
+ }
1288
+ function getVariableSuggestions(char = _maily_to_shared.DEFAULT_VARIABLE_START_TRIGGER) {
1289
+ return {
1290
+ char,
1291
+ items: ({ editor, query }) => filterVariableSuggestions(editor.storage.variable?.variables, {
1292
+ editor,
1293
+ query
1294
+ }),
1295
+ render: () => {
1296
+ let component = null;
1297
+ return {
1298
+ onStart: async (props) => {
1299
+ const { editor, range } = props;
1300
+ const parentElement = editor.view.dom.parentElement;
1301
+ if (!parentElement) return;
1302
+ component = new _tiptap_react.ReactRenderer(VariableSuggestionList, {
1303
+ editor,
1304
+ props
1305
+ });
1306
+ if (!props.clientRect) return;
1307
+ component.element.style.position = "absolute";
1308
+ component.element.id = VARIABLE_SUGGESTION_POPOVER_ID;
1309
+ parentElement.append(component.element);
1310
+ await updatePosition$1(editor, component.element, range);
1311
+ },
1312
+ onUpdate: async (props) => {
1313
+ const { editor, range } = props;
1314
+ if (!component) return;
1315
+ component.updateProps(props);
1316
+ if (!props.clientRect) return;
1317
+ await updatePosition$1(editor, component.element, range);
1318
+ },
1319
+ onKeyDown(props) {
1320
+ if (!component) return false;
1321
+ if (props.event.key === "Escape") {
1322
+ component.destroy();
1323
+ return true;
1324
+ }
1325
+ return component.ref?.onKeyDown(props) ?? false;
1326
+ },
1327
+ onExit() {
1328
+ if (!component) return;
1329
+ component.element.remove();
1330
+ component.destroy();
1331
+ }
1332
+ };
1333
+ }
1334
+ };
1335
+ }
1336
+ //#endregion
1337
+ //#region src/extensions/variable/variable-view.tsx
1338
+ function VariableView(props) {
1339
+ const $ = (0, react_compiler_runtime.c)(6);
1340
+ const { node } = props;
1341
+ const { id, label } = node.attrs;
1342
+ let t0;
1343
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1344
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1345
+ "data-mly-variable-trigger": "",
1346
+ children: [_maily_to_shared.DEFAULT_VARIABLE_START_TRIGGER, "\xA0"]
1347
+ });
1348
+ $[0] = t0;
1349
+ } else t0 = $[0];
1350
+ const t1 = label ?? id;
1351
+ let t2;
1352
+ if ($[1] !== t1) {
1353
+ t2 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1354
+ "data-mly-variable-label": "",
1355
+ children: t1
1356
+ });
1357
+ $[1] = t1;
1358
+ $[2] = t2;
1359
+ } else t2 = $[2];
1360
+ let t3;
1361
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
1362
+ t3 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1363
+ "data-mly-variable-trigger": "",
1364
+ children: ["\xA0", _maily_to_shared.DEFAULT_VARIABLE_END_TRIGGER]
1365
+ });
1366
+ $[3] = t3;
1367
+ } else t3 = $[3];
1368
+ let t4;
1369
+ if ($[4] !== t2) {
1370
+ t4 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_tiptap_react.NodeViewWrapper, {
1371
+ as: "span",
1372
+ "data-mly-variable": "",
1373
+ children: [
1374
+ t0,
1375
+ t2,
1376
+ t3
1377
+ ]
1378
+ });
1379
+ $[4] = t2;
1380
+ $[5] = t4;
1381
+ } else t4 = $[5];
1382
+ return t4;
1383
+ }
1384
+ //#endregion
1385
+ //#region src/extensions/variable/variable.ts
1386
+ const VariableExtension = Variable.extend({
1387
+ addOptions() {
1388
+ return {
1389
+ ...this.parent?.(),
1390
+ isIdEditable: true,
1391
+ variables: void 0
1392
+ };
1393
+ },
1394
+ addStorage() {
1395
+ return {
1396
+ isIdEditable: this.options.isIdEditable,
1397
+ variables: this.options.variables
1398
+ };
1399
+ },
1400
+ addNodeView() {
1401
+ return (0, _tiptap_react.ReactNodeViewRenderer)(VariableView, { attrs: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: this.name } });
1402
+ }
1403
+ }).configure({ suggestion: getVariableSuggestions() });
1404
+ //#endregion
1405
+ //#region src/utils/spacing.ts
1406
+ const MIN_SPACER_HEIGHT = 1;
1407
+ const MAX_SPACER_HEIGHT = 1e3;
1408
+ const SPACER_SPACING = [
1409
+ {
1410
+ displayValue: "XS",
1411
+ label: "Extra Small",
1412
+ value: 4
1413
+ },
1414
+ {
1415
+ displayValue: "SM",
1416
+ label: "Small",
1417
+ value: 8
1418
+ },
1419
+ {
1420
+ displayValue: "MD",
1421
+ label: "Medium",
1422
+ value: 16
1423
+ },
1424
+ {
1425
+ displayValue: "LG",
1426
+ label: "Large",
1427
+ value: 32
1428
+ },
1429
+ {
1430
+ displayValue: "XL",
1431
+ label: "Extra Large",
1432
+ value: 64
1433
+ }
1434
+ ];
1435
+ const SPACING_PRESETS = [
1436
+ {
1437
+ label: "None",
1438
+ value: 0
1439
+ },
1440
+ {
1441
+ label: "Small",
1442
+ value: 8
1443
+ },
1444
+ {
1445
+ label: "Medium",
1446
+ value: 16
1447
+ },
1448
+ {
1449
+ label: "Large",
1450
+ value: 32
1451
+ }
1452
+ ];
1453
+ //#endregion
1454
+ //#region src/utils/columns.ts
1455
+ function getClosestColumns(editor) {
1456
+ return (0, _tiptap_core.findParentNode)((node) => node.type.name === _maily_to_shared.MAILY_NODE_TYPES.COLUMNS)(editor.state.selection);
1457
+ }
1458
+ function getColumnWidths(editor) {
1459
+ const columns = getClosestColumns(editor);
1460
+ if (!columns) return [];
1461
+ const widths = [];
1462
+ columns.node.forEach((child) => {
1463
+ if (child.type.name === _maily_to_shared.MAILY_NODE_TYPES.COLUMN) {
1464
+ const width = child.attrs.width;
1465
+ widths.push(typeof width === "number" ? width : null);
1466
+ }
1467
+ });
1468
+ return widths;
1469
+ }
1470
+ function updateColumnWidth(editor, columnIndex, width) {
1471
+ const columns = getClosestColumns(editor);
1472
+ if (!columns) return false;
1473
+ const { node: columnsNode, pos: columnsPos } = columns;
1474
+ const { dispatch, state } = editor.view;
1475
+ const { selection, tr } = state;
1476
+ const selectionRelative = {
1477
+ from: selection.from - columnsPos,
1478
+ to: selection.to - columnsPos
1479
+ };
1480
+ const updatedContent = [];
1481
+ columnsNode.content.forEach((child, _, index) => {
1482
+ updatedContent.push(child.type.create({
1483
+ ...child.attrs,
1484
+ width: index === columnIndex ? width : child.attrs.width
1485
+ }, child.content));
1486
+ });
1487
+ const transaction = tr.replaceWith(columnsPos, columnsPos + columnsNode.nodeSize, columnsNode.type.create(columnsNode.attrs, updatedContent, columnsNode.marks));
1488
+ dispatch(transaction.setSelection(_tiptap_pm_state.TextSelection.create(transaction.doc, columnsPos + selectionRelative.from, columnsPos + selectionRelative.to)));
1489
+ return true;
1490
+ }
1491
+ function addColumn(editor) {
1492
+ const columns = getClosestColumns(editor);
1493
+ if (!columns) return false;
1494
+ const { node: columnsNode, pos: columnsPos } = columns;
1495
+ const { dispatch, state } = editor.view;
1496
+ const { tr } = state;
1497
+ const newColumn = state.schema.nodes[_maily_to_shared.MAILY_NODE_TYPES.COLUMN].create({ width: null }, state.schema.nodes[_maily_to_shared.MAILY_NODE_TYPES.PARAGRAPH].create());
1498
+ const updatedContent = [];
1499
+ columnsNode.content.forEach((child) => {
1500
+ updatedContent.push(child);
1501
+ });
1502
+ updatedContent.push(newColumn);
1503
+ const updatedColumnsNode = columnsNode.type.create({
1504
+ ...columnsNode.attrs,
1505
+ columnCount: columnsNode.childCount + 1
1506
+ }, updatedContent);
1507
+ const transaction = tr.replaceWith(columnsPos, columnsPos + columnsNode.nodeSize, updatedColumnsNode);
1508
+ dispatch(transaction.setSelection(_tiptap_pm_state.TextSelection.create(transaction.doc, columnsPos + 3)));
1509
+ return true;
1510
+ }
1511
+ function removeColumn(editor) {
1512
+ const columns = getClosestColumns(editor);
1513
+ if (!columns) return false;
1514
+ const { node: columnsNode, pos: columnsPos } = columns;
1515
+ if (columnsNode.childCount <= 1) return false;
1516
+ const { dispatch, state } = editor.view;
1517
+ const { selection, tr } = state;
1518
+ const removeIndex = columnsNode.childCount - 1;
1519
+ const updatedContent = [];
1520
+ columnsNode.content.forEach((child, _, childIndex) => {
1521
+ if (childIndex !== removeIndex) updatedContent.push(child);
1522
+ });
1523
+ const updatedColumnsNode = columnsNode.type.create({
1524
+ ...columnsNode.attrs,
1525
+ columnCount: columnsNode.childCount - 1
1526
+ }, updatedContent);
1527
+ const selectionFrom = selection.from - columnsPos;
1528
+ const transaction = tr.replaceWith(columnsPos, columnsPos + columnsNode.nodeSize, updatedColumnsNode);
1529
+ const maxPos = columnsPos + updatedColumnsNode.nodeSize - 1;
1530
+ dispatch(transaction.setSelection(_tiptap_pm_state.TextSelection.near(transaction.doc.resolve(Math.min(columnsPos + selectionFrom, maxPos)))));
1531
+ return true;
1532
+ }
1533
+ function goToSiblingColumn(editor, direction) {
1534
+ const { $from } = editor.state.selection;
1535
+ let columnDepth = -1;
1536
+ for (let depth = $from.depth; depth > 0; depth--) if ($from.node(depth).type.name === _maily_to_shared.MAILY_NODE_TYPES.COLUMN) {
1537
+ columnDepth = depth;
1538
+ break;
1539
+ }
1540
+ if (columnDepth === -1) return false;
1541
+ const columnsDepth = columnDepth - 1;
1542
+ const columnIndex = $from.index(columnsDepth);
1543
+ const targetIndex = direction === "next" ? columnIndex + 1 : columnIndex - 1;
1544
+ if (targetIndex < 0 || targetIndex >= $from.node(columnsDepth).childCount) return false;
1545
+ const targetPos = direction === "next" ? $from.after(columnDepth) + 1 : $from.before(columnDepth) - 1;
1546
+ const { tr } = editor.state;
1547
+ tr.setSelection(_tiptap_pm_state.TextSelection.near(tr.doc.resolve(targetPos), direction === "next" ? 1 : -1));
1548
+ editor.view.dispatch(tr);
1549
+ return true;
1550
+ }
1551
+ //#endregion
1552
+ //#region src/utils/exit-on-triple-enter.ts
1553
+ /**
1554
+ * Exits a container node when the user presses Enter three times
1555
+ * (i.e. the last three children are empty). Deletes the trailing
1556
+ * empty blocks and inserts a paragraph after the container.
1557
+ */
1558
+ function exitOnTripleEnter(options) {
1559
+ const { editor, exitDepthOffset = 0, nodeName } = options;
1560
+ const { state } = editor;
1561
+ const { $from, empty } = state.selection;
1562
+ if (!empty) return false;
1563
+ let nodeDepth = -1;
1564
+ for (let d = $from.depth; d > 0; d--) if ($from.node(d).type.name === nodeName) {
1565
+ nodeDepth = d;
1566
+ break;
1567
+ }
1568
+ if (nodeDepth === -1) return false;
1569
+ const node = $from.node(nodeDepth);
1570
+ const lastChildIndex = node.childCount - 1;
1571
+ if (node.childCount < 3 || $from.index(nodeDepth) !== lastChildIndex || $from.parent.content.size !== 0 || node.child(lastChildIndex - 1).content.size !== 0 || node.child(lastChildIndex - 2).content.size !== 0) return false;
1572
+ const exitDepth = nodeDepth + exitDepthOffset;
1573
+ const deleteCount = Math.min(3, node.childCount - 1);
1574
+ let deleteFrom = $from.start(nodeDepth);
1575
+ for (let i = 0; i < node.childCount - deleteCount; i++) deleteFrom += node.child(i).nodeSize;
1576
+ return editor.chain().command(({ tr }) => {
1577
+ const afterNode = $from.after(exitDepth);
1578
+ tr.delete(deleteFrom, $from.end(nodeDepth));
1579
+ const mappedPos = tr.mapping.map(afterNode);
1580
+ tr.insert(mappedPos, editor.schema.nodes.paragraph.create());
1581
+ tr.setSelection(_tiptap_pm_state.TextSelection.near(tr.doc.resolve(mappedPos + 1)));
1582
+ return true;
1583
+ }).run();
1584
+ }
1585
+ //#endregion
1586
+ //#region src/extensions/columns/column.ts
1587
+ const DEFAULT_COLUMN_WIDTH = null;
1588
+ const ColumnExtension = _tiptap_core.Node.create({
1589
+ name: _maily_to_shared.MAILY_NODE_TYPES.COLUMN,
1590
+ group: "column",
1591
+ content: "block+",
1592
+ defining: true,
1593
+ isolating: true,
1594
+ addAttributes() {
1595
+ return {
1596
+ width: {
1597
+ default: DEFAULT_COLUMN_WIDTH,
1598
+ parseHTML: (element) => {
1599
+ return (0, _maily_to_shared.getColumnWidth)(element.style.width) ?? DEFAULT_COLUMN_WIDTH;
1600
+ },
1601
+ renderHTML: (attributes) => {
1602
+ const width = attributes.width;
1603
+ if (width === null) return {};
1604
+ const value = (0, _maily_to_shared.getColumnWidthValue)(width);
1605
+ return { style: `width:${value};max-width:${value}` };
1606
+ }
1607
+ },
1608
+ verticalAlign: {
1609
+ default: "top",
1610
+ parseHTML: (element) => {
1611
+ if (element.style.verticalAlign) return element.style.verticalAlign;
1612
+ if (element.style.justifyContent === "center") return "middle";
1613
+ if (element.style.justifyContent === "flex-end") return "bottom";
1614
+ return "top";
1615
+ },
1616
+ renderHTML: (attributes) => {
1617
+ const verticalAlign = attributes.verticalAlign;
1618
+ if (!verticalAlign || verticalAlign === "top") return {};
1619
+ if (verticalAlign === "middle") return { style: "display:flex;flex-direction:column;justify-content:center" };
1620
+ if (verticalAlign === "bottom") return { style: "display:flex;flex-direction:column;justify-content:flex-end" };
1621
+ return {};
1622
+ }
1623
+ }
1624
+ };
1625
+ },
1626
+ addCommands() {
1627
+ return { updateColumn: (attrs) => ({ commands }) => commands.updateAttributes(this.name, attrs) };
1628
+ },
1629
+ addKeyboardShortcuts() {
1630
+ return {
1631
+ Tab: ({ editor }) => goToSiblingColumn(editor, "next"),
1632
+ "Shift-Tab": ({ editor }) => goToSiblingColumn(editor, "previous"),
1633
+ Enter: ({ editor }) => {
1634
+ return exitOnTripleEnter({
1635
+ editor,
1636
+ exitDepthOffset: -1,
1637
+ nodeName: this.name
1638
+ });
1639
+ }
1640
+ };
1641
+ },
1642
+ parseHTML() {
1643
+ return [{ tag: `div[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${_maily_to_shared.MAILY_NODE_TYPES.COLUMN}"]` }];
1644
+ },
1645
+ renderHTML({ HTMLAttributes }) {
1646
+ return [
1647
+ "div",
1648
+ (0, _tiptap_core.mergeAttributes)(HTMLAttributes, { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.COLUMN }),
1649
+ 0
1650
+ ];
1651
+ }
1652
+ });
1653
+ const ColumnsExtension = _tiptap_core.Node.create({
1654
+ name: _maily_to_shared.MAILY_NODE_TYPES.COLUMNS,
1655
+ group: "block",
1656
+ content: "column+",
1657
+ defining: true,
1658
+ isolating: true,
1659
+ draggable: true,
1660
+ addAttributes() {
1661
+ return {
1662
+ columnCount: {
1663
+ default: 2,
1664
+ parseHTML: (element) => Number(element.getAttribute("data-column-count")) || 2,
1665
+ renderHTML: (attributes) => ({ "data-column-count": attributes.columnCount })
1666
+ },
1667
+ gap: {
1668
+ default: 8,
1669
+ parseHTML: (element) => Number(element.getAttribute("data-gap")) || 8,
1670
+ renderHTML: (attributes) => ({
1671
+ "data-gap": attributes.gap,
1672
+ style: `gap:${attributes.gap}px`
1673
+ })
1674
+ }
1675
+ };
1676
+ },
1677
+ addCommands() {
1678
+ return {
1679
+ setColumns: (columnCount = 2) => ({ tr, dispatch, editor }) => {
1680
+ const columnNodes = Array.from({ length: columnCount }, () => editor.schema.nodes[_maily_to_shared.MAILY_NODE_TYPES.COLUMN].createAndFill({}, editor.schema.nodes.paragraph.create())).filter((node) => node !== null);
1681
+ const columnsNode = editor.schema.nodes[this.name].createAndFill({ columnCount }, columnNodes);
1682
+ if (!columnsNode) return false;
1683
+ const { $from } = tr.selection;
1684
+ const isEmptyBlock = $from.parent.isTextblock && $from.parent.content.size === 0;
1685
+ const insertFrom = isEmptyBlock ? $from.before($from.depth) : $from.after($from.depth);
1686
+ const insertTo = isEmptyBlock ? $from.after($from.depth) : insertFrom;
1687
+ tr.replaceWith(insertFrom, insertTo, columnsNode);
1688
+ tr.setSelection(_tiptap_pm_state.TextSelection.near(tr.doc.resolve(insertFrom + 3)));
1689
+ if (dispatch) dispatch(tr);
1690
+ return true;
1691
+ },
1692
+ updateColumns: (attrs) => ({ commands }) => commands.updateAttributes(this.name, attrs)
1693
+ };
1694
+ },
1695
+ parseHTML() {
1696
+ return [{ tag: `div[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${_maily_to_shared.MAILY_NODE_TYPES.COLUMNS}"]` }];
1697
+ },
1698
+ renderHTML({ HTMLAttributes }) {
1699
+ return [
1700
+ "div",
1701
+ (0, _tiptap_core.mergeAttributes)(HTMLAttributes, { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.COLUMNS }),
1702
+ 0
1703
+ ];
1704
+ }
1705
+ });
1706
+ //#endregion
1707
+ //#region src/extensions/visibility/visibility.ts
1708
+ const VISIBILITY_SUPPORTED_TYPES = [
1709
+ _maily_to_shared.MAILY_NODE_TYPES.PARAGRAPH,
1710
+ _maily_to_shared.MAILY_NODE_TYPES.HEADING,
1711
+ _maily_to_shared.MAILY_NODE_TYPES.IMAGE,
1712
+ _maily_to_shared.MAILY_NODE_TYPES.SPACER,
1713
+ _maily_to_shared.MAILY_NODE_TYPES.SECTION,
1714
+ _maily_to_shared.MAILY_NODE_TYPES.COLUMNS,
1715
+ _maily_to_shared.MAILY_NODE_TYPES.BULLET_LIST,
1716
+ _maily_to_shared.MAILY_NODE_TYPES.ORDERED_LIST,
1717
+ _maily_to_shared.MAILY_NODE_TYPES.HORIZONTAL_RULE,
1718
+ _maily_to_shared.MAILY_NODE_TYPES.BUTTON,
1719
+ _maily_to_shared.MAILY_NODE_TYPES.REPEAT,
1720
+ _maily_to_shared.MAILY_NODE_TYPES.HTML_CODE_BLOCK,
1721
+ _maily_to_shared.MAILY_NODE_TYPES.LINK_CARD
1722
+ ];
1723
+ function getRuleAttributes(rule) {
1724
+ const attributes = {
1725
+ "data-visibility-action": rule.action,
1726
+ "data-visibility-operator": rule.operator,
1727
+ "data-visibility-variable": rule.variable
1728
+ };
1729
+ if ((0, _maily_to_shared.getVisibilityValueSupport)(rule.operator)) attributes["data-visibility-value"] = rule.value;
1730
+ return attributes;
1731
+ }
1732
+ const VisibilityExtension = _tiptap_core.Extension.create({
1733
+ name: _maily_to_shared.MAILY_EXTENSION_TYPES.VISIBILITY,
1734
+ addOptions() {
1735
+ return { types: VISIBILITY_SUPPORTED_TYPES };
1736
+ },
1737
+ addGlobalAttributes() {
1738
+ return [{
1739
+ types: this.options.types,
1740
+ attributes: { visibilityRule: {
1741
+ default: null,
1742
+ keepOnSplit: false,
1743
+ parseHTML: (element) => (0, _maily_to_shared.getVisibilityRule)({
1744
+ action: element.getAttribute("data-visibility-action"),
1745
+ operator: element.getAttribute("data-visibility-operator"),
1746
+ value: element.getAttribute("data-visibility-value"),
1747
+ variable: element.getAttribute("data-visibility-variable")
1748
+ }),
1749
+ renderHTML: (attributes) => {
1750
+ const rule = attributes.visibilityRule;
1751
+ return rule ? getRuleAttributes(rule) : {};
1752
+ }
1753
+ } }
1754
+ }];
1755
+ },
1756
+ addCommands() {
1757
+ return {
1758
+ setVisibilityRule: (typeOrName, rule) => ({ commands }) => commands.updateAttributes(typeOrName, { visibilityRule: rule }),
1759
+ unsetVisibilityRule: (typeOrName) => ({ commands }) => commands.updateAttributes(typeOrName, { visibilityRule: null })
1760
+ };
1761
+ }
1762
+ });
1763
+ //#endregion
1764
+ //#region src/utils/collaboration.ts
1765
+ const Y_SYNC_META_KEY = "y-sync$";
1766
+ function isRemoteChange(tr) {
1767
+ return Boolean(tr.getMeta(Y_SYNC_META_KEY));
1768
+ }
1769
+ //#endregion
1770
+ //#region src/extensions/variable/protect-variable-trigger.ts
1771
+ const ProtectVariableTrigger = _tiptap_core.Extension.create({
1772
+ name: "protectVariableTrigger",
1773
+ addProseMirrorPlugins() {
1774
+ return [new _tiptap_pm_state.Plugin({ appendTransaction(transactions, _oldState, newState) {
1775
+ if (!transactions.some((tr) => tr.docChanged) || transactions.some(isRemoteChange)) return null;
1776
+ let hasVariable = false;
1777
+ newState.doc.descendants((node) => {
1778
+ if (node.type.name === _maily_to_shared.MAILY_NODE_TYPES.VARIABLE) {
1779
+ hasVariable = true;
1780
+ return false;
1781
+ }
1782
+ return true;
1783
+ });
1784
+ if (hasVariable) return null;
1785
+ const paragraph = newState.doc.firstChild;
1786
+ if (!paragraph) return null;
1787
+ if (paragraph.textContent.startsWith(_maily_to_shared.DEFAULT_VARIABLE_START_TRIGGER)) return null;
1788
+ const tr = newState.tr;
1789
+ const start = 1;
1790
+ return tr.replaceWith(start, start + paragraph.content.size, newState.schema.text(_maily_to_shared.DEFAULT_VARIABLE_START_TRIGGER));
1791
+ } })];
1792
+ }
1793
+ });
1794
+ //#endregion
1795
+ //#region src/extensions/repeat/repeat.ts
1796
+ const DEFAULT_REPEAT_EACH = "{{items}}";
1797
+ const RepeatExtension = _tiptap_core.Node.create({
1798
+ name: _maily_to_shared.MAILY_NODE_TYPES.REPEAT,
1799
+ group: "block",
1800
+ content: "block+",
1801
+ defining: true,
1802
+ isolating: true,
1803
+ draggable: true,
1804
+ addOptions() {
1805
+ return { HTMLAttributes: {} };
1806
+ },
1807
+ addAttributes() {
1808
+ return { each: {
1809
+ default: DEFAULT_REPEAT_EACH,
1810
+ parseHTML: (element) => {
1811
+ return element.getAttribute("data-each") || "{{items}}";
1812
+ },
1813
+ renderHTML: (attributes) => ({ "data-each": attributes.each })
1814
+ } };
1815
+ },
1816
+ addCommands() {
1817
+ return {
1818
+ setRepeat: (attrs) => ({ commands }) => commands.insertContent({
1819
+ type: this.name,
1820
+ attrs: { ...attrs },
1821
+ content: [{ type: _maily_to_shared.MAILY_NODE_TYPES.PARAGRAPH }]
1822
+ }),
1823
+ updateRepeat: (attrs) => ({ commands }) => commands.updateAttributes(this.name, attrs)
1824
+ };
1825
+ },
1826
+ addKeyboardShortcuts() {
1827
+ return { "Mod-Backspace": ({ editor }) => editor.commands.deleteNode(this.name) };
1828
+ },
1829
+ parseHTML() {
1830
+ return [{ tag: `div[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${this.name}"]` }];
1831
+ },
1832
+ renderHTML({ HTMLAttributes }) {
1833
+ return [
1834
+ "div",
1835
+ (0, _tiptap_core.mergeAttributes)({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: this.name }, this.options.HTMLAttributes, HTMLAttributes),
1836
+ 0
1837
+ ];
1838
+ }
1839
+ });
1840
+ //#endregion
1841
+ //#region src/extensions/blockquote/blockquote.ts
1842
+ const BlockquoteExtension = _tiptap_extension_blockquote.Blockquote.extend({ renderHTML({ HTMLAttributes }) {
1843
+ return [
1844
+ "blockquote",
1845
+ (0, _tiptap_core.mergeAttributes)({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.BLOCKQUOTE }, this.options.HTMLAttributes, HTMLAttributes),
1846
+ 0
1847
+ ];
1848
+ } });
1849
+ //#endregion
1850
+ //#region src/extensions/body/body.ts
1851
+ const BodyExtension = _tiptap_core.Node.create({
1852
+ name: _maily_to_shared.MAILY_NODE_TYPES.BODY,
1853
+ content: `${_maily_to_shared.MAILY_NODE_TYPES.CONTAINER}+`,
1854
+ defining: true,
1855
+ parseHTML() {
1856
+ return [{ tag: `div[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${_maily_to_shared.MAILY_NODE_TYPES.BODY}"]` }];
1857
+ },
1858
+ renderHTML({ HTMLAttributes }) {
1859
+ return [
1860
+ "div",
1861
+ (0, _tiptap_core.mergeAttributes)({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.BODY }, HTMLAttributes),
1862
+ 0
1863
+ ];
1864
+ }
1865
+ });
1866
+ //#endregion
1867
+ //#region src/utils/table.ts
1868
+ function getSingleCell(element) {
1869
+ if (isDataTable(element)) return null;
1870
+ const cells = element.querySelectorAll(":scope > tbody > tr > td");
1871
+ return cells.length === 1 ? cells[0] : null;
1872
+ }
1873
+ function isDataTable(element) {
1874
+ const border = element.getAttribute("border");
1875
+ return element.querySelector(":scope > thead, :scope > tbody > tr > th") !== null || border !== null && border !== "0";
1876
+ }
1877
+ function isBodyTable(element) {
1878
+ return element.parentElement?.tagName === "BODY";
1879
+ }
1880
+ //#endregion
1881
+ //#region src/utils/style.ts
1882
+ const BOLD_FONT_WEIGHTS = [
1883
+ "bold",
1884
+ "bolder",
1885
+ String(_maily_to_shared.FONT_WEIGHTS.BOLD)
1886
+ ];
1887
+ const MARKED_TEXT_DECORATIONS = ["underline", "line-through"];
1888
+ function isBoldFontWeight(value) {
1889
+ return BOLD_FONT_WEIGHTS.includes(value.trim().toLowerCase());
1890
+ }
1891
+ function isItalicFontStyle(value) {
1892
+ return value.trim().toLowerCase() === _maily_to_shared.FONT_STYLES.ITALIC;
1893
+ }
1894
+ function isMarkedTextDecoration(value) {
1895
+ const decoration = value.toLowerCase();
1896
+ return MARKED_TEXT_DECORATIONS.some((keyword) => {
1897
+ return decoration.includes(keyword);
1898
+ });
1899
+ }
1900
+ const CLAIMED_BY_MARKS = {
1901
+ fontStyle: isItalicFontStyle,
1902
+ fontWeight: isBoldFontWeight,
1903
+ textDecoration: isMarkedTextDecoration,
1904
+ textDecorationLine: isMarkedTextDecoration
1905
+ };
1906
+ const CLAIMED_ON_SPAN = {
1907
+ ...CLAIMED_BY_MARKS,
1908
+ color: true
1909
+ };
1910
+ const CLAIMED_ON_INLINE_IMAGE = { display: true };
1911
+ const CLAIMED_ON_COLUMNS = {
1912
+ gap: true,
1913
+ columnGap: true,
1914
+ rowGap: true
1915
+ };
1916
+ const CLAIMED_ON_COLUMN = {
1917
+ display: true,
1918
+ flexDirection: true,
1919
+ justifyContent: true,
1920
+ maxWidth: true,
1921
+ width: true,
1922
+ verticalAlign: true
1923
+ };
1924
+ function getUnclaimedStyle(options) {
1925
+ const { style, claimed } = options;
1926
+ if (!style) return null;
1927
+ const declarations = (0, _maily_to_shared.parseInlineStyles)(style);
1928
+ for (const [property, claims] of Object.entries(claimed)) {
1929
+ const value = declarations[property];
1930
+ if (value === void 0) continue;
1931
+ if (claims === true || claims(value)) delete declarations[property];
1932
+ }
1933
+ return (0, _maily_to_shared.stringifyInlineStyles)(declarations) || null;
1934
+ }
1935
+ function getMarkStyle(style) {
1936
+ return getUnclaimedStyle({
1937
+ style,
1938
+ claimed: CLAIMED_BY_MARKS
1939
+ });
1940
+ }
1941
+ function getSpanStyle(style) {
1942
+ return getUnclaimedStyle({
1943
+ style,
1944
+ claimed: CLAIMED_ON_SPAN
1945
+ });
1946
+ }
1947
+ function getInlineImageStyle(element) {
1948
+ return getUnclaimedStyle({
1949
+ style: getElementStyle(element),
1950
+ claimed: CLAIMED_ON_INLINE_IMAGE
1951
+ });
1952
+ }
1953
+ function getColumnsStyle(style) {
1954
+ return getUnclaimedStyle({
1955
+ style,
1956
+ claimed: CLAIMED_ON_COLUMNS
1957
+ });
1958
+ }
1959
+ function getColumnStyle(style) {
1960
+ return getUnclaimedStyle({
1961
+ style,
1962
+ claimed: CLAIMED_ON_COLUMN
1963
+ });
1964
+ }
1965
+ const TABLE_ALIGNMENT = {
1966
+ center: {
1967
+ marginLeft: "auto",
1968
+ marginRight: "auto"
1969
+ },
1970
+ left: { marginRight: "auto" },
1971
+ right: { marginLeft: "auto" }
1972
+ };
1973
+ function toCssLength(value) {
1974
+ const trimmed = value.trim();
1975
+ return /^\d+(?:\.\d+)?$/.test(trimmed) ? `${trimmed}px` : trimmed;
1976
+ }
1977
+ function getPresentationalStyle(element) {
1978
+ const style = {};
1979
+ const width = element.getAttribute("width");
1980
+ const height = element.getAttribute("height");
1981
+ const align = element.getAttribute("align");
1982
+ const verticalAlign = element.getAttribute("valign");
1983
+ const backgroundColor = element.getAttribute("bgcolor");
1984
+ if (width) style.width = toCssLength(width);
1985
+ if (height) style.height = toCssLength(height);
1986
+ if (align) Object.assign(style, element.tagName === "TABLE" ? TABLE_ALIGNMENT[align.toLowerCase()] : { textAlign: align });
1987
+ if (verticalAlign) style.verticalAlign = verticalAlign;
1988
+ if (backgroundColor) style.backgroundColor = backgroundColor;
1989
+ return style;
1990
+ }
1991
+ function getWrapperAlignment(element) {
1992
+ const align = element.getAttribute("align")?.toLowerCase();
1993
+ if (!align || align === _maily_to_shared.TEXT_ALIGNMENTS.LEFT || align === _maily_to_shared.TEXT_ALIGNMENTS.CENTER) return {};
1994
+ return TABLE_ALIGNMENT[align] ?? {};
1995
+ }
1996
+ function getWrapperStyle(element) {
1997
+ const cell = getSingleCell(element);
1998
+ const style = (0, _maily_to_shared.mergeInlineStyles)(getWrapperAlignment(element), (0, _maily_to_shared.parseInlineStyles)(element.getAttribute("style") ?? ""));
1999
+ const inner = cell?.getAttribute("style");
2000
+ return (0, _maily_to_shared.stringifyInlineStyles)(inner ? (0, _maily_to_shared.mergeInlineStyles)(style, (0, _maily_to_shared.parseInlineStyles)(inner)) : style) || null;
2001
+ }
2002
+ function getElementStyle(element) {
2003
+ const authored = element.getAttribute("style");
2004
+ const presentational = getPresentationalStyle(element);
2005
+ if (Object.keys(presentational).length === 0) return authored;
2006
+ return (0, _maily_to_shared.stringifyInlineStyles)((0, _maily_to_shared.mergeInlineStyles)(presentational, authored ? (0, _maily_to_shared.parseInlineStyles)(authored) : {})) || null;
2007
+ }
2008
+ function setStyleDeclarations(style, declarations) {
2009
+ const merged = style ? (0, _maily_to_shared.parseInlineStyles)(style) : {};
2010
+ for (const [property, value] of Object.entries(declarations)) if (value === null || value === void 0 || value === "") delete merged[property];
2011
+ else merged[property] = value;
2012
+ return (0, _maily_to_shared.stringifyInlineStyles)(merged) || null;
2013
+ }
2014
+ //#endregion
2015
+ //#region src/extensions/bold/bold.ts
2016
+ const BoldExtension = _tiptap_extension_bold.Bold.extend({ parseHTML() {
2017
+ return [
2018
+ { tag: "strong" },
2019
+ {
2020
+ tag: "b",
2021
+ getAttrs: (element) => {
2022
+ return element.style.fontWeight !== "normal" && null;
2023
+ }
2024
+ },
2025
+ {
2026
+ style: "font-weight=400",
2027
+ clearMark: (mark) => {
2028
+ return mark.type.name === this.name;
2029
+ }
2030
+ },
2031
+ {
2032
+ style: "font-weight",
2033
+ getAttrs: (value) => {
2034
+ return isBoldFontWeight(value) && null;
2035
+ }
2036
+ }
2037
+ ];
2038
+ } });
2039
+ //#endregion
2040
+ //#region src/extensions/button/button.ts
2041
+ const DEFAULT_BUTTON_ALIGN = _maily_to_shared.TEXT_ALIGNMENTS.CENTER;
2042
+ const ButtonExtension = _tiptap_core.Node.create({
2043
+ name: _maily_to_shared.MAILY_NODE_TYPES.BUTTON,
2044
+ group: "block",
2045
+ content: "(inline)*",
2046
+ defining: true,
2047
+ isolating: true,
2048
+ addOptions() {
2049
+ return { HTMLAttributes: {} };
2050
+ },
2051
+ addAttributes() {
2052
+ return {
2053
+ url: {
2054
+ default: "",
2055
+ parseHTML: (element) => element.getAttribute("data-url") || "",
2056
+ renderHTML: (attributes) => ({ "data-url": attributes.url })
2057
+ },
2058
+ kind: {
2059
+ default: _maily_to_shared.DEFAULT_BUTTON_KIND,
2060
+ parseHTML: (element) => {
2061
+ const kind = element.getAttribute("data-kind");
2062
+ return (0, _maily_to_shared.isAllowedButtonKind)(kind) ? kind : _maily_to_shared.DEFAULT_BUTTON_KIND;
2063
+ },
2064
+ renderHTML: (attributes) => ({ "data-kind": attributes.kind })
2065
+ },
2066
+ align: {
2067
+ default: DEFAULT_BUTTON_ALIGN,
2068
+ parseHTML: (element) => {
2069
+ const align = element.getAttribute("data-align");
2070
+ return (0, _maily_to_shared.isAllowedTextAlignment)(align) ? align : DEFAULT_BUTTON_ALIGN;
2071
+ },
2072
+ renderHTML: (attributes) => ({ "data-align": attributes.align })
2073
+ }
2074
+ };
2075
+ },
2076
+ addCommands() {
2077
+ return {
2078
+ setButton: (attrs) => ({ commands }) => commands.insertContent({
2079
+ type: this.name,
2080
+ attrs: { ...attrs },
2081
+ content: [{
2082
+ type: _maily_to_shared.MAILY_NODE_TYPES.TEXT,
2083
+ text: "Button"
2084
+ }]
2085
+ }),
2086
+ updateButtonAttributes: (attrs) => ({ commands }) => commands.updateAttributes(this.name, attrs)
2087
+ };
2088
+ },
2089
+ addKeyboardShortcuts() {
2090
+ return {
2091
+ "Mod-Backspace": ({ editor }) => editor.commands.deleteNode(this.name),
2092
+ Backspace: ({ editor }) => {
2093
+ const { $anchor, empty } = editor.state.selection;
2094
+ if (!empty || $anchor.parent.type.name !== this.name || $anchor.parent.content.size > 0) return false;
2095
+ return editor.commands.deleteNode(this.name);
2096
+ },
2097
+ Enter: ({ editor }) => {
2098
+ const { $from, empty } = editor.state.selection;
2099
+ if (!empty || $from.parent.type.name !== this.name) return false;
2100
+ if (!($from.parentOffset === $from.parent.nodeSize - 2)) return false;
2101
+ return editor.chain().insertContent({
2102
+ type: _maily_to_shared.MAILY_NODE_TYPES.PARAGRAPH,
2103
+ content: []
2104
+ }).run();
2105
+ }
2106
+ };
2107
+ },
2108
+ parseHTML() {
2109
+ return [{ tag: `div[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${this.name}"]` }];
2110
+ },
2111
+ renderHTML({ HTMLAttributes }) {
2112
+ return [
2113
+ "div",
2114
+ (0, _tiptap_core.mergeAttributes)({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: this.name }, this.options.HTMLAttributes, HTMLAttributes),
2115
+ 0
2116
+ ];
2117
+ }
2118
+ });
2119
+ //#endregion
2120
+ //#region src/extensions/container/container.ts
2121
+ const ContainerExtension = _tiptap_core.Node.create({
2122
+ name: _maily_to_shared.MAILY_NODE_TYPES.CONTAINER,
2123
+ group: "block",
2124
+ content: "block+",
2125
+ defining: true,
2126
+ isolating: true,
2127
+ parseHTML() {
2128
+ return [{ tag: `div[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${_maily_to_shared.MAILY_NODE_TYPES.CONTAINER}"]` }, {
2129
+ tag: "table",
2130
+ priority: 60,
2131
+ getAttrs: (element) => {
2132
+ if (!element.style.maxWidth) return false;
2133
+ return getSingleCell(element) ? null : false;
2134
+ },
2135
+ contentElement: (element) => getSingleCell(element) ?? element
2136
+ }];
2137
+ },
2138
+ renderHTML({ HTMLAttributes }) {
2139
+ return [
2140
+ "div",
2141
+ (0, _tiptap_core.mergeAttributes)({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.CONTAINER }, HTMLAttributes),
2142
+ 0
2143
+ ];
2144
+ }
2145
+ });
2146
+ //#endregion
2147
+ //#region src/extensions/footer/footer.ts
2148
+ const FooterExtension = _tiptap_core.Node.create({
2149
+ name: _maily_to_shared.MAILY_NODE_TYPES.FOOTER,
2150
+ group: "block",
2151
+ content: "inline*",
2152
+ addOptions() {
2153
+ return { HTMLAttributes: {} };
2154
+ },
2155
+ addCommands() {
2156
+ return {
2157
+ setFooter: () => ({ commands }) => commands.setNode(this.name),
2158
+ updateFooterAttributes: (attrs) => ({ commands }) => commands.updateAttributes(this.name, attrs)
2159
+ };
2160
+ },
2161
+ parseHTML() {
2162
+ return [{ tag: `small[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${this.name}"]` }];
2163
+ },
2164
+ renderHTML({ HTMLAttributes }) {
2165
+ return [
2166
+ "small",
2167
+ (0, _tiptap_core.mergeAttributes)({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: this.name }, this.options.HTMLAttributes, HTMLAttributes),
2168
+ 0
2169
+ ];
2170
+ }
2171
+ });
2172
+ //#endregion
2173
+ //#region src/extensions/horizontal-rule/horizontal-rule.ts
2174
+ const HorizontalRuleExtension = _tiptap_extension_horizontal_rule.HorizontalRule.configure({ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.HORIZONTAL_RULE } });
2175
+ //#endregion
2176
+ //#region src/extensions/html-code-block/html-code-block-view.tsx
2177
+ const PREVIEW_RESET = `
2178
+ * { font-family: 'Inter', sans-serif; }
2179
+ blockquote, h1, h2, h3, img, li, ol, p, ul {
2180
+ margin-top: 0;
2181
+ margin-bottom: 0;
2182
+ }
2183
+ `;
2184
+ function HtmlCodeBlockView(props) {
2185
+ const $ = (0, react_compiler_runtime.c)(16);
2186
+ const { node, updateAttributes } = props;
2187
+ const { activeTab, language } = node.attrs;
2188
+ let parsed;
2189
+ let t0;
2190
+ if ($[0] !== node.content.content) {
2191
+ const source = node.content.content.reduce(_temp$1, "");
2192
+ parsed = new DOMParser().parseFromString(source, "text/html");
2193
+ t0 = Array.from(parsed.querySelectorAll("style")).map(_temp2$1);
2194
+ $[0] = node.content.content;
2195
+ $[1] = parsed;
2196
+ $[2] = t0;
2197
+ } else {
2198
+ parsed = $[1];
2199
+ t0 = $[2];
2200
+ }
2201
+ const html = `<style>${t0.join("\n")}</style>${parsed.body.innerHTML}`;
2202
+ const isEmpty = html === "<style></style>";
2203
+ let t1;
2204
+ if ($[3] !== html) {
2205
+ t1 = (element_0) => {
2206
+ if (!element_0 || element_0.shadowRoot) return;
2207
+ const shadow = element_0.attachShadow({ mode: "open" });
2208
+ const sheet = new CSSStyleSheet();
2209
+ sheet.replaceSync(PREVIEW_RESET);
2210
+ shadow.adoptedStyleSheets = [sheet];
2211
+ const container = document.createElement("div");
2212
+ container.innerHTML = html;
2213
+ shadow.append(container);
2214
+ };
2215
+ $[3] = html;
2216
+ $[4] = t1;
2217
+ } else t1 = $[4];
2218
+ const setPreviewElement = t1;
2219
+ let t2;
2220
+ if ($[5] !== activeTab || $[6] !== language) {
2221
+ t2 = activeTab === _maily_to_shared.HTML_CODE_BLOCK_TABS.CODE && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
2222
+ "data-mly-html-code-block": "",
2223
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewContent, {
2224
+ as: "code",
2225
+ className: language ? `language-${language}` : void 0
2226
+ })
2227
+ });
2228
+ $[5] = activeTab;
2229
+ $[6] = language;
2230
+ $[7] = t2;
2231
+ } else t2 = $[7];
2232
+ let t3;
2233
+ if ($[8] !== activeTab || $[9] !== isEmpty || $[10] !== setPreviewElement || $[11] !== updateAttributes) {
2234
+ t3 = activeTab === _maily_to_shared.HTML_CODE_BLOCK_TABS.PREVIEW && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2235
+ contentEditable: false,
2236
+ "data-empty": isEmpty ? "" : void 0,
2237
+ "data-mly-html-code-block-preview": "",
2238
+ onClick: () => {
2239
+ if (isEmpty) updateAttributes({ activeTab: _maily_to_shared.HTML_CODE_BLOCK_TABS.CODE });
2240
+ },
2241
+ ref: setPreviewElement
2242
+ });
2243
+ $[8] = activeTab;
2244
+ $[9] = isEmpty;
2245
+ $[10] = setPreviewElement;
2246
+ $[11] = updateAttributes;
2247
+ $[12] = t3;
2248
+ } else t3 = $[12];
2249
+ let t4;
2250
+ if ($[13] !== t2 || $[14] !== t3) {
2251
+ t4 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_tiptap_react.NodeViewWrapper, {
2252
+ "data-drag-handle": false,
2253
+ draggable: false,
2254
+ children: [t2, t3]
2255
+ });
2256
+ $[13] = t2;
2257
+ $[14] = t3;
2258
+ $[15] = t4;
2259
+ } else t4 = $[15];
2260
+ return t4;
2261
+ }
2262
+ function _temp2$1(element) {
2263
+ return element.innerHTML;
2264
+ }
2265
+ function _temp$1(text, child) {
2266
+ if (child.type.name !== _maily_to_shared.MAILY_NODE_TYPES.TEXT) return text;
2267
+ return text + child.text;
2268
+ }
2269
+ //#endregion
2270
+ //#region src/extensions/html-code-block/html-code-block.ts
2271
+ const lowlight$1 = (0, lowlight.createLowlight)(lowlight.common);
2272
+ lowlight$1.register("html", highlight_js_lib_languages_xml.default);
2273
+ const HtmlCodeBlockExtension = _tiptap_extension_code_block_lowlight.CodeBlockLowlight.extend({
2274
+ name: _maily_to_shared.MAILY_NODE_TYPES.HTML_CODE_BLOCK,
2275
+ content: "(text|variable)*",
2276
+ addAttributes() {
2277
+ return {
2278
+ ...this.parent?.(),
2279
+ activeTab: { default: _maily_to_shared.DEFAULT_HTML_CODE_BLOCK_TAB }
2280
+ };
2281
+ },
2282
+ addNodeView() {
2283
+ return (0, _tiptap_react.ReactNodeViewRenderer)(HtmlCodeBlockView, { attrs: (props) => {
2284
+ const { node } = props;
2285
+ const { activeTab } = node.attrs;
2286
+ return {
2287
+ "data-active-tab": activeTab,
2288
+ [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.HTML_CODE_BLOCK
2289
+ };
2290
+ } });
2291
+ },
2292
+ addCommands() {
2293
+ return {
2294
+ setHtmlCodeBlock: (attrs) => {
2295
+ return ({ commands }) => {
2296
+ return commands.setNode(this.name, attrs);
2297
+ };
2298
+ },
2299
+ updateHtmlCodeBlock: (attrs) => {
2300
+ return ({ commands }) => {
2301
+ return commands.updateAttributes(this.name, attrs);
2302
+ };
2303
+ }
2304
+ };
2305
+ },
2306
+ addKeyboardShortcuts() {
2307
+ return {
2308
+ ...this.parent?.(),
2309
+ /**
2310
+ * Without this the browser selects the whole document from inside a code
2311
+ * block, because the block is one text node and nothing scopes the
2312
+ * selection to it.
2313
+ */
2314
+ "Mod-a": ({ editor }) => {
2315
+ const $pos = editor.state.selection.$anchor;
2316
+ if ($pos.node($pos.depth).type.name !== this.name) return false;
2317
+ let depth = $pos.depth;
2318
+ for (let level = depth; level > 0; level -= 1) if ($pos.node(level).type.name === this.name) {
2319
+ depth = level;
2320
+ break;
2321
+ }
2322
+ const from = editor.state.doc.resolve($pos.before(depth) + 1);
2323
+ const to = editor.state.doc.resolve($pos.after(depth) - 1);
2324
+ const transaction = editor.state.tr.setSelection(_tiptap_pm_state.TextSelection.between(from, to));
2325
+ editor.view.dispatch(transaction);
2326
+ return true;
2327
+ },
2328
+ "Mod-Backspace": ({ editor }) => {
2329
+ return editor.commands.deleteNode(this.name);
2330
+ }
2331
+ };
2332
+ }
2333
+ }).configure({ lowlight: lowlight$1 });
2334
+ //#endregion
2335
+ //#region src/extensions/image-upload/upload-image-file.ts
2336
+ function notifyUploadStatusChanged(editor) {
2337
+ editor.view.dispatch(editor.state.tr.setMeta("__mly_image_upload_status_changed", true));
2338
+ }
2339
+ function getUploadOptions(editor) {
2340
+ const extension = editor.extensionManager.extensions.find((candidate) => candidate.name === IMAGE_UPLOAD_EXTENSION_NAME);
2341
+ (0, _maily_to_shared.invariant)(extension, `You must add the "${IMAGE_UPLOAD_EXTENSION_NAME}" extension to the editor to upload images.`);
2342
+ return extension.options;
2343
+ }
2344
+ function findImageByBlobUrl(editor, blobUrl) {
2345
+ let found = null;
2346
+ editor.state.doc.descendants((node, pos) => {
2347
+ if (found) return false;
2348
+ if (node.type.name === _maily_to_shared.MAILY_NODE_TYPES.IMAGE && node.attrs.src === blobUrl) {
2349
+ found = {
2350
+ node,
2351
+ pos
2352
+ };
2353
+ return false;
2354
+ }
2355
+ return true;
2356
+ });
2357
+ return found;
2358
+ }
2359
+ function updateImageByBlobUrl(editor, blobUrl, attrs) {
2360
+ const found = findImageByBlobUrl(editor, blobUrl);
2361
+ if (!found) return;
2362
+ const { tr } = editor.state;
2363
+ tr.setNodeMarkup(found.pos, void 0, {
2364
+ ...found.node.attrs,
2365
+ ...attrs
2366
+ });
2367
+ editor.view.dispatch(tr);
2368
+ }
2369
+ function removeImageByBlobUrl(editor, blobUrl) {
2370
+ const found = findImageByBlobUrl(editor, blobUrl);
2371
+ if (!found) return;
2372
+ editor.view.dispatch(editor.state.tr.delete(found.pos, found.pos + found.node.nodeSize));
2373
+ }
2374
+ function uploadImageFile(editor, file, position) {
2375
+ const { onImageUpload, onImageUploadError } = getUploadOptions(editor);
2376
+ if (!onImageUpload) return;
2377
+ const blobUrl = URL.createObjectURL(file);
2378
+ if (!editor.chain().insertContentAt(position, {
2379
+ type: _maily_to_shared.MAILY_NODE_TYPES.IMAGE,
2380
+ attrs: { src: blobUrl }
2381
+ }).run()) {
2382
+ URL.revokeObjectURL(blobUrl);
2383
+ return;
2384
+ }
2385
+ const context = {
2386
+ position,
2387
+ removeImage: () => removeImageByBlobUrl(editor, blobUrl)
2388
+ };
2389
+ const { uploads } = editor.storage.imageUpload;
2390
+ uploads.set(blobUrl, IMAGE_UPLOAD_STATUSES.LOADING);
2391
+ notifyUploadStatusChanged(editor);
2392
+ onImageUpload(file, context).then((url) => {
2393
+ uploads.delete(blobUrl);
2394
+ notifyUploadStatusChanged(editor);
2395
+ updateImageByBlobUrl(editor, blobUrl, { src: url });
2396
+ URL.revokeObjectURL(blobUrl);
2397
+ }).catch((error) => {
2398
+ uploads.set(blobUrl, IMAGE_UPLOAD_STATUSES.ERROR);
2399
+ notifyUploadStatusChanged(editor);
2400
+ onImageUploadError?.(error, file, context);
2401
+ URL.revokeObjectURL(blobUrl);
2402
+ });
2403
+ }
2404
+ //#endregion
2405
+ //#region src/extensions/image-upload/image-upload.ts
2406
+ const IMAGE_UPLOAD_EXTENSION_NAME = "imageUpload";
2407
+ const IMAGE_UPLOAD_STATUSES = {
2408
+ IDLE: "idle",
2409
+ LOADING: "loading",
2410
+ ERROR: "error",
2411
+ LOADED: "loaded"
2412
+ };
2413
+ const ALLOWED_IMAGE_MIME_TYPES = [
2414
+ "image/jpeg",
2415
+ "image/png",
2416
+ "image/gif",
2417
+ "image/webp",
2418
+ "image/svg+xml"
2419
+ ];
2420
+ const ImageUploadExtension = _tiptap_core.Extension.create({
2421
+ name: IMAGE_UPLOAD_EXTENSION_NAME,
2422
+ addOptions() {
2423
+ return {
2424
+ onImageUpload: void 0,
2425
+ onImageUploadError: void 0
2426
+ };
2427
+ },
2428
+ addStorage() {
2429
+ return { uploads: /* @__PURE__ */ new Map() };
2430
+ },
2431
+ addExtensions() {
2432
+ return [_tiptap_extension_file_handler.FileHandler.configure({
2433
+ allowedMimeTypes: [...ALLOWED_IMAGE_MIME_TYPES],
2434
+ onDrop: (editor, files, pos) => {
2435
+ for (const file of files) uploadImageFile(editor, file, pos);
2436
+ },
2437
+ onPaste: (editor, files) => {
2438
+ for (const file of files) uploadImageFile(editor, file, editor.state.selection.from);
2439
+ }
2440
+ })];
2441
+ }
2442
+ });
2443
+ //#endregion
2444
+ //#region src/utils/pointer.ts
2445
+ function capturePointer(options) {
2446
+ const { element, pointerId } = options;
2447
+ try {
2448
+ element.setPointerCapture(pointerId);
2449
+ return true;
2450
+ } catch {
2451
+ return false;
2452
+ }
2453
+ }
2454
+ function releasePointer(options) {
2455
+ const { element, pointerId } = options;
2456
+ try {
2457
+ element.releasePointerCapture(pointerId);
2458
+ return true;
2459
+ } catch {
2460
+ return false;
2461
+ }
2462
+ }
2463
+ //#endregion
2464
+ //#region src/hooks/use-image-resize-controller.ts
2465
+ function useImageResizeController(options) {
2466
+ const $ = (0, react_compiler_runtime.c)(8);
2467
+ const { align, onWidthChange: t0, onWidthCommitted: t1 } = options;
2468
+ const onWidthChange = t0 === void 0 ? _maily_to_shared.noop : t0;
2469
+ const onWidthCommitted = t1 === void 0 ? _maily_to_shared.noop : t1;
2470
+ const containerRef = (0, react.useRef)(null);
2471
+ const imageWrapperRef = (0, react.useRef)(null);
2472
+ const [shouldShowDragHandles, setShouldShowDragHandles] = (0, react.useState)(false);
2473
+ const [isResizing, setIsResizing] = (0, react.useState)(false);
2474
+ let t2;
2475
+ if ($[0] !== align || $[1] !== onWidthChange || $[2] !== onWidthCommitted) {
2476
+ t2 = (event, initialResizeParams) => {
2477
+ let activeResizeState = initialResizeParams;
2478
+ let nextWidth = (0, _maily_to_shared.clampImageWidthPercentage)(Math.round((0, _maily_to_shared.percentage)(initialResizeParams.initialWidth, containerRef.current?.clientWidth ?? 0)));
2479
+ const targetElement = event.currentTarget;
2480
+ capturePointer({
2481
+ element: targetElement,
2482
+ pointerId: event.pointerId
2483
+ });
2484
+ const handlePointerMove = (moveEvent) => {
2485
+ const imageWrapper = imageWrapperRef.current;
2486
+ const container = containerRef.current;
2487
+ if (!activeResizeState || !imageWrapper || !container) return;
2488
+ const pointerDeltaX = moveEvent.clientX - activeResizeState.initialClientX;
2489
+ const { handleUsed, initialWidth } = activeResizeState;
2490
+ const delta = handleUsed === "left" ? -pointerDeltaX : pointerDeltaX;
2491
+ const maxWidth = container.clientWidth;
2492
+ const newWidthInPixels = (0, _maily_to_shared.clamp)(initialWidth + (align === _maily_to_shared.TEXT_ALIGNMENTS.CENTER ? delta * 2 : delta), [0, maxWidth]);
2493
+ nextWidth = (0, _maily_to_shared.clamp)(Math.round((0, _maily_to_shared.percentage)(newWidthInPixels, maxWidth)), [_maily_to_shared.MIN_IMAGE_WIDTH_PERCENTAGE, _maily_to_shared.MAX_IMAGE_WIDTH_PERCENTAGE]);
2494
+ imageWrapper.style.width = `${nextWidth}%`;
2495
+ onWidthChange(nextWidth);
2496
+ };
2497
+ const handlePointerUp = (upEvent) => {
2498
+ activeResizeState = null;
2499
+ setIsResizing(false);
2500
+ releasePointer({
2501
+ element: targetElement,
2502
+ pointerId: upEvent.pointerId
2503
+ });
2504
+ onWidthChange(nextWidth);
2505
+ onWidthCommitted(nextWidth);
2506
+ window.removeEventListener("pointermove", handlePointerMove);
2507
+ window.removeEventListener("pointerup", handlePointerUp);
2508
+ };
2509
+ window.addEventListener("pointermove", handlePointerMove);
2510
+ window.addEventListener("pointerup", handlePointerUp);
2511
+ setIsResizing(true);
2512
+ };
2513
+ $[0] = align;
2514
+ $[1] = onWidthChange;
2515
+ $[2] = onWidthCommitted;
2516
+ $[3] = t2;
2517
+ } else t2 = $[3];
2518
+ const handleResize = t2;
2519
+ let t3;
2520
+ if ($[4] !== handleResize || $[5] !== isResizing || $[6] !== shouldShowDragHandles) {
2521
+ t3 = {
2522
+ containerRef,
2523
+ handleResize,
2524
+ imageWrapperRef,
2525
+ isResizing,
2526
+ setShouldShowDragHandles,
2527
+ shouldShowDragHandles
2528
+ };
2529
+ $[4] = handleResize;
2530
+ $[5] = isResizing;
2531
+ $[6] = shouldShowDragHandles;
2532
+ $[7] = t3;
2533
+ } else t3 = $[7];
2534
+ return t3;
2535
+ }
2536
+ //#endregion
2537
+ //#region src/extensions/image/image-handle.tsx
2538
+ function ImageHandle(props) {
2539
+ const $ = (0, react_compiler_runtime.c)(6);
2540
+ let handle;
2541
+ let rest;
2542
+ if ($[0] !== props) {
2543
+ ({handle, ...rest} = props);
2544
+ $[0] = props;
2545
+ $[1] = handle;
2546
+ $[2] = rest;
2547
+ } else {
2548
+ handle = $[1];
2549
+ rest = $[2];
2550
+ }
2551
+ let t0;
2552
+ if ($[3] !== handle || $[4] !== rest) {
2553
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2554
+ ...rest,
2555
+ "data-mly-image-handle": "",
2556
+ "data-side": handle
2557
+ });
2558
+ $[3] = handle;
2559
+ $[4] = rest;
2560
+ $[5] = t0;
2561
+ } else t0 = $[5];
2562
+ return t0;
2563
+ }
2564
+ //#endregion
2565
+ //#region src/components/interface/visually-hidden.tsx
2566
+ function VisuallyHidden(props) {
2567
+ const $ = (0, react_compiler_runtime.c)(8);
2568
+ let rest;
2569
+ let style;
2570
+ if ($[0] !== props) {
2571
+ ({style, ...rest} = props);
2572
+ $[0] = props;
2573
+ $[1] = rest;
2574
+ $[2] = style;
2575
+ } else {
2576
+ rest = $[1];
2577
+ style = $[2];
2578
+ }
2579
+ let t0;
2580
+ if ($[3] !== style) {
2581
+ t0 = {
2582
+ border: 0,
2583
+ clipPath: "inset(50%)",
2584
+ height: 1,
2585
+ margin: -1,
2586
+ overflow: "hidden",
2587
+ padding: 0,
2588
+ position: "absolute",
2589
+ whiteSpace: "nowrap",
2590
+ width: 1,
2591
+ ...style
2592
+ };
2593
+ $[3] = style;
2594
+ $[4] = t0;
2595
+ } else t0 = $[4];
2596
+ let t1;
2597
+ if ($[5] !== rest || $[6] !== t0) {
2598
+ t1 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2599
+ "data-mly-visually-hidden": "",
2600
+ ...rest,
2601
+ style: t0
2602
+ });
2603
+ $[5] = rest;
2604
+ $[6] = t0;
2605
+ $[7] = t1;
2606
+ } else t1 = $[7];
2607
+ return t1;
2608
+ }
2609
+ //#endregion
2610
+ //#region src/extensions/image/image-state.tsx
2611
+ function ImageState(props) {
2612
+ const $ = (0, react_compiler_runtime.c)(14);
2613
+ let Icon;
2614
+ let children;
2615
+ let rest;
2616
+ let state;
2617
+ if ($[0] !== props) {
2618
+ ({children, icon: Icon, state, ...rest} = props);
2619
+ $[0] = props;
2620
+ $[1] = Icon;
2621
+ $[2] = children;
2622
+ $[3] = rest;
2623
+ $[4] = state;
2624
+ } else {
2625
+ Icon = $[1];
2626
+ children = $[2];
2627
+ rest = $[3];
2628
+ state = $[4];
2629
+ }
2630
+ let t0;
2631
+ if ($[5] !== Icon) {
2632
+ t0 = Icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
2633
+ size: 16,
2634
+ strokeWidth: 2.5
2635
+ }) : null;
2636
+ $[5] = Icon;
2637
+ $[6] = t0;
2638
+ } else t0 = $[6];
2639
+ let t1;
2640
+ if ($[7] !== children) {
2641
+ t1 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2642
+ "data-mly-image-state-label": "",
2643
+ children
2644
+ });
2645
+ $[7] = children;
2646
+ $[8] = t1;
2647
+ } else t1 = $[8];
2648
+ let t2;
2649
+ if ($[9] !== rest || $[10] !== state || $[11] !== t0 || $[12] !== t1) {
2650
+ t2 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2651
+ ...rest,
2652
+ "data-mly-image-state": "",
2653
+ "data-state": state,
2654
+ children: [t0, t1]
2655
+ });
2656
+ $[9] = rest;
2657
+ $[10] = state;
2658
+ $[11] = t0;
2659
+ $[12] = t1;
2660
+ $[13] = t2;
2661
+ } else t2 = $[13];
2662
+ return t2;
2663
+ }
2664
+ function ImageIdleState() {
2665
+ const $ = (0, react_compiler_runtime.c)(1);
2666
+ let t0;
2667
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
2668
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageState, {
2669
+ state: "idle",
2670
+ children: "No image"
2671
+ });
2672
+ $[0] = t0;
2673
+ } else t0 = $[0];
2674
+ return t0;
2675
+ }
2676
+ function ImageErrorState() {
2677
+ const $ = (0, react_compiler_runtime.c)(1);
2678
+ let t0;
2679
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
2680
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageState, {
2681
+ role: "alert",
2682
+ state: "error",
2683
+ children: "Failed to upload image"
2684
+ });
2685
+ $[0] = t0;
2686
+ } else t0 = $[0];
2687
+ return t0;
2688
+ }
2689
+ function ImageVariableState() {
2690
+ const $ = (0, react_compiler_runtime.c)(1);
2691
+ let t0;
2692
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
2693
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageState, {
2694
+ state: "variable",
2695
+ children: "Dynamic image source"
2696
+ });
2697
+ $[0] = t0;
2698
+ } else t0 = $[0];
2699
+ return t0;
2700
+ }
2701
+ function ImageLoadingState(props) {
2702
+ const $ = (0, react_compiler_runtime.c)(7);
2703
+ const { alt, src } = props;
2704
+ const t0 = alt ?? void 0;
2705
+ let t1;
2706
+ if ($[0] !== src || $[1] !== t0) {
2707
+ t1 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
2708
+ alt: t0,
2709
+ "data-mly-image-preview": "",
2710
+ src
2711
+ });
2712
+ $[0] = src;
2713
+ $[1] = t0;
2714
+ $[2] = t1;
2715
+ } else t1 = $[2];
2716
+ let t2;
2717
+ let t3;
2718
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
2719
+ t2 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { "data-mly-image-spinner": "" });
2720
+ t3 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VisuallyHidden, {
2721
+ role: "status",
2722
+ children: "Uploading image"
2723
+ });
2724
+ $[3] = t2;
2725
+ $[4] = t3;
2726
+ } else {
2727
+ t2 = $[3];
2728
+ t3 = $[4];
2729
+ }
2730
+ let t4;
2731
+ if ($[5] !== t1) {
2732
+ t4 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2733
+ "aria-busy": "true",
2734
+ "data-mly-image-loading": "",
2735
+ children: [
2736
+ t1,
2737
+ t2,
2738
+ t3
2739
+ ]
2740
+ });
2741
+ $[5] = t1;
2742
+ $[6] = t4;
2743
+ } else t4 = $[6];
2744
+ return t4;
2745
+ }
2746
+ function ImagePlaceholder(props) {
2747
+ const $ = (0, react_compiler_runtime.c)(3);
2748
+ const { onFileSelect } = props;
2749
+ let t0;
2750
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
2751
+ t0 = ALLOWED_IMAGE_MIME_TYPES.join(",");
2752
+ $[0] = t0;
2753
+ } else t0 = $[0];
2754
+ let t1;
2755
+ if ($[1] !== onFileSelect) {
2756
+ t1 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ImageState, {
2757
+ state: "placeholder",
2758
+ children: ["Click or drop an image here", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2759
+ accept: t0,
2760
+ "data-mly-image-input": "",
2761
+ onChange: (event) => {
2762
+ const file = event.target.files?.[0];
2763
+ if (file) onFileSelect(file);
2764
+ },
2765
+ type: "file"
2766
+ })]
2767
+ });
2768
+ $[1] = onFileSelect;
2769
+ $[2] = t1;
2770
+ } else t1 = $[2];
2771
+ return t1;
2772
+ }
2773
+ //#endregion
2774
+ //#region src/extensions/image/image-view.tsx
2775
+ function useUploadStatus(editor, src) {
2776
+ const $ = (0, react_compiler_runtime.c)(5);
2777
+ let t0;
2778
+ if ($[0] !== src) {
2779
+ t0 = (ctx) => src ? ctx.editor.storage.imageUpload?.uploads.get(src) : void 0;
2780
+ $[0] = src;
2781
+ $[1] = t0;
2782
+ } else t0 = $[1];
2783
+ let t1;
2784
+ if ($[2] !== editor || $[3] !== t0) {
2785
+ t1 = {
2786
+ editor,
2787
+ selector: t0
2788
+ };
2789
+ $[2] = editor;
2790
+ $[3] = t0;
2791
+ $[4] = t1;
2792
+ } else t1 = $[4];
2793
+ const status = (0, _tiptap_react.useEditorState)(t1);
2794
+ if (!src) return IMAGE_UPLOAD_STATUSES.IDLE;
2795
+ return status ?? IMAGE_UPLOAD_STATUSES.LOADED;
2796
+ }
2797
+ function ImageView(props) {
2798
+ const $ = (0, react_compiler_runtime.c)(65);
2799
+ const { editor, getPos, node, updateAttributes } = props;
2800
+ const { align, alt, src, width, style } = node.attrs;
2801
+ const t0 = style ?? "";
2802
+ let t1;
2803
+ if ($[0] !== t0) {
2804
+ t1 = (0, _maily_to_shared.parseInlineStyles)(t0);
2805
+ $[0] = t0;
2806
+ $[1] = t1;
2807
+ } else t1 = $[1];
2808
+ let authoredStyle;
2809
+ if ($[2] !== t1) {
2810
+ const { width: _width, maxWidth: _maxWidth, height: _height, ...t2 } = t1;
2811
+ authoredStyle = t2;
2812
+ $[2] = t1;
2813
+ $[3] = authoredStyle;
2814
+ } else authoredStyle = $[3];
2815
+ let t2;
2816
+ if ($[4] !== src) {
2817
+ t2 = !!src && (0, _maily_to_shared.hasVariableInText)(src);
2818
+ $[4] = src;
2819
+ $[5] = t2;
2820
+ } else t2 = $[5];
2821
+ const isSrcVariable = t2;
2822
+ const status = useUploadStatus(editor, isSrcVariable ? void 0 : src);
2823
+ let t3;
2824
+ if ($[6] !== updateAttributes) {
2825
+ t3 = (committed) => updateAttributes({ width: `${committed}%` });
2826
+ $[6] = updateAttributes;
2827
+ $[7] = t3;
2828
+ } else t3 = $[7];
2829
+ const t4 = t3;
2830
+ let t5;
2831
+ if ($[8] !== align || $[9] !== t4) {
2832
+ t5 = {
2833
+ align,
2834
+ onWidthCommitted: t4
2835
+ };
2836
+ $[8] = align;
2837
+ $[9] = t4;
2838
+ $[10] = t5;
2839
+ } else t5 = $[10];
2840
+ const { containerRef, handleResize, imageWrapperRef, isResizing, setShouldShowDragHandles, shouldShowDragHandles } = useImageResizeController(t5);
2841
+ let t6;
2842
+ if ($[11] !== handleResize || $[12] !== imageWrapperRef) {
2843
+ t6 = (handle, event) => {
2844
+ const imageWrapper = imageWrapperRef.current;
2845
+ if (!imageWrapper) return;
2846
+ event.preventDefault();
2847
+ handleResize(event, {
2848
+ handleUsed: handle,
2849
+ initialClientX: event.clientX,
2850
+ initialWidth: imageWrapper.clientWidth
2851
+ });
2852
+ };
2853
+ $[11] = handleResize;
2854
+ $[12] = imageWrapperRef;
2855
+ $[13] = t6;
2856
+ } else t6 = $[13];
2857
+ const handlePointerDown = t6;
2858
+ let t7;
2859
+ if ($[14] !== editor || $[15] !== getPos || $[16] !== node.nodeSize) {
2860
+ t7 = (file) => {
2861
+ const pos = getPos();
2862
+ if (pos == null) return;
2863
+ editor.view.dispatch(editor.state.tr.delete(pos, pos + node.nodeSize));
2864
+ uploadImageFile(editor, file, pos);
2865
+ };
2866
+ $[14] = editor;
2867
+ $[15] = getPos;
2868
+ $[16] = node.nodeSize;
2869
+ $[17] = t7;
2870
+ } else t7 = $[17];
2871
+ const handleFileSelect = t7;
2872
+ const isLoaded = status === IMAGE_UPLOAD_STATUSES.LOADED;
2873
+ const t8 = editor.isEditable && isLoaded;
2874
+ const t9 = editor.isEditable && isLoaded;
2875
+ let t10;
2876
+ if ($[18] !== editor.isEditable || $[19] !== setShouldShowDragHandles) {
2877
+ t10 = () => setShouldShowDragHandles(editor.isEditable);
2878
+ $[18] = editor.isEditable;
2879
+ $[19] = setShouldShowDragHandles;
2880
+ $[20] = t10;
2881
+ } else t10 = $[20];
2882
+ let t11;
2883
+ if ($[21] !== setShouldShowDragHandles) {
2884
+ t11 = () => setShouldShowDragHandles(false);
2885
+ $[21] = setShouldShowDragHandles;
2886
+ $[22] = t11;
2887
+ } else t11 = $[22];
2888
+ let t12;
2889
+ if ($[23] !== width) {
2890
+ t12 = { width };
2891
+ $[23] = width;
2892
+ $[24] = t12;
2893
+ } else t12 = $[24];
2894
+ let t13;
2895
+ if ($[25] !== isSrcVariable) {
2896
+ t13 = isSrcVariable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageVariableState, {}) : null;
2897
+ $[25] = isSrcVariable;
2898
+ $[26] = t13;
2899
+ } else t13 = $[26];
2900
+ let t14;
2901
+ if ($[27] !== editor.isEditable || $[28] !== handleFileSelect || $[29] !== isSrcVariable || $[30] !== status) {
2902
+ t14 = !isSrcVariable && status === IMAGE_UPLOAD_STATUSES.IDLE ? editor.isEditable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImagePlaceholder, { onFileSelect: handleFileSelect }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageIdleState, {}) : null;
2903
+ $[27] = editor.isEditable;
2904
+ $[28] = handleFileSelect;
2905
+ $[29] = isSrcVariable;
2906
+ $[30] = status;
2907
+ $[31] = t14;
2908
+ } else t14 = $[31];
2909
+ let t15;
2910
+ if ($[32] !== alt || $[33] !== isSrcVariable || $[34] !== src || $[35] !== status) {
2911
+ t15 = !isSrcVariable && status === IMAGE_UPLOAD_STATUSES.LOADING ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageLoadingState, {
2912
+ alt,
2913
+ src
2914
+ }) : null;
2915
+ $[32] = alt;
2916
+ $[33] = isSrcVariable;
2917
+ $[34] = src;
2918
+ $[35] = status;
2919
+ $[36] = t15;
2920
+ } else t15 = $[36];
2921
+ let t16;
2922
+ if ($[37] !== status) {
2923
+ t16 = status === IMAGE_UPLOAD_STATUSES.ERROR ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageErrorState, {}) : null;
2924
+ $[37] = status;
2925
+ $[38] = t16;
2926
+ } else t16 = $[38];
2927
+ let t17;
2928
+ if ($[39] !== alt || $[40] !== authoredStyle || $[41] !== editor.isEditable || $[42] !== handlePointerDown || $[43] !== isLoaded || $[44] !== isResizing || $[45] !== isSrcVariable || $[46] !== shouldShowDragHandles || $[47] !== src) {
2929
+ t17 = !isSrcVariable && isLoaded ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
2930
+ alt: alt ?? void 0,
2931
+ contentEditable: false,
2932
+ "data-mly-image": "",
2933
+ draggable: editor.isEditable,
2934
+ src,
2935
+ style: authoredStyle
2936
+ }), shouldShowDragHandles || isResizing ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageHandle, {
2937
+ handle: "left",
2938
+ onPointerDown: (event_0) => handlePointerDown("left", event_0)
2939
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImageHandle, {
2940
+ handle: "right",
2941
+ onPointerDown: (event_1) => handlePointerDown("right", event_1)
2942
+ })] }) : null] }) : null;
2943
+ $[39] = alt;
2944
+ $[40] = authoredStyle;
2945
+ $[41] = editor.isEditable;
2946
+ $[42] = handlePointerDown;
2947
+ $[43] = isLoaded;
2948
+ $[44] = isResizing;
2949
+ $[45] = isSrcVariable;
2950
+ $[46] = shouldShowDragHandles;
2951
+ $[47] = src;
2952
+ $[48] = t17;
2953
+ } else t17 = $[48];
2954
+ let t18;
2955
+ if ($[49] !== align || $[50] !== imageWrapperRef || $[51] !== t12 || $[52] !== t13 || $[53] !== t14 || $[54] !== t15 || $[55] !== t16 || $[56] !== t17) {
2956
+ t18 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2957
+ "data-align": align,
2958
+ "data-mly-image-wrapper": "",
2959
+ ref: imageWrapperRef,
2960
+ style: t12,
2961
+ children: [
2962
+ t13,
2963
+ t14,
2964
+ t15,
2965
+ t16,
2966
+ t17
2967
+ ]
2968
+ });
2969
+ $[49] = align;
2970
+ $[50] = imageWrapperRef;
2971
+ $[51] = t12;
2972
+ $[52] = t13;
2973
+ $[53] = t14;
2974
+ $[54] = t15;
2975
+ $[55] = t16;
2976
+ $[56] = t17;
2977
+ $[57] = t18;
2978
+ } else t18 = $[57];
2979
+ let t19;
2980
+ if ($[58] !== containerRef || $[59] !== t10 || $[60] !== t11 || $[61] !== t18 || $[62] !== t8 || $[63] !== t9) {
2981
+ t19 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, {
2982
+ "data-drag-handle": t8,
2983
+ "data-mly-image-view": "",
2984
+ draggable: t9,
2985
+ onMouseEnter: t10,
2986
+ onMouseLeave: t11,
2987
+ ref: containerRef,
2988
+ children: t18
2989
+ });
2990
+ $[58] = containerRef;
2991
+ $[59] = t10;
2992
+ $[60] = t11;
2993
+ $[61] = t18;
2994
+ $[62] = t8;
2995
+ $[63] = t9;
2996
+ $[64] = t19;
2997
+ } else t19 = $[64];
2998
+ return t19;
2999
+ }
3000
+ //#endregion
3001
+ //#region src/extensions/image/image.ts
3002
+ const DEFAULT_IMAGE_ALIGN = _maily_to_shared.DEFAULT_TEXT_ALIGN;
3003
+ const DEFAULT_IMAGE_WIDTH = "100%";
3004
+ const UNITLESS_REGEX = /^-?\d*\.?\d+$/;
3005
+ const ImageExtension = _tiptap_extension_image.Image.extend({
3006
+ name: _maily_to_shared.MAILY_NODE_TYPES.IMAGE,
3007
+ addAttributes() {
3008
+ return {
3009
+ ...this.parent?.(),
3010
+ width: {
3011
+ default: DEFAULT_IMAGE_WIDTH,
3012
+ parseHTML: (element) => {
3013
+ const width = element.style.width || element.getAttribute("width");
3014
+ if (!width) return DEFAULT_IMAGE_WIDTH;
3015
+ return UNITLESS_REGEX.test(width) ? `${width}px` : width;
3016
+ },
3017
+ renderHTML: (attributes) => ({ width: attributes.width })
3018
+ },
3019
+ align: {
3020
+ default: DEFAULT_IMAGE_ALIGN,
3021
+ parseHTML: (element) => {
3022
+ const align = element.getAttribute("data-align");
3023
+ return (0, _maily_to_shared.isAllowedTextAlignment)(align) ? align : DEFAULT_IMAGE_ALIGN;
3024
+ },
3025
+ renderHTML: (attributes) => ({ "data-align": attributes.align })
3026
+ },
3027
+ externalLink: {
3028
+ default: null,
3029
+ parseHTML: (element) => element.getAttribute("data-external-link"),
3030
+ renderHTML: (attributes) => attributes.externalLink ? { "data-external-link": attributes.externalLink } : {}
3031
+ }
3032
+ };
3033
+ },
3034
+ addNodeView() {
3035
+ return (0, _tiptap_react.ReactNodeViewRenderer)(ImageView, { attrs: () => ({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.IMAGE }) });
3036
+ }
3037
+ }).configure({ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.IMAGE } });
3038
+ //#endregion
3039
+ //#region src/extensions/inline-image/inline-image.ts
3040
+ const DEFAULT_INLINE_IMAGE_SIZE = 20;
3041
+ const INLINE_PARENTS = /* @__PURE__ */ new Set([
3042
+ "A",
3043
+ "B",
3044
+ "EM",
3045
+ "I",
3046
+ "SPAN",
3047
+ "STRONG"
3048
+ ]);
3049
+ const InlineImageExtension = _tiptap_core.Node.create({
3050
+ name: _maily_to_shared.MAILY_NODE_TYPES.INLINE_IMAGE,
3051
+ group: "inline",
3052
+ inline: true,
3053
+ atom: true,
3054
+ selectable: true,
3055
+ addOptions() {
3056
+ return { HTMLAttributes: {} };
3057
+ },
3058
+ addAttributes() {
3059
+ return {
3060
+ src: {
3061
+ default: "",
3062
+ parseHTML: (element) => element.getAttribute("src") || "",
3063
+ renderHTML: (attributes) => attributes.src ? { src: attributes.src } : {}
3064
+ },
3065
+ alt: {
3066
+ default: null,
3067
+ parseHTML: (element) => element.getAttribute("alt"),
3068
+ renderHTML: (attributes) => attributes.alt ? { alt: attributes.alt } : {}
3069
+ },
3070
+ title: {
3071
+ default: null,
3072
+ parseHTML: (element) => element.getAttribute("title"),
3073
+ renderHTML: (attributes) => attributes.title ? { title: attributes.title } : {}
3074
+ },
3075
+ width: {
3076
+ default: DEFAULT_INLINE_IMAGE_SIZE,
3077
+ parseHTML: (element) => Number(element.getAttribute("width")) || DEFAULT_INLINE_IMAGE_SIZE,
3078
+ renderHTML: (attributes) => ({ width: attributes.width })
3079
+ },
3080
+ height: {
3081
+ default: DEFAULT_INLINE_IMAGE_SIZE,
3082
+ parseHTML: (element) => Number(element.getAttribute("height")) || DEFAULT_INLINE_IMAGE_SIZE,
3083
+ renderHTML: (attributes) => ({ height: attributes.height })
3084
+ },
3085
+ externalLink: {
3086
+ default: null,
3087
+ parseHTML: (element) => element.getAttribute("data-external-link"),
3088
+ renderHTML: (attributes) => attributes.externalLink ? { "data-external-link": attributes.externalLink } : {}
3089
+ }
3090
+ };
3091
+ },
3092
+ addCommands() {
3093
+ return {
3094
+ setInlineImage: (attrs) => ({ commands }) => commands.insertContent({
3095
+ type: this.name,
3096
+ attrs
3097
+ }),
3098
+ updateInlineImageAttributes: (attrs) => ({ commands }) => commands.updateAttributes(this.name, attrs)
3099
+ };
3100
+ },
3101
+ parseHTML() {
3102
+ return [{ tag: `img[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${this.name}"]` }, {
3103
+ tag: "img[src]",
3104
+ priority: 60,
3105
+ getAttrs: (element) => {
3106
+ const parent = element.parentElement;
3107
+ return parent && INLINE_PARENTS.has(parent.tagName) ? null : false;
3108
+ }
3109
+ }];
3110
+ },
3111
+ renderHTML({ HTMLAttributes }) {
3112
+ return ["img", (0, _tiptap_core.mergeAttributes)({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: this.name }, this.options.HTMLAttributes, HTMLAttributes)];
3113
+ }
3114
+ });
3115
+ //#endregion
3116
+ //#region src/extensions/inline-span/inline-span.ts
3117
+ const InlineSpanExtension = _tiptap_core.Node.create({
3118
+ name: _maily_to_shared.MAILY_NODE_TYPES.INLINE_SPAN,
3119
+ group: "inline",
3120
+ inline: true,
3121
+ atom: true,
3122
+ selectable: true,
3123
+ parseHTML() {
3124
+ return [{
3125
+ tag: "span[style]",
3126
+ priority: 60,
3127
+ getAttrs: (element) => {
3128
+ return element.childNodes.length === 0 ? null : false;
3129
+ }
3130
+ }];
3131
+ },
3132
+ renderHTML({ HTMLAttributes }) {
3133
+ return ["span", (0, _tiptap_core.mergeAttributes)(HTMLAttributes)];
3134
+ }
3135
+ });
3136
+ //#endregion
3137
+ //#region src/extensions/paragraph/paragraph.ts
3138
+ const ParagraphExtension = _tiptap_extension_paragraph.Paragraph.configure({ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.PARAGRAPH } });
3139
+ //#endregion
3140
+ //#region src/extensions/placeholder/placeholder.ts
3141
+ const PlaceholderExtension = _tiptap_extensions.Placeholder.configure({
3142
+ placeholder: ({ node }) => {
3143
+ const { name } = node.type;
3144
+ if (name === _maily_to_shared.MAILY_NODE_TYPES.HEADING) return `Heading ${node.attrs.level}`;
3145
+ else if (name === _maily_to_shared.MAILY_NODE_TYPES.HTML_CODE_BLOCK) return "Type your HTML code...";
3146
+ else if ([
3147
+ _maily_to_shared.MAILY_NODE_TYPES.BUTTON,
3148
+ _maily_to_shared.MAILY_NODE_TYPES.SECTION,
3149
+ _maily_to_shared.MAILY_NODE_TYPES.BULLET_LIST,
3150
+ _maily_to_shared.MAILY_NODE_TYPES.ORDERED_LIST,
3151
+ _maily_to_shared.MAILY_NODE_TYPES.LIST_ITEM,
3152
+ _maily_to_shared.MAILY_NODE_TYPES.COLUMNS,
3153
+ _maily_to_shared.MAILY_NODE_TYPES.COLUMN,
3154
+ _maily_to_shared.MAILY_NODE_TYPES.REPEAT,
3155
+ _maily_to_shared.MAILY_NODE_TYPES.BLOCKQUOTE
3156
+ ].includes(name)) return "";
3157
+ return "Write something or / to see commands";
3158
+ },
3159
+ includeChildren: true
3160
+ });
3161
+ //#endregion
3162
+ //#region src/extensions/section/section.ts
3163
+ const SectionExtension = _tiptap_core.Node.create({
3164
+ name: _maily_to_shared.MAILY_NODE_TYPES.SECTION,
3165
+ group: "block",
3166
+ content: "block+",
3167
+ defining: true,
3168
+ isolating: true,
3169
+ addCommands() {
3170
+ return {
3171
+ setSection: () => ({ commands }) => commands.insertContent({
3172
+ type: this.name,
3173
+ content: [{ type: _maily_to_shared.MAILY_NODE_TYPES.PARAGRAPH }]
3174
+ }),
3175
+ updateSection: (attrs) => ({ commands }) => commands.updateAttributes(this.name, attrs)
3176
+ };
3177
+ },
3178
+ addKeyboardShortcuts() {
3179
+ return { Enter: ({ editor }) => {
3180
+ return exitOnTripleEnter({
3181
+ editor,
3182
+ nodeName: this.name
3183
+ });
3184
+ } };
3185
+ },
3186
+ parseHTML() {
3187
+ return [{ tag: `div[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${_maily_to_shared.MAILY_NODE_TYPES.SECTION}"]` }];
3188
+ },
3189
+ renderHTML({ HTMLAttributes }) {
3190
+ return [
3191
+ "div",
3192
+ (0, _tiptap_core.mergeAttributes)({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.SECTION }, HTMLAttributes),
3193
+ 0
3194
+ ];
3195
+ }
3196
+ });
3197
+ //#endregion
3198
+ //#region src/extensions/slash-command/default-slash-commands.tsx
3199
+ const DEFAULT_SLASH_COMMANDS = [{
3200
+ title: "Blocks",
3201
+ commands: [
3202
+ require_typography.text,
3203
+ require_typography.heading1,
3204
+ require_typography.heading2,
3205
+ require_typography.heading3,
3206
+ require_typography.bulletList,
3207
+ require_typography.orderedList,
3208
+ require_typography.blockquote,
3209
+ require_typography.image,
3210
+ require_typography.inlineImage,
3211
+ require_typography.divider,
3212
+ require_typography.spacer,
3213
+ require_typography.section,
3214
+ require_typography.columns,
3215
+ require_typography.repeat,
3216
+ require_typography.button,
3217
+ require_typography.linkCard,
3218
+ require_typography.footer,
3219
+ require_typography.hardBreak,
3220
+ require_typography.clearLine
3221
+ ]
3222
+ }, {
3223
+ title: "Components",
3224
+ commands: [
3225
+ {
3226
+ id: "headers",
3227
+ title: "Headers",
3228
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Heading1Icon, { size: 16 }),
3229
+ description: "Pre-designed headers block",
3230
+ searchTerms: ["header", "headers"],
3231
+ commands: [
3232
+ require_typography.headerLogoWithTextVertical,
3233
+ require_typography.headerLogoWithTextHorizontal,
3234
+ require_typography.headerLogoWithCoverImage
3235
+ ]
3236
+ },
3237
+ {
3238
+ id: "footers",
3239
+ title: "Footers",
3240
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.FootprintsIcon, { size: 16 }),
3241
+ description: "Pre-designed footers block",
3242
+ searchTerms: ["footer", "footers"],
3243
+ commands: [
3244
+ require_typography.footerCopyrightText,
3245
+ require_typography.footerCommunityFeedbackCta,
3246
+ require_typography.footerCompanySignature
3247
+ ]
3248
+ },
3249
+ require_typography.htmlCodeBlock
3250
+ ]
3251
+ }];
3252
+ //#endregion
3253
+ //#region src/utils/slash-command.ts
3254
+ const SLASH_COMMAND_SUGGESTION_POPOVER_ID = "mly-slash-command-suggestion-popover";
3255
+ function isNestedCommand(item) {
3256
+ return "commands" in item && Array.isArray(item.commands) && !!item.id;
3257
+ }
3258
+ function match(item, search) {
3259
+ return item.title.toLowerCase().includes(search) || (item.description?.toLowerCase().includes(search) ?? false) || item.searchTerms.some((term) => term.toLowerCase().includes(search));
3260
+ }
3261
+ function findNestedCommand(groups, id) {
3262
+ const lowerId = id.toLowerCase();
3263
+ for (const group of groups) for (const command of group.commands) if (isNestedCommand(command) && command.id.toLowerCase() === lowerId) return command;
3264
+ }
3265
+ function getVisibleGroups(options) {
3266
+ const { editor, groups } = options;
3267
+ const isVisible = (item) => {
3268
+ return item.render?.(editor) !== null;
3269
+ };
3270
+ return groups.map((group) => {
3271
+ return {
3272
+ ...group,
3273
+ commands: group.commands.filter(isVisible).map((item) => {
3274
+ return isNestedCommand(item) ? {
3275
+ ...item,
3276
+ commands: item.commands.filter(isVisible)
3277
+ } : item;
3278
+ })
3279
+ };
3280
+ });
3281
+ }
3282
+ /**
3283
+ * Filters slash command groups by query. Supports nested commands
3284
+ * via dot notation (e.g. "headers.h1"). When a nested group matches,
3285
+ * it's expanded inline and made navigable.
3286
+ */
3287
+ function filterSlashCommands(options) {
3288
+ const { editor, query } = options;
3289
+ const groups = getVisibleGroups({
3290
+ editor,
3291
+ groups: options.groups
3292
+ });
3293
+ const search = query.toLowerCase();
3294
+ const subCommandMatch = /^([^.]+)\./.exec(search);
3295
+ if (subCommandMatch) {
3296
+ const [fullMatch, subCommandId] = subCommandMatch;
3297
+ const subCommand = findNestedCommand(groups, subCommandId);
3298
+ if (!subCommand) return [];
3299
+ const remainingSearch = search.slice(fullMatch.length);
3300
+ const filtered = subCommand.commands.filter((item) => !remainingSearch || match(item, remainingSearch));
3301
+ return filtered.length ? [{
3302
+ ...subCommand,
3303
+ commands: filtered
3304
+ }] : [];
3305
+ }
3306
+ return groups.map((group) => ({
3307
+ ...group,
3308
+ commands: group.commands.flatMap((item) => {
3309
+ if (!isNestedCommand(item)) return !search || match(item, search) ? [item] : [];
3310
+ const navigable = {
3311
+ ...item,
3312
+ command: ({ editor, range }) => {
3313
+ editor.chain().focus().insertContentAt(range, `/${item.id}.`).run();
3314
+ }
3315
+ };
3316
+ if (match(navigable, search)) return [navigable];
3317
+ return item.commands.some((child) => match(child, search)) ? item.commands : [];
3318
+ })
3319
+ })).filter((group) => group.commands.length > 0);
3320
+ }
3321
+ //#endregion
3322
+ //#region src/hooks/use-delayed-state.ts
3323
+ function useDelayedState(isOpen, t0) {
3324
+ const $ = (0, react_compiler_runtime.c)(6);
3325
+ let t1;
3326
+ if ($[0] !== t0) {
3327
+ t1 = t0 === void 0 ? {} : t0;
3328
+ $[0] = t0;
3329
+ $[1] = t1;
3330
+ } else t1 = $[1];
3331
+ const { delay: t2 } = t1;
3332
+ const delay = t2 === void 0 ? 200 : t2;
3333
+ const [value, setValue] = (0, react.useState)(false);
3334
+ const timerRef = (0, react.useRef)(0);
3335
+ let t3;
3336
+ let t4;
3337
+ if ($[2] !== delay || $[3] !== isOpen) {
3338
+ t3 = () => {
3339
+ window.clearTimeout(timerRef.current);
3340
+ if (!isOpen) {
3341
+ timerRef.current = 0;
3342
+ setValue(false);
3343
+ return;
3344
+ }
3345
+ timerRef.current = window.setTimeout(() => {
3346
+ setValue(true);
3347
+ timerRef.current = 0;
3348
+ }, delay);
3349
+ return () => {
3350
+ if (!timerRef.current) return;
3351
+ window.clearTimeout(timerRef.current);
3352
+ timerRef.current = 0;
3353
+ };
3354
+ };
3355
+ t4 = [delay, isOpen];
3356
+ $[2] = delay;
3357
+ $[3] = isOpen;
3358
+ $[4] = t3;
3359
+ $[5] = t4;
3360
+ } else {
3361
+ t3 = $[4];
3362
+ t4 = $[5];
3363
+ }
3364
+ (0, react.useEffect)(t3, t4);
3365
+ return value;
3366
+ }
3367
+ //#endregion
3368
+ //#region src/extensions/slash-command/slash-command-item.tsx
3369
+ function SlashCommandItem(props) {
3370
+ const $ = (0, react_compiler_runtime.c)(36);
3371
+ let editor;
3372
+ let hoveredKey;
3373
+ let isSelected;
3374
+ let item;
3375
+ let itemKey;
3376
+ let onHover;
3377
+ let rest;
3378
+ if ($[0] !== props) {
3379
+ ({editor, hoveredKey, isSelected, item, itemKey, onHover, ...rest} = props);
3380
+ $[0] = props;
3381
+ $[1] = editor;
3382
+ $[2] = hoveredKey;
3383
+ $[3] = isSelected;
3384
+ $[4] = item;
3385
+ $[5] = itemKey;
3386
+ $[6] = onHover;
3387
+ $[7] = rest;
3388
+ } else {
3389
+ editor = $[1];
3390
+ hoveredKey = $[2];
3391
+ isSelected = $[3];
3392
+ item = $[4];
3393
+ itemKey = $[5];
3394
+ onHover = $[6];
3395
+ rest = $[7];
3396
+ }
3397
+ const isHovered = hoveredKey === itemKey;
3398
+ const isNested = "commands" in item;
3399
+ const open = useDelayedState(Boolean(item.preview) && (isHovered || isSelected && !hoveredKey));
3400
+ let t0;
3401
+ if ($[8] !== editor || $[9] !== item) {
3402
+ t0 = item.render ? item.render(editor) : null;
3403
+ $[8] = editor;
3404
+ $[9] = item;
3405
+ $[10] = t0;
3406
+ } else t0 = $[10];
3407
+ const rendered = t0;
3408
+ const isCustomRow = rendered !== null && rendered !== true && rendered !== void 0;
3409
+ const t1 = isSelected ? "" : void 0;
3410
+ let t2;
3411
+ let t3;
3412
+ if ($[11] !== onHover) {
3413
+ t2 = () => onHover(true);
3414
+ t3 = () => onHover(false);
3415
+ $[11] = onHover;
3416
+ $[12] = t2;
3417
+ $[13] = t3;
3418
+ } else {
3419
+ t2 = $[12];
3420
+ t3 = $[13];
3421
+ }
3422
+ let t4;
3423
+ if ($[14] !== isCustomRow || $[15] !== isNested || $[16] !== item.description || $[17] !== item.icon || $[18] !== item.title || $[19] !== rendered) {
3424
+ t4 = isCustomRow ? rendered : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
3425
+ item.icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3426
+ "data-mly-slash-command-icon": "",
3427
+ children: item.icon
3428
+ }) : null,
3429
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3430
+ "data-mly-slash-command-text": "",
3431
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3432
+ "data-mly-slash-command-title": "",
3433
+ children: item.title
3434
+ }), item.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3435
+ "data-mly-slash-command-description": "",
3436
+ children: item.description
3437
+ }) : null]
3438
+ }),
3439
+ isNested ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3440
+ "data-mly-slash-command-chevron": "",
3441
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRightIcon, {
3442
+ size: 14,
3443
+ strokeWidth: 2.5
3444
+ })
3445
+ }) : null
3446
+ ] });
3447
+ $[14] = isCustomRow;
3448
+ $[15] = isNested;
3449
+ $[16] = item.description;
3450
+ $[17] = item.icon;
3451
+ $[18] = item.title;
3452
+ $[19] = rendered;
3453
+ $[20] = t4;
3454
+ } else t4 = $[20];
3455
+ let t5;
3456
+ if ($[21] !== rest || $[22] !== t1 || $[23] !== t2 || $[24] !== t3 || $[25] !== t4) {
3457
+ t5 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTrigger, { render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3458
+ ...rest,
3459
+ "data-mly-slash-command-item": "",
3460
+ "data-selected": t1,
3461
+ onMouseEnter: t2,
3462
+ onMouseLeave: t3,
3463
+ type: "button",
3464
+ children: t4
3465
+ }) });
3466
+ $[21] = rest;
3467
+ $[22] = t1;
3468
+ $[23] = t2;
3469
+ $[24] = t3;
3470
+ $[25] = t4;
3471
+ $[26] = t5;
3472
+ } else t5 = $[26];
3473
+ let t6;
3474
+ if ($[27] !== editor || $[28] !== item) {
3475
+ t6 = typeof item.preview === "function" ? item.preview(editor) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("figure", {
3476
+ "data-mly-slash-command-preview": "",
3477
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
3478
+ alt: item.title,
3479
+ src: item.preview
3480
+ })
3481
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3482
+ "data-mly-slash-command-preview-description": "",
3483
+ children: item.description
3484
+ })] });
3485
+ $[27] = editor;
3486
+ $[28] = item;
3487
+ $[29] = t6;
3488
+ } else t6 = $[29];
3489
+ let t7;
3490
+ if ($[30] !== t6) {
3491
+ t7 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipPositioner, {
3492
+ side: "right",
3493
+ sideOffset: 8,
3494
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipPopup, {
3495
+ "data-variant": "preview",
3496
+ children: t6
3497
+ })
3498
+ });
3499
+ $[30] = t6;
3500
+ $[31] = t7;
3501
+ } else t7 = $[31];
3502
+ let t8;
3503
+ if ($[32] !== open || $[33] !== t5 || $[34] !== t7) {
3504
+ t8 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, {
3505
+ open,
3506
+ children: [t5, t7]
3507
+ });
3508
+ $[32] = open;
3509
+ $[33] = t5;
3510
+ $[34] = t7;
3511
+ $[35] = t8;
3512
+ } else t8 = $[35];
3513
+ return t8;
3514
+ }
3515
+ //#endregion
3516
+ //#region src/extensions/slash-command/slash-command-suggestion-list.tsx
3517
+ const NAVIGATION_KEYS = /* @__PURE__ */ new Set([
3518
+ ARROW_UP,
3519
+ ARROW_DOWN,
3520
+ ENTER,
3521
+ HOME,
3522
+ "End"
3523
+ ]);
3524
+ const SlashCommandSuggestionList = (0, react.forwardRef)((props, ref) => {
3525
+ const { command: selectItem, editor, items: groups } = props;
3526
+ const flattened = groups.flatMap((group) => group.commands);
3527
+ const [selectedIndex, setSelectedIndex] = (0, react.useState)(0);
3528
+ const [hoveredKey, setHoveredKey] = (0, react.useState)(null);
3529
+ const [prevGroups, setPrevGroups] = (0, react.useState)(groups);
3530
+ const { activeRef: activeItemRef, containerRef: scrollContainerRef } = useScrollIntoView([selectedIndex]);
3531
+ if (prevGroups !== groups) {
3532
+ setPrevGroups(groups);
3533
+ setSelectedIndex(0);
3534
+ if (scrollContainerRef.current) scrollContainerRef.current.scrollTop = 0;
3535
+ }
3536
+ const selectCommand = (item) => {
3537
+ selectItem(item);
3538
+ };
3539
+ (0, react.useImperativeHandle)(ref, () => ({ onKeyDown: ({ event }) => {
3540
+ if (!NAVIGATION_KEYS.has(event.key) || !flattened.length) return false;
3541
+ let newIndex = selectedIndex;
3542
+ let shouldSelect = false;
3543
+ switch (event.key) {
3544
+ case HOME:
3545
+ newIndex = 0;
3546
+ break;
3547
+ case "End":
3548
+ newIndex = flattened.length - 1;
3549
+ break;
3550
+ case ARROW_UP:
3551
+ newIndex = (selectedIndex + flattened.length - 1) % flattened.length;
3552
+ break;
3553
+ case ARROW_DOWN:
3554
+ newIndex = (selectedIndex + 1) % flattened.length;
3555
+ break;
3556
+ case ENTER:
3557
+ shouldSelect = true;
3558
+ break;
3559
+ default: return false;
3560
+ }
3561
+ event.preventDefault();
3562
+ if (shouldSelect) {
3563
+ const item = flattened[selectedIndex];
3564
+ if (item) selectCommand(item);
3565
+ return true;
3566
+ }
3567
+ if (newIndex !== selectedIndex) setSelectedIndex(newIndex);
3568
+ return true;
3569
+ } }));
3570
+ if (!groups || groups.length === 0) return null;
3571
+ let itemIndex = -1;
3572
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(SuggestionWrapper, {
3573
+ "data-variant": "slash-command",
3574
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3575
+ "data-mly-suggestion-body": "",
3576
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3577
+ "data-axis": "y",
3578
+ "data-mly-scroll-fade": "",
3579
+ "data-mly-suggestion-scroll": "",
3580
+ ref: scrollContainerRef,
3581
+ children: groups.map((group, groupIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3582
+ "data-first": groupIndex === 0 ? "" : void 0,
3583
+ "data-mly-slash-command-group": "",
3584
+ children: group.title
3585
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3586
+ "data-mly-suggestion-items": "",
3587
+ children: group.commands.map((item) => {
3588
+ itemIndex += 1;
3589
+ const isSelected = itemIndex === selectedIndex;
3590
+ const itemKey = `${groupIndex}-${itemIndex}`;
3591
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SlashCommandItem, {
3592
+ editor,
3593
+ hoveredKey,
3594
+ isSelected,
3595
+ item,
3596
+ itemKey,
3597
+ onClick: () => selectCommand(item),
3598
+ onHover: (isHovered) => setHoveredKey(isHovered ? itemKey : null),
3599
+ ref: isSelected ? activeItemRef : null
3600
+ }, item.title);
3601
+ })
3602
+ })] }, group.title))
3603
+ })
3604
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SuggestionFooter, {})]
3605
+ });
3606
+ });
3607
+ SlashCommandSuggestionList.displayName = "SlashCommandSuggestionList";
3608
+ //#endregion
3609
+ //#region src/extensions/slash-command/slash-command-suggestion.ts
3610
+ async function updatePosition(editor, element, range) {
3611
+ const position = await (0, _floating_ui_react.computePosition)({ getBoundingClientRect: () => (0, _tiptap_react.posToDOMRect)(editor.view, range.from, range.to) }, element, {
3612
+ placement: "bottom-start",
3613
+ strategy: "absolute",
3614
+ middleware: [
3615
+ (0, _floating_ui_react.shift)(),
3616
+ (0, _floating_ui_react.flip)(),
3617
+ (0, _floating_ui_react.offset)(8)
3618
+ ]
3619
+ });
3620
+ element.style.width = "max-content";
3621
+ element.style.position = position.strategy;
3622
+ element.style.left = `${position.x}px`;
3623
+ element.style.top = `${position.y}px`;
3624
+ element.style.zIndex = "9999";
3625
+ }
3626
+ function getSlashCommandSuggestions() {
3627
+ return {
3628
+ char: "/",
3629
+ items: ({ editor, query }) => filterSlashCommands({
3630
+ editor,
3631
+ groups: editor.storage.slashCommand?.commands ?? [],
3632
+ query
3633
+ }),
3634
+ command: ({ editor, props, range }) => {
3635
+ props.command({
3636
+ editor,
3637
+ range
3638
+ });
3639
+ },
3640
+ render: () => {
3641
+ let component = null;
3642
+ return {
3643
+ onStart: async (props) => {
3644
+ const { editor, range } = props;
3645
+ const parentElement = editor.view.dom.parentElement;
3646
+ if (!parentElement) return;
3647
+ component = new _tiptap_react.ReactRenderer(SlashCommandSuggestionList, {
3648
+ editor,
3649
+ props
3650
+ });
3651
+ if (!props.clientRect) return;
3652
+ component.element.style.position = "absolute";
3653
+ component.element.id = SLASH_COMMAND_SUGGESTION_POPOVER_ID;
3654
+ parentElement.append(component.element);
3655
+ await updatePosition(editor, component.element, range);
3656
+ },
3657
+ onUpdate: async (props) => {
3658
+ const { editor, range } = props;
3659
+ if (!component) return;
3660
+ component.updateProps(props);
3661
+ if (!props.clientRect) return;
3662
+ await updatePosition(editor, component.element, range);
3663
+ },
3664
+ onKeyDown(props) {
3665
+ if (!component) return false;
3666
+ if (props.event.key === "Escape") {
3667
+ component.destroy();
3668
+ return true;
3669
+ }
3670
+ return component.ref?.onKeyDown(props) ?? false;
3671
+ },
3672
+ onExit() {
3673
+ if (!component) return;
3674
+ component.element.remove();
3675
+ component.destroy();
3676
+ }
3677
+ };
3678
+ }
3679
+ };
3680
+ }
3681
+ //#endregion
3682
+ //#region src/extensions/slash-command/slash-command.ts
3683
+ const SlashCommandExtension = _tiptap_core.Extension.create({
3684
+ name: "slashCommand",
3685
+ priority: 101,
3686
+ addOptions() {
3687
+ return {
3688
+ commands: DEFAULT_SLASH_COMMANDS,
3689
+ suggestion: getSlashCommandSuggestions()
3690
+ };
3691
+ },
3692
+ addStorage() {
3693
+ return { commands: this.options.commands };
3694
+ },
3695
+ addProseMirrorPlugins() {
3696
+ return [(0, _tiptap_suggestion.Suggestion)({
3697
+ editor: this.editor,
3698
+ ...this.options.suggestion
3699
+ })];
3700
+ }
3701
+ });
3702
+ //#endregion
3703
+ //#region src/hooks/use-spacer-resize-controller.ts
3704
+ function useSpacerResizeController(options) {
3705
+ const $ = (0, react_compiler_runtime.c)(8);
3706
+ const { height, onHeightChange: t0, onHeightCommitted: t1 } = options;
3707
+ const onHeightChange = t0 === void 0 ? _maily_to_shared.noop : t0;
3708
+ const onHeightCommitted = t1 === void 0 ? _maily_to_shared.noop : t1;
3709
+ const containerRef = (0, react.useRef)(null);
3710
+ const spacerWrapperRef = (0, react.useRef)(null);
3711
+ const [shouldShowDragHandles, setShouldShowDragHandles] = (0, react.useState)(false);
3712
+ const [isResizing, setIsResizing] = (0, react.useState)(false);
3713
+ const heightRef = useValueAsRef(height);
3714
+ let t2;
3715
+ if ($[0] !== heightRef || $[1] !== onHeightChange || $[2] !== onHeightCommitted) {
3716
+ t2 = (event, initialResizeParams) => {
3717
+ let activeResizeState = initialResizeParams;
3718
+ let nextHeight = heightRef.current;
3719
+ const targetElement = event.currentTarget;
3720
+ capturePointer({
3721
+ element: targetElement,
3722
+ pointerId: event.pointerId
3723
+ });
3724
+ const handlePointerMove = (moveEvent) => {
3725
+ const spacerWrapper = spacerWrapperRef.current;
3726
+ if (!activeResizeState || !spacerWrapper) return;
3727
+ const pointerDeltaY = moveEvent.clientY - activeResizeState.initialClientY;
3728
+ const { handleUsed, initialHeight } = activeResizeState;
3729
+ const delta = handleUsed === "top" ? -pointerDeltaY : pointerDeltaY;
3730
+ nextHeight = (0, _maily_to_shared.clamp)(Math.round(initialHeight + delta), [1, MAX_SPACER_HEIGHT]);
3731
+ spacerWrapper.style.height = `${nextHeight}px`;
3732
+ onHeightChange(nextHeight);
3733
+ };
3734
+ const handlePointerUp = (upEvent) => {
3735
+ activeResizeState = null;
3736
+ setIsResizing(false);
3737
+ releasePointer({
3738
+ element: targetElement,
3739
+ pointerId: upEvent.pointerId
3740
+ });
3741
+ onHeightChange(nextHeight);
3742
+ onHeightCommitted(nextHeight);
3743
+ window.removeEventListener("pointermove", handlePointerMove);
3744
+ window.removeEventListener("pointerup", handlePointerUp);
3745
+ };
3746
+ window.addEventListener("pointermove", handlePointerMove);
3747
+ window.addEventListener("pointerup", handlePointerUp);
3748
+ setIsResizing(true);
3749
+ };
3750
+ $[0] = heightRef;
3751
+ $[1] = onHeightChange;
3752
+ $[2] = onHeightCommitted;
3753
+ $[3] = t2;
3754
+ } else t2 = $[3];
3755
+ const handleResize = t2;
3756
+ let t3;
3757
+ if ($[4] !== handleResize || $[5] !== isResizing || $[6] !== shouldShowDragHandles) {
3758
+ t3 = {
3759
+ containerRef,
3760
+ handleResize,
3761
+ isResizing,
3762
+ setShouldShowDragHandles,
3763
+ shouldShowDragHandles,
3764
+ spacerWrapperRef
3765
+ };
3766
+ $[4] = handleResize;
3767
+ $[5] = isResizing;
3768
+ $[6] = shouldShowDragHandles;
3769
+ $[7] = t3;
3770
+ } else t3 = $[7];
3771
+ return t3;
3772
+ }
3773
+ //#endregion
3774
+ //#region src/extensions/spacer/spacer-handle.tsx
3775
+ function SpacerHandle(props) {
3776
+ const $ = (0, react_compiler_runtime.c)(6);
3777
+ let handle;
3778
+ let rest;
3779
+ if ($[0] !== props) {
3780
+ ({handle, ...rest} = props);
3781
+ $[0] = props;
3782
+ $[1] = handle;
3783
+ $[2] = rest;
3784
+ } else {
3785
+ handle = $[1];
3786
+ rest = $[2];
3787
+ }
3788
+ let t0;
3789
+ if ($[3] !== handle || $[4] !== rest) {
3790
+ t0 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3791
+ ...rest,
3792
+ "data-mly-spacer-handle": "",
3793
+ "data-side": handle
3794
+ });
3795
+ $[3] = handle;
3796
+ $[4] = rest;
3797
+ $[5] = t0;
3798
+ } else t0 = $[5];
3799
+ return t0;
3800
+ }
3801
+ //#endregion
3802
+ //#region src/extensions/spacer/spacer-view.tsx
3803
+ function SpacerView(props) {
3804
+ const $ = (0, react_compiler_runtime.c)(33);
3805
+ const { editor, getPos, node, updateAttributes } = props;
3806
+ const { height } = node.attrs;
3807
+ let t0;
3808
+ if ($[0] !== updateAttributes) {
3809
+ t0 = (committed) => updateAttributes({ height: committed });
3810
+ $[0] = updateAttributes;
3811
+ $[1] = t0;
3812
+ } else t0 = $[1];
3813
+ const t1 = t0;
3814
+ let t2;
3815
+ if ($[2] !== height || $[3] !== t1) {
3816
+ t2 = {
3817
+ height,
3818
+ onHeightCommitted: t1
3819
+ };
3820
+ $[2] = height;
3821
+ $[3] = t1;
3822
+ $[4] = t2;
3823
+ } else t2 = $[4];
3824
+ const { containerRef, handleResize, isResizing, setShouldShowDragHandles, shouldShowDragHandles, spacerWrapperRef } = useSpacerResizeController(t2);
3825
+ let t3;
3826
+ if ($[5] !== handleResize || $[6] !== spacerWrapperRef) {
3827
+ t3 = (handle, event) => {
3828
+ const spacerWrapper = spacerWrapperRef.current;
3829
+ if (!spacerWrapper) return;
3830
+ event.preventDefault();
3831
+ handleResize(event, {
3832
+ handleUsed: handle,
3833
+ initialClientY: event.clientY,
3834
+ initialHeight: spacerWrapper.clientHeight
3835
+ });
3836
+ };
3837
+ $[5] = handleResize;
3838
+ $[6] = spacerWrapperRef;
3839
+ $[7] = t3;
3840
+ } else t3 = $[7];
3841
+ const handlePointerDown = t3;
3842
+ let t4;
3843
+ if ($[8] !== editor.commands || $[9] !== getPos) {
3844
+ t4 = () => {
3845
+ const position = getPos();
3846
+ if (typeof position !== "number") return;
3847
+ editor.commands.setNodeSelection(position);
3848
+ };
3849
+ $[8] = editor.commands;
3850
+ $[9] = getPos;
3851
+ $[10] = t4;
3852
+ } else t4 = $[10];
3853
+ const handleSelect = t4;
3854
+ let t5;
3855
+ if ($[11] !== editor.isEditable || $[12] !== setShouldShowDragHandles) {
3856
+ t5 = () => setShouldShowDragHandles(editor.isEditable);
3857
+ $[11] = editor.isEditable;
3858
+ $[12] = setShouldShowDragHandles;
3859
+ $[13] = t5;
3860
+ } else t5 = $[13];
3861
+ let t6;
3862
+ if ($[14] !== setShouldShowDragHandles) {
3863
+ t6 = () => setShouldShowDragHandles(false);
3864
+ $[14] = setShouldShowDragHandles;
3865
+ $[15] = t6;
3866
+ } else t6 = $[15];
3867
+ const t7 = `${height}px`;
3868
+ let t8;
3869
+ if ($[16] !== t7) {
3870
+ t8 = { height: t7 };
3871
+ $[16] = t7;
3872
+ $[17] = t8;
3873
+ } else t8 = $[17];
3874
+ let t9;
3875
+ if ($[18] !== handlePointerDown || $[19] !== isResizing || $[20] !== shouldShowDragHandles) {
3876
+ t9 = shouldShowDragHandles || isResizing ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SpacerHandle, {
3877
+ handle: "top",
3878
+ onPointerDown: (event_0) => handlePointerDown("top", event_0)
3879
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SpacerHandle, {
3880
+ handle: "bottom",
3881
+ onPointerDown: (event_1) => handlePointerDown("bottom", event_1)
3882
+ })] }) : null;
3883
+ $[18] = handlePointerDown;
3884
+ $[19] = isResizing;
3885
+ $[20] = shouldShowDragHandles;
3886
+ $[21] = t9;
3887
+ } else t9 = $[21];
3888
+ let t10;
3889
+ if ($[22] !== spacerWrapperRef || $[23] !== t8 || $[24] !== t9) {
3890
+ t10 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3891
+ "data-mly-spacer-wrapper": "",
3892
+ ref: spacerWrapperRef,
3893
+ style: t8,
3894
+ children: t9
3895
+ });
3896
+ $[22] = spacerWrapperRef;
3897
+ $[23] = t8;
3898
+ $[24] = t9;
3899
+ $[25] = t10;
3900
+ } else t10 = $[25];
3901
+ let t11;
3902
+ if ($[26] !== containerRef || $[27] !== editor.isEditable || $[28] !== handleSelect || $[29] !== t10 || $[30] !== t5 || $[31] !== t6) {
3903
+ t11 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tiptap_react.NodeViewWrapper, {
3904
+ "data-drag-handle": editor.isEditable,
3905
+ "data-mly-spacer-view": "",
3906
+ draggable: editor.isEditable,
3907
+ onMouseEnter: t5,
3908
+ onMouseLeave: t6,
3909
+ onPointerDown: handleSelect,
3910
+ ref: containerRef,
3911
+ children: t10
3912
+ });
3913
+ $[26] = containerRef;
3914
+ $[27] = editor.isEditable;
3915
+ $[28] = handleSelect;
3916
+ $[29] = t10;
3917
+ $[30] = t5;
3918
+ $[31] = t6;
3919
+ $[32] = t11;
3920
+ } else t11 = $[32];
3921
+ return t11;
3922
+ }
3923
+ const SpacerExtension = _tiptap_core.Node.create({
3924
+ name: _maily_to_shared.MAILY_NODE_TYPES.SPACER,
3925
+ priority: 1e3,
3926
+ group: "block",
3927
+ draggable: true,
3928
+ addOptions() {
3929
+ return { HTMLAttributes: {} };
3930
+ },
3931
+ addAttributes() {
3932
+ return { height: {
3933
+ default: 8,
3934
+ parseHTML: (element) => Number(element.getAttribute("data-height")) || 8,
3935
+ renderHTML: (attributes) => ({ "data-height": attributes.height })
3936
+ } };
3937
+ },
3938
+ addCommands() {
3939
+ return {
3940
+ setSpacer: (attrs) => ({ commands }) => commands.insertContent({
3941
+ type: this.name,
3942
+ attrs
3943
+ }),
3944
+ unsetSpacer: () => ({ commands }) => commands.deleteNode(this.name),
3945
+ updateSpacerAttributes: (attrs) => ({ commands }) => commands.updateAttributes(this.name, attrs)
3946
+ };
3947
+ },
3948
+ parseHTML() {
3949
+ return [{ tag: `div[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${this.name}"]` }];
3950
+ },
3951
+ renderHTML({ HTMLAttributes, node }) {
3952
+ const { height } = node.attrs;
3953
+ return ["div", (0, _tiptap_core.mergeAttributes)({ [_maily_to_shared.DATA_NODE_TYPE_KEY]: this.name }, this.options.HTMLAttributes, HTMLAttributes, {
3954
+ contenteditable: "false",
3955
+ style: `height:${height}px`
3956
+ })];
3957
+ },
3958
+ addNodeView() {
3959
+ return (0, _tiptap_react.ReactNodeViewRenderer)(SpacerView, { attrs: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: this.name } });
3960
+ }
3961
+ });
3962
+ //#endregion
3963
+ //#region src/extensions/span/span.ts
3964
+ const SpanExtension = _tiptap_core.Mark.create({
3965
+ name: _maily_to_shared.MAILY_MARK_TYPES.SPAN,
3966
+ addAttributes() {
3967
+ return { style: {
3968
+ default: null,
3969
+ parseHTML: (element) => getSpanStyle(element.getAttribute("style")),
3970
+ renderHTML: (attributes) => {
3971
+ if (typeof attributes.style !== "string") return {};
3972
+ return { style: attributes.style };
3973
+ }
3974
+ } };
3975
+ },
3976
+ parseHTML() {
3977
+ return [{
3978
+ tag: "span[style]",
3979
+ getAttrs: (element) => getSpanStyle(element.getAttribute("style")) ? null : false
3980
+ }];
3981
+ },
3982
+ renderHTML({ HTMLAttributes }) {
3983
+ return [
3984
+ "span",
3985
+ (0, _tiptap_core.mergeAttributes)(HTMLAttributes),
3986
+ 0
3987
+ ];
3988
+ }
3989
+ });
3990
+ //#endregion
3991
+ //#region src/extensions/style/style.ts
3992
+ const WRAPPER_TYPES = [
3993
+ _maily_to_shared.MAILY_NODE_TYPES.BODY,
3994
+ _maily_to_shared.MAILY_NODE_TYPES.CONTAINER,
3995
+ _maily_to_shared.MAILY_NODE_TYPES.SECTION
3996
+ ];
3997
+ const STYLE_SUPPORTED_TYPES = [
3998
+ ...WRAPPER_TYPES,
3999
+ _maily_to_shared.MAILY_NODE_TYPES.COLUMNS,
4000
+ _maily_to_shared.MAILY_NODE_TYPES.COLUMN,
4001
+ _maily_to_shared.MAILY_NODE_TYPES.PARAGRAPH,
4002
+ _maily_to_shared.MAILY_NODE_TYPES.HEADING,
4003
+ _maily_to_shared.MAILY_NODE_TYPES.IMAGE,
4004
+ _maily_to_shared.MAILY_NODE_TYPES.INLINE_IMAGE,
4005
+ _maily_to_shared.MAILY_NODE_TYPES.INLINE_SPAN,
4006
+ _maily_to_shared.MAILY_NODE_TYPES.SPACER,
4007
+ _maily_to_shared.MAILY_NODE_TYPES.BUTTON,
4008
+ _maily_to_shared.MAILY_NODE_TYPES.FOOTER,
4009
+ _maily_to_shared.MAILY_NODE_TYPES.BLOCKQUOTE,
4010
+ _maily_to_shared.MAILY_NODE_TYPES.HORIZONTAL_RULE,
4011
+ _maily_to_shared.MAILY_NODE_TYPES.BULLET_LIST,
4012
+ _maily_to_shared.MAILY_NODE_TYPES.ORDERED_LIST,
4013
+ _maily_to_shared.MAILY_NODE_TYPES.LIST_ITEM,
4014
+ _maily_to_shared.MAILY_NODE_TYPES.TABLE,
4015
+ _maily_to_shared.MAILY_NODE_TYPES.TABLE_ROW,
4016
+ _maily_to_shared.MAILY_NODE_TYPES.TABLE_CELL,
4017
+ _maily_to_shared.MAILY_NODE_TYPES.TABLE_HEADER
4018
+ ];
4019
+ const STYLE_SUPPORTED_MARK_TYPES = [
4020
+ _maily_to_shared.MAILY_MARK_TYPES.BOLD,
4021
+ _maily_to_shared.MAILY_MARK_TYPES.ITALIC,
4022
+ _maily_to_shared.MAILY_MARK_TYPES.STRIKE,
4023
+ _maily_to_shared.MAILY_MARK_TYPES.UNDERLINE,
4024
+ _maily_to_shared.MAILY_MARK_TYPES.LINK,
4025
+ _maily_to_shared.MAILY_MARK_TYPES.CODE
4026
+ ];
4027
+ function getStyleAttribute(parseHTML) {
4028
+ return { style: {
4029
+ default: null,
4030
+ parseHTML,
4031
+ renderHTML: (attributes) => typeof attributes.style === "string" ? { style: attributes.style } : {}
4032
+ } };
4033
+ }
4034
+ const StyleExtension = _tiptap_core.Extension.create({
4035
+ name: _maily_to_shared.MAILY_EXTENSION_TYPES.STYLE,
4036
+ addOptions() {
4037
+ return {
4038
+ fontFamilies: _maily_to_shared.DEFAULT_FONT_FAMILIES,
4039
+ markTypes: STYLE_SUPPORTED_MARK_TYPES,
4040
+ types: STYLE_SUPPORTED_TYPES
4041
+ };
4042
+ },
4043
+ addCommands() {
4044
+ return { updateNodeStyle: (typeOrName, declarations) => ({ commands, editor }) => commands.updateAttributes(typeOrName, { style: setStyleDeclarations(editor.getAttributes(typeOrName).style, declarations) }) };
4045
+ },
4046
+ addGlobalAttributes() {
4047
+ return [
4048
+ {
4049
+ types: this.options.types.filter((type) => !WRAPPER_TYPES.includes(type) && type !== _maily_to_shared.MAILY_NODE_TYPES.COLUMNS && type !== _maily_to_shared.MAILY_NODE_TYPES.COLUMN && type !== _maily_to_shared.MAILY_NODE_TYPES.INLINE_IMAGE),
4050
+ attributes: getStyleAttribute(getElementStyle)
4051
+ },
4052
+ {
4053
+ types: [_maily_to_shared.MAILY_NODE_TYPES.INLINE_IMAGE],
4054
+ attributes: getStyleAttribute(getInlineImageStyle)
4055
+ },
4056
+ {
4057
+ types: [_maily_to_shared.MAILY_NODE_TYPES.COLUMNS],
4058
+ attributes: getStyleAttribute((element) => getColumnsStyle(getElementStyle(element)))
4059
+ },
4060
+ {
4061
+ types: [_maily_to_shared.MAILY_NODE_TYPES.COLUMN],
4062
+ attributes: getStyleAttribute((element) => getColumnStyle(getElementStyle(element)))
4063
+ },
4064
+ {
4065
+ types: this.options.types.filter((type) => WRAPPER_TYPES.includes(type)),
4066
+ attributes: getStyleAttribute(getWrapperStyle)
4067
+ },
4068
+ {
4069
+ types: this.options.markTypes,
4070
+ attributes: getStyleAttribute((element) => getMarkStyle(element.getAttribute("style")))
4071
+ }
4072
+ ];
4073
+ }
4074
+ });
4075
+ //#endregion
4076
+ //#region src/extensions/table/table.ts
4077
+ function getNumericAttribute(name) {
4078
+ return {
4079
+ default: 0,
4080
+ parseHTML: (element) => Number(element.getAttribute(name)) || 0,
4081
+ renderHTML: (attributes) => ({ [name]: attributes[name] })
4082
+ };
4083
+ }
4084
+ const TableExtension = _tiptap_extension_table.Table.extend({ addAttributes() {
4085
+ return {
4086
+ ...this.parent?.(),
4087
+ border: getNumericAttribute("border"),
4088
+ cellpadding: getNumericAttribute("cellpadding"),
4089
+ cellspacing: getNumericAttribute("cellspacing"),
4090
+ responsive: {
4091
+ default: false,
4092
+ parseHTML: (element) => {
4093
+ if (element.getAttribute("data-mly-responsive") === "stack") return true;
4094
+ return element.querySelectorAll(":scope > tbody > tr > td[data-id=\"__react-email-column\"]").length > 1;
4095
+ },
4096
+ renderHTML: (attributes) => attributes.responsive ? { "data-mly-responsive": "stack" } : {}
4097
+ }
4098
+ };
4099
+ } }).configure({
4100
+ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.TABLE },
4101
+ resizable: false,
4102
+ View: null
4103
+ });
4104
+ //#endregion
4105
+ //#region src/extensions/table/table-cell.ts
4106
+ const TableCellExtension = _tiptap_extension_table.TableCell.configure({ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.TABLE_CELL } });
4107
+ //#endregion
4108
+ //#region src/extensions/table/table-header.ts
4109
+ const TableHeaderExtension = _tiptap_extension_table.TableHeader.configure({ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.TABLE_HEADER } });
4110
+ //#endregion
4111
+ //#region src/extensions/table/table-row.ts
4112
+ const TableRowExtension = _tiptap_extension_table.TableRow.configure({ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.TABLE_ROW } });
4113
+ //#endregion
4114
+ //#region src/utils/extensions.ts
4115
+ function mergeExtensions(defaults, overrides) {
4116
+ const overrideNames = new Set(overrides.map((extension) => extension.name));
4117
+ return [...defaults.filter((extension) => !overrideNames.has(extension.name)), ...overrides];
4118
+ }
4119
+ //#endregion
4120
+ //#region src/utils/html.ts
4121
+ const LITERAL_SELECTORS = [
4122
+ "code",
4123
+ "pre",
4124
+ "script",
4125
+ "style",
4126
+ `[${_maily_to_shared.DATA_NODE_TYPE_KEY}="${_maily_to_shared.MAILY_NODE_TYPES.VARIABLE}"]`
4127
+ ].join(",");
4128
+ const PHRASING_TAGS = /* @__PURE__ */ new Set([
4129
+ "A",
4130
+ "ABBR",
4131
+ "B",
4132
+ "BR",
4133
+ "CITE",
4134
+ "CODE",
4135
+ "EM",
4136
+ "FONT",
4137
+ "I",
4138
+ "IMG",
4139
+ "KBD",
4140
+ "MARK",
4141
+ "Q",
4142
+ "S",
4143
+ "SMALL",
4144
+ "SPAN",
4145
+ "STRIKE",
4146
+ "STRONG",
4147
+ "SUB",
4148
+ "SUP",
4149
+ "U"
4150
+ ]);
4151
+ const HIDDEN_SELECTORS = ["[data-skip-in-text=\"true\"]", ".preheader"].join(",");
4152
+ const INHERITED_PROPERTIES = /* @__PURE__ */ new Set([
4153
+ "color",
4154
+ "direction",
4155
+ "fontFamily",
4156
+ "fontSize",
4157
+ "fontStyle",
4158
+ "fontVariant",
4159
+ "fontWeight",
4160
+ "letterSpacing",
4161
+ "lineHeight",
4162
+ "listStyle",
4163
+ "listStyleType",
4164
+ "textAlign",
4165
+ "textIndent",
4166
+ "textTransform",
4167
+ "whiteSpace",
4168
+ "wordSpacing"
4169
+ ]);
4170
+ function getRules(document) {
4171
+ const rules = [];
4172
+ for (const source of document.querySelectorAll("style")) {
4173
+ const sheet = window.document.createElement("style");
4174
+ sheet.textContent = source.textContent;
4175
+ window.document.head.append(sheet);
4176
+ for (const rule of Array.from(sheet.sheet?.cssRules ?? [])) if (rule instanceof CSSStyleRule) rules.push(rule);
4177
+ sheet.remove();
4178
+ }
4179
+ return rules;
4180
+ }
4181
+ function setRuleStyles(document) {
4182
+ const declared = /* @__PURE__ */ new Map();
4183
+ for (const rule of getRules(document)) {
4184
+ const style = (0, _maily_to_shared.parseInlineStyles)(rule.style.cssText);
4185
+ for (const element of document.querySelectorAll(rule.selectorText)) declared.set(element, {
4186
+ ...declared.get(element),
4187
+ ...style
4188
+ });
4189
+ }
4190
+ const authored = /* @__PURE__ */ new Map();
4191
+ for (const [element] of declared) authored.set(element, (0, _maily_to_shared.parseInlineStyles)(element.getAttribute("style") ?? ""));
4192
+ for (const [element, style] of declared) for (const [property, value] of Object.entries(style)) {
4193
+ if (!INHERITED_PROPERTIES.has(property)) continue;
4194
+ for (let ancestor = element.parentElement; ancestor && ancestor !== document.body; ancestor = ancestor.parentElement) {
4195
+ const above = authored.get(ancestor)?.[property] ?? declared.get(ancestor)?.[property];
4196
+ if (above === void 0) continue;
4197
+ if (above === value) delete style[property];
4198
+ break;
4199
+ }
4200
+ }
4201
+ for (const [element, style] of declared) {
4202
+ const merged = (0, _maily_to_shared.stringifyInlineStyles)((0, _maily_to_shared.mergeInlineStyles)(style, authored.get(element) ?? {}));
4203
+ if (merged) element.setAttribute("style", merged);
4204
+ }
4205
+ }
4206
+ function removeHidden(document) {
4207
+ for (const element of document.querySelectorAll(HIDDEN_SELECTORS)) element.remove();
4208
+ for (const element of document.querySelectorAll("[style]")) if (element.style.display === "none") element.remove();
4209
+ }
4210
+ function isPhrasing(node) {
4211
+ return node.nodeType === Node.TEXT_NODE || PHRASING_TAGS.has(node.nodeName);
4212
+ }
4213
+ function setCellParagraphs(document) {
4214
+ for (const parent of document.querySelectorAll("td, th")) {
4215
+ const runs = [[]];
4216
+ for (const child of parent.childNodes) if (isPhrasing(child)) runs.at(-1).push(child);
4217
+ else runs.push([]);
4218
+ for (const run of runs) {
4219
+ if (!run.some((node) => node.textContent?.trim())) continue;
4220
+ const paragraph = document.createElement("p");
4221
+ paragraph.setAttribute("style", "margin:0");
4222
+ run[0].before(paragraph);
4223
+ paragraph.append(...run);
4224
+ }
4225
+ }
4226
+ }
4227
+ function getSoleImage(anchor) {
4228
+ const images = anchor.querySelectorAll("img");
4229
+ return images.length === 1 && anchor.textContent?.trim() === "" ? images[0] : null;
4230
+ }
4231
+ function getSpacingAsMargin(style) {
4232
+ const moved = {};
4233
+ for (const [property, value] of Object.entries(style)) {
4234
+ const key = property.startsWith("padding") ? property.replace("padding", "margin") : property;
4235
+ moved[key] = value;
4236
+ }
4237
+ return moved;
4238
+ }
4239
+ function setLinkedImages(document) {
4240
+ for (const anchor of document.querySelectorAll("a[href]")) {
4241
+ const image = getSoleImage(anchor);
4242
+ if (!image) continue;
4243
+ const anchorStyle = anchor.getAttribute("style");
4244
+ if (anchorStyle) {
4245
+ image.setAttribute("style", (0, _maily_to_shared.stringifyInlineStyles)((0, _maily_to_shared.mergeInlineStyles)(getSpacingAsMargin((0, _maily_to_shared.parseInlineStyles)(anchorStyle)), (0, _maily_to_shared.parseInlineStyles)(image.getAttribute("style") ?? ""))));
4246
+ anchor.removeAttribute("style");
4247
+ }
4248
+ image.setAttribute("data-external-link", anchor.getAttribute("href") ?? "");
4249
+ anchor.removeAttribute("href");
4250
+ }
4251
+ }
4252
+ function getBodyWrapper(document) {
4253
+ for (const table of document.body.querySelectorAll("table")) if (!(table.style.maxWidth || !isBodyTable(table)) && getSingleCell(table)) return table;
4254
+ return null;
4255
+ }
4256
+ /**
4257
+ * Every HTML document has exactly one `<body>` and it is the document, so its
4258
+ * style has to reach the body node however the source wrote it. React Email
4259
+ * splits that style in two — background on `<body>`, the rest on an inner cell,
4260
+ * because Yahoo and AOL drop body styles — so the wrapper it writes is merged
4261
+ * in and unwrapped rather than surviving as a stray table.
4262
+ */
4263
+ function getBodyStyle(document) {
4264
+ const authored = (0, _maily_to_shared.parseInlineStyles)(document.body.getAttribute("style") ?? "");
4265
+ const wrapper = getBodyWrapper(document);
4266
+ const cell = wrapper ? getSingleCell(wrapper) : null;
4267
+ if (!(wrapper && cell)) return (0, _maily_to_shared.stringifyInlineStyles)(authored) || null;
4268
+ const merged = (0, _maily_to_shared.mergeInlineStyles)(authored, (0, _maily_to_shared.parseInlineStyles)(getWrapperStyle(wrapper) ?? ""));
4269
+ wrapper.replaceWith(...Array.from(cell.childNodes));
4270
+ return (0, _maily_to_shared.stringifyInlineStyles)(merged) || null;
4271
+ }
4272
+ function getVariableElement(document, variable) {
4273
+ const element = document.createElement("span");
4274
+ element.setAttribute(_maily_to_shared.DATA_NODE_TYPE_KEY, _maily_to_shared.MAILY_NODE_TYPES.VARIABLE);
4275
+ element.setAttribute("data-id", variable.id);
4276
+ element.setAttribute("data-required", String(variable.required));
4277
+ element.setAttribute("data-is-default-editable", String(variable.isDefaultEditable));
4278
+ if (variable.fallback) element.setAttribute("data-fallback", variable.fallback);
4279
+ if (variable.label) element.setAttribute("data-label", variable.label);
4280
+ if (variable.style) element.setAttribute("style", variable.style);
4281
+ return element;
4282
+ }
4283
+ function setVariables(document) {
4284
+ const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
4285
+ const texts = [];
4286
+ while (walker.nextNode()) {
4287
+ const text = walker.currentNode;
4288
+ if ((0, _maily_to_shared.hasVariableInText)(text.data) && !text.parentElement?.closest(LITERAL_SELECTORS)) texts.push(text);
4289
+ }
4290
+ for (const text of texts) text.replaceWith(...(0, _maily_to_shared.getVariableSegments)(text.data).map((segment) => {
4291
+ return segment.isReference ? getVariableElement(document, (0, _maily_to_shared.deserializeVariableFromText)(segment.text)) : segment.text;
4292
+ }));
4293
+ }
4294
+ function getNormalizedHtml(html) {
4295
+ const parsed = new DOMParser().parseFromString(html, "text/html");
4296
+ if (!parsed.body) return html;
4297
+ setRuleStyles(parsed);
4298
+ removeHidden(parsed);
4299
+ setLinkedImages(parsed);
4300
+ setVariables(parsed);
4301
+ setCellParagraphs(parsed);
4302
+ const style = getBodyStyle(parsed);
4303
+ if (!style) return parsed.body.innerHTML;
4304
+ const wrapper = parsed.createElement("div");
4305
+ wrapper.setAttribute(_maily_to_shared.DATA_NODE_TYPE_KEY, _maily_to_shared.MAILY_NODE_TYPES.BODY);
4306
+ wrapper.setAttribute("style", style);
4307
+ wrapper.append(...Array.from(parsed.body.childNodes));
4308
+ return wrapper.outerHTML;
4309
+ }
4310
+ //#endregion
4311
+ //#region src/utils/paste.ts
4312
+ function isPlainPaste(view) {
4313
+ const { input } = view;
4314
+ return Boolean(input?.shiftKey) || Boolean(view.state.selection.$from.parent.type.spec.code);
4315
+ }
4316
+ function isHtmlSource(text) {
4317
+ return text.startsWith("<") && text.endsWith(">");
4318
+ }
4319
+ function pasteHtmlSource(options) {
4320
+ const { event, view } = options;
4321
+ const text = event.clipboardData?.getData("text/plain")?.trim() ?? "";
4322
+ if (event.clipboardData?.getData("text/html") || isPlainPaste(view) || !isHtmlSource(text)) return false;
4323
+ const element = document.createElement("div");
4324
+ element.innerHTML = getNormalizedHtml(text);
4325
+ const parsed = _tiptap_pm_model.DOMParser.fromSchema(view.state.schema).parse(element);
4326
+ const container = parsed.firstChild?.firstChild;
4327
+ if (!container?.content.size) return false;
4328
+ const wasEmpty = (0, _tiptap_core.isNodeEmpty)(view.state.doc);
4329
+ const from = view.state.selection.from;
4330
+ view.dispatch(view.state.tr.insertText(text).setMeta("paste", true));
4331
+ const converted = (0, _tiptap_pm_history.closeHistory)(view.state.tr);
4332
+ const to = view.state.selection.from;
4333
+ if (wasEmpty) converted.replaceWith(0, view.state.doc.content.size, parsed.content);
4334
+ else converted.replaceRange(from, to, _tiptap_pm_model.Slice.maxOpen(container.content));
4335
+ view.dispatch(converted.setMeta("paste", true));
4336
+ return true;
4337
+ }
4338
+ //#endregion
4339
+ //#region src/hooks/use-maily-editor.ts
4340
+ const DEFAULT_EXTENSIONS = [
4341
+ Document,
4342
+ BodyExtension,
4343
+ ContainerExtension,
4344
+ SectionExtension,
4345
+ RepeatExtension,
4346
+ ColumnsExtension,
4347
+ ColumnExtension,
4348
+ ParagraphExtension,
4349
+ _tiptap_extension_heading.Heading.configure({
4350
+ levels: [
4351
+ 1,
4352
+ 2,
4353
+ 3
4354
+ ],
4355
+ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.HEADING }
4356
+ }),
4357
+ _tiptap_extension_text.Text,
4358
+ PlaceholderExtension,
4359
+ _tiptap_extension_hard_break.HardBreak,
4360
+ BoldExtension,
4361
+ _tiptap_extension_italic.Italic,
4362
+ _tiptap_extension_strike.Strike,
4363
+ _tiptap_extension_underline.Underline,
4364
+ _tiptap_extension_link.Link.configure({
4365
+ openOnClick: false,
4366
+ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_MARK_TYPES.LINK }
4367
+ }),
4368
+ _tiptap_extension_code.Code.configure({ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_MARK_TYPES.CODE } }),
4369
+ _tiptap_extension_text_style.TextStyleKit.configure({
4370
+ fontFamily: false,
4371
+ fontSize: false,
4372
+ lineHeight: false,
4373
+ backgroundColor: false,
4374
+ textStyle: false
4375
+ }),
4376
+ _tiptap_extension_text_style.TextStyle.extend({ parseHTML() {
4377
+ return [{
4378
+ tag: "span[style]",
4379
+ consuming: false,
4380
+ getAttrs: (element) => element.style.color ? {} : false
4381
+ }];
4382
+ } }),
4383
+ _tiptap_extension_highlight.Highlight.configure({ multicolor: true }),
4384
+ SpanExtension,
4385
+ InlineSpanExtension,
4386
+ HorizontalRuleExtension,
4387
+ ImageExtension,
4388
+ ImageUploadExtension,
4389
+ InlineImageExtension,
4390
+ SpacerExtension,
4391
+ ButtonExtension,
4392
+ FooterExtension,
4393
+ BlockquoteExtension,
4394
+ HtmlCodeBlockExtension,
4395
+ _tiptap_extension_list.BulletList.configure({ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.BULLET_LIST } }),
4396
+ _tiptap_extension_list.ListItem.configure({ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.LIST_ITEM } }),
4397
+ _tiptap_extension_list.OrderedList.configure({ HTMLAttributes: { [_maily_to_shared.DATA_NODE_TYPE_KEY]: _maily_to_shared.MAILY_NODE_TYPES.ORDERED_LIST } }),
4398
+ TableExtension,
4399
+ TableRowExtension,
4400
+ TableCellExtension,
4401
+ TableHeaderExtension,
4402
+ StyleExtension,
4403
+ VisibilityExtension,
4404
+ VariableExtension,
4405
+ SlashCommandExtension,
4406
+ _tiptap_extension_typography.Typography,
4407
+ _tiptap_extensions.UndoRedo,
4408
+ _tiptap_extensions.Dropcursor.configure({
4409
+ color: "#d1d5dc",
4410
+ width: 2
4411
+ }),
4412
+ _tiptap_extensions.Gapcursor,
4413
+ _tiptap_extensions.Selection,
4414
+ _tiptap_extensions.Focus,
4415
+ _tiptap_extension_unique_id.UniqueID.configure({
4416
+ types: [
4417
+ _maily_to_shared.MAILY_NODE_TYPES.HEADING,
4418
+ _maily_to_shared.MAILY_NODE_TYPES.PARAGRAPH,
4419
+ _maily_to_shared.MAILY_NODE_TYPES.SECTION,
4420
+ _maily_to_shared.MAILY_NODE_TYPES.REPEAT,
4421
+ _maily_to_shared.MAILY_NODE_TYPES.COLUMNS,
4422
+ _maily_to_shared.MAILY_NODE_TYPES.COLUMN,
4423
+ _maily_to_shared.MAILY_NODE_TYPES.BULLET_LIST,
4424
+ _maily_to_shared.MAILY_NODE_TYPES.ORDERED_LIST,
4425
+ _maily_to_shared.MAILY_NODE_TYPES.LIST_ITEM,
4426
+ _maily_to_shared.MAILY_NODE_TYPES.HORIZONTAL_RULE,
4427
+ _maily_to_shared.MAILY_NODE_TYPES.BLOCKQUOTE
4428
+ ],
4429
+ filterTransaction: (tr) => !isRemoteChange(tr)
4430
+ })
4431
+ ];
4432
+ function useMailyEditor(options, dependencies) {
4433
+ const $ = (0, react_compiler_runtime.c)(24);
4434
+ let content;
4435
+ let editorProps;
4436
+ let rest;
4437
+ let userExtensions;
4438
+ if ($[0] !== options) {
4439
+ ({content, editorProps, extensions: userExtensions, ...rest} = options);
4440
+ $[0] = options;
4441
+ $[1] = content;
4442
+ $[2] = editorProps;
4443
+ $[3] = rest;
4444
+ $[4] = userExtensions;
4445
+ } else {
4446
+ content = $[1];
4447
+ editorProps = $[2];
4448
+ rest = $[3];
4449
+ userExtensions = $[4];
4450
+ }
4451
+ let t0;
4452
+ if ($[5] !== userExtensions) {
4453
+ const merged = userExtensions ? mergeExtensions(DEFAULT_EXTENSIONS, userExtensions) : DEFAULT_EXTENSIONS;
4454
+ t0 = merged.some(_temp) ? merged.filter(_temp2) : merged;
4455
+ $[5] = userExtensions;
4456
+ $[6] = t0;
4457
+ } else t0 = $[6];
4458
+ const extensions = t0;
4459
+ const t1 = typeof content !== "string";
4460
+ let t2;
4461
+ if ($[7] !== content) {
4462
+ t2 = typeof content === "string" ? getNormalizedHtml(content) : content;
4463
+ $[7] = content;
4464
+ $[8] = t2;
4465
+ } else t2 = $[8];
4466
+ let t3;
4467
+ let t4;
4468
+ let t5;
4469
+ if ($[9] !== editorProps) {
4470
+ t3 = (state) => ({
4471
+ role: "textbox",
4472
+ spellcheck: "false",
4473
+ ...typeof editorProps?.attributes === "function" ? editorProps.attributes(state) : editorProps?.attributes
4474
+ });
4475
+ t4 = (view, event, slice) => pasteHtmlSource({
4476
+ event,
4477
+ view
4478
+ }) || (editorProps?.handlePaste?.(view, event, slice) ?? false);
4479
+ t5 = (html, view_0) => {
4480
+ const normalized = getNormalizedHtml(html);
4481
+ return editorProps?.transformPastedHTML?.(normalized, view_0) ?? normalized;
4482
+ };
4483
+ $[9] = editorProps;
4484
+ $[10] = t3;
4485
+ $[11] = t4;
4486
+ $[12] = t5;
4487
+ } else {
4488
+ t3 = $[10];
4489
+ t4 = $[11];
4490
+ t5 = $[12];
4491
+ }
4492
+ let t6;
4493
+ if ($[13] !== editorProps || $[14] !== t3 || $[15] !== t4 || $[16] !== t5) {
4494
+ t6 = {
4495
+ ...editorProps,
4496
+ attributes: t3,
4497
+ handlePaste: t4,
4498
+ transformPastedHTML: t5
4499
+ };
4500
+ $[13] = editorProps;
4501
+ $[14] = t3;
4502
+ $[15] = t4;
4503
+ $[16] = t5;
4504
+ $[17] = t6;
4505
+ } else t6 = $[17];
4506
+ let t7;
4507
+ if ($[18] !== extensions || $[19] !== rest || $[20] !== t1 || $[21] !== t2 || $[22] !== t6) {
4508
+ t7 = {
4509
+ enableContentCheck: t1,
4510
+ onContentError: _temp3,
4511
+ ...rest,
4512
+ content: t2,
4513
+ editorProps: t6,
4514
+ extensions
4515
+ };
4516
+ $[18] = extensions;
4517
+ $[19] = rest;
4518
+ $[20] = t1;
4519
+ $[21] = t2;
4520
+ $[22] = t6;
4521
+ $[23] = t7;
4522
+ } else t7 = $[23];
4523
+ return (0, _tiptap_react.useEditor)(t7, dependencies);
4524
+ }
4525
+ function _temp3(t0) {
4526
+ const { error } = t0;
4527
+ console.error(error);
4528
+ }
4529
+ function _temp2(extension) {
4530
+ return extension.name !== _tiptap_extensions.UndoRedo.name;
4531
+ }
4532
+ function _temp(extension_0) {
4533
+ return extension_0.name === "collaboration";
4534
+ }
4535
+ //#endregion
4536
+ Object.defineProperty(exports, "ALLOWED_IMAGE_MIME_TYPES", {
4537
+ enumerable: true,
4538
+ get: function() {
4539
+ return ALLOWED_IMAGE_MIME_TYPES;
4540
+ }
4541
+ });
4542
+ Object.defineProperty(exports, "ArrowIcon", {
4543
+ enumerable: true,
4544
+ get: function() {
4545
+ return ArrowIcon;
4546
+ }
4547
+ });
4548
+ Object.defineProperty(exports, "BlockquoteExtension", {
4549
+ enumerable: true,
4550
+ get: function() {
4551
+ return BlockquoteExtension;
4552
+ }
4553
+ });
4554
+ Object.defineProperty(exports, "BodyExtension", {
4555
+ enumerable: true,
4556
+ get: function() {
4557
+ return BodyExtension;
4558
+ }
4559
+ });
4560
+ Object.defineProperty(exports, "BoldExtension", {
4561
+ enumerable: true,
4562
+ get: function() {
4563
+ return BoldExtension;
4564
+ }
4565
+ });
4566
+ Object.defineProperty(exports, "ButtonExtension", {
4567
+ enumerable: true,
4568
+ get: function() {
4569
+ return ButtonExtension;
4570
+ }
4571
+ });
4572
+ Object.defineProperty(exports, "ColumnExtension", {
4573
+ enumerable: true,
4574
+ get: function() {
4575
+ return ColumnExtension;
4576
+ }
4577
+ });
4578
+ Object.defineProperty(exports, "ColumnsExtension", {
4579
+ enumerable: true,
4580
+ get: function() {
4581
+ return ColumnsExtension;
4582
+ }
4583
+ });
4584
+ Object.defineProperty(exports, "ContainerExtension", {
4585
+ enumerable: true,
4586
+ get: function() {
4587
+ return ContainerExtension;
4588
+ }
4589
+ });
4590
+ Object.defineProperty(exports, "DEFAULT_EXTENSIONS", {
4591
+ enumerable: true,
4592
+ get: function() {
4593
+ return DEFAULT_EXTENSIONS;
4594
+ }
4595
+ });
4596
+ Object.defineProperty(exports, "DEFAULT_REPEAT_EACH", {
4597
+ enumerable: true,
4598
+ get: function() {
4599
+ return DEFAULT_REPEAT_EACH;
4600
+ }
4601
+ });
4602
+ Object.defineProperty(exports, "DEFAULT_SLASH_COMMANDS", {
4603
+ enumerable: true,
4604
+ get: function() {
4605
+ return DEFAULT_SLASH_COMMANDS;
4606
+ }
4607
+ });
4608
+ Object.defineProperty(exports, "Document", {
4609
+ enumerable: true,
4610
+ get: function() {
4611
+ return Document;
4612
+ }
4613
+ });
4614
+ Object.defineProperty(exports, "FLOATING_ELEMENT_HEIGHT", {
4615
+ enumerable: true,
4616
+ get: function() {
4617
+ return FLOATING_ELEMENT_HEIGHT;
4618
+ }
4619
+ });
4620
+ Object.defineProperty(exports, "FLOATING_ELEMENT_IDS", {
4621
+ enumerable: true,
4622
+ get: function() {
4623
+ return FLOATING_ELEMENT_IDS;
4624
+ }
4625
+ });
4626
+ Object.defineProperty(exports, "FLOATING_ELEMENT_ORDER", {
4627
+ enumerable: true,
4628
+ get: function() {
4629
+ return FLOATING_ELEMENT_ORDER;
4630
+ }
4631
+ });
4632
+ Object.defineProperty(exports, "FLOATING_ELEMENT_PADDING", {
4633
+ enumerable: true,
4634
+ get: function() {
4635
+ return FLOATING_ELEMENT_PADDING;
4636
+ }
4637
+ });
4638
+ Object.defineProperty(exports, "FloatingElement", {
4639
+ enumerable: true,
4640
+ get: function() {
4641
+ return FloatingElement;
4642
+ }
4643
+ });
4644
+ Object.defineProperty(exports, "FooterExtension", {
4645
+ enumerable: true,
4646
+ get: function() {
4647
+ return FooterExtension;
4648
+ }
4649
+ });
4650
+ Object.defineProperty(exports, "HorizontalRuleExtension", {
4651
+ enumerable: true,
4652
+ get: function() {
4653
+ return HorizontalRuleExtension;
4654
+ }
4655
+ });
4656
+ Object.defineProperty(exports, "HtmlCodeBlockExtension", {
4657
+ enumerable: true,
4658
+ get: function() {
4659
+ return HtmlCodeBlockExtension;
4660
+ }
4661
+ });
4662
+ Object.defineProperty(exports, "IMAGE_UPLOAD_STATUSES", {
4663
+ enumerable: true,
4664
+ get: function() {
4665
+ return IMAGE_UPLOAD_STATUSES;
4666
+ }
4667
+ });
4668
+ Object.defineProperty(exports, "ImageExtension", {
4669
+ enumerable: true,
4670
+ get: function() {
4671
+ return ImageExtension;
4672
+ }
4673
+ });
4674
+ Object.defineProperty(exports, "ImageState", {
4675
+ enumerable: true,
4676
+ get: function() {
4677
+ return ImageState;
4678
+ }
4679
+ });
4680
+ Object.defineProperty(exports, "ImageUploadExtension", {
4681
+ enumerable: true,
4682
+ get: function() {
4683
+ return ImageUploadExtension;
4684
+ }
4685
+ });
4686
+ Object.defineProperty(exports, "InlineImageExtension", {
4687
+ enumerable: true,
4688
+ get: function() {
4689
+ return InlineImageExtension;
4690
+ }
4691
+ });
4692
+ Object.defineProperty(exports, "InlineSpanExtension", {
4693
+ enumerable: true,
4694
+ get: function() {
4695
+ return InlineSpanExtension;
4696
+ }
4697
+ });
4698
+ Object.defineProperty(exports, "MAX_SPACER_HEIGHT", {
4699
+ enumerable: true,
4700
+ get: function() {
4701
+ return MAX_SPACER_HEIGHT;
4702
+ }
4703
+ });
4704
+ Object.defineProperty(exports, "MIN_SPACER_HEIGHT", {
4705
+ enumerable: true,
4706
+ get: function() {
4707
+ return MIN_SPACER_HEIGHT;
4708
+ }
4709
+ });
4710
+ Object.defineProperty(exports, "ProtectVariableTrigger", {
4711
+ enumerable: true,
4712
+ get: function() {
4713
+ return ProtectVariableTrigger;
4714
+ }
4715
+ });
4716
+ Object.defineProperty(exports, "SPACER_SPACING", {
4717
+ enumerable: true,
4718
+ get: function() {
4719
+ return SPACER_SPACING;
4720
+ }
4721
+ });
4722
+ Object.defineProperty(exports, "SPACING_PRESETS", {
4723
+ enumerable: true,
4724
+ get: function() {
4725
+ return SPACING_PRESETS;
4726
+ }
4727
+ });
4728
+ Object.defineProperty(exports, "STYLE_SUPPORTED_TYPES", {
4729
+ enumerable: true,
4730
+ get: function() {
4731
+ return STYLE_SUPPORTED_TYPES;
4732
+ }
4733
+ });
4734
+ Object.defineProperty(exports, "SectionExtension", {
4735
+ enumerable: true,
4736
+ get: function() {
4737
+ return SectionExtension;
4738
+ }
4739
+ });
4740
+ Object.defineProperty(exports, "SlashCommandExtension", {
4741
+ enumerable: true,
4742
+ get: function() {
4743
+ return SlashCommandExtension;
4744
+ }
4745
+ });
4746
+ Object.defineProperty(exports, "SpacerExtension", {
4747
+ enumerable: true,
4748
+ get: function() {
4749
+ return SpacerExtension;
4750
+ }
4751
+ });
4752
+ Object.defineProperty(exports, "SpanExtension", {
4753
+ enumerable: true,
4754
+ get: function() {
4755
+ return SpanExtension;
4756
+ }
4757
+ });
4758
+ Object.defineProperty(exports, "StyleExtension", {
4759
+ enumerable: true,
4760
+ get: function() {
4761
+ return StyleExtension;
4762
+ }
4763
+ });
4764
+ Object.defineProperty(exports, "Tooltip", {
4765
+ enumerable: true,
4766
+ get: function() {
4767
+ return Tooltip;
4768
+ }
4769
+ });
4770
+ Object.defineProperty(exports, "TooltipArrow", {
4771
+ enumerable: true,
4772
+ get: function() {
4773
+ return TooltipArrow;
4774
+ }
4775
+ });
4776
+ Object.defineProperty(exports, "TooltipPopup", {
4777
+ enumerable: true,
4778
+ get: function() {
4779
+ return TooltipPopup;
4780
+ }
4781
+ });
4782
+ Object.defineProperty(exports, "TooltipPositioner", {
4783
+ enumerable: true,
4784
+ get: function() {
4785
+ return TooltipPositioner;
4786
+ }
4787
+ });
4788
+ Object.defineProperty(exports, "TooltipProvider", {
4789
+ enumerable: true,
4790
+ get: function() {
4791
+ return TooltipProvider;
4792
+ }
4793
+ });
4794
+ Object.defineProperty(exports, "TooltipTrigger", {
4795
+ enumerable: true,
4796
+ get: function() {
4797
+ return TooltipTrigger;
4798
+ }
4799
+ });
4800
+ Object.defineProperty(exports, "VARIABLE_SUGGESTION_POPOVER_ID", {
4801
+ enumerable: true,
4802
+ get: function() {
4803
+ return VARIABLE_SUGGESTION_POPOVER_ID;
4804
+ }
4805
+ });
4806
+ Object.defineProperty(exports, "VISIBILITY_SUPPORTED_TYPES", {
4807
+ enumerable: true,
4808
+ get: function() {
4809
+ return VISIBILITY_SUPPORTED_TYPES;
4810
+ }
4811
+ });
4812
+ Object.defineProperty(exports, "VariableExtension", {
4813
+ enumerable: true,
4814
+ get: function() {
4815
+ return VariableExtension;
4816
+ }
4817
+ });
4818
+ Object.defineProperty(exports, "VisibilityExtension", {
4819
+ enumerable: true,
4820
+ get: function() {
4821
+ return VisibilityExtension;
4822
+ }
4823
+ });
4824
+ Object.defineProperty(exports, "VisuallyHidden", {
4825
+ enumerable: true,
4826
+ get: function() {
4827
+ return VisuallyHidden;
4828
+ }
4829
+ });
4830
+ Object.defineProperty(exports, "__exportAll", {
4831
+ enumerable: true,
4832
+ get: function() {
4833
+ return __exportAll;
4834
+ }
4835
+ });
4836
+ Object.defineProperty(exports, "addColumn", {
4837
+ enumerable: true,
4838
+ get: function() {
4839
+ return addColumn;
4840
+ }
4841
+ });
4842
+ Object.defineProperty(exports, "clearInitialNodeSelection", {
4843
+ enumerable: true,
4844
+ get: function() {
4845
+ return clearInitialNodeSelection;
4846
+ }
4847
+ });
4848
+ Object.defineProperty(exports, "filterVariableSuggestions", {
4849
+ enumerable: true,
4850
+ get: function() {
4851
+ return filterVariableSuggestions;
4852
+ }
4853
+ });
4854
+ Object.defineProperty(exports, "getColumnWidths", {
4855
+ enumerable: true,
4856
+ get: function() {
4857
+ return getColumnWidths;
4858
+ }
4859
+ });
4860
+ Object.defineProperty(exports, "getMergedNodeTheme", {
4861
+ enumerable: true,
4862
+ get: function() {
4863
+ return getMergedNodeTheme;
4864
+ }
4865
+ });
4866
+ Object.defineProperty(exports, "getNodeStyleState", {
4867
+ enumerable: true,
4868
+ get: function() {
4869
+ return getNodeStyleState;
4870
+ }
4871
+ });
4872
+ Object.defineProperty(exports, "getNodeTheme", {
4873
+ enumerable: true,
4874
+ get: function() {
4875
+ return getNodeTheme;
4876
+ }
4877
+ });
4878
+ Object.defineProperty(exports, "getNormalizedHtml", {
4879
+ enumerable: true,
4880
+ get: function() {
4881
+ return getNormalizedHtml;
4882
+ }
4883
+ });
4884
+ Object.defineProperty(exports, "getShellNodes", {
4885
+ enumerable: true,
4886
+ get: function() {
4887
+ return getShellNodes;
4888
+ }
4889
+ });
4890
+ Object.defineProperty(exports, "getThemeCss", {
4891
+ enumerable: true,
4892
+ get: function() {
4893
+ return getThemeCss;
4894
+ }
4895
+ });
4896
+ Object.defineProperty(exports, "getVariableSuggestions", {
4897
+ enumerable: true,
4898
+ get: function() {
4899
+ return getVariableSuggestions;
4900
+ }
4901
+ });
4902
+ Object.defineProperty(exports, "mergeExtensions", {
4903
+ enumerable: true,
4904
+ get: function() {
4905
+ return mergeExtensions;
4906
+ }
4907
+ });
4908
+ Object.defineProperty(exports, "removeColumn", {
4909
+ enumerable: true,
4910
+ get: function() {
4911
+ return removeColumn;
4912
+ }
4913
+ });
4914
+ Object.defineProperty(exports, "setStyleDeclarations", {
4915
+ enumerable: true,
4916
+ get: function() {
4917
+ return setStyleDeclarations;
4918
+ }
4919
+ });
4920
+ Object.defineProperty(exports, "updateColumnWidth", {
4921
+ enumerable: true,
4922
+ get: function() {
4923
+ return updateColumnWidth;
4924
+ }
4925
+ });
4926
+ Object.defineProperty(exports, "useEditorInstance", {
4927
+ enumerable: true,
4928
+ get: function() {
4929
+ return useEditorInstance;
4930
+ }
4931
+ });
4932
+ Object.defineProperty(exports, "useFloatingStore", {
4933
+ enumerable: true,
4934
+ get: function() {
4935
+ return useFloatingStore;
4936
+ }
4937
+ });
4938
+ Object.defineProperty(exports, "useMailyEditor", {
4939
+ enumerable: true,
4940
+ get: function() {
4941
+ return useMailyEditor;
4942
+ }
4943
+ });
4944
+ Object.defineProperty(exports, "useOnSelectionUpdate", {
4945
+ enumerable: true,
4946
+ get: function() {
4947
+ return useOnSelectionUpdate;
4948
+ }
4949
+ });
4950
+ Object.defineProperty(exports, "useValueAsRef", {
4951
+ enumerable: true,
4952
+ get: function() {
4953
+ return useValueAsRef;
4954
+ }
4955
+ });