@maily-to/core 0.2.2 → 0.2.4

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.
@@ -1878,7 +1878,7 @@ function Divider(props) {
1878
1878
  }
1879
1879
 
1880
1880
  // src/editor/components/ui/link-input-popover.tsx
1881
- import { ChevronDownIcon, Link } from "lucide-react";
1881
+ import { Link, LinkIcon } from "lucide-react";
1882
1882
  import { useRef as useRef4, useState as useState3 } from "react";
1883
1883
 
1884
1884
  // src/editor/provider.tsx
@@ -1956,7 +1956,7 @@ var inlineImage = {
1956
1956
  icon: /* @__PURE__ */ jsx15(ImageIcon, { className: "mly-h-4 mly-w-4" }),
1957
1957
  command: ({ editor, range }) => {
1958
1958
  editor.chain().focus().deleteRange(range).setInlineImage({
1959
- src: ""
1959
+ src: "https://maily.to/brand/logo.png"
1960
1960
  }).command((props) => {
1961
1961
  const { tr, state, view, editor: editor2 } = props;
1962
1962
  const { from } = range;
@@ -2803,7 +2803,7 @@ var DEFAULT_SLASH_COMMANDS = [
2803
2803
 
2804
2804
  // src/editor/provider.tsx
2805
2805
  import { jsx as jsx25 } from "react/jsx-runtime";
2806
- var DEFAULT_PLACEHOLDER_URL = "maily.to/";
2806
+ var DEFAULT_PLACEHOLDER_URL = "https://maily.to/";
2807
2807
  var MailyContext = createContext({
2808
2808
  placeholderUrl: DEFAULT_PLACEHOLDER_URL,
2809
2809
  blocks: DEFAULT_SLASH_COMMANDS
@@ -3230,10 +3230,9 @@ var VariableExtension = Node8.create({
3230
3230
  });
3231
3231
 
3232
3232
  // src/editor/components/ui/link-input-popover.tsx
3233
- import { Fragment as Fragment2, jsx as jsx28, jsxs as jsxs12 } from "react/jsx-runtime";
3234
- var LINK_PROTOCOL_REGEX = /https?:\/\//;
3233
+ import { jsx as jsx28, jsxs as jsxs12 } from "react/jsx-runtime";
3235
3234
  function LinkInputPopover(props) {
3236
- var _a, _b, _c;
3235
+ var _a, _b;
3237
3236
  const {
3238
3237
  defaultValue = "",
3239
3238
  onValueChange,
@@ -3242,22 +3241,16 @@ function LinkInputPopover(props) {
3242
3241
  editor,
3243
3242
  isVariable
3244
3243
  } = props;
3245
- const defaultProtocol = (_a = defaultValue.match(LINK_PROTOCOL_REGEX)) == null ? void 0 : _a[0];
3246
- const defaultUrlWithoutProtocol = defaultValue.replace(
3247
- LINK_PROTOCOL_REGEX,
3248
- ""
3249
- );
3250
3244
  const [isOpen, setIsOpen] = useState3(false);
3251
- const [protocol, setProtocol] = useState3(defaultProtocol || "https://");
3252
3245
  const [isEditing, setIsEditing] = useState3(!isVariable);
3253
3246
  const linkInputRef = useRef4(null);
3254
3247
  const { placeholderUrl = DEFAULT_PLACEHOLDER_URL } = useMailyContext();
3255
3248
  const options = useVariableOptions(editor);
3256
3249
  const renderVariable = options == null ? void 0 : options.renderVariable;
3257
3250
  const variables = options == null ? void 0 : options.variables;
3258
- const variableTriggerCharacter = (_c = (_b = options == null ? void 0 : options.suggestion) == null ? void 0 : _b.char) != null ? _c : DEFAULT_VARIABLE_TRIGGER_CHAR;
3251
+ const variableTriggerCharacter = (_b = (_a = options == null ? void 0 : options.suggestion) == null ? void 0 : _a.char) != null ? _b : DEFAULT_VARIABLE_TRIGGER_CHAR;
3259
3252
  const autoCompleteOptions = useMemo5(() => {
3260
- const withoutTrigger = defaultUrlWithoutProtocol.replace(
3253
+ const withoutTrigger = defaultValue.replace(
3261
3254
  new RegExp(variableTriggerCharacter, "g"),
3262
3255
  ""
3263
3256
  );
@@ -3266,7 +3259,7 @@ function LinkInputPopover(props) {
3266
3259
  from: "bubble-variable",
3267
3260
  editor
3268
3261
  }).map((variable) => variable.name);
3269
- }, [variables, variableTriggerCharacter, defaultUrlWithoutProtocol, editor]);
3262
+ }, [variables, variableTriggerCharacter, defaultValue, editor]);
3270
3263
  const popoverButton = /* @__PURE__ */ jsx28(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx28(
3271
3264
  BaseButton,
3272
3265
  {
@@ -3274,135 +3267,110 @@ function LinkInputPopover(props) {
3274
3267
  size: "sm",
3275
3268
  type: "button",
3276
3269
  className: "mly-size-7",
3277
- "data-state": !!defaultUrlWithoutProtocol,
3270
+ "data-state": !!defaultValue,
3278
3271
  children: /* @__PURE__ */ jsx28(Icon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-midnight-gray" })
3279
3272
  }
3280
3273
  ) });
3281
- const normalizeProtocol = (value, p = protocol) => {
3282
- value = value == null ? void 0 : value.replace(LINK_PROTOCOL_REGEX, "");
3283
- return p + value;
3284
- };
3285
- return /* @__PURE__ */ jsxs12(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [
3286
- tooltip ? /* @__PURE__ */ jsxs12(Tooltip, { children: [
3287
- /* @__PURE__ */ jsx28(TooltipTrigger, { asChild: true, children: popoverButton }),
3288
- /* @__PURE__ */ jsx28(TooltipContent, { sideOffset: 8, children: tooltip })
3289
- ] }) : popoverButton,
3290
- /* @__PURE__ */ jsx28(
3291
- PopoverContent,
3292
- {
3293
- align: "end",
3294
- side: "top",
3295
- className: "mly-w-max mly-rounded-none mly-border-none mly-bg-transparent !mly-p-0 mly-shadow-none",
3296
- sideOffset: 8,
3297
- onCloseAutoFocus: (e) => e.preventDefault(),
3298
- children: /* @__PURE__ */ jsx28(
3299
- "form",
3274
+ return /* @__PURE__ */ jsxs12(
3275
+ Popover,
3276
+ {
3277
+ open: isOpen,
3278
+ onOpenChange: (open) => {
3279
+ setIsOpen(open);
3280
+ if (open) {
3281
+ setTimeout(() => {
3282
+ var _a2;
3283
+ (_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
3284
+ }, 0);
3285
+ }
3286
+ },
3287
+ children: [
3288
+ tooltip ? /* @__PURE__ */ jsxs12(Tooltip, { children: [
3289
+ /* @__PURE__ */ jsx28(TooltipTrigger, { asChild: true, children: popoverButton }),
3290
+ /* @__PURE__ */ jsx28(TooltipContent, { sideOffset: 8, children: tooltip })
3291
+ ] }) : popoverButton,
3292
+ /* @__PURE__ */ jsx28(
3293
+ PopoverContent,
3300
3294
  {
3301
- onSubmit: (e) => {
3302
- e.preventDefault();
3303
- const input = linkInputRef.current;
3304
- if (!input) {
3305
- return;
3306
- }
3307
- let value = normalizeProtocol(input.value);
3308
- onValueChange == null ? void 0 : onValueChange(value);
3309
- setIsOpen(false);
3310
- },
3311
- children: /* @__PURE__ */ jsxs12("div", { className: "mly-isolate mly-flex mly-rounded-lg", children: [
3312
- !isEditing && /* @__PURE__ */ jsx28("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__ */ jsx28(
3313
- "button",
3314
- {
3315
- onClick: () => {
3316
- setIsEditing(true);
3317
- setTimeout(() => {
3318
- var _a2;
3319
- (_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
3320
- }, 0);
3321
- },
3322
- children: renderVariable({
3323
- variable: {
3324
- name: defaultUrlWithoutProtocol,
3325
- valid: true
3326
- },
3327
- fallback: "",
3328
- from: "bubble-variable",
3329
- editor
3330
- })
3331
- }
3332
- ) }),
3333
- isEditing && /* @__PURE__ */ jsxs12(Fragment2, { children: [
3334
- /* @__PURE__ */ jsxs12("div", { className: "mly-relative", children: [
3335
- /* @__PURE__ */ jsxs12(
3336
- "select",
3295
+ align: "end",
3296
+ side: "top",
3297
+ className: "mly-w-max mly-rounded-none mly-border-none mly-bg-transparent !mly-p-0 mly-shadow-none",
3298
+ sideOffset: 8,
3299
+ onCloseAutoFocus: (e) => e.preventDefault(),
3300
+ children: /* @__PURE__ */ jsx28(
3301
+ "form",
3302
+ {
3303
+ onSubmit: (e) => {
3304
+ e.preventDefault();
3305
+ const input = linkInputRef.current;
3306
+ if (!input) {
3307
+ return;
3308
+ }
3309
+ onValueChange == null ? void 0 : onValueChange(input.value);
3310
+ setIsOpen(false);
3311
+ },
3312
+ children: /* @__PURE__ */ jsxs12("div", { className: "mly-isolate mly-flex mly-rounded-lg", children: [
3313
+ !isEditing && /* @__PURE__ */ jsx28("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__ */ jsx28(
3314
+ "button",
3337
3315
  {
3338
- 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",
3339
- "aria-label": "Protocol",
3340
- value: protocol,
3341
- onChange: (e) => {
3342
- var _a2;
3343
- const protocol2 = e.target.value;
3344
- setProtocol(protocol2);
3345
- const newValue = normalizeProtocol(
3346
- ((_a2 = linkInputRef.current) == null ? void 0 : _a2.value) || "",
3347
- protocol2
3348
- );
3349
- onValueChange == null ? void 0 : onValueChange(newValue);
3316
+ onClick: () => {
3317
+ setIsEditing(true);
3318
+ setTimeout(() => {
3319
+ var _a2;
3320
+ (_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
3321
+ }, 0);
3350
3322
  },
3351
- children: [
3352
- /* @__PURE__ */ jsx28("option", { value: "https://", children: "https://" }),
3353
- /* @__PURE__ */ jsx28("option", { value: "http://", children: "http://" })
3354
- ]
3355
- }
3356
- ),
3357
- /* @__PURE__ */ jsx28("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__ */ jsx28(
3358
- ChevronDownIcon,
3359
- {
3360
- size: 16,
3361
- strokeWidth: 2,
3362
- "aria-hidden": "true",
3363
- role: "img"
3323
+ children: renderVariable({
3324
+ variable: {
3325
+ name: defaultValue,
3326
+ valid: true
3327
+ },
3328
+ fallback: "",
3329
+ from: "bubble-variable",
3330
+ editor
3331
+ })
3364
3332
  }
3365
- ) })
3366
- ] }),
3367
- /* @__PURE__ */ jsx28(
3368
- InputAutocomplete,
3369
- {
3370
- editor,
3371
- value: defaultUrlWithoutProtocol,
3372
- onValueChange: (value) => {
3373
- let newValue = normalizeProtocol(value);
3374
- onValueChange == null ? void 0 : onValueChange(newValue);
3375
- },
3376
- autoCompleteOptions,
3377
- ref: linkInputRef,
3378
- placeholder: placeholderUrl,
3379
- 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",
3380
- triggerChar: variableTriggerCharacter,
3381
- onSelectOption: (value) => {
3382
- var _a2;
3383
- const isVariable2 = (_a2 = autoCompleteOptions.includes(value)) != null ? _a2 : false;
3384
- if (isVariable2) {
3385
- setIsEditing(false);
3386
- } else {
3387
- value = normalizeProtocol(value);
3333
+ ) }),
3334
+ isEditing && /* @__PURE__ */ jsxs12("div", { className: "mly-relative", children: [
3335
+ /* @__PURE__ */ jsx28("div", { className: "mly-absolute mly-inset-y-0 mly-left-1.5 mly-z-10 mly-flex mly-items-center", children: /* @__PURE__ */ jsx28(LinkIcon, { className: "mly-h-3 mly-w-3 mly-stroke-[2.5] mly-text-midnight-gray" }) }),
3336
+ /* @__PURE__ */ jsx28(
3337
+ InputAutocomplete,
3338
+ {
3339
+ editor,
3340
+ value: defaultValue,
3341
+ onValueChange: (value) => {
3342
+ onValueChange == null ? void 0 : onValueChange(value);
3343
+ },
3344
+ autoCompleteOptions,
3345
+ ref: linkInputRef,
3346
+ placeholder: placeholderUrl,
3347
+ 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",
3348
+ triggerChar: variableTriggerCharacter,
3349
+ onSelectOption: (value) => {
3350
+ var _a2;
3351
+ const isVariable2 = (_a2 = autoCompleteOptions.includes(value)) != null ? _a2 : false;
3352
+ if (isVariable2) {
3353
+ setIsEditing(false);
3354
+ }
3355
+ onValueChange == null ? void 0 : onValueChange(value, isVariable2);
3356
+ setIsOpen(false);
3357
+ }
3388
3358
  }
3389
- onValueChange == null ? void 0 : onValueChange(value, isVariable2);
3390
- setIsOpen(false);
3391
- }
3392
- }
3393
- )
3394
- ] })
3395
- ] })
3359
+ )
3360
+ ] })
3361
+ ] })
3362
+ }
3363
+ )
3396
3364
  }
3397
3365
  )
3398
- }
3399
- )
3400
- ] });
3366
+ ]
3367
+ }
3368
+ );
3401
3369
  }
3402
3370
 
3403
3371
  // src/editor/components/ui/select.tsx
3404
3372
  import { useId } from "react";
3405
- import { ChevronDownIcon as ChevronDownIcon2 } from "lucide-react";
3373
+ import { ChevronDownIcon } from "lucide-react";
3406
3374
  import { jsx as jsx29, jsxs as jsxs13 } from "react/jsx-runtime";
3407
3375
  function Select(props) {
3408
3376
  const {
@@ -3434,7 +3402,7 @@ function Select(props) {
3434
3402
  }
3435
3403
  ),
3436
3404
  /* @__PURE__ */ jsx29("span", { className: "mly-pointer-events-none mly-absolute mly-inset-y-0 mly-right-0 mly-z-10 mly-flex mly-h-full mly-w-7 mly-items-center mly-justify-center mly-text-gray-600 peer-disabled:mly-opacity-50", children: /* @__PURE__ */ jsx29(
3437
- ChevronDownIcon2,
3405
+ ChevronDownIcon,
3438
3406
  {
3439
3407
  size: 16,
3440
3408
  strokeWidth: 2,
@@ -4109,10 +4077,21 @@ var useEvent = (handler) => {
4109
4077
  }, []);
4110
4078
  };
4111
4079
 
4080
+ // src/editor/utils/aspect-ratio.ts
4081
+ function getAspectRatio(width, height) {
4082
+ return width / height;
4083
+ }
4084
+ function getNewHeight(width, aspectRatio) {
4085
+ if (width <= 0 || aspectRatio <= 0) {
4086
+ return 0;
4087
+ }
4088
+ return width / aspectRatio;
4089
+ }
4090
+
4112
4091
  // src/editor/nodes/image/image-view.tsx
4113
- import { Fragment as Fragment3, jsx as jsx32, jsxs as jsxs16 } from "react/jsx-runtime";
4092
+ import { Fragment as Fragment2, jsx as jsx32, jsxs as jsxs16 } from "react/jsx-runtime";
4114
4093
  var MIN_WIDTH = 20;
4115
- var MAX_WIDTH = 600;
4094
+ var IMAGE_MAX_WIDTH = 600;
4116
4095
  function ImageView(props) {
4117
4096
  const { node, updateAttributes: updateAttributes2, selected, editor } = props;
4118
4097
  const [status, setStatus] = useState5("idle");
@@ -4130,7 +4109,10 @@ function ImageView(props) {
4130
4109
  if (!imgRef.current || !imageParent || !selected) {
4131
4110
  return;
4132
4111
  }
4133
- const imageParentWidth = Math.max(imageParent.offsetWidth, MAX_WIDTH);
4112
+ const imageParentWidth = Math.max(
4113
+ imageParent.offsetWidth,
4114
+ IMAGE_MAX_WIDTH
4115
+ );
4134
4116
  event.preventDefault();
4135
4117
  const direction = event.currentTarget.dataset.direction || "--";
4136
4118
  const initialXPosition = event.clientX;
@@ -4142,7 +4124,8 @@ function ImageView(props) {
4142
4124
  const removeListeners = () => {
4143
4125
  window.removeEventListener("mousemove", mouseMoveHandler);
4144
4126
  window.removeEventListener("mouseup", removeListeners);
4145
- updateAttributes2({ width: newWidth, height: newHeight });
4127
+ const aspectRatio = getAspectRatio(newWidth, newHeight);
4128
+ updateAttributes2({ width: newWidth, height: newHeight, aspectRatio });
4146
4129
  setResizingStyle(void 0);
4147
4130
  };
4148
4131
  const mouseMoveHandler = (event2) => {
@@ -4188,17 +4171,29 @@ function ImageView(props) {
4188
4171
  },
4189
4172
  [handleMouseDown, isPlaceholderImage]
4190
4173
  );
4191
- let { alignment = "center", width, height, src } = node.attrs || {};
4174
+ let {
4175
+ alignment = "center",
4176
+ width,
4177
+ height,
4178
+ src,
4179
+ borderRadius
4180
+ } = node.attrs || {};
4192
4181
  const _a = node.attrs || {}, {
4193
4182
  externalLink,
4194
4183
  isExternalLinkVariable,
4195
4184
  isSrcVariable,
4196
- showIfKey
4185
+ showIfKey,
4186
+ aspectRatio: defaultAspectRatio,
4187
+ borderRadius: _,
4188
+ lockAspectRatio
4197
4189
  } = _a, attrs = __objRest(_a, [
4198
4190
  "externalLink",
4199
4191
  "isExternalLinkVariable",
4200
4192
  "isSrcVariable",
4201
- "showIfKey"
4193
+ "showIfKey",
4194
+ "aspectRatio",
4195
+ "borderRadius",
4196
+ "lockAspectRatio"
4202
4197
  ]);
4203
4198
  const hasImageSrc = !!attrs.src;
4204
4199
  const isDroppable = !!onImageUpload && editor.isEditable && !hasImageSrc && !isSrcVariable && status === "idle";
@@ -4245,14 +4240,15 @@ function ImageView(props) {
4245
4240
  return;
4246
4241
  }
4247
4242
  const wrapperWidth = wrapper.offsetWidth;
4248
- const aspectRatio = naturalWidth / naturalHeight;
4243
+ const aspectRatio = getAspectRatio(naturalWidth, naturalHeight);
4249
4244
  const calculatedHeight = Math.min(
4250
- wrapperWidth / aspectRatio,
4245
+ getNewHeight(wrapperWidth, aspectRatio),
4251
4246
  naturalHeight
4252
4247
  );
4253
4248
  updateAttributes2({
4254
4249
  width: Math.min(wrapperWidth, naturalWidth),
4255
- height: Math.min(calculatedHeight, naturalHeight)
4250
+ height: Math.min(calculatedHeight, naturalHeight),
4251
+ aspectRatio
4256
4252
  });
4257
4253
  };
4258
4254
  img.onerror = () => {
@@ -4322,7 +4318,8 @@ function ImageView(props) {
4322
4318
  position: "relative",
4323
4319
  // Weird! Basically tiptap/prose wraps this in a span and the line height causes an annoying buffer.
4324
4320
  lineHeight: "0px",
4325
- display: "block"
4321
+ display: "block",
4322
+ maxWidth: "100%"
4326
4323
  }), {
4327
4324
  center: { marginLeft: "auto", marginRight: "auto" },
4328
4325
  left: { marginRight: "auto" },
@@ -4357,14 +4354,15 @@ function ImageView(props) {
4357
4354
  multiple: false
4358
4355
  }
4359
4356
  ),
4360
- hasImageSrc && status === "loaded" && !isSrcVariable && /* @__PURE__ */ jsxs16(Fragment3, { children: [
4357
+ hasImageSrc && status === "loaded" && !isSrcVariable && /* @__PURE__ */ jsxs16(Fragment2, { children: [
4361
4358
  /* @__PURE__ */ jsx32(
4362
4359
  "img",
4363
4360
  __spreadProps(__spreadValues({}, attrs), {
4364
4361
  ref: imgRef,
4365
4362
  style: __spreadProps(__spreadValues({}, resizingStyle), {
4366
4363
  cursor: "default",
4367
- marginBottom: 0
4364
+ marginBottom: 0,
4365
+ borderRadius
4368
4366
  }),
4369
4367
  draggable: editor.isEditable,
4370
4368
  className: cn(
@@ -4372,7 +4370,7 @@ function ImageView(props) {
4372
4370
  )
4373
4371
  })
4374
4372
  ),
4375
- selected && editor.isEditable && !isPlaceholderImage && /* @__PURE__ */ jsxs16(Fragment3, { children: [
4373
+ selected && editor.isEditable && !isPlaceholderImage && /* @__PURE__ */ jsxs16(Fragment2, { children: [
4376
4374
  [
4377
4375
  { left: 0, top: 0, height: "100%", width: "1px" },
4378
4376
  { right: 0, top: 0, height: "100%", width: "1px" },
@@ -4415,23 +4413,23 @@ function ImageStatusLabel(props) {
4415
4413
  minHeight
4416
4414
  } : {}), style),
4417
4415
  children: [
4418
- status === "idle" && !isDropZone && /* @__PURE__ */ jsxs16(Fragment3, { children: [
4416
+ status === "idle" && !isDropZone && /* @__PURE__ */ jsxs16(Fragment2, { children: [
4419
4417
  /* @__PURE__ */ jsx32(ImageOffIcon, { className: "mly-size-4 mly-stroke-[2.5]" }),
4420
4418
  /* @__PURE__ */ jsx32("span", { children: "No image selected" })
4421
4419
  ] }),
4422
- status === "idle" && isDropZone && /* @__PURE__ */ jsxs16(Fragment3, { children: [
4420
+ status === "idle" && isDropZone && /* @__PURE__ */ jsxs16(Fragment2, { children: [
4423
4421
  /* @__PURE__ */ jsx32(GrabIcon, { className: "mly-size-4 mly-stroke-[2.5]" }),
4424
4422
  /* @__PURE__ */ jsx32("span", { children: "Click or Drop image here" })
4425
4423
  ] }),
4426
- status === "loading" && /* @__PURE__ */ jsxs16(Fragment3, { children: [
4424
+ status === "loading" && /* @__PURE__ */ jsxs16(Fragment2, { children: [
4427
4425
  /* @__PURE__ */ jsx32(Loader2, { className: "mly-size-4 mly-animate-spin mly-stroke-[2.5]" }),
4428
4426
  /* @__PURE__ */ jsx32("span", { children: "Loading image..." })
4429
4427
  ] }),
4430
- status === "error" && /* @__PURE__ */ jsxs16(Fragment3, { children: [
4428
+ status === "error" && /* @__PURE__ */ jsxs16(Fragment2, { children: [
4431
4429
  /* @__PURE__ */ jsx32(Ban, { className: "mly-size-4 mly-stroke-[2.5]" }),
4432
4430
  /* @__PURE__ */ jsx32("span", { children: "Error loading image" })
4433
4431
  ] }),
4434
- status === "variable" && /* @__PURE__ */ jsxs16(Fragment3, { children: [
4432
+ status === "variable" && /* @__PURE__ */ jsxs16(Fragment2, { children: [
4435
4433
  /* @__PURE__ */ jsx32(BracesIcon, { className: "mly-size-4 mly-stroke-[2.5]" }),
4436
4434
  /* @__PURE__ */ jsx32("span", { children: "Variable Image URL" })
4437
4435
  ] })
@@ -4718,6 +4716,7 @@ var LogoExtension = TiptapImage.extend({
4718
4716
  // src/editor/nodes/image/image.ts
4719
4717
  import TiptapImage2 from "@tiptap/extension-image";
4720
4718
  import { ReactNodeViewRenderer as ReactNodeViewRenderer5 } from "@tiptap/react";
4719
+ var DEFAULT_IMAGE_BORDER_RADIUS = 0;
4721
4720
  var ImageExtension = TiptapImage2.extend({
4722
4721
  addAttributes() {
4723
4722
  var _a;
@@ -4781,6 +4780,17 @@ var ImageExtension = TiptapImage2.extend({
4781
4780
  };
4782
4781
  }
4783
4782
  },
4783
+ borderRadius: {
4784
+ default: DEFAULT_IMAGE_BORDER_RADIUS,
4785
+ parseHTML: (element) => {
4786
+ return Number(element.getAttribute("data-border-radius"));
4787
+ },
4788
+ renderHTML: (attributes) => {
4789
+ return {
4790
+ "data-border-radius": attributes.borderRadius
4791
+ };
4792
+ }
4793
+ },
4784
4794
  // Later we will remove this attribute
4785
4795
  // and use the `src` attribute instead when implement
4786
4796
  // the URL variable feature
@@ -4798,6 +4808,34 @@ var ImageExtension = TiptapImage2.extend({
4798
4808
  };
4799
4809
  }
4800
4810
  },
4811
+ aspectRatio: {
4812
+ default: null,
4813
+ parseHTML: (element) => {
4814
+ return element.getAttribute("data-aspect-ratio") || null;
4815
+ },
4816
+ renderHTML: (attributes) => {
4817
+ if (!(attributes == null ? void 0 : attributes.aspectRatio)) {
4818
+ return {};
4819
+ }
4820
+ return {
4821
+ "data-aspect-ratio": attributes == null ? void 0 : attributes.aspectRatio
4822
+ };
4823
+ }
4824
+ },
4825
+ lockAspectRatio: {
4826
+ default: true,
4827
+ parseHTML: (element) => {
4828
+ return element.getAttribute("data-lock-aspect-ratio") === "true";
4829
+ },
4830
+ renderHTML: (attributes) => {
4831
+ if (!attributes.lockAspectRatio) {
4832
+ return {};
4833
+ }
4834
+ return {
4835
+ "data-lock-aspect-ratio": "true"
4836
+ };
4837
+ }
4838
+ },
4801
4839
  showIfKey: {
4802
4840
  default: DEFAULT_SECTION_SHOW_IF_KEY,
4803
4841
  parseHTML: (element) => {
@@ -5166,21 +5204,123 @@ import { ReactRenderer } from "@tiptap/react";
5166
5204
  import {
5167
5205
  forwardRef as forwardRef8,
5168
5206
  Fragment as Fragment4,
5169
- useCallback as useCallback5,
5170
- useEffect as useEffect5,
5207
+ useCallback as useCallback6,
5208
+ useEffect as useEffect6,
5171
5209
  useImperativeHandle as useImperativeHandle2,
5172
5210
  useLayoutEffect as useLayoutEffect2,
5173
- useRef as useRef8,
5174
- useState as useState7
5211
+ useRef as useRef9,
5212
+ useState as useState8
5175
5213
  } from "react";
5176
5214
  import tippy from "tippy.js";
5215
+
5216
+ // src/editor/extensions/slash-command/slash-command-item.tsx
5177
5217
  import { ChevronRightIcon } from "lucide-react";
5178
- import { Fragment as Fragment5, jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
5218
+ import { useCallback as useCallback5, useState as useState7, useRef as useRef8, useEffect as useEffect5 } from "react";
5219
+ import { Fragment as Fragment3, jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
5220
+ function SlashCommandItem(props) {
5221
+ var _a;
5222
+ const {
5223
+ item,
5224
+ groupIndex,
5225
+ commandIndex,
5226
+ selectedGroupIndex,
5227
+ selectedCommandIndex,
5228
+ editor,
5229
+ activeCommandRef,
5230
+ selectItem
5231
+ } = props;
5232
+ const [open, setOpen] = useState7(false);
5233
+ const [isHovered, setIsHovered] = useState7(false);
5234
+ const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
5235
+ const isSubCommand = item && "commands" in item;
5236
+ const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && (isActive || isHovered);
5237
+ const hasRenderFunction = typeof item.render === "function";
5238
+ const renderFunctionValue = hasRenderFunction ? (_a = item.render) == null ? void 0 : _a.call(item, editor) : null;
5239
+ let value = /* @__PURE__ */ jsxs19(Fragment3, { children: [
5240
+ /* @__PURE__ */ jsx35("div", { className: "mly-flex mly-h-6 mly-w-6 mly-shrink-0 mly-items-center mly-justify-center", children: item.icon }),
5241
+ /* @__PURE__ */ jsxs19("div", { className: "mly-grow", children: [
5242
+ /* @__PURE__ */ jsx35("p", { className: "mly-font-medium", children: item.title }),
5243
+ /* @__PURE__ */ jsx35("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
5244
+ ] }),
5245
+ isSubCommand && /* @__PURE__ */ jsx35("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ jsx35(ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
5246
+ ] });
5247
+ if (renderFunctionValue !== null && renderFunctionValue !== true) {
5248
+ value = renderFunctionValue;
5249
+ }
5250
+ const openTimerRef = useRef8(0);
5251
+ const handleDelayedOpen = useCallback5(() => {
5252
+ window.clearTimeout(openTimerRef.current);
5253
+ const delay = 200;
5254
+ openTimerRef.current = window.setTimeout(() => {
5255
+ setOpen(true);
5256
+ openTimerRef.current = 0;
5257
+ }, delay);
5258
+ }, [setOpen]);
5259
+ useEffect5(() => {
5260
+ if (shouldOpenTooltip) {
5261
+ handleDelayedOpen();
5262
+ } else {
5263
+ window.clearTimeout(openTimerRef.current);
5264
+ openTimerRef.current = 0;
5265
+ setOpen(false);
5266
+ }
5267
+ }, [shouldOpenTooltip]);
5268
+ useEffect5(() => {
5269
+ return () => {
5270
+ if (openTimerRef.current) {
5271
+ window.clearTimeout(openTimerRef.current);
5272
+ openTimerRef.current = 0;
5273
+ }
5274
+ };
5275
+ }, []);
5276
+ return /* @__PURE__ */ jsxs19(Tooltip, { open, children: [
5277
+ /* @__PURE__ */ jsx35(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx35(
5278
+ "button",
5279
+ {
5280
+ className: cn(
5281
+ "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",
5282
+ isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
5283
+ ),
5284
+ onClick: () => selectItem(groupIndex, commandIndex),
5285
+ onMouseEnter: () => setIsHovered(true),
5286
+ onMouseLeave: () => setIsHovered(false),
5287
+ type: "button",
5288
+ ref: isActive ? activeCommandRef : null,
5289
+ children: value
5290
+ }
5291
+ ) }),
5292
+ /* @__PURE__ */ jsx35(
5293
+ TooltipContent,
5294
+ {
5295
+ side: "right",
5296
+ sideOffset: 10,
5297
+ className: "mly-w-52 mly-rounded-lg mly-border-none mly-p-1 mly-shadow",
5298
+ children: typeof item.preview === "function" ? item == null ? void 0 : item.preview(editor) : /* @__PURE__ */ jsxs19(Fragment3, { children: [
5299
+ /* @__PURE__ */ jsx35("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__ */ jsx35(
5300
+ "img",
5301
+ {
5302
+ src: item == null ? void 0 : item.preview,
5303
+ alt: item == null ? void 0 : item.title,
5304
+ className: "mly-absolute mly-inset-0 mly-h-full mly-w-full mly-object-cover"
5305
+ }
5306
+ ) }),
5307
+ /* @__PURE__ */ jsx35("p", { className: "mly-mt-2 mly-px-0.5 mly-text-gray-500", children: item.description })
5308
+ ] })
5309
+ }
5310
+ )
5311
+ ] }, `${groupIndex}-${commandIndex}`);
5312
+ }
5313
+
5314
+ // src/editor/extensions/slash-command/slash-command-view.tsx
5315
+ import { jsx as jsx36, jsxs as jsxs20 } from "react/jsx-runtime";
5179
5316
  var CommandList = forwardRef8(function CommandList2(props, ref) {
5180
- const { items: groups, command, editor } = props;
5181
- const [selectedGroupIndex, setSelectedGroupIndex] = useState7(0);
5182
- const [selectedCommandIndex, setSelectedCommandIndex] = useState7(0);
5183
- const selectItem = useCallback5(
5317
+ const { items: groups, command, editor, range, query } = props;
5318
+ const [selectedGroupIndex, setSelectedGroupIndex] = useState8(0);
5319
+ const [selectedCommandIndex, setSelectedCommandIndex] = useState8(0);
5320
+ const prevQuery = useRef9("");
5321
+ const prevSelectedGroupIndex = useRef9(0);
5322
+ const prevSelectedCommandIndex = useRef9(0);
5323
+ const selectItem = useCallback6(
5184
5324
  (groupIndex, commandIndex) => {
5185
5325
  const item = groups[groupIndex].commands[commandIndex];
5186
5326
  if (!item) {
@@ -5192,62 +5332,94 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
5192
5332
  );
5193
5333
  useImperativeHandle2(ref, () => ({
5194
5334
  onKeyDown: ({ event }) => {
5195
- var _a, _b;
5196
- const navigationKeys = ["ArrowUp", "ArrowDown", "Enter"];
5335
+ var _a, _b, _c, _d;
5336
+ const navigationKeys = [
5337
+ "ArrowUp",
5338
+ "ArrowDown",
5339
+ "Enter",
5340
+ "ArrowLeft",
5341
+ "ArrowRight"
5342
+ ];
5197
5343
  if (navigationKeys.includes(event.key)) {
5198
- if (event.key === "ArrowUp") {
5199
- if (!groups.length) {
5200
- return false;
5201
- }
5202
- let newCommandIndex = selectedCommandIndex - 1;
5203
- let newGroupIndex = selectedGroupIndex;
5204
- if (newCommandIndex < 0) {
5205
- newGroupIndex = selectedGroupIndex - 1;
5206
- newCommandIndex = ((_a = groups[newGroupIndex]) == null ? void 0 : _a.commands.length) - 1 || 0;
5207
- }
5208
- if (newGroupIndex < 0) {
5209
- newGroupIndex = groups.length - 1;
5210
- newCommandIndex = ((_b = groups[newGroupIndex]) == null ? void 0 : _b.commands.length) - 1 || 0;
5211
- }
5212
- setSelectedGroupIndex(newGroupIndex);
5213
- setSelectedCommandIndex(newCommandIndex);
5214
- return true;
5215
- }
5216
- if (event.key === "ArrowDown") {
5217
- if (!groups.length) {
5218
- return false;
5219
- }
5220
- const commands = groups[selectedGroupIndex].commands;
5221
- let newCommandIndex = selectedCommandIndex + 1;
5222
- let newGroupIndex = selectedGroupIndex;
5223
- if (commands.length - 1 < newCommandIndex) {
5224
- newCommandIndex = 0;
5225
- newGroupIndex = selectedGroupIndex + 1;
5226
- }
5227
- if (groups.length - 1 < newGroupIndex) {
5228
- newGroupIndex = 0;
5229
- }
5230
- setSelectedGroupIndex(newGroupIndex);
5231
- setSelectedCommandIndex(newCommandIndex);
5232
- return true;
5233
- }
5234
- if (event.key === "Enter") {
5235
- if (!groups.length) {
5344
+ let newCommandIndex = selectedCommandIndex;
5345
+ let newGroupIndex = selectedGroupIndex;
5346
+ switch (event.key) {
5347
+ case "ArrowLeft":
5348
+ event.preventDefault();
5349
+ const group = groups == null ? void 0 : groups[selectedGroupIndex];
5350
+ const isInsideSubCommand = group && "id" in group;
5351
+ if (!isInsideSubCommand) {
5352
+ return false;
5353
+ }
5354
+ editor.chain().focus().insertContentAt(range, `/${prevQuery.current}`).run();
5355
+ setTimeout(() => {
5356
+ setSelectedGroupIndex(prevSelectedGroupIndex.current);
5357
+ setSelectedCommandIndex(prevSelectedCommandIndex.current);
5358
+ }, 0);
5359
+ return true;
5360
+ case "ArrowRight":
5361
+ event.preventDefault();
5362
+ const command2 = (_b = (_a = groups == null ? void 0 : groups[selectedGroupIndex]) == null ? void 0 : _a.commands) == null ? void 0 : _b[selectedCommandIndex];
5363
+ const isSelectingSubCommand = command2 && "commands" in command2;
5364
+ if (!isSelectingSubCommand) {
5365
+ return false;
5366
+ }
5367
+ selectItem(selectedGroupIndex, selectedCommandIndex);
5368
+ prevQuery.current = query;
5369
+ prevSelectedGroupIndex.current = selectedGroupIndex;
5370
+ prevSelectedCommandIndex.current = selectedCommandIndex;
5371
+ return true;
5372
+ case "Enter":
5373
+ if (!groups.length) {
5374
+ return false;
5375
+ }
5376
+ selectItem(selectedGroupIndex, selectedCommandIndex);
5377
+ prevQuery.current = query;
5378
+ prevSelectedGroupIndex.current = selectedGroupIndex;
5379
+ prevSelectedCommandIndex.current = selectedCommandIndex;
5380
+ return true;
5381
+ case "ArrowUp":
5382
+ if (!groups.length) {
5383
+ return false;
5384
+ }
5385
+ newCommandIndex = selectedCommandIndex - 1;
5386
+ newGroupIndex = selectedGroupIndex;
5387
+ if (newCommandIndex < 0) {
5388
+ newGroupIndex = selectedGroupIndex - 1;
5389
+ newCommandIndex = ((_c = groups[newGroupIndex]) == null ? void 0 : _c.commands.length) - 1 || 0;
5390
+ }
5391
+ if (newGroupIndex < 0) {
5392
+ newGroupIndex = groups.length - 1;
5393
+ newCommandIndex = ((_d = groups[newGroupIndex]) == null ? void 0 : _d.commands.length) - 1 || 0;
5394
+ }
5395
+ setSelectedGroupIndex(newGroupIndex);
5396
+ setSelectedCommandIndex(newCommandIndex);
5397
+ return true;
5398
+ case "ArrowDown":
5399
+ if (!groups.length) {
5400
+ return false;
5401
+ }
5402
+ const commands = groups[selectedGroupIndex].commands;
5403
+ newCommandIndex = selectedCommandIndex + 1;
5404
+ newGroupIndex = selectedGroupIndex;
5405
+ if (commands.length - 1 < newCommandIndex) {
5406
+ newCommandIndex = 0;
5407
+ newGroupIndex = selectedGroupIndex + 1;
5408
+ }
5409
+ if (groups.length - 1 < newGroupIndex) {
5410
+ newGroupIndex = 0;
5411
+ }
5412
+ setSelectedGroupIndex(newGroupIndex);
5413
+ setSelectedCommandIndex(newCommandIndex);
5414
+ return true;
5415
+ default:
5236
5416
  return false;
5237
- }
5238
- selectItem(selectedGroupIndex, selectedCommandIndex);
5239
- return true;
5240
5417
  }
5241
- return false;
5242
5418
  }
5243
5419
  }
5244
5420
  }));
5245
- useEffect5(() => {
5246
- setSelectedGroupIndex(0);
5247
- setSelectedCommandIndex(0);
5248
- }, [groups]);
5249
- const commandListContainer = useRef8(null);
5250
- const activeCommandRef = useRef8(null);
5421
+ const commandListContainer = useRef9(null);
5422
+ const activeCommandRef = useRef9(null);
5251
5423
  useLayoutEffect2(() => {
5252
5424
  const container = commandListContainer == null ? void 0 : commandListContainer.current;
5253
5425
  const activeCommandContainer = activeCommandRef == null ? void 0 : activeCommandRef.current;
@@ -5255,6 +5427,7 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
5255
5427
  return;
5256
5428
  }
5257
5429
  const { offsetTop, offsetHeight } = activeCommandContainer;
5430
+ container.style.transition = "none";
5258
5431
  container.scrollTop = offsetTop - offsetHeight;
5259
5432
  }, [
5260
5433
  selectedGroupIndex,
@@ -5262,15 +5435,26 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
5262
5435
  commandListContainer,
5263
5436
  activeCommandRef
5264
5437
  ]);
5265
- return groups.length > 0 ? /* @__PURE__ */ jsx35(TooltipProvider, { children: /* @__PURE__ */ jsxs19("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: [
5266
- /* @__PURE__ */ jsx35(
5438
+ useEffect6(() => {
5439
+ setSelectedGroupIndex(0);
5440
+ setSelectedCommandIndex(0);
5441
+ }, [groups]);
5442
+ useEffect6(() => {
5443
+ return () => {
5444
+ prevQuery.current = "";
5445
+ prevSelectedGroupIndex.current = 0;
5446
+ prevSelectedCommandIndex.current = 0;
5447
+ };
5448
+ }, []);
5449
+ return groups.length > 0 ? /* @__PURE__ */ jsx36(TooltipProvider, { children: /* @__PURE__ */ jsxs20("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: [
5450
+ /* @__PURE__ */ jsx36(
5267
5451
  "div",
5268
5452
  {
5269
5453
  id: "slash-command",
5270
5454
  ref: commandListContainer,
5271
- className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto mly-scroll-smooth",
5272
- children: groups.map((group, groupIndex) => /* @__PURE__ */ jsxs19(Fragment4, { children: [
5273
- /* @__PURE__ */ jsx35(
5455
+ className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto",
5456
+ children: groups.map((group, groupIndex) => /* @__PURE__ */ jsxs20(Fragment4, { children: [
5457
+ /* @__PURE__ */ jsx36(
5274
5458
  "span",
5275
5459
  {
5276
5460
  className: cn(
@@ -5280,72 +5464,35 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
5280
5464
  children: group.title
5281
5465
  }
5282
5466
  ),
5283
- /* @__PURE__ */ jsx35("div", { className: "mly-space-y-0.5 mly-p-1", children: group.commands.map((item, commandIndex) => {
5284
- var _a;
5285
- const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
5286
- const isSubCommand = "commands" in item;
5287
- const hasRenderFunction = typeof item.render === "function";
5288
- const renderFunctionValue = hasRenderFunction ? (_a = item.render) == null ? void 0 : _a.call(item, editor) : null;
5289
- let value = /* @__PURE__ */ jsxs19(Fragment5, { children: [
5290
- /* @__PURE__ */ jsx35("div", { className: "mly-flex mly-h-6 mly-w-6 mly-shrink-0 mly-items-center mly-justify-center", children: item.icon }),
5291
- /* @__PURE__ */ jsxs19("div", { className: "mly-grow", children: [
5292
- /* @__PURE__ */ jsx35("p", { className: "mly-font-medium", children: item.title }),
5293
- /* @__PURE__ */ jsx35("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
5294
- ] }),
5295
- isSubCommand && /* @__PURE__ */ jsx35("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ jsx35(ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
5296
- ] });
5297
- if (renderFunctionValue !== null && renderFunctionValue !== true) {
5298
- value = renderFunctionValue;
5299
- }
5300
- const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && isActive;
5301
- return /* @__PURE__ */ jsxs19(Tooltip, { open: shouldOpenTooltip, children: [
5302
- /* @__PURE__ */ jsx35(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx35(
5303
- "button",
5304
- {
5305
- className: cn(
5306
- "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",
5307
- isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
5308
- ),
5309
- onClick: () => selectItem(groupIndex, commandIndex),
5310
- type: "button",
5311
- ref: isActive ? activeCommandRef : null,
5312
- children: value
5313
- }
5314
- ) }),
5315
- /* @__PURE__ */ jsx35(
5316
- TooltipContent,
5317
- {
5318
- side: "right",
5319
- sideOffset: 10,
5320
- className: "mly-w-52 mly-rounded-lg mly-border-none mly-p-1 mly-shadow",
5321
- children: typeof item.preview === "function" ? item == null ? void 0 : item.preview(editor) : /* @__PURE__ */ jsxs19(Fragment5, { children: [
5322
- /* @__PURE__ */ jsx35("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__ */ jsx35(
5323
- "img",
5324
- {
5325
- src: item == null ? void 0 : item.preview,
5326
- alt: item == null ? void 0 : item.title,
5327
- className: "mly-absolute mly-inset-0 mly-h-full mly-w-full mly-object-cover"
5328
- }
5329
- ) }),
5330
- /* @__PURE__ */ jsx35("p", { className: "mly-mt-2 mly-px-0.5 mly-text-gray-500", children: item.description })
5331
- ] })
5332
- }
5333
- )
5334
- ] }, commandIndex);
5467
+ /* @__PURE__ */ jsx36("div", { className: "mly-space-y-0.5 mly-p-1", children: group.commands.map((item, commandIndex) => {
5468
+ return /* @__PURE__ */ jsx36(
5469
+ SlashCommandItem,
5470
+ {
5471
+ item,
5472
+ groupIndex,
5473
+ commandIndex,
5474
+ selectedGroupIndex,
5475
+ selectedCommandIndex,
5476
+ selectItem: () => selectItem(groupIndex, commandIndex),
5477
+ editor,
5478
+ activeCommandRef
5479
+ },
5480
+ commandIndex
5481
+ );
5335
5482
  }) })
5336
5483
  ] }, groupIndex))
5337
5484
  }
5338
5485
  ),
5339
- /* @__PURE__ */ jsx35("div", { className: "mly-border-t mly-border-gray-200 mly-px-1 mly-py-3 mly-pl-4", children: /* @__PURE__ */ jsxs19("div", { className: "mly-flex mly-items-center", children: [
5340
- /* @__PURE__ */ jsxs19("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
5341
- /* @__PURE__ */ jsx35("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2191" }),
5342
- /* @__PURE__ */ jsx35("kbd", { className: "mly-ml-1 mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2193" }),
5486
+ /* @__PURE__ */ jsx36("div", { className: "mly-border-t mly-border-gray-200 mly-px-1 mly-py-3 mly-pl-4", children: /* @__PURE__ */ jsxs20("div", { className: "mly-flex mly-items-center", children: [
5487
+ /* @__PURE__ */ jsxs20("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
5488
+ /* @__PURE__ */ jsx36("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2191" }),
5489
+ /* @__PURE__ */ jsx36("kbd", { className: "mly-ml-1 mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2193" }),
5343
5490
  " ",
5344
5491
  "to navigate"
5345
5492
  ] }),
5346
- /* @__PURE__ */ jsx35("span", { "aria-hidden": "true", className: "mly-select-none mly-px-1", children: "\xB7" }),
5347
- /* @__PURE__ */ jsxs19("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
5348
- /* @__PURE__ */ jsx35("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-1.5 mly-font-medium", children: "Enter" }),
5493
+ /* @__PURE__ */ jsx36("span", { "aria-hidden": "true", className: "mly-select-none mly-px-1", children: "\xB7" }),
5494
+ /* @__PURE__ */ jsxs20("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
5495
+ /* @__PURE__ */ jsx36("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-1.5 mly-font-medium", children: "Enter" }),
5349
5496
  " ",
5350
5497
  "to select"
5351
5498
  ] })
@@ -5444,28 +5591,41 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
5444
5591
  content: component.element,
5445
5592
  showOnCreate: true,
5446
5593
  interactive: true,
5447
- trigger: "manual"
5594
+ trigger: "manual",
5595
+ placement: "top-start"
5448
5596
  });
5449
5597
  },
5450
5598
  onUpdate: (props) => {
5599
+ var _a;
5600
+ const currentPopup = popup == null ? void 0 : popup[0];
5601
+ if (!currentPopup || ((_a = currentPopup == null ? void 0 : currentPopup.state) == null ? void 0 : _a.isDestroyed)) {
5602
+ return;
5603
+ }
5451
5604
  component == null ? void 0 : component.updateProps(props);
5452
- popup && popup[0].setProps({
5605
+ currentPopup.setProps({
5453
5606
  getReferenceClientRect: props.clientRect
5454
5607
  });
5455
5608
  },
5456
5609
  onKeyDown: (props) => {
5457
- var _a;
5610
+ var _a, _b;
5458
5611
  if (props.event.key === "Escape") {
5459
- popup == null ? void 0 : popup[0].hide();
5612
+ const currentPopup = popup == null ? void 0 : popup[0];
5613
+ if (!((_a = currentPopup == null ? void 0 : currentPopup.state) == null ? void 0 : _a.isDestroyed)) {
5614
+ currentPopup == null ? void 0 : currentPopup.destroy();
5615
+ }
5616
+ component == null ? void 0 : component.destroy();
5460
5617
  return true;
5461
5618
  }
5462
- return (_a = component == null ? void 0 : component.ref) == null ? void 0 : _a.onKeyDown(props);
5619
+ return (_b = component == null ? void 0 : component.ref) == null ? void 0 : _b.onKeyDown(props);
5463
5620
  },
5464
5621
  onExit: () => {
5465
5622
  if (!popup || !(popup == null ? void 0 : popup[0]) || !component) {
5466
5623
  return;
5467
5624
  }
5468
- popup == null ? void 0 : popup[0].destroy();
5625
+ const currentPopup = popup == null ? void 0 : popup[0];
5626
+ if (!currentPopup.state.isDestroyed) {
5627
+ currentPopup.destroy();
5628
+ }
5469
5629
  component == null ? void 0 : component.destroy();
5470
5630
  }
5471
5631
  };
@@ -5475,13 +5635,13 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
5475
5635
 
5476
5636
  // src/editor/nodes/variable/variable-suggestions.tsx
5477
5637
  import { ReactRenderer as ReactRenderer2 } from "@tiptap/react";
5478
- import { forwardRef as forwardRef9, useImperativeHandle as useImperativeHandle3, useRef as useRef9 } from "react";
5638
+ import { forwardRef as forwardRef9, useImperativeHandle as useImperativeHandle3, useRef as useRef10 } from "react";
5479
5639
  import tippy2 from "tippy.js";
5480
- import { jsx as jsx36 } from "react/jsx-runtime";
5640
+ import { jsx as jsx37 } from "react/jsx-runtime";
5481
5641
  var VariableList = forwardRef9((props, ref) => {
5482
5642
  var _a;
5483
5643
  const { items = [], editor } = props;
5484
- const popoverRef = useRef9(null);
5644
+ const popoverRef = useRef10(null);
5485
5645
  const VariableSuggestionPopoverComponent = (_a = useVariableOptions(editor)) == null ? void 0 : _a.variableSuggestionsPopover;
5486
5646
  useImperativeHandle3(ref, () => ({
5487
5647
  onKeyDown: ({ event }) => {
@@ -5506,7 +5666,7 @@ var VariableList = forwardRef9((props, ref) => {
5506
5666
  return false;
5507
5667
  }
5508
5668
  }));
5509
- return /* @__PURE__ */ jsx36(
5669
+ return /* @__PURE__ */ jsx37(
5510
5670
  VariableSuggestionPopoverComponent,
5511
5671
  {
5512
5672
  items,
@@ -5597,14 +5757,14 @@ import { createLowlight, common } from "lowlight";
5597
5757
 
5598
5758
  // src/editor/nodes/html/html-view.tsx
5599
5759
  import { NodeViewContent as NodeViewContent2, NodeViewWrapper as NodeViewWrapper7 } from "@tiptap/react";
5600
- import { useMemo as useMemo8 } from "react";
5601
- import { jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
5760
+ import { useMemo as useMemo9 } from "react";
5761
+ import { jsx as jsx38, jsxs as jsxs21 } from "react/jsx-runtime";
5602
5762
  function HTMLCodeBlockView(props) {
5603
5763
  const { node, updateAttributes: updateAttributes2 } = props;
5604
5764
  let { language, activeTab = "code" } = node.attrs;
5605
5765
  activeTab || (activeTab = "code");
5606
5766
  const languageClass = language ? `language-${language}` : "";
5607
- const html2 = useMemo8(() => {
5767
+ const html2 = useMemo9(() => {
5608
5768
  const text2 = node.content.content.reduce((acc, cur) => {
5609
5769
  if (cur.type.name === "text") {
5610
5770
  return acc + cur.text;
@@ -5621,28 +5781,45 @@ function HTMLCodeBlockView(props) {
5621
5781
  return body.innerHTML;
5622
5782
  }, [activeTab]);
5623
5783
  const isEmpty = html2 === "";
5624
- return /* @__PURE__ */ jsxs20(
5784
+ return /* @__PURE__ */ jsxs21(
5625
5785
  NodeViewWrapper7,
5626
5786
  {
5627
5787
  draggable: false,
5628
5788
  "data-drag-handle": false,
5629
5789
  "data-type": "htmlCodeBlock",
5630
5790
  children: [
5631
- activeTab === "code" && /* @__PURE__ */ jsx37("pre", { className: "mly-my-0 mly-rounded-lg mly-border mly-border-gray-200 mly-bg-white mly-p-2 mly-text-black", children: /* @__PURE__ */ jsx37(
5791
+ activeTab === "code" && /* @__PURE__ */ jsx38("pre", { className: "mly-my-0 mly-rounded-lg mly-border mly-border-gray-200 mly-bg-white mly-p-2 mly-text-black", children: /* @__PURE__ */ jsx38(
5632
5792
  NodeViewContent2,
5633
5793
  {
5634
5794
  as: "code",
5635
5795
  className: cn("is-editable", languageClass)
5636
5796
  }
5637
5797
  ) }),
5638
- activeTab === "preview" && /* @__PURE__ */ jsx37(
5798
+ activeTab === "preview" && /* @__PURE__ */ jsx38(
5639
5799
  "div",
5640
5800
  {
5641
5801
  className: cn(
5642
5802
  "mly-not-prose mly-rounded-lg mly-border mly-border-gray-200 mly-p-2",
5643
5803
  isEmpty && "mly-min-h-[42px]"
5644
5804
  ),
5645
- dangerouslySetInnerHTML: { __html: html2 },
5805
+ ref: (node2) => {
5806
+ if (!node2 || (node2 == null ? void 0 : node2.shadowRoot)) {
5807
+ return;
5808
+ }
5809
+ const shadow = node2.attachShadow({ mode: "open" });
5810
+ const sheet = new CSSStyleSheet();
5811
+ sheet.replaceSync(`
5812
+ * { font-family: 'Inter', sans-serif; }
5813
+ blockquote, h1, h2, h3, img, li, ol, p, ul {
5814
+ margin-top: 0;
5815
+ margin-bottom: 0;
5816
+ }
5817
+ `);
5818
+ shadow.adoptedStyleSheets = [sheet];
5819
+ const container = document.createElement("div");
5820
+ container.innerHTML = html2;
5821
+ shadow.appendChild(container);
5822
+ },
5646
5823
  contentEditable: false,
5647
5824
  onClick: () => {
5648
5825
  if (!isEmpty) {