@maily-to/core 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -53,7 +53,7 @@ var __async = (__this, __arguments, generator) => {
53
53
 
54
54
  // src/editor/index.tsx
55
55
  import { EditorContent, useEditor } from "@tiptap/react";
56
- import { useMemo as useMemo13, useRef as useRef12 } from "react";
56
+ import { useMemo as useMemo14, useRef as useRef13 } from "react";
57
57
 
58
58
  // src/editor/components/column-menu/columns-bubble-menu.tsx
59
59
  import { BubbleMenu } from "@tiptap/react";
@@ -2559,10 +2559,24 @@ var useEvent = (handler) => {
2559
2559
  }, []);
2560
2560
  };
2561
2561
 
2562
+ // src/editor/utils/aspect-ratio.ts
2563
+ function getAspectRatio(width, height) {
2564
+ return width / height;
2565
+ }
2566
+ function getNewHeight(width, aspectRatio) {
2567
+ if (width <= 0 || aspectRatio <= 0) {
2568
+ return 0;
2569
+ }
2570
+ return width / aspectRatio;
2571
+ }
2572
+ function getNewWidth(height, aspectRatio) {
2573
+ return height * aspectRatio;
2574
+ }
2575
+
2562
2576
  // src/editor/nodes/image/image-view.tsx
2563
2577
  import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
2564
2578
  var MIN_WIDTH = 20;
2565
- var MAX_WIDTH = 600;
2579
+ var IMAGE_MAX_WIDTH = 600;
2566
2580
  function ImageView(props) {
2567
2581
  const { node, updateAttributes: updateAttributes2, selected, editor } = props;
2568
2582
  const [status, setStatus] = useState4("idle");
@@ -2580,7 +2594,10 @@ function ImageView(props) {
2580
2594
  if (!imgRef.current || !imageParent || !selected) {
2581
2595
  return;
2582
2596
  }
2583
- const imageParentWidth = Math.max(imageParent.offsetWidth, MAX_WIDTH);
2597
+ const imageParentWidth = Math.max(
2598
+ imageParent.offsetWidth,
2599
+ IMAGE_MAX_WIDTH
2600
+ );
2584
2601
  event.preventDefault();
2585
2602
  const direction = event.currentTarget.dataset.direction || "--";
2586
2603
  const initialXPosition = event.clientX;
@@ -2592,7 +2609,8 @@ function ImageView(props) {
2592
2609
  const removeListeners = () => {
2593
2610
  window.removeEventListener("mousemove", mouseMoveHandler);
2594
2611
  window.removeEventListener("mouseup", removeListeners);
2595
- updateAttributes2({ width: newWidth, height: newHeight });
2612
+ const aspectRatio = getAspectRatio(newWidth, newHeight);
2613
+ updateAttributes2({ width: newWidth, height: newHeight, aspectRatio });
2596
2614
  setResizingStyle(void 0);
2597
2615
  };
2598
2616
  const mouseMoveHandler = (event2) => {
@@ -2638,17 +2656,29 @@ function ImageView(props) {
2638
2656
  },
2639
2657
  [handleMouseDown, isPlaceholderImage]
2640
2658
  );
2641
- let { alignment = "center", width, height, src } = node.attrs || {};
2659
+ let {
2660
+ alignment = "center",
2661
+ width,
2662
+ height,
2663
+ src,
2664
+ borderRadius: borderRadius2
2665
+ } = node.attrs || {};
2642
2666
  const _a = node.attrs || {}, {
2643
2667
  externalLink,
2644
2668
  isExternalLinkVariable,
2645
2669
  isSrcVariable,
2646
- showIfKey
2670
+ showIfKey,
2671
+ aspectRatio: defaultAspectRatio,
2672
+ borderRadius: _,
2673
+ lockAspectRatio
2647
2674
  } = _a, attrs = __objRest(_a, [
2648
2675
  "externalLink",
2649
2676
  "isExternalLinkVariable",
2650
2677
  "isSrcVariable",
2651
- "showIfKey"
2678
+ "showIfKey",
2679
+ "aspectRatio",
2680
+ "borderRadius",
2681
+ "lockAspectRatio"
2652
2682
  ]);
2653
2683
  const hasImageSrc = !!attrs.src;
2654
2684
  const isDroppable = !!onImageUpload && editor.isEditable && !hasImageSrc && !isSrcVariable && status === "idle";
@@ -2695,14 +2725,15 @@ function ImageView(props) {
2695
2725
  return;
2696
2726
  }
2697
2727
  const wrapperWidth = wrapper.offsetWidth;
2698
- const aspectRatio = naturalWidth / naturalHeight;
2728
+ const aspectRatio = getAspectRatio(naturalWidth, naturalHeight);
2699
2729
  const calculatedHeight = Math.min(
2700
- wrapperWidth / aspectRatio,
2730
+ getNewHeight(wrapperWidth, aspectRatio),
2701
2731
  naturalHeight
2702
2732
  );
2703
2733
  updateAttributes2({
2704
2734
  width: Math.min(wrapperWidth, naturalWidth),
2705
- height: Math.min(calculatedHeight, naturalHeight)
2735
+ height: Math.min(calculatedHeight, naturalHeight),
2736
+ aspectRatio
2706
2737
  });
2707
2738
  };
2708
2739
  img.onerror = () => {
@@ -2772,7 +2803,8 @@ function ImageView(props) {
2772
2803
  position: "relative",
2773
2804
  // Weird! Basically tiptap/prose wraps this in a span and the line height causes an annoying buffer.
2774
2805
  lineHeight: "0px",
2775
- display: "block"
2806
+ display: "block",
2807
+ maxWidth: "100%"
2776
2808
  }), {
2777
2809
  center: { marginLeft: "auto", marginRight: "auto" },
2778
2810
  left: { marginRight: "auto" },
@@ -2814,7 +2846,8 @@ function ImageView(props) {
2814
2846
  ref: imgRef,
2815
2847
  style: __spreadProps(__spreadValues({}, resizingStyle), {
2816
2848
  cursor: "default",
2817
- marginBottom: 0
2849
+ marginBottom: 0,
2850
+ borderRadius: borderRadius2
2818
2851
  }),
2819
2852
  draggable: editor.isEditable,
2820
2853
  className: cn(
@@ -3164,9 +3197,33 @@ var LogoExtension = TiptapImage.extend({
3164
3197
  }
3165
3198
  });
3166
3199
 
3200
+ // src/editor/utils/border-radius.ts
3201
+ var borderRadius = [
3202
+ {
3203
+ name: "Sharp",
3204
+ value: 0
3205
+ },
3206
+ {
3207
+ name: "Smooth",
3208
+ value: 8
3209
+ },
3210
+ {
3211
+ name: "Smoother",
3212
+ value: 16
3213
+ },
3214
+ {
3215
+ name: "Rounded",
3216
+ value: 24
3217
+ },
3218
+ {
3219
+ name: "Circle",
3220
+ value: 9999
3221
+ }
3222
+ ];
3223
+
3167
3224
  // src/editor/components/image-menu/image-bubble-menu.tsx
3168
3225
  import { BubbleMenu as BubbleMenu3 } from "@tiptap/react";
3169
- import { ImageDown } from "lucide-react";
3226
+ import { ImageDown, LockIcon, LockOpenIcon } from "lucide-react";
3170
3227
  import { sticky as sticky3 } from "tippy.js";
3171
3228
 
3172
3229
  // src/editor/components/alignment-switch.tsx
@@ -3242,7 +3299,7 @@ function AlignmentSwitch(props) {
3242
3299
  }
3243
3300
 
3244
3301
  // src/editor/components/ui/link-input-popover.tsx
3245
- import { ChevronDownIcon as ChevronDownIcon2, Link } from "lucide-react";
3302
+ import { Link, LinkIcon as LinkIcon2 } from "lucide-react";
3246
3303
  import { useRef as useRef7, useState as useState7 } from "react";
3247
3304
 
3248
3305
  // src/editor/provider.tsx
@@ -3320,7 +3377,7 @@ var inlineImage = {
3320
3377
  icon: /* @__PURE__ */ jsx22(ImageIcon, { className: "mly-h-4 mly-w-4" }),
3321
3378
  command: ({ editor, range }) => {
3322
3379
  editor.chain().focus().deleteRange(range).setInlineImage({
3323
- src: ""
3380
+ src: "https://maily.to/brand/logo.png"
3324
3381
  }).command((props) => {
3325
3382
  const { tr, state, view, editor: editor2 } = props;
3326
3383
  const { from } = range;
@@ -4167,7 +4224,7 @@ var DEFAULT_SLASH_COMMANDS = [
4167
4224
 
4168
4225
  // src/editor/provider.tsx
4169
4226
  import { jsx as jsx32 } from "react/jsx-runtime";
4170
- var DEFAULT_PLACEHOLDER_URL = "maily.to/";
4227
+ var DEFAULT_PLACEHOLDER_URL = "https://maily.to/";
4171
4228
  var MailyContext = createContext({
4172
4229
  placeholderUrl: DEFAULT_PLACEHOLDER_URL,
4173
4230
  blocks: DEFAULT_SLASH_COMMANDS
@@ -4598,10 +4655,9 @@ var VariableExtension = Node4.create({
4598
4655
  });
4599
4656
 
4600
4657
  // src/editor/components/ui/link-input-popover.tsx
4601
- import { Fragment as Fragment4, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
4602
- var LINK_PROTOCOL_REGEX = /https?:\/\//;
4658
+ import { jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
4603
4659
  function LinkInputPopover(props) {
4604
- var _a, _b, _c;
4660
+ var _a, _b;
4605
4661
  const {
4606
4662
  defaultValue = "",
4607
4663
  onValueChange,
@@ -4610,22 +4666,16 @@ function LinkInputPopover(props) {
4610
4666
  editor,
4611
4667
  isVariable
4612
4668
  } = props;
4613
- const defaultProtocol = (_a = defaultValue.match(LINK_PROTOCOL_REGEX)) == null ? void 0 : _a[0];
4614
- const defaultUrlWithoutProtocol = defaultValue.replace(
4615
- LINK_PROTOCOL_REGEX,
4616
- ""
4617
- );
4618
4669
  const [isOpen, setIsOpen] = useState7(false);
4619
- const [protocol, setProtocol] = useState7(defaultProtocol || "https://");
4620
4670
  const [isEditing, setIsEditing] = useState7(!isVariable);
4621
4671
  const linkInputRef = useRef7(null);
4622
4672
  const { placeholderUrl = DEFAULT_PLACEHOLDER_URL } = useMailyContext();
4623
4673
  const options = useVariableOptions(editor);
4624
4674
  const renderVariable = options == null ? void 0 : options.renderVariable;
4625
4675
  const variables = options == null ? void 0 : options.variables;
4626
- const variableTriggerCharacter = (_c = (_b = options == null ? void 0 : options.suggestion) == null ? void 0 : _b.char) != null ? _c : DEFAULT_VARIABLE_TRIGGER_CHAR;
4676
+ const variableTriggerCharacter = (_b = (_a = options == null ? void 0 : options.suggestion) == null ? void 0 : _a.char) != null ? _b : DEFAULT_VARIABLE_TRIGGER_CHAR;
4627
4677
  const autoCompleteOptions = useMemo6(() => {
4628
- const withoutTrigger = defaultUrlWithoutProtocol.replace(
4678
+ const withoutTrigger = defaultValue.replace(
4629
4679
  new RegExp(variableTriggerCharacter, "g"),
4630
4680
  ""
4631
4681
  );
@@ -4634,7 +4684,7 @@ function LinkInputPopover(props) {
4634
4684
  from: "bubble-variable",
4635
4685
  editor
4636
4686
  }).map((variable) => variable.name);
4637
- }, [variables, variableTriggerCharacter, defaultUrlWithoutProtocol, editor]);
4687
+ }, [variables, variableTriggerCharacter, defaultValue, editor]);
4638
4688
  const popoverButton = /* @__PURE__ */ jsx35(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx35(
4639
4689
  BaseButton,
4640
4690
  {
@@ -4642,130 +4692,105 @@ function LinkInputPopover(props) {
4642
4692
  size: "sm",
4643
4693
  type: "button",
4644
4694
  className: "mly-size-7",
4645
- "data-state": !!defaultUrlWithoutProtocol,
4695
+ "data-state": !!defaultValue,
4646
4696
  children: /* @__PURE__ */ jsx35(Icon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-midnight-gray" })
4647
4697
  }
4648
4698
  ) });
4649
- const normalizeProtocol = (value, p = protocol) => {
4650
- value = value == null ? void 0 : value.replace(LINK_PROTOCOL_REGEX, "");
4651
- return p + value;
4652
- };
4653
- return /* @__PURE__ */ jsxs17(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [
4654
- tooltip ? /* @__PURE__ */ jsxs17(Tooltip, { children: [
4655
- /* @__PURE__ */ jsx35(TooltipTrigger, { asChild: true, children: popoverButton }),
4656
- /* @__PURE__ */ jsx35(TooltipContent, { sideOffset: 8, children: tooltip })
4657
- ] }) : popoverButton,
4658
- /* @__PURE__ */ jsx35(
4659
- PopoverContent,
4660
- {
4661
- align: "end",
4662
- side: "top",
4663
- className: "mly-w-max mly-rounded-none mly-border-none mly-bg-transparent !mly-p-0 mly-shadow-none",
4664
- sideOffset: 8,
4665
- onCloseAutoFocus: (e) => e.preventDefault(),
4666
- children: /* @__PURE__ */ jsx35(
4667
- "form",
4699
+ return /* @__PURE__ */ jsxs17(
4700
+ Popover,
4701
+ {
4702
+ open: isOpen,
4703
+ onOpenChange: (open) => {
4704
+ setIsOpen(open);
4705
+ if (open) {
4706
+ setTimeout(() => {
4707
+ var _a2;
4708
+ (_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
4709
+ }, 0);
4710
+ }
4711
+ },
4712
+ children: [
4713
+ tooltip ? /* @__PURE__ */ jsxs17(Tooltip, { children: [
4714
+ /* @__PURE__ */ jsx35(TooltipTrigger, { asChild: true, children: popoverButton }),
4715
+ /* @__PURE__ */ jsx35(TooltipContent, { sideOffset: 8, children: tooltip })
4716
+ ] }) : popoverButton,
4717
+ /* @__PURE__ */ jsx35(
4718
+ PopoverContent,
4668
4719
  {
4669
- onSubmit: (e) => {
4670
- e.preventDefault();
4671
- const input = linkInputRef.current;
4672
- if (!input) {
4673
- return;
4674
- }
4675
- let value = normalizeProtocol(input.value);
4676
- onValueChange == null ? void 0 : onValueChange(value);
4677
- setIsOpen(false);
4678
- },
4679
- children: /* @__PURE__ */ jsxs17("div", { className: "mly-isolate mly-flex mly-rounded-lg", children: [
4680
- !isEditing && /* @__PURE__ */ jsx35("div", { className: "mly-flex mly-h-8 mly-items-center mly-rounded-lg mly-border mly-border-gray-300 mly-bg-white mly-px-0.5", children: /* @__PURE__ */ jsx35(
4681
- "button",
4682
- {
4683
- onClick: () => {
4684
- setIsEditing(true);
4685
- setTimeout(() => {
4686
- var _a2;
4687
- (_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
4688
- }, 0);
4689
- },
4690
- children: renderVariable({
4691
- variable: {
4692
- name: defaultUrlWithoutProtocol,
4693
- valid: true
4694
- },
4695
- fallback: "",
4696
- from: "bubble-variable",
4697
- editor
4698
- })
4699
- }
4700
- ) }),
4701
- isEditing && /* @__PURE__ */ jsxs17(Fragment4, { children: [
4702
- /* @__PURE__ */ jsxs17("div", { className: "mly-relative", children: [
4703
- /* @__PURE__ */ jsxs17(
4704
- "select",
4720
+ align: "end",
4721
+ side: "top",
4722
+ className: "mly-w-max mly-rounded-none mly-border-none mly-bg-transparent !mly-p-0 mly-shadow-none",
4723
+ sideOffset: 8,
4724
+ onCloseAutoFocus: (e) => e.preventDefault(),
4725
+ children: /* @__PURE__ */ jsx35(
4726
+ "form",
4727
+ {
4728
+ onSubmit: (e) => {
4729
+ e.preventDefault();
4730
+ const input = linkInputRef.current;
4731
+ if (!input) {
4732
+ return;
4733
+ }
4734
+ onValueChange == null ? void 0 : onValueChange(input.value);
4735
+ setIsOpen(false);
4736
+ },
4737
+ children: /* @__PURE__ */ jsxs17("div", { className: "mly-isolate mly-flex mly-rounded-lg", children: [
4738
+ !isEditing && /* @__PURE__ */ jsx35("div", { className: "mly-flex mly-h-8 mly-items-center mly-rounded-lg mly-border mly-border-gray-300 mly-bg-white mly-px-0.5", children: /* @__PURE__ */ jsx35(
4739
+ "button",
4705
4740
  {
4706
- className: "hover:text-accent-foreground mly-peer mly-inline-flex mly-h-full mly-appearance-none mly-items-center mly-rounded-none mly-rounded-s-lg mly-border mly-border-gray-300 mly-bg-gray-50 mly-pe-8 mly-ps-3 mly-text-sm mly-text-gray-700 mly-transition-shadow hover:mly-bg-gray-100 focus:mly-z-10 focus-visible:mly-outline-none disabled:mly-pointer-events-none disabled:mly-cursor-not-allowed disabled:mly-opacity-50",
4707
- "aria-label": "Protocol",
4708
- value: protocol,
4709
- onChange: (e) => {
4710
- var _a2;
4711
- const protocol2 = e.target.value;
4712
- setProtocol(protocol2);
4713
- const newValue = normalizeProtocol(
4714
- ((_a2 = linkInputRef.current) == null ? void 0 : _a2.value) || "",
4715
- protocol2
4716
- );
4717
- onValueChange == null ? void 0 : onValueChange(newValue);
4741
+ onClick: () => {
4742
+ setIsEditing(true);
4743
+ setTimeout(() => {
4744
+ var _a2;
4745
+ (_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
4746
+ }, 0);
4718
4747
  },
4719
- children: [
4720
- /* @__PURE__ */ jsx35("option", { value: "https://", children: "https://" }),
4721
- /* @__PURE__ */ jsx35("option", { value: "http://", children: "http://" })
4722
- ]
4723
- }
4724
- ),
4725
- /* @__PURE__ */ jsx35("span", { className: "mly-pointer-events-none mly-absolute mly-inset-y-0 mly-right-0 mly-z-10 mly-flex mly-h-full mly-w-9 mly-items-center mly-justify-center mly-text-gray-600 peer-disabled:mly-opacity-50", children: /* @__PURE__ */ jsx35(
4726
- ChevronDownIcon2,
4727
- {
4728
- size: 16,
4729
- strokeWidth: 2,
4730
- "aria-hidden": "true",
4731
- role: "img"
4748
+ children: renderVariable({
4749
+ variable: {
4750
+ name: defaultValue,
4751
+ valid: true
4752
+ },
4753
+ fallback: "",
4754
+ from: "bubble-variable",
4755
+ editor
4756
+ })
4732
4757
  }
4733
- ) })
4734
- ] }),
4735
- /* @__PURE__ */ jsx35(
4736
- InputAutocomplete,
4737
- {
4738
- editor,
4739
- value: defaultUrlWithoutProtocol,
4740
- onValueChange: (value) => {
4741
- let newValue = normalizeProtocol(value);
4742
- onValueChange == null ? void 0 : onValueChange(newValue);
4743
- },
4744
- autoCompleteOptions,
4745
- ref: linkInputRef,
4746
- placeholder: placeholderUrl,
4747
- className: "-mly-ms-px mly-block mly-h-8 mly-w-52 mly-rounded-lg mly-rounded-s-none mly-border mly-border-gray-300 mly-px-2 mly-py-1.5 mly-pr-6 mly-text-sm mly-shadow-sm mly-outline-none placeholder:mly-text-gray-400",
4748
- triggerChar: variableTriggerCharacter,
4749
- onSelectOption: (value) => {
4750
- var _a2;
4751
- const isVariable2 = (_a2 = autoCompleteOptions.includes(value)) != null ? _a2 : false;
4752
- if (isVariable2) {
4753
- setIsEditing(false);
4754
- } else {
4755
- value = normalizeProtocol(value);
4758
+ ) }),
4759
+ isEditing && /* @__PURE__ */ jsxs17("div", { className: "mly-relative", children: [
4760
+ /* @__PURE__ */ jsx35("div", { className: "mly-absolute mly-inset-y-0 mly-left-1.5 mly-z-10 mly-flex mly-items-center", children: /* @__PURE__ */ jsx35(LinkIcon2, { className: "mly-h-3 mly-w-3 mly-stroke-[2.5] mly-text-midnight-gray" }) }),
4761
+ /* @__PURE__ */ jsx35(
4762
+ InputAutocomplete,
4763
+ {
4764
+ editor,
4765
+ value: defaultValue,
4766
+ onValueChange: (value) => {
4767
+ onValueChange == null ? void 0 : onValueChange(value);
4768
+ },
4769
+ autoCompleteOptions,
4770
+ ref: linkInputRef,
4771
+ placeholder: placeholderUrl,
4772
+ className: "-mly-ms-px mly-block mly-h-8 mly-w-56 mly-rounded-lg mly-border mly-border-gray-300 mly-px-2 mly-py-1.5 mly-pl-6 mly-pr-6 mly-text-sm mly-shadow-sm mly-outline-none placeholder:mly-text-gray-400",
4773
+ triggerChar: variableTriggerCharacter,
4774
+ onSelectOption: (value) => {
4775
+ var _a2;
4776
+ const isVariable2 = (_a2 = autoCompleteOptions.includes(value)) != null ? _a2 : false;
4777
+ if (isVariable2) {
4778
+ setIsEditing(false);
4779
+ }
4780
+ onValueChange == null ? void 0 : onValueChange(value, isVariable2);
4781
+ setIsOpen(false);
4782
+ }
4756
4783
  }
4757
- onValueChange == null ? void 0 : onValueChange(value, isVariable2);
4758
- setIsOpen(false);
4759
- }
4760
- }
4761
- )
4762
- ] })
4763
- ] })
4784
+ )
4785
+ ] })
4786
+ ] })
4787
+ }
4788
+ )
4764
4789
  }
4765
4790
  )
4766
- }
4767
- )
4768
- ] });
4791
+ ]
4792
+ }
4793
+ );
4769
4794
  }
4770
4795
 
4771
4796
  // src/editor/components/image-menu/image-size.tsx
@@ -4794,19 +4819,22 @@ var useImageState = (editor) => {
4794
4819
  const states = useEditorState3({
4795
4820
  editor,
4796
4821
  selector: ({ editor: editor2 }) => {
4797
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
4822
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
4798
4823
  return {
4799
4824
  width: String(editor2.getAttributes("image").width),
4800
4825
  height: String(editor2.getAttributes("image").height),
4801
4826
  isImageActive: editor2.isActive("image"),
4802
4827
  isLogoActive: editor2.isActive("logo"),
4803
4828
  alignment: ((_a = editor2.getAttributes("image")) == null ? void 0 : _a.alignment) || ((_b = editor2.getAttributes("logo")) == null ? void 0 : _b.alignment),
4804
- logoSize: ((_c = editor2.getAttributes("logo")) == null ? void 0 : _c.size) || DEFAULT_LOGO_SIZE,
4805
- imageSrc: ((_d = editor2.getAttributes("image")) == null ? void 0 : _d.src) || ((_e = editor2.getAttributes("logo")) == null ? void 0 : _e.src) || "",
4806
- isSrcVariable: (_i = (_h = (_f = editor2.getAttributes("image")) == null ? void 0 : _f.isSrcVariable) != null ? _h : (_g = editor2.getAttributes("logo")) == null ? void 0 : _g.isSrcVariable) != null ? _i : false,
4807
- imageExternalLink: ((_j = editor2.getAttributes("image")) == null ? void 0 : _j.externalLink) || "",
4808
- isExternalLinkVariable: (_k = editor2.getAttributes("image")) == null ? void 0 : _k.isExternalLinkVariable,
4809
- currentShowIfKey: ((_l = editor2.getAttributes("image")) == null ? void 0 : _l.showIfKey) || ((_m = editor2.getAttributes("logo")) == null ? void 0 : _m.showIfKey) || ""
4829
+ borderRadius: (_c = editor2.getAttributes("image")) == null ? void 0 : _c.borderRadius,
4830
+ logoSize: ((_d = editor2.getAttributes("logo")) == null ? void 0 : _d.size) || DEFAULT_LOGO_SIZE,
4831
+ imageSrc: ((_e = editor2.getAttributes("image")) == null ? void 0 : _e.src) || ((_f = editor2.getAttributes("logo")) == null ? void 0 : _f.src) || "",
4832
+ isSrcVariable: (_j = (_i = (_g = editor2.getAttributes("image")) == null ? void 0 : _g.isSrcVariable) != null ? _i : (_h = editor2.getAttributes("logo")) == null ? void 0 : _h.isSrcVariable) != null ? _j : false,
4833
+ imageExternalLink: ((_k = editor2.getAttributes("image")) == null ? void 0 : _k.externalLink) || "",
4834
+ isExternalLinkVariable: (_l = editor2.getAttributes("image")) == null ? void 0 : _l.isExternalLinkVariable,
4835
+ lockAspectRatio: (_m = editor2.getAttributes("image")) == null ? void 0 : _m.lockAspectRatio,
4836
+ aspectRatio: (_n = editor2.getAttributes("image")) == null ? void 0 : _n.aspectRatio,
4837
+ currentShowIfKey: ((_o = editor2.getAttributes("image")) == null ? void 0 : _o.showIfKey) || ((_p = editor2.getAttributes("logo")) == null ? void 0 : _p.showIfKey) || ""
4810
4838
  };
4811
4839
  },
4812
4840
  equalityFn: deepEql3
@@ -4815,7 +4843,7 @@ var useImageState = (editor) => {
4815
4843
  };
4816
4844
 
4817
4845
  // src/editor/components/image-menu/image-bubble-menu.tsx
4818
- import { Fragment as Fragment5, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
4846
+ import { Fragment as Fragment4, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
4819
4847
  function ImageBubbleMenu(props) {
4820
4848
  var _a, _b, _c, _d;
4821
4849
  const { editor, appendTo } = props;
@@ -4839,12 +4867,13 @@ function ImageBubbleMenu(props) {
4839
4867
  maxWidth: "100%"
4840
4868
  }
4841
4869
  });
4870
+ const { lockAspectRatio } = state;
4842
4871
  return /* @__PURE__ */ jsx37(
4843
4872
  BubbleMenu3,
4844
4873
  __spreadProps(__spreadValues({}, bubbleMenuProps), {
4845
4874
  className: "mly-flex mly-rounded-lg mly-border mly-border-gray-200 mly-bg-white mly-p-0.5 mly-shadow-md",
4846
4875
  children: /* @__PURE__ */ jsxs19(TooltipProvider, { children: [
4847
- state.isLogoActive && state.imageSrc && /* @__PURE__ */ jsxs19(Fragment5, { children: [
4876
+ state.isLogoActive && state.imageSrc && /* @__PURE__ */ jsxs19(Fragment4, { children: [
4848
4877
  /* @__PURE__ */ jsx37(
4849
4878
  Select,
4850
4879
  {
@@ -4916,8 +4945,26 @@ function ImageBubbleMenu(props) {
4916
4945
  }
4917
4946
  )
4918
4947
  ] }),
4919
- state.isImageActive && state.imageSrc && /* @__PURE__ */ jsxs19(Fragment5, { children: [
4948
+ state.isImageActive && state.imageSrc && /* @__PURE__ */ jsxs19(Fragment4, { children: [
4920
4949
  /* @__PURE__ */ jsx37(Divider, {}),
4950
+ /* @__PURE__ */ jsx37(
4951
+ Select,
4952
+ {
4953
+ label: "Border Radius",
4954
+ value: state == null ? void 0 : state.borderRadius,
4955
+ options: borderRadius.map((value) => ({
4956
+ value: String(value.value),
4957
+ label: value.name
4958
+ })),
4959
+ onValueChange: (value) => {
4960
+ editor == null ? void 0 : editor.chain().updateAttributes("image", {
4961
+ borderRadius: Number(value)
4962
+ }).run();
4963
+ },
4964
+ tooltip: "Border Radius",
4965
+ className: "mly-capitalize"
4966
+ }
4967
+ ),
4921
4968
  /* @__PURE__ */ jsxs19("div", { className: "mly-flex mly-space-x-0.5", children: [
4922
4969
  /* @__PURE__ */ jsx37(
4923
4970
  ImageSize,
@@ -4925,7 +4972,14 @@ function ImageBubbleMenu(props) {
4925
4972
  dimension: "width",
4926
4973
  value: (_c = state == null ? void 0 : state.width) != null ? _c : "",
4927
4974
  onValueChange: (value) => {
4928
- editor == null ? void 0 : editor.chain().updateAttributes("image", { width: value || null }).run();
4975
+ const width = Math.min(Number(value) || 0, IMAGE_MAX_WIDTH);
4976
+ editor == null ? void 0 : editor.chain().updateAttributes("image", __spreadValues({
4977
+ width: String(width)
4978
+ }, lockAspectRatio && value ? {
4979
+ height: String(
4980
+ getNewHeight(width, state.aspectRatio)
4981
+ )
4982
+ } : {})).run();
4929
4983
  }
4930
4984
  }
4931
4985
  ),
@@ -4935,9 +4989,33 @@ function ImageBubbleMenu(props) {
4935
4989
  dimension: "height",
4936
4990
  value: (_d = state == null ? void 0 : state.height) != null ? _d : "",
4937
4991
  onValueChange: (value) => {
4938
- editor == null ? void 0 : editor.chain().updateAttributes("image", { height: value || null }).run();
4992
+ const height = Number(value) || 0;
4993
+ editor == null ? void 0 : editor.chain().updateAttributes("image", __spreadValues({
4994
+ height: String(height)
4995
+ }, lockAspectRatio && value ? {
4996
+ width: String(
4997
+ getNewWidth(height, state.aspectRatio)
4998
+ )
4999
+ } : {})).run();
4939
5000
  }
4940
5001
  }
5002
+ ),
5003
+ /* @__PURE__ */ jsx37(
5004
+ BubbleMenuButton,
5005
+ {
5006
+ isActive: () => lockAspectRatio,
5007
+ command: () => {
5008
+ const width = Number(state.width) || 0;
5009
+ const height = Number(state.height) || 0;
5010
+ const aspectRatio = width / height;
5011
+ editor == null ? void 0 : editor.chain().updateAttributes("image", {
5012
+ lockAspectRatio: !lockAspectRatio,
5013
+ aspectRatio
5014
+ }).run();
5015
+ },
5016
+ icon: lockAspectRatio ? LockIcon : LockOpenIcon,
5017
+ tooltip: "Lock Aspect Ratio"
5018
+ }
4941
5019
  )
4942
5020
  ] })
4943
5021
  ] }),
@@ -5585,7 +5663,7 @@ var useSectionState = (editor) => {
5585
5663
  };
5586
5664
 
5587
5665
  // src/editor/components/section-menu/section-bubble-menu.tsx
5588
- import { Fragment as Fragment6, jsx as jsx44, jsxs as jsxs24 } from "react/jsx-runtime";
5666
+ import { Fragment as Fragment5, jsx as jsx44, jsxs as jsxs24 } from "react/jsx-runtime";
5589
5667
  function SectionBubbleMenu(props) {
5590
5668
  const { appendTo, editor } = props;
5591
5669
  if (!editor) {
@@ -5821,7 +5899,7 @@ function SectionBubbleMenu(props) {
5821
5899
  editor
5822
5900
  }
5823
5901
  ),
5824
- state.isColumnsActive && /* @__PURE__ */ jsxs24(Fragment6, { children: [
5902
+ state.isColumnsActive && /* @__PURE__ */ jsxs24(Fragment5, { children: [
5825
5903
  /* @__PURE__ */ jsx44(Divider, {}),
5826
5904
  /* @__PURE__ */ jsxs24(Popover, { children: [
5827
5905
  /* @__PURE__ */ jsxs24(PopoverTrigger, { className: "mly-flex mly-items-center mly-gap-1 mly-rounded-md mly-px-1.5 mly-text-sm data-[state=open]:mly-bg-soft-gray hover:mly-bg-soft-gray", children: [
@@ -7079,6 +7157,7 @@ var ButtonExtension = Node9.create({
7079
7157
  // src/editor/nodes/image/image.ts
7080
7158
  import TiptapImage2 from "@tiptap/extension-image";
7081
7159
  import { ReactNodeViewRenderer as ReactNodeViewRenderer5 } from "@tiptap/react";
7160
+ var DEFAULT_IMAGE_BORDER_RADIUS = 0;
7082
7161
  var ImageExtension = TiptapImage2.extend({
7083
7162
  addAttributes() {
7084
7163
  var _a;
@@ -7142,6 +7221,17 @@ var ImageExtension = TiptapImage2.extend({
7142
7221
  };
7143
7222
  }
7144
7223
  },
7224
+ borderRadius: {
7225
+ default: DEFAULT_IMAGE_BORDER_RADIUS,
7226
+ parseHTML: (element) => {
7227
+ return Number(element.getAttribute("data-border-radius"));
7228
+ },
7229
+ renderHTML: (attributes) => {
7230
+ return {
7231
+ "data-border-radius": attributes.borderRadius
7232
+ };
7233
+ }
7234
+ },
7145
7235
  // Later we will remove this attribute
7146
7236
  // and use the `src` attribute instead when implement
7147
7237
  // the URL variable feature
@@ -7159,6 +7249,34 @@ var ImageExtension = TiptapImage2.extend({
7159
7249
  };
7160
7250
  }
7161
7251
  },
7252
+ aspectRatio: {
7253
+ default: null,
7254
+ parseHTML: (element) => {
7255
+ return element.getAttribute("data-aspect-ratio") || null;
7256
+ },
7257
+ renderHTML: (attributes) => {
7258
+ if (!(attributes == null ? void 0 : attributes.aspectRatio)) {
7259
+ return {};
7260
+ }
7261
+ return {
7262
+ "data-aspect-ratio": attributes == null ? void 0 : attributes.aspectRatio
7263
+ };
7264
+ }
7265
+ },
7266
+ lockAspectRatio: {
7267
+ default: true,
7268
+ parseHTML: (element) => {
7269
+ return element.getAttribute("data-lock-aspect-ratio") === "true";
7270
+ },
7271
+ renderHTML: (attributes) => {
7272
+ if (!attributes.lockAspectRatio) {
7273
+ return {};
7274
+ }
7275
+ return {
7276
+ "data-lock-aspect-ratio": "true"
7277
+ };
7278
+ }
7279
+ },
7162
7280
  showIfKey: {
7163
7281
  default: DEFAULT_SECTION_SHOW_IF_KEY,
7164
7282
  parseHTML: (element) => {
@@ -7238,7 +7356,24 @@ function HTMLCodeBlockView(props) {
7238
7356
  "mly-not-prose mly-rounded-lg mly-border mly-border-gray-200 mly-p-2",
7239
7357
  isEmpty && "mly-min-h-[42px]"
7240
7358
  ),
7241
- dangerouslySetInnerHTML: { __html: html2 },
7359
+ ref: (node2) => {
7360
+ if (!node2 || (node2 == null ? void 0 : node2.shadowRoot)) {
7361
+ return;
7362
+ }
7363
+ const shadow = node2.attachShadow({ mode: "open" });
7364
+ const sheet = new CSSStyleSheet();
7365
+ sheet.replaceSync(`
7366
+ * { font-family: 'Inter', sans-serif; }
7367
+ blockquote, h1, h2, h3, img, li, ol, p, ul {
7368
+ margin-top: 0;
7369
+ margin-bottom: 0;
7370
+ }
7371
+ `);
7372
+ shadow.adoptedStyleSheets = [sheet];
7373
+ const container = document.createElement("div");
7374
+ container.innerHTML = html2;
7375
+ shadow.appendChild(container);
7376
+ },
7242
7377
  contentEditable: false,
7243
7378
  onClick: () => {
7244
7379
  if (!isEmpty) {
@@ -7663,21 +7798,123 @@ import { ReactRenderer } from "@tiptap/react";
7663
7798
  import {
7664
7799
  forwardRef as forwardRef8,
7665
7800
  Fragment as Fragment7,
7666
- useCallback as useCallback10,
7667
- useEffect as useEffect7,
7801
+ useCallback as useCallback11,
7802
+ useEffect as useEffect8,
7668
7803
  useImperativeHandle as useImperativeHandle2,
7669
7804
  useLayoutEffect as useLayoutEffect2,
7670
- useRef as useRef10,
7671
- useState as useState10
7805
+ useRef as useRef11,
7806
+ useState as useState11
7672
7807
  } from "react";
7673
7808
  import tippy2 from "tippy.js";
7809
+
7810
+ // src/editor/extensions/slash-command/slash-command-item.tsx
7674
7811
  import { ChevronRightIcon } from "lucide-react";
7675
- import { Fragment as Fragment8, jsx as jsx53, jsxs as jsxs31 } from "react/jsx-runtime";
7812
+ import { useCallback as useCallback10, useState as useState10, useRef as useRef10, useEffect as useEffect7 } from "react";
7813
+ import { Fragment as Fragment6, jsx as jsx53, jsxs as jsxs31 } from "react/jsx-runtime";
7814
+ function SlashCommandItem(props) {
7815
+ var _a;
7816
+ const {
7817
+ item,
7818
+ groupIndex,
7819
+ commandIndex,
7820
+ selectedGroupIndex,
7821
+ selectedCommandIndex,
7822
+ editor,
7823
+ activeCommandRef,
7824
+ selectItem
7825
+ } = props;
7826
+ const [open, setOpen] = useState10(false);
7827
+ const [isHovered, setIsHovered] = useState10(false);
7828
+ const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
7829
+ const isSubCommand = item && "commands" in item;
7830
+ const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && (isActive || isHovered);
7831
+ const hasRenderFunction = typeof item.render === "function";
7832
+ const renderFunctionValue = hasRenderFunction ? (_a = item.render) == null ? void 0 : _a.call(item, editor) : null;
7833
+ let value = /* @__PURE__ */ jsxs31(Fragment6, { children: [
7834
+ /* @__PURE__ */ jsx53("div", { className: "mly-flex mly-h-6 mly-w-6 mly-shrink-0 mly-items-center mly-justify-center", children: item.icon }),
7835
+ /* @__PURE__ */ jsxs31("div", { className: "mly-grow", children: [
7836
+ /* @__PURE__ */ jsx53("p", { className: "mly-font-medium", children: item.title }),
7837
+ /* @__PURE__ */ jsx53("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
7838
+ ] }),
7839
+ isSubCommand && /* @__PURE__ */ jsx53("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ jsx53(ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
7840
+ ] });
7841
+ if (renderFunctionValue !== null && renderFunctionValue !== true) {
7842
+ value = renderFunctionValue;
7843
+ }
7844
+ const openTimerRef = useRef10(0);
7845
+ const handleDelayedOpen = useCallback10(() => {
7846
+ window.clearTimeout(openTimerRef.current);
7847
+ const delay = 200;
7848
+ openTimerRef.current = window.setTimeout(() => {
7849
+ setOpen(true);
7850
+ openTimerRef.current = 0;
7851
+ }, delay);
7852
+ }, [setOpen]);
7853
+ useEffect7(() => {
7854
+ if (shouldOpenTooltip) {
7855
+ handleDelayedOpen();
7856
+ } else {
7857
+ window.clearTimeout(openTimerRef.current);
7858
+ openTimerRef.current = 0;
7859
+ setOpen(false);
7860
+ }
7861
+ }, [shouldOpenTooltip]);
7862
+ useEffect7(() => {
7863
+ return () => {
7864
+ if (openTimerRef.current) {
7865
+ window.clearTimeout(openTimerRef.current);
7866
+ openTimerRef.current = 0;
7867
+ }
7868
+ };
7869
+ }, []);
7870
+ return /* @__PURE__ */ jsxs31(Tooltip, { open, children: [
7871
+ /* @__PURE__ */ jsx53(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx53(
7872
+ "button",
7873
+ {
7874
+ className: cn(
7875
+ "mly-flex mly-w-full mly-items-center mly-gap-2 mly-rounded-md mly-px-2 mly-py-1 mly-text-left mly-text-sm mly-text-gray-900 hover:mly-bg-gray-100 hover:mly-text-gray-900",
7876
+ isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
7877
+ ),
7878
+ onClick: () => selectItem(groupIndex, commandIndex),
7879
+ onMouseEnter: () => setIsHovered(true),
7880
+ onMouseLeave: () => setIsHovered(false),
7881
+ type: "button",
7882
+ ref: isActive ? activeCommandRef : null,
7883
+ children: value
7884
+ }
7885
+ ) }),
7886
+ /* @__PURE__ */ jsx53(
7887
+ TooltipContent,
7888
+ {
7889
+ side: "right",
7890
+ sideOffset: 10,
7891
+ className: "mly-w-52 mly-rounded-lg mly-border-none mly-p-1 mly-shadow",
7892
+ children: typeof item.preview === "function" ? item == null ? void 0 : item.preview(editor) : /* @__PURE__ */ jsxs31(Fragment6, { children: [
7893
+ /* @__PURE__ */ jsx53("figure", { className: "mly-relative mly-aspect-[2.5] mly-w-full mly-overflow-hidden mly-rounded-md mly-border mly-border-gray-200", children: /* @__PURE__ */ jsx53(
7894
+ "img",
7895
+ {
7896
+ src: item == null ? void 0 : item.preview,
7897
+ alt: item == null ? void 0 : item.title,
7898
+ className: "mly-absolute mly-inset-0 mly-h-full mly-w-full mly-object-cover"
7899
+ }
7900
+ ) }),
7901
+ /* @__PURE__ */ jsx53("p", { className: "mly-mt-2 mly-px-0.5 mly-text-gray-500", children: item.description })
7902
+ ] })
7903
+ }
7904
+ )
7905
+ ] }, `${groupIndex}-${commandIndex}`);
7906
+ }
7907
+
7908
+ // src/editor/extensions/slash-command/slash-command-view.tsx
7909
+ import { jsx as jsx54, jsxs as jsxs32 } from "react/jsx-runtime";
7676
7910
  var CommandList = forwardRef8(function CommandList2(props, ref) {
7677
- const { items: groups, command, editor } = props;
7678
- const [selectedGroupIndex, setSelectedGroupIndex] = useState10(0);
7679
- const [selectedCommandIndex, setSelectedCommandIndex] = useState10(0);
7680
- const selectItem = useCallback10(
7911
+ const { items: groups, command, editor, range, query } = props;
7912
+ const [selectedGroupIndex, setSelectedGroupIndex] = useState11(0);
7913
+ const [selectedCommandIndex, setSelectedCommandIndex] = useState11(0);
7914
+ const prevQuery = useRef11("");
7915
+ const prevSelectedGroupIndex = useRef11(0);
7916
+ const prevSelectedCommandIndex = useRef11(0);
7917
+ const selectItem = useCallback11(
7681
7918
  (groupIndex, commandIndex) => {
7682
7919
  const item = groups[groupIndex].commands[commandIndex];
7683
7920
  if (!item) {
@@ -7689,62 +7926,94 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
7689
7926
  );
7690
7927
  useImperativeHandle2(ref, () => ({
7691
7928
  onKeyDown: ({ event }) => {
7692
- var _a, _b;
7693
- const navigationKeys = ["ArrowUp", "ArrowDown", "Enter"];
7929
+ var _a, _b, _c, _d;
7930
+ const navigationKeys = [
7931
+ "ArrowUp",
7932
+ "ArrowDown",
7933
+ "Enter",
7934
+ "ArrowLeft",
7935
+ "ArrowRight"
7936
+ ];
7694
7937
  if (navigationKeys.includes(event.key)) {
7695
- if (event.key === "ArrowUp") {
7696
- if (!groups.length) {
7697
- return false;
7698
- }
7699
- let newCommandIndex = selectedCommandIndex - 1;
7700
- let newGroupIndex = selectedGroupIndex;
7701
- if (newCommandIndex < 0) {
7702
- newGroupIndex = selectedGroupIndex - 1;
7703
- newCommandIndex = ((_a = groups[newGroupIndex]) == null ? void 0 : _a.commands.length) - 1 || 0;
7704
- }
7705
- if (newGroupIndex < 0) {
7706
- newGroupIndex = groups.length - 1;
7707
- newCommandIndex = ((_b = groups[newGroupIndex]) == null ? void 0 : _b.commands.length) - 1 || 0;
7708
- }
7709
- setSelectedGroupIndex(newGroupIndex);
7710
- setSelectedCommandIndex(newCommandIndex);
7711
- return true;
7712
- }
7713
- if (event.key === "ArrowDown") {
7714
- if (!groups.length) {
7715
- return false;
7716
- }
7717
- const commands = groups[selectedGroupIndex].commands;
7718
- let newCommandIndex = selectedCommandIndex + 1;
7719
- let newGroupIndex = selectedGroupIndex;
7720
- if (commands.length - 1 < newCommandIndex) {
7721
- newCommandIndex = 0;
7722
- newGroupIndex = selectedGroupIndex + 1;
7723
- }
7724
- if (groups.length - 1 < newGroupIndex) {
7725
- newGroupIndex = 0;
7726
- }
7727
- setSelectedGroupIndex(newGroupIndex);
7728
- setSelectedCommandIndex(newCommandIndex);
7729
- return true;
7730
- }
7731
- if (event.key === "Enter") {
7732
- if (!groups.length) {
7938
+ let newCommandIndex = selectedCommandIndex;
7939
+ let newGroupIndex = selectedGroupIndex;
7940
+ switch (event.key) {
7941
+ case "ArrowLeft":
7942
+ event.preventDefault();
7943
+ const group = groups == null ? void 0 : groups[selectedGroupIndex];
7944
+ const isInsideSubCommand = group && "id" in group;
7945
+ if (!isInsideSubCommand) {
7946
+ return false;
7947
+ }
7948
+ editor.chain().focus().insertContentAt(range, `/${prevQuery.current}`).run();
7949
+ setTimeout(() => {
7950
+ setSelectedGroupIndex(prevSelectedGroupIndex.current);
7951
+ setSelectedCommandIndex(prevSelectedCommandIndex.current);
7952
+ }, 0);
7953
+ return true;
7954
+ case "ArrowRight":
7955
+ event.preventDefault();
7956
+ const command2 = (_b = (_a = groups == null ? void 0 : groups[selectedGroupIndex]) == null ? void 0 : _a.commands) == null ? void 0 : _b[selectedCommandIndex];
7957
+ const isSelectingSubCommand = command2 && "commands" in command2;
7958
+ if (!isSelectingSubCommand) {
7959
+ return false;
7960
+ }
7961
+ selectItem(selectedGroupIndex, selectedCommandIndex);
7962
+ prevQuery.current = query;
7963
+ prevSelectedGroupIndex.current = selectedGroupIndex;
7964
+ prevSelectedCommandIndex.current = selectedCommandIndex;
7965
+ return true;
7966
+ case "Enter":
7967
+ if (!groups.length) {
7968
+ return false;
7969
+ }
7970
+ selectItem(selectedGroupIndex, selectedCommandIndex);
7971
+ prevQuery.current = query;
7972
+ prevSelectedGroupIndex.current = selectedGroupIndex;
7973
+ prevSelectedCommandIndex.current = selectedCommandIndex;
7974
+ return true;
7975
+ case "ArrowUp":
7976
+ if (!groups.length) {
7977
+ return false;
7978
+ }
7979
+ newCommandIndex = selectedCommandIndex - 1;
7980
+ newGroupIndex = selectedGroupIndex;
7981
+ if (newCommandIndex < 0) {
7982
+ newGroupIndex = selectedGroupIndex - 1;
7983
+ newCommandIndex = ((_c = groups[newGroupIndex]) == null ? void 0 : _c.commands.length) - 1 || 0;
7984
+ }
7985
+ if (newGroupIndex < 0) {
7986
+ newGroupIndex = groups.length - 1;
7987
+ newCommandIndex = ((_d = groups[newGroupIndex]) == null ? void 0 : _d.commands.length) - 1 || 0;
7988
+ }
7989
+ setSelectedGroupIndex(newGroupIndex);
7990
+ setSelectedCommandIndex(newCommandIndex);
7991
+ return true;
7992
+ case "ArrowDown":
7993
+ if (!groups.length) {
7994
+ return false;
7995
+ }
7996
+ const commands = groups[selectedGroupIndex].commands;
7997
+ newCommandIndex = selectedCommandIndex + 1;
7998
+ newGroupIndex = selectedGroupIndex;
7999
+ if (commands.length - 1 < newCommandIndex) {
8000
+ newCommandIndex = 0;
8001
+ newGroupIndex = selectedGroupIndex + 1;
8002
+ }
8003
+ if (groups.length - 1 < newGroupIndex) {
8004
+ newGroupIndex = 0;
8005
+ }
8006
+ setSelectedGroupIndex(newGroupIndex);
8007
+ setSelectedCommandIndex(newCommandIndex);
8008
+ return true;
8009
+ default:
7733
8010
  return false;
7734
- }
7735
- selectItem(selectedGroupIndex, selectedCommandIndex);
7736
- return true;
7737
8011
  }
7738
- return false;
7739
8012
  }
7740
8013
  }
7741
8014
  }));
7742
- useEffect7(() => {
7743
- setSelectedGroupIndex(0);
7744
- setSelectedCommandIndex(0);
7745
- }, [groups]);
7746
- const commandListContainer = useRef10(null);
7747
- const activeCommandRef = useRef10(null);
8015
+ const commandListContainer = useRef11(null);
8016
+ const activeCommandRef = useRef11(null);
7748
8017
  useLayoutEffect2(() => {
7749
8018
  const container = commandListContainer == null ? void 0 : commandListContainer.current;
7750
8019
  const activeCommandContainer = activeCommandRef == null ? void 0 : activeCommandRef.current;
@@ -7752,6 +8021,7 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
7752
8021
  return;
7753
8022
  }
7754
8023
  const { offsetTop, offsetHeight } = activeCommandContainer;
8024
+ container.style.transition = "none";
7755
8025
  container.scrollTop = offsetTop - offsetHeight;
7756
8026
  }, [
7757
8027
  selectedGroupIndex,
@@ -7759,15 +8029,26 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
7759
8029
  commandListContainer,
7760
8030
  activeCommandRef
7761
8031
  ]);
7762
- return groups.length > 0 ? /* @__PURE__ */ jsx53(TooltipProvider, { children: /* @__PURE__ */ jsxs31("div", { className: "mly-z-50 mly-w-72 mly-overflow-hidden mly-rounded-md mly-border mly-border-gray-200 mly-bg-white mly-shadow-md mly-transition-all", children: [
7763
- /* @__PURE__ */ jsx53(
8032
+ useEffect8(() => {
8033
+ setSelectedGroupIndex(0);
8034
+ setSelectedCommandIndex(0);
8035
+ }, [groups]);
8036
+ useEffect8(() => {
8037
+ return () => {
8038
+ prevQuery.current = "";
8039
+ prevSelectedGroupIndex.current = 0;
8040
+ prevSelectedCommandIndex.current = 0;
8041
+ };
8042
+ }, []);
8043
+ return groups.length > 0 ? /* @__PURE__ */ jsx54(TooltipProvider, { children: /* @__PURE__ */ jsxs32("div", { className: "mly-z-50 mly-w-72 mly-overflow-hidden mly-rounded-md mly-border mly-border-gray-200 mly-bg-white mly-shadow-md mly-transition-all", children: [
8044
+ /* @__PURE__ */ jsx54(
7764
8045
  "div",
7765
8046
  {
7766
8047
  id: "slash-command",
7767
8048
  ref: commandListContainer,
7768
- className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto mly-scroll-smooth",
7769
- children: groups.map((group, groupIndex) => /* @__PURE__ */ jsxs31(Fragment7, { children: [
7770
- /* @__PURE__ */ jsx53(
8049
+ className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto",
8050
+ children: groups.map((group, groupIndex) => /* @__PURE__ */ jsxs32(Fragment7, { children: [
8051
+ /* @__PURE__ */ jsx54(
7771
8052
  "span",
7772
8053
  {
7773
8054
  className: cn(
@@ -7777,72 +8058,35 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
7777
8058
  children: group.title
7778
8059
  }
7779
8060
  ),
7780
- /* @__PURE__ */ jsx53("div", { className: "mly-space-y-0.5 mly-p-1", children: group.commands.map((item, commandIndex) => {
7781
- var _a;
7782
- const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
7783
- const isSubCommand = "commands" in item;
7784
- const hasRenderFunction = typeof item.render === "function";
7785
- const renderFunctionValue = hasRenderFunction ? (_a = item.render) == null ? void 0 : _a.call(item, editor) : null;
7786
- let value = /* @__PURE__ */ jsxs31(Fragment8, { children: [
7787
- /* @__PURE__ */ jsx53("div", { className: "mly-flex mly-h-6 mly-w-6 mly-shrink-0 mly-items-center mly-justify-center", children: item.icon }),
7788
- /* @__PURE__ */ jsxs31("div", { className: "mly-grow", children: [
7789
- /* @__PURE__ */ jsx53("p", { className: "mly-font-medium", children: item.title }),
7790
- /* @__PURE__ */ jsx53("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
7791
- ] }),
7792
- isSubCommand && /* @__PURE__ */ jsx53("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ jsx53(ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
7793
- ] });
7794
- if (renderFunctionValue !== null && renderFunctionValue !== true) {
7795
- value = renderFunctionValue;
7796
- }
7797
- const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && isActive;
7798
- return /* @__PURE__ */ jsxs31(Tooltip, { open: shouldOpenTooltip, children: [
7799
- /* @__PURE__ */ jsx53(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx53(
7800
- "button",
7801
- {
7802
- className: cn(
7803
- "mly-flex mly-w-full mly-items-center mly-gap-2 mly-rounded-md mly-px-2 mly-py-1 mly-text-left mly-text-sm mly-text-gray-900 hover:mly-bg-gray-100 hover:mly-text-gray-900",
7804
- isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
7805
- ),
7806
- onClick: () => selectItem(groupIndex, commandIndex),
7807
- type: "button",
7808
- ref: isActive ? activeCommandRef : null,
7809
- children: value
7810
- }
7811
- ) }),
7812
- /* @__PURE__ */ jsx53(
7813
- TooltipContent,
7814
- {
7815
- side: "right",
7816
- sideOffset: 10,
7817
- className: "mly-w-52 mly-rounded-lg mly-border-none mly-p-1 mly-shadow",
7818
- children: typeof item.preview === "function" ? item == null ? void 0 : item.preview(editor) : /* @__PURE__ */ jsxs31(Fragment8, { children: [
7819
- /* @__PURE__ */ jsx53("figure", { className: "mly-relative mly-aspect-[2.5] mly-w-full mly-overflow-hidden mly-rounded-md mly-border mly-border-gray-200", children: /* @__PURE__ */ jsx53(
7820
- "img",
7821
- {
7822
- src: item == null ? void 0 : item.preview,
7823
- alt: item == null ? void 0 : item.title,
7824
- className: "mly-absolute mly-inset-0 mly-h-full mly-w-full mly-object-cover"
7825
- }
7826
- ) }),
7827
- /* @__PURE__ */ jsx53("p", { className: "mly-mt-2 mly-px-0.5 mly-text-gray-500", children: item.description })
7828
- ] })
7829
- }
7830
- )
7831
- ] }, commandIndex);
8061
+ /* @__PURE__ */ jsx54("div", { className: "mly-space-y-0.5 mly-p-1", children: group.commands.map((item, commandIndex) => {
8062
+ return /* @__PURE__ */ jsx54(
8063
+ SlashCommandItem,
8064
+ {
8065
+ item,
8066
+ groupIndex,
8067
+ commandIndex,
8068
+ selectedGroupIndex,
8069
+ selectedCommandIndex,
8070
+ selectItem: () => selectItem(groupIndex, commandIndex),
8071
+ editor,
8072
+ activeCommandRef
8073
+ },
8074
+ commandIndex
8075
+ );
7832
8076
  }) })
7833
8077
  ] }, groupIndex))
7834
8078
  }
7835
8079
  ),
7836
- /* @__PURE__ */ jsx53("div", { className: "mly-border-t mly-border-gray-200 mly-px-1 mly-py-3 mly-pl-4", children: /* @__PURE__ */ jsxs31("div", { className: "mly-flex mly-items-center", children: [
7837
- /* @__PURE__ */ jsxs31("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
7838
- /* @__PURE__ */ jsx53("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2191" }),
7839
- /* @__PURE__ */ jsx53("kbd", { className: "mly-ml-1 mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2193" }),
8080
+ /* @__PURE__ */ jsx54("div", { className: "mly-border-t mly-border-gray-200 mly-px-1 mly-py-3 mly-pl-4", children: /* @__PURE__ */ jsxs32("div", { className: "mly-flex mly-items-center", children: [
8081
+ /* @__PURE__ */ jsxs32("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
8082
+ /* @__PURE__ */ jsx54("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2191" }),
8083
+ /* @__PURE__ */ jsx54("kbd", { className: "mly-ml-1 mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2193" }),
7840
8084
  " ",
7841
8085
  "to navigate"
7842
8086
  ] }),
7843
- /* @__PURE__ */ jsx53("span", { "aria-hidden": "true", className: "mly-select-none mly-px-1", children: "\xB7" }),
7844
- /* @__PURE__ */ jsxs31("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
7845
- /* @__PURE__ */ jsx53("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-1.5 mly-font-medium", children: "Enter" }),
8087
+ /* @__PURE__ */ jsx54("span", { "aria-hidden": "true", className: "mly-select-none mly-px-1", children: "\xB7" }),
8088
+ /* @__PURE__ */ jsxs32("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
8089
+ /* @__PURE__ */ jsx54("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-1.5 mly-font-medium", children: "Enter" }),
7846
8090
  " ",
7847
8091
  "to select"
7848
8092
  ] })
@@ -7945,24 +8189,36 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
7945
8189
  });
7946
8190
  },
7947
8191
  onUpdate: (props) => {
8192
+ var _a;
8193
+ const currentPopup = popup == null ? void 0 : popup[0];
8194
+ if (!currentPopup || ((_a = currentPopup == null ? void 0 : currentPopup.state) == null ? void 0 : _a.isDestroyed)) {
8195
+ return;
8196
+ }
7948
8197
  component == null ? void 0 : component.updateProps(props);
7949
- popup && popup[0].setProps({
8198
+ currentPopup.setProps({
7950
8199
  getReferenceClientRect: props.clientRect
7951
8200
  });
7952
8201
  },
7953
8202
  onKeyDown: (props) => {
7954
- var _a;
8203
+ var _a, _b;
7955
8204
  if (props.event.key === "Escape") {
7956
- popup == null ? void 0 : popup[0].hide();
8205
+ const currentPopup = popup == null ? void 0 : popup[0];
8206
+ if (!((_a = currentPopup == null ? void 0 : currentPopup.state) == null ? void 0 : _a.isDestroyed)) {
8207
+ currentPopup == null ? void 0 : currentPopup.destroy();
8208
+ }
8209
+ component == null ? void 0 : component.destroy();
7957
8210
  return true;
7958
8211
  }
7959
- return (_a = component == null ? void 0 : component.ref) == null ? void 0 : _a.onKeyDown(props);
8212
+ return (_b = component == null ? void 0 : component.ref) == null ? void 0 : _b.onKeyDown(props);
7960
8213
  },
7961
8214
  onExit: () => {
7962
8215
  if (!popup || !(popup == null ? void 0 : popup[0]) || !component) {
7963
8216
  return;
7964
8217
  }
7965
- popup == null ? void 0 : popup[0].destroy();
8218
+ const currentPopup = popup == null ? void 0 : popup[0];
8219
+ if (!currentPopup.state.isDestroyed) {
8220
+ currentPopup.destroy();
8221
+ }
7966
8222
  component == null ? void 0 : component.destroy();
7967
8223
  }
7968
8224
  };
@@ -7972,13 +8228,13 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
7972
8228
 
7973
8229
  // src/editor/nodes/variable/variable-suggestions.tsx
7974
8230
  import { ReactRenderer as ReactRenderer2 } from "@tiptap/react";
7975
- import { forwardRef as forwardRef9, useImperativeHandle as useImperativeHandle3, useRef as useRef11 } from "react";
8231
+ import { forwardRef as forwardRef9, useImperativeHandle as useImperativeHandle3, useRef as useRef12 } from "react";
7976
8232
  import tippy3 from "tippy.js";
7977
- import { jsx as jsx54 } from "react/jsx-runtime";
8233
+ import { jsx as jsx55 } from "react/jsx-runtime";
7978
8234
  var VariableList = forwardRef9((props, ref) => {
7979
8235
  var _a;
7980
8236
  const { items = [], editor } = props;
7981
- const popoverRef = useRef11(null);
8237
+ const popoverRef = useRef12(null);
7982
8238
  const VariableSuggestionPopoverComponent = (_a = useVariableOptions(editor)) == null ? void 0 : _a.variableSuggestionsPopover;
7983
8239
  useImperativeHandle3(ref, () => ({
7984
8240
  onKeyDown: ({ event }) => {
@@ -8003,7 +8259,7 @@ var VariableList = forwardRef9((props, ref) => {
8003
8259
  return false;
8004
8260
  }
8005
8261
  }));
8006
- return /* @__PURE__ */ jsx54(
8262
+ return /* @__PURE__ */ jsx55(
8007
8263
  VariableSuggestionPopoverComponent,
8008
8264
  {
8009
8265
  items,
@@ -8225,7 +8481,7 @@ var useTextMenuState = (editor) => {
8225
8481
  };
8226
8482
 
8227
8483
  // src/editor/components/text-menu/text-bubble-content.tsx
8228
- import { Fragment as Fragment9, jsx as jsx55, jsxs as jsxs32 } from "react/jsx-runtime";
8484
+ import { Fragment as Fragment8, jsx as jsx56, jsxs as jsxs33 } from "react/jsx-runtime";
8229
8485
  function TextBubbleContent(props) {
8230
8486
  var _a, _b, _c, _d;
8231
8487
  const { editor, showListMenu = true } = props;
@@ -8269,9 +8525,9 @@ function TextBubbleContent(props) {
8269
8525
  tooltip: "Code"
8270
8526
  }
8271
8527
  ];
8272
- return /* @__PURE__ */ jsxs32(Fragment9, { children: [
8273
- items.map((item, index) => /* @__PURE__ */ jsx55(BubbleMenuButton, __spreadValues({}, item), index)),
8274
- /* @__PURE__ */ jsx55(
8528
+ return /* @__PURE__ */ jsxs33(Fragment8, { children: [
8529
+ items.map((item, index) => /* @__PURE__ */ jsx56(BubbleMenuButton, __spreadValues({}, item), index)),
8530
+ /* @__PURE__ */ jsx56(
8275
8531
  AlignmentSwitch,
8276
8532
  {
8277
8533
  alignment: state.textAlign,
@@ -8280,8 +8536,8 @@ function TextBubbleContent(props) {
8280
8536
  }
8281
8537
  }
8282
8538
  ),
8283
- !state.isListActive && showListMenu && /* @__PURE__ */ jsxs32(Fragment9, { children: [
8284
- /* @__PURE__ */ jsx55(
8539
+ !state.isListActive && showListMenu && /* @__PURE__ */ jsxs33(Fragment8, { children: [
8540
+ /* @__PURE__ */ jsx56(
8285
8541
  BubbleMenuButton,
8286
8542
  {
8287
8543
  icon: List2,
@@ -8291,7 +8547,7 @@ function TextBubbleContent(props) {
8291
8547
  tooltip: "Bullet List"
8292
8548
  }
8293
8549
  ),
8294
- /* @__PURE__ */ jsx55(
8550
+ /* @__PURE__ */ jsx56(
8295
8551
  BubbleMenuButton,
8296
8552
  {
8297
8553
  icon: ListOrdered2,
@@ -8302,13 +8558,12 @@ function TextBubbleContent(props) {
8302
8558
  }
8303
8559
  )
8304
8560
  ] }),
8305
- /* @__PURE__ */ jsx55(
8561
+ /* @__PURE__ */ jsx56(
8306
8562
  LinkInputPopover,
8307
8563
  {
8308
8564
  defaultValue: (_d = state == null ? void 0 : state.linkUrl) != null ? _d : "",
8309
8565
  onValueChange: (value, isVariable) => {
8310
- const defaultValueWithoutProtocol = value.replace(/https?:\/\//, "");
8311
- if (!defaultValueWithoutProtocol) {
8566
+ if (!value) {
8312
8567
  editor == null ? void 0 : editor.chain().focus().extendMarkRange("link").unsetLink().unsetUnderline().run();
8313
8568
  return;
8314
8569
  }
@@ -8319,8 +8574,8 @@ function TextBubbleContent(props) {
8319
8574
  isVariable: state.isUrlVariable
8320
8575
  }
8321
8576
  ),
8322
- /* @__PURE__ */ jsx55(Divider, {}),
8323
- /* @__PURE__ */ jsx55(
8577
+ /* @__PURE__ */ jsx56(Divider, {}),
8578
+ /* @__PURE__ */ jsx56(
8324
8579
  ColorPicker,
8325
8580
  {
8326
8581
  color: state.currentTextColor,
@@ -8329,16 +8584,16 @@ function TextBubbleContent(props) {
8329
8584
  },
8330
8585
  tooltip: "Text Color",
8331
8586
  suggestedColors,
8332
- children: /* @__PURE__ */ jsx55(
8587
+ children: /* @__PURE__ */ jsx56(
8333
8588
  BaseButton,
8334
8589
  {
8335
8590
  variant: "ghost",
8336
8591
  size: "sm",
8337
8592
  type: "button",
8338
8593
  className: "!mly-h-7 mly-w-7 mly-shrink-0 mly-p-0",
8339
- children: /* @__PURE__ */ jsxs32("div", { className: "mly-flex mly-flex-col mly-items-center mly-justify-center mly-gap-[1px]", children: [
8340
- /* @__PURE__ */ jsx55("span", { className: "mly-font-bolder mly-font-mono mly-text-xs mly-text-slate-700", children: "A" }),
8341
- /* @__PURE__ */ jsx55(
8594
+ children: /* @__PURE__ */ jsxs33("div", { className: "mly-flex mly-flex-col mly-items-center mly-justify-center mly-gap-[1px]", children: [
8595
+ /* @__PURE__ */ jsx56("span", { className: "mly-font-bolder mly-font-mono mly-text-xs mly-text-slate-700", children: "A" }),
8596
+ /* @__PURE__ */ jsx56(
8342
8597
  "div",
8343
8598
  {
8344
8599
  className: "mly-h-[2px] mly-w-3",
@@ -8354,35 +8609,35 @@ function TextBubbleContent(props) {
8354
8609
  }
8355
8610
 
8356
8611
  // src/editor/components/text-menu/turn-into-block.tsx
8357
- import { ChevronDownIcon as ChevronDownIcon3, PilcrowIcon } from "lucide-react";
8358
- import { useMemo as useMemo12 } from "react";
8359
- import { jsx as jsx56, jsxs as jsxs33 } from "react/jsx-runtime";
8612
+ import { ChevronDownIcon as ChevronDownIcon2, PilcrowIcon } from "lucide-react";
8613
+ import { useMemo as useMemo13 } from "react";
8614
+ import { jsx as jsx57, jsxs as jsxs34 } from "react/jsx-runtime";
8360
8615
  var isOption = (option) => option.type === "option";
8361
8616
  var isCategory = (option) => option.type === "category";
8362
8617
  function TurnIntoBlock(props) {
8363
8618
  const { options } = props;
8364
- const activeItem = useMemo12(
8619
+ const activeItem = useMemo13(
8365
8620
  () => options.find((option) => option.type === "option" && option.isActive()),
8366
8621
  [options]
8367
8622
  );
8368
8623
  const { icon: ActiveIcon = PilcrowIcon } = activeItem || {};
8369
- return /* @__PURE__ */ jsxs33(Popover, { children: [
8370
- /* @__PURE__ */ jsxs33(Tooltip, { children: [
8371
- /* @__PURE__ */ jsx56(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs33(
8624
+ return /* @__PURE__ */ jsxs34(Popover, { children: [
8625
+ /* @__PURE__ */ jsxs34(Tooltip, { children: [
8626
+ /* @__PURE__ */ jsx57(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs34(
8372
8627
  PopoverTrigger,
8373
8628
  {
8374
8629
  className: cn(
8375
8630
  "mly-flex mly-aspect-square mly-h-7 mly-items-center mly-justify-center mly-gap-1 mly-rounded-md mly-px-1.5 mly-text-sm data-[state=open]:mly-bg-soft-gray hover:mly-bg-soft-gray focus-visible:mly-relative focus-visible:mly-z-10 focus-visible:mly-outline-none focus-visible:mly-ring-2 focus-visible:mly-ring-gray-400 focus-visible:mly-ring-offset-2"
8376
8631
  ),
8377
8632
  children: [
8378
- /* @__PURE__ */ jsx56(ActiveIcon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5]" }),
8379
- /* @__PURE__ */ jsx56(ChevronDownIcon3, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5]" })
8633
+ /* @__PURE__ */ jsx57(ActiveIcon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5]" }),
8634
+ /* @__PURE__ */ jsx57(ChevronDownIcon2, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5]" })
8380
8635
  ]
8381
8636
  }
8382
8637
  ) }),
8383
- /* @__PURE__ */ jsx56(TooltipContent, { sideOffset: 8, children: "Turn into" })
8638
+ /* @__PURE__ */ jsx57(TooltipContent, { sideOffset: 8, children: "Turn into" })
8384
8639
  ] }),
8385
- /* @__PURE__ */ jsx56(
8640
+ /* @__PURE__ */ jsx57(
8386
8641
  PopoverContent,
8387
8642
  {
8388
8643
  align: "start",
@@ -8391,21 +8646,21 @@ function TurnIntoBlock(props) {
8391
8646
  className: "mly-flex mly-w-[160px] mly-flex-col mly-rounded-md mly-p-1",
8392
8647
  children: options.map((option, index) => {
8393
8648
  if (isOption(option)) {
8394
- return /* @__PURE__ */ jsxs33(
8649
+ return /* @__PURE__ */ jsxs34(
8395
8650
  BaseButton,
8396
8651
  {
8397
8652
  onClick: option.onClick,
8398
8653
  variant: "ghost",
8399
8654
  className: "mly-h-auto mly-justify-start mly-gap-2 !mly-rounded mly-px-2 mly-py-1 mly-text-sm mly-font-normal mly-text-midnight-gray",
8400
8655
  children: [
8401
- /* @__PURE__ */ jsx56(option.icon, { className: "mly-size-[15px] mly-shrink-0" }),
8656
+ /* @__PURE__ */ jsx57(option.icon, { className: "mly-size-[15px] mly-shrink-0" }),
8402
8657
  option.label
8403
8658
  ]
8404
8659
  },
8405
8660
  option.id
8406
8661
  );
8407
8662
  } else if (isCategory(option)) {
8408
- return /* @__PURE__ */ jsx56(
8663
+ return /* @__PURE__ */ jsx57(
8409
8664
  "label",
8410
8665
  {
8411
8666
  className: cn(
@@ -8518,7 +8773,7 @@ function useTurnIntoBlockOptions(editor) {
8518
8773
  }
8519
8774
 
8520
8775
  // src/editor/components/text-menu/text-bubble-menu.tsx
8521
- import { jsx as jsx57, jsxs as jsxs34 } from "react/jsx-runtime";
8776
+ import { jsx as jsx58, jsxs as jsxs35 } from "react/jsx-runtime";
8522
8777
  function TextBubbleMenu(props) {
8523
8778
  const { editor, appendTo } = props;
8524
8779
  if (!editor) {
@@ -8569,14 +8824,14 @@ function TextBubbleMenu(props) {
8569
8824
  }
8570
8825
  });
8571
8826
  const turnIntoBlockOptions = useTurnIntoBlockOptions(editor);
8572
- return /* @__PURE__ */ jsx57(
8827
+ return /* @__PURE__ */ jsx58(
8573
8828
  BubbleMenu8,
8574
8829
  __spreadProps(__spreadValues({}, bubbleMenuProps), {
8575
8830
  className: "mly-flex mly-gap-0.5 mly-rounded-lg mly-border mly-border-gray-200 mly-bg-white mly-p-0.5 mly-shadow-md",
8576
- children: /* @__PURE__ */ jsxs34(TooltipProvider, { children: [
8577
- /* @__PURE__ */ jsx57(TurnIntoBlock, { options: turnIntoBlockOptions }),
8578
- /* @__PURE__ */ jsx57(Divider, { className: "mly-mx-0" }),
8579
- /* @__PURE__ */ jsx57(TextBubbleContent, { editor })
8831
+ children: /* @__PURE__ */ jsxs35(TooltipProvider, { children: [
8832
+ /* @__PURE__ */ jsx58(TurnIntoBlock, { options: turnIntoBlockOptions }),
8833
+ /* @__PURE__ */ jsx58(Divider, { className: "mly-mx-0" }),
8834
+ /* @__PURE__ */ jsx58(TextBubbleContent, { editor })
8580
8835
  ] })
8581
8836
  })
8582
8837
  );
@@ -8585,7 +8840,7 @@ function TextBubbleMenu(props) {
8585
8840
  // src/editor/components/variable-menu/variable-bubble-menu.tsx
8586
8841
  import { BubbleMenu as BubbleMenu9 } from "@tiptap/react";
8587
8842
  import { sticky as sticky7 } from "tippy.js";
8588
- import { jsx as jsx58 } from "react/jsx-runtime";
8843
+ import { jsx as jsx59 } from "react/jsx-runtime";
8589
8844
  function VariableBubbleMenu(props) {
8590
8845
  const { editor, appendTo } = props;
8591
8846
  if (!editor) {
@@ -8608,11 +8863,11 @@ function VariableBubbleMenu(props) {
8608
8863
  placement: "top-start"
8609
8864
  }
8610
8865
  });
8611
- return /* @__PURE__ */ jsx58(
8866
+ return /* @__PURE__ */ jsx59(
8612
8867
  BubbleMenu9,
8613
8868
  __spreadProps(__spreadValues({}, bubbleMenuProps), {
8614
8869
  className: "mly-flex mly-gap-0.5 mly-rounded-lg mly-border mly-border-slate-200 mly-bg-white mly-p-0.5 mly-shadow-md",
8615
- children: /* @__PURE__ */ jsx58(TooltipProvider, { children: /* @__PURE__ */ jsx58(TextBubbleContent, { showListMenu: false, editor }) })
8870
+ children: /* @__PURE__ */ jsx59(TooltipProvider, { children: /* @__PURE__ */ jsx59(TextBubbleContent, { showListMenu: false, editor }) })
8616
8871
  })
8617
8872
  );
8618
8873
  }
@@ -8666,7 +8921,7 @@ function replaceDeprecatedNode(json) {
8666
8921
  }
8667
8922
 
8668
8923
  // src/editor/index.tsx
8669
- import { jsx as jsx59, jsxs as jsxs35 } from "react/jsx-runtime";
8924
+ import { jsx as jsx60, jsxs as jsxs36 } from "react/jsx-runtime";
8670
8925
  function Editor13(props) {
8671
8926
  const {
8672
8927
  config: {
@@ -8687,7 +8942,7 @@ function Editor13(props) {
8687
8942
  editable = true,
8688
8943
  placeholderUrl = DEFAULT_PLACEHOLDER_URL
8689
8944
  } = props;
8690
- const formattedContent = useMemo13(() => {
8945
+ const formattedContent = useMemo14(() => {
8691
8946
  if (contentJson) {
8692
8947
  const json = (contentJson == null ? void 0 : contentJson.type) === "doc" ? contentJson : {
8693
8948
  type: "doc",
@@ -8708,7 +8963,7 @@ function Editor13(props) {
8708
8963
  };
8709
8964
  }
8710
8965
  }, [contentHtml, contentJson, replaceDeprecatedNode]);
8711
- const menuContainerRef = useRef12(null);
8966
+ const menuContainerRef = useRef13(null);
8712
8967
  const editor = useEditor({
8713
8968
  editorProps: {
8714
8969
  attributes: {
@@ -8734,7 +8989,7 @@ function Editor13(props) {
8734
8989
  if (!editor) {
8735
8990
  return null;
8736
8991
  }
8737
- return /* @__PURE__ */ jsx59(MailyProvider, { placeholderUrl, children: /* @__PURE__ */ jsxs35(
8992
+ return /* @__PURE__ */ jsx60(MailyProvider, { placeholderUrl, children: /* @__PURE__ */ jsxs36(
8738
8993
  "div",
8739
8994
  {
8740
8995
  className: cn(
@@ -8744,8 +8999,8 @@ function Editor13(props) {
8744
8999
  ),
8745
9000
  ref: menuContainerRef,
8746
9001
  children: [
8747
- hasMenuBar && /* @__PURE__ */ jsx59(EditorMenuBar, { config: props.config, editor }),
8748
- /* @__PURE__ */ jsxs35(
9002
+ hasMenuBar && /* @__PURE__ */ jsx60(EditorMenuBar, { config: props.config, editor }),
9003
+ /* @__PURE__ */ jsxs36(
8749
9004
  "div",
8750
9005
  {
8751
9006
  className: cn(
@@ -8753,17 +9008,17 @@ function Editor13(props) {
8753
9008
  bodyClassName
8754
9009
  ),
8755
9010
  children: [
8756
- /* @__PURE__ */ jsx59(TextBubbleMenu, { editor, appendTo: menuContainerRef }),
8757
- /* @__PURE__ */ jsx59(ImageBubbleMenu, { editor, appendTo: menuContainerRef }),
8758
- /* @__PURE__ */ jsx59(SpacerBubbleMenu, { editor, appendTo: menuContainerRef }),
8759
- /* @__PURE__ */ jsx59(EditorContent, { editor }),
8760
- /* @__PURE__ */ jsx59(SectionBubbleMenu, { editor, appendTo: menuContainerRef }),
8761
- /* @__PURE__ */ jsx59(ColumnsBubbleMenu, { editor, appendTo: menuContainerRef }),
8762
- /* @__PURE__ */ jsx59(ContentMenu, { editor }),
8763
- /* @__PURE__ */ jsx59(VariableBubbleMenu, { editor, appendTo: menuContainerRef }),
8764
- /* @__PURE__ */ jsx59(RepeatBubbleMenu, { editor, appendTo: menuContainerRef }),
8765
- /* @__PURE__ */ jsx59(HTMLBubbleMenu, { editor, appendTo: menuContainerRef }),
8766
- /* @__PURE__ */ jsx59(InlineImageBubbleMenu, { editor, appendTo: menuContainerRef })
9011
+ /* @__PURE__ */ jsx60(TextBubbleMenu, { editor, appendTo: menuContainerRef }),
9012
+ /* @__PURE__ */ jsx60(ImageBubbleMenu, { editor, appendTo: menuContainerRef }),
9013
+ /* @__PURE__ */ jsx60(SpacerBubbleMenu, { editor, appendTo: menuContainerRef }),
9014
+ /* @__PURE__ */ jsx60(EditorContent, { editor }),
9015
+ /* @__PURE__ */ jsx60(SectionBubbleMenu, { editor, appendTo: menuContainerRef }),
9016
+ /* @__PURE__ */ jsx60(ColumnsBubbleMenu, { editor, appendTo: menuContainerRef }),
9017
+ /* @__PURE__ */ jsx60(ContentMenu, { editor }),
9018
+ /* @__PURE__ */ jsx60(VariableBubbleMenu, { editor, appendTo: menuContainerRef }),
9019
+ /* @__PURE__ */ jsx60(RepeatBubbleMenu, { editor, appendTo: menuContainerRef }),
9020
+ /* @__PURE__ */ jsx60(HTMLBubbleMenu, { editor, appendTo: menuContainerRef }),
9021
+ /* @__PURE__ */ jsx60(InlineImageBubbleMenu, { editor, appendTo: menuContainerRef })
8767
9022
  ]
8768
9023
  }
8769
9024
  )