@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.
@@ -144,7 +144,7 @@ __export(extensions_exports, {
144
144
  module.exports = __toCommonJS(extensions_exports);
145
145
 
146
146
  // src/editor/extensions/color.ts
147
- var import_extension_color = __toESM(require("@tiptap/extension-color"));
147
+ var import_extension_color = __toESM(require("@tiptap/extension-color"), 1);
148
148
  var Color = import_extension_color.default.extend({
149
149
  addStorage() {
150
150
  return {
@@ -320,16 +320,16 @@ function useImageUploadOptions(editor) {
320
320
 
321
321
  // src/editor/extensions/maily-kit.tsx
322
322
  var import_core14 = require("@tiptap/core");
323
- var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
324
- var import_extension_list_item = __toESM(require("@tiptap/extension-list-item"));
325
- var import_extension_paragraph2 = __toESM(require("@tiptap/extension-paragraph"));
326
- var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"));
327
- var import_extension_text_style = __toESM(require("@tiptap/extension-text-style"));
328
- var import_extension_heading2 = __toESM(require("@tiptap/extension-heading"));
329
- var import_extension_underline = __toESM(require("@tiptap/extension-underline"));
330
- var import_extension_document = __toESM(require("@tiptap/extension-document"));
331
- var import_extension_focus = __toESM(require("@tiptap/extension-focus"));
332
- var import_extension_dropcursor = __toESM(require("@tiptap/extension-dropcursor"));
323
+ var import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
324
+ var import_extension_list_item = __toESM(require("@tiptap/extension-list-item"), 1);
325
+ var import_extension_paragraph2 = __toESM(require("@tiptap/extension-paragraph"), 1);
326
+ var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"), 1);
327
+ var import_extension_text_style = __toESM(require("@tiptap/extension-text-style"), 1);
328
+ var import_extension_heading2 = __toESM(require("@tiptap/extension-heading"), 1);
329
+ var import_extension_underline = __toESM(require("@tiptap/extension-underline"), 1);
330
+ var import_extension_document = __toESM(require("@tiptap/extension-document"), 1);
331
+ var import_extension_focus = __toESM(require("@tiptap/extension-focus"), 1);
332
+ var import_extension_dropcursor = __toESM(require("@tiptap/extension-dropcursor"), 1);
333
333
 
334
334
  // src/editor/nodes/footer.ts
335
335
  var import_core3 = require("@tiptap/core");
@@ -793,7 +793,7 @@ var import_react3 = require("@tiptap/react");
793
793
  var import_react2 = require("@tiptap/react");
794
794
 
795
795
  // src/editor/components/input.tsx
796
- var React = __toESM(require("react"));
796
+ var React = __toESM(require("react"), 1);
797
797
 
798
798
  // src/editor/utils/classname.ts
799
799
  var import_clsx = require("clsx");
@@ -834,8 +834,8 @@ var Input = React.forwardRef(
834
834
  Input.displayName = "Input";
835
835
 
836
836
  // src/editor/components/popover.tsx
837
- var React2 = __toESM(require("react"));
838
- var PopoverPrimitive = __toESM(require("@radix-ui/react-popover"));
837
+ var React2 = __toESM(require("react"), 1);
838
+ var PopoverPrimitive = __toESM(require("@radix-ui/react-popover"), 1);
839
839
  var import_jsx_runtime2 = require("react/jsx-runtime");
840
840
  var Popover = PopoverPrimitive.Root;
841
841
  var PopoverTrigger = PopoverPrimitive.Trigger;
@@ -858,7 +858,7 @@ var PopoverContent = React2.forwardRef((_a, ref) => {
858
858
  PopoverContent.displayName = PopoverPrimitive.Content.displayName;
859
859
 
860
860
  // src/editor/components/textarea.tsx
861
- var React3 = __toESM(require("react"));
861
+ var React3 = __toESM(require("react"), 1);
862
862
  var import_jsx_runtime3 = require("react/jsx-runtime");
863
863
  var Textarea = React3.forwardRef(
864
864
  (_a, ref) => {
@@ -1366,7 +1366,7 @@ var import_react20 = require("@tiptap/react");
1366
1366
  var import_lucide_react = require("lucide-react");
1367
1367
 
1368
1368
  // src/editor/components/base-button.tsx
1369
- var React4 = __toESM(require("react"));
1369
+ var React4 = __toESM(require("react"), 1);
1370
1370
  var import_react_slot = require("@radix-ui/react-slot");
1371
1371
  var import_jsx_runtime5 = require("react/jsx-runtime");
1372
1372
  var BaseButton = React4.forwardRef(
@@ -1411,8 +1411,8 @@ var BaseButton = React4.forwardRef(
1411
1411
  BaseButton.displayName = "BaseButton";
1412
1412
 
1413
1413
  // src/editor/components/ui/tooltip.tsx
1414
- var React5 = __toESM(require("react"));
1415
- var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"));
1414
+ var React5 = __toESM(require("react"), 1);
1415
+ var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"), 1);
1416
1416
  var import_jsx_runtime6 = require("react/jsx-runtime");
1417
1417
  var TooltipProvider = TooltipPrimitive.Provider;
1418
1418
  var Tooltip = TooltipPrimitive.Root;
@@ -2049,7 +2049,7 @@ var inlineImage = {
2049
2049
  icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react6.ImageIcon, { className: "mly-h-4 mly-w-4" }),
2050
2050
  command: ({ editor, range }) => {
2051
2051
  editor.chain().focus().deleteRange(range).setInlineImage({
2052
- src: ""
2052
+ src: "https://maily.to/brand/logo.png"
2053
2053
  }).command((props) => {
2054
2054
  const { tr, state, view, editor: editor2 } = props;
2055
2055
  const { from } = range;
@@ -2877,7 +2877,7 @@ var DEFAULT_SLASH_COMMANDS = [
2877
2877
 
2878
2878
  // src/editor/provider.tsx
2879
2879
  var import_jsx_runtime25 = require("react/jsx-runtime");
2880
- var DEFAULT_PLACEHOLDER_URL = "maily.to/";
2880
+ var DEFAULT_PLACEHOLDER_URL = "https://maily.to/";
2881
2881
  var MailyContext = (0, import_react9.createContext)({
2882
2882
  placeholderUrl: DEFAULT_PLACEHOLDER_URL,
2883
2883
  blocks: DEFAULT_SLASH_COMMANDS
@@ -2897,7 +2897,7 @@ var import_react15 = require("react");
2897
2897
  var import_core11 = require("@tiptap/core");
2898
2898
  var import_state4 = require("@tiptap/pm/state");
2899
2899
  var import_react13 = require("@tiptap/react");
2900
- var import_suggestion = __toESM(require("@tiptap/suggestion"));
2900
+ var import_suggestion = __toESM(require("@tiptap/suggestion"), 1);
2901
2901
 
2902
2902
  // src/editor/nodes/variable/variable-suggestions-popover.tsx
2903
2903
  var import_lucide_react12 = require("lucide-react");
@@ -3294,9 +3294,8 @@ var VariableExtension = import_core11.Node.create({
3294
3294
 
3295
3295
  // src/editor/components/ui/link-input-popover.tsx
3296
3296
  var import_jsx_runtime28 = require("react/jsx-runtime");
3297
- var LINK_PROTOCOL_REGEX = /https?:\/\//;
3298
3297
  function LinkInputPopover(props) {
3299
- var _a, _b, _c;
3298
+ var _a, _b;
3300
3299
  const {
3301
3300
  defaultValue = "",
3302
3301
  onValueChange,
@@ -3305,22 +3304,16 @@ function LinkInputPopover(props) {
3305
3304
  editor,
3306
3305
  isVariable
3307
3306
  } = props;
3308
- const defaultProtocol = (_a = defaultValue.match(LINK_PROTOCOL_REGEX)) == null ? void 0 : _a[0];
3309
- const defaultUrlWithoutProtocol = defaultValue.replace(
3310
- LINK_PROTOCOL_REGEX,
3311
- ""
3312
- );
3313
3307
  const [isOpen, setIsOpen] = (0, import_react14.useState)(false);
3314
- const [protocol, setProtocol] = (0, import_react14.useState)(defaultProtocol || "https://");
3315
3308
  const [isEditing, setIsEditing] = (0, import_react14.useState)(!isVariable);
3316
3309
  const linkInputRef = (0, import_react14.useRef)(null);
3317
3310
  const { placeholderUrl = DEFAULT_PLACEHOLDER_URL } = useMailyContext();
3318
3311
  const options = useVariableOptions(editor);
3319
3312
  const renderVariable = options == null ? void 0 : options.renderVariable;
3320
3313
  const variables = options == null ? void 0 : options.variables;
3321
- const variableTriggerCharacter = (_c = (_b = options == null ? void 0 : options.suggestion) == null ? void 0 : _b.char) != null ? _c : DEFAULT_VARIABLE_TRIGGER_CHAR;
3314
+ const variableTriggerCharacter = (_b = (_a = options == null ? void 0 : options.suggestion) == null ? void 0 : _a.char) != null ? _b : DEFAULT_VARIABLE_TRIGGER_CHAR;
3322
3315
  const autoCompleteOptions = (0, import_react15.useMemo)(() => {
3323
- const withoutTrigger = defaultUrlWithoutProtocol.replace(
3316
+ const withoutTrigger = defaultValue.replace(
3324
3317
  new RegExp(variableTriggerCharacter, "g"),
3325
3318
  ""
3326
3319
  );
@@ -3329,7 +3322,7 @@ function LinkInputPopover(props) {
3329
3322
  from: "bubble-variable",
3330
3323
  editor
3331
3324
  }).map((variable) => variable.name);
3332
- }, [variables, variableTriggerCharacter, defaultUrlWithoutProtocol, editor]);
3325
+ }, [variables, variableTriggerCharacter, defaultValue, editor]);
3333
3326
  const popoverButton = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3334
3327
  BaseButton,
3335
3328
  {
@@ -3337,130 +3330,105 @@ function LinkInputPopover(props) {
3337
3330
  size: "sm",
3338
3331
  type: "button",
3339
3332
  className: "mly-size-7",
3340
- "data-state": !!defaultUrlWithoutProtocol,
3333
+ "data-state": !!defaultValue,
3341
3334
  children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Icon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-midnight-gray" })
3342
3335
  }
3343
3336
  ) });
3344
- const normalizeProtocol = (value, p = protocol) => {
3345
- value = value == null ? void 0 : value.replace(LINK_PROTOCOL_REGEX, "");
3346
- return p + value;
3347
- };
3348
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [
3349
- tooltip ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tooltip, { children: [
3350
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipTrigger, { asChild: true, children: popoverButton }),
3351
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipContent, { sideOffset: 8, children: tooltip })
3352
- ] }) : popoverButton,
3353
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3354
- PopoverContent,
3355
- {
3356
- align: "end",
3357
- side: "top",
3358
- className: "mly-w-max mly-rounded-none mly-border-none mly-bg-transparent !mly-p-0 mly-shadow-none",
3359
- sideOffset: 8,
3360
- onCloseAutoFocus: (e) => e.preventDefault(),
3361
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3362
- "form",
3337
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3338
+ Popover,
3339
+ {
3340
+ open: isOpen,
3341
+ onOpenChange: (open) => {
3342
+ setIsOpen(open);
3343
+ if (open) {
3344
+ setTimeout(() => {
3345
+ var _a2;
3346
+ (_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
3347
+ }, 0);
3348
+ }
3349
+ },
3350
+ children: [
3351
+ tooltip ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tooltip, { children: [
3352
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipTrigger, { asChild: true, children: popoverButton }),
3353
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipContent, { sideOffset: 8, children: tooltip })
3354
+ ] }) : popoverButton,
3355
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3356
+ PopoverContent,
3363
3357
  {
3364
- onSubmit: (e) => {
3365
- e.preventDefault();
3366
- const input = linkInputRef.current;
3367
- if (!input) {
3368
- return;
3369
- }
3370
- let value = normalizeProtocol(input.value);
3371
- onValueChange == null ? void 0 : onValueChange(value);
3372
- setIsOpen(false);
3373
- },
3374
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-isolate mly-flex mly-rounded-lg", children: [
3375
- !isEditing && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "mly-flex mly-h-8 mly-items-center mly-rounded-lg mly-border mly-border-gray-300 mly-bg-white mly-px-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3376
- "button",
3377
- {
3378
- onClick: () => {
3379
- setIsEditing(true);
3380
- setTimeout(() => {
3381
- var _a2;
3382
- (_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
3383
- }, 0);
3384
- },
3385
- children: renderVariable({
3386
- variable: {
3387
- name: defaultUrlWithoutProtocol,
3388
- valid: true
3389
- },
3390
- fallback: "",
3391
- from: "bubble-variable",
3392
- editor
3393
- })
3394
- }
3395
- ) }),
3396
- isEditing && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
3397
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-relative", children: [
3398
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3399
- "select",
3358
+ align: "end",
3359
+ side: "top",
3360
+ className: "mly-w-max mly-rounded-none mly-border-none mly-bg-transparent !mly-p-0 mly-shadow-none",
3361
+ sideOffset: 8,
3362
+ onCloseAutoFocus: (e) => e.preventDefault(),
3363
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3364
+ "form",
3365
+ {
3366
+ onSubmit: (e) => {
3367
+ e.preventDefault();
3368
+ const input = linkInputRef.current;
3369
+ if (!input) {
3370
+ return;
3371
+ }
3372
+ onValueChange == null ? void 0 : onValueChange(input.value);
3373
+ setIsOpen(false);
3374
+ },
3375
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-isolate mly-flex mly-rounded-lg", children: [
3376
+ !isEditing && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "mly-flex mly-h-8 mly-items-center mly-rounded-lg mly-border mly-border-gray-300 mly-bg-white mly-px-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3377
+ "button",
3400
3378
  {
3401
- 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",
3402
- "aria-label": "Protocol",
3403
- value: protocol,
3404
- onChange: (e) => {
3405
- var _a2;
3406
- const protocol2 = e.target.value;
3407
- setProtocol(protocol2);
3408
- const newValue = normalizeProtocol(
3409
- ((_a2 = linkInputRef.current) == null ? void 0 : _a2.value) || "",
3410
- protocol2
3411
- );
3412
- onValueChange == null ? void 0 : onValueChange(newValue);
3379
+ onClick: () => {
3380
+ setIsEditing(true);
3381
+ setTimeout(() => {
3382
+ var _a2;
3383
+ (_a2 = linkInputRef.current) == null ? void 0 : _a2.focus();
3384
+ }, 0);
3413
3385
  },
3414
- children: [
3415
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: "https://", children: "https://" }),
3416
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("option", { value: "http://", children: "http://" })
3417
- ]
3418
- }
3419
- ),
3420
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "mly-pointer-events-none mly-absolute mly-inset-y-0 mly-right-0 mly-z-10 mly-flex mly-h-full mly-w-9 mly-items-center mly-justify-center mly-text-gray-600 peer-disabled:mly-opacity-50", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3421
- import_lucide_react14.ChevronDownIcon,
3422
- {
3423
- size: 16,
3424
- strokeWidth: 2,
3425
- "aria-hidden": "true",
3426
- role: "img"
3386
+ children: renderVariable({
3387
+ variable: {
3388
+ name: defaultValue,
3389
+ valid: true
3390
+ },
3391
+ fallback: "",
3392
+ from: "bubble-variable",
3393
+ editor
3394
+ })
3427
3395
  }
3428
- ) })
3429
- ] }),
3430
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3431
- InputAutocomplete,
3432
- {
3433
- editor,
3434
- value: defaultUrlWithoutProtocol,
3435
- onValueChange: (value) => {
3436
- let newValue = normalizeProtocol(value);
3437
- onValueChange == null ? void 0 : onValueChange(newValue);
3438
- },
3439
- autoCompleteOptions,
3440
- ref: linkInputRef,
3441
- placeholder: placeholderUrl,
3442
- 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",
3443
- triggerChar: variableTriggerCharacter,
3444
- onSelectOption: (value) => {
3445
- var _a2;
3446
- const isVariable2 = (_a2 = autoCompleteOptions.includes(value)) != null ? _a2 : false;
3447
- if (isVariable2) {
3448
- setIsEditing(false);
3449
- } else {
3450
- value = normalizeProtocol(value);
3396
+ ) }),
3397
+ isEditing && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-relative", children: [
3398
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "mly-absolute mly-inset-y-0 mly-left-1.5 mly-z-10 mly-flex mly-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react14.LinkIcon, { className: "mly-h-3 mly-w-3 mly-stroke-[2.5] mly-text-midnight-gray" }) }),
3399
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3400
+ InputAutocomplete,
3401
+ {
3402
+ editor,
3403
+ value: defaultValue,
3404
+ onValueChange: (value) => {
3405
+ onValueChange == null ? void 0 : onValueChange(value);
3406
+ },
3407
+ autoCompleteOptions,
3408
+ ref: linkInputRef,
3409
+ placeholder: placeholderUrl,
3410
+ 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",
3411
+ triggerChar: variableTriggerCharacter,
3412
+ onSelectOption: (value) => {
3413
+ var _a2;
3414
+ const isVariable2 = (_a2 = autoCompleteOptions.includes(value)) != null ? _a2 : false;
3415
+ if (isVariable2) {
3416
+ setIsEditing(false);
3417
+ }
3418
+ onValueChange == null ? void 0 : onValueChange(value, isVariable2);
3419
+ setIsOpen(false);
3420
+ }
3451
3421
  }
3452
- onValueChange == null ? void 0 : onValueChange(value, isVariable2);
3453
- setIsOpen(false);
3454
- }
3455
- }
3456
- )
3457
- ] })
3458
- ] })
3422
+ )
3423
+ ] })
3424
+ ] })
3425
+ }
3426
+ )
3459
3427
  }
3460
3428
  )
3461
- }
3462
- )
3463
- ] });
3429
+ ]
3430
+ }
3431
+ );
3464
3432
  }
3465
3433
 
3466
3434
  // src/editor/components/ui/select.tsx
@@ -4139,7 +4107,7 @@ var ButtonExtension = import_core12.Node.create({
4139
4107
  });
4140
4108
 
4141
4109
  // src/editor/nodes/logo/logo.ts
4142
- var import_extension_image = __toESM(require("@tiptap/extension-image"));
4110
+ var import_extension_image = __toESM(require("@tiptap/extension-image"), 1);
4143
4111
  var import_react27 = require("@tiptap/react");
4144
4112
 
4145
4113
  // src/editor/nodes/logo/logo-view.tsx
@@ -4167,10 +4135,21 @@ var useEvent = (handler) => {
4167
4135
  }, []);
4168
4136
  };
4169
4137
 
4138
+ // src/editor/utils/aspect-ratio.ts
4139
+ function getAspectRatio(width, height) {
4140
+ return width / height;
4141
+ }
4142
+ function getNewHeight(width, aspectRatio) {
4143
+ if (width <= 0 || aspectRatio <= 0) {
4144
+ return 0;
4145
+ }
4146
+ return width / aspectRatio;
4147
+ }
4148
+
4170
4149
  // src/editor/nodes/image/image-view.tsx
4171
4150
  var import_jsx_runtime32 = require("react/jsx-runtime");
4172
4151
  var MIN_WIDTH = 20;
4173
- var MAX_WIDTH = 600;
4152
+ var IMAGE_MAX_WIDTH = 600;
4174
4153
  function ImageView(props) {
4175
4154
  const { node, updateAttributes: updateAttributes2, selected, editor } = props;
4176
4155
  const [status, setStatus] = (0, import_react22.useState)("idle");
@@ -4188,7 +4167,10 @@ function ImageView(props) {
4188
4167
  if (!imgRef.current || !imageParent || !selected) {
4189
4168
  return;
4190
4169
  }
4191
- const imageParentWidth = Math.max(imageParent.offsetWidth, MAX_WIDTH);
4170
+ const imageParentWidth = Math.max(
4171
+ imageParent.offsetWidth,
4172
+ IMAGE_MAX_WIDTH
4173
+ );
4192
4174
  event.preventDefault();
4193
4175
  const direction = event.currentTarget.dataset.direction || "--";
4194
4176
  const initialXPosition = event.clientX;
@@ -4200,7 +4182,8 @@ function ImageView(props) {
4200
4182
  const removeListeners = () => {
4201
4183
  window.removeEventListener("mousemove", mouseMoveHandler);
4202
4184
  window.removeEventListener("mouseup", removeListeners);
4203
- updateAttributes2({ width: newWidth, height: newHeight });
4185
+ const aspectRatio = getAspectRatio(newWidth, newHeight);
4186
+ updateAttributes2({ width: newWidth, height: newHeight, aspectRatio });
4204
4187
  setResizingStyle(void 0);
4205
4188
  };
4206
4189
  const mouseMoveHandler = (event2) => {
@@ -4246,17 +4229,29 @@ function ImageView(props) {
4246
4229
  },
4247
4230
  [handleMouseDown, isPlaceholderImage]
4248
4231
  );
4249
- let { alignment = "center", width, height, src } = node.attrs || {};
4232
+ let {
4233
+ alignment = "center",
4234
+ width,
4235
+ height,
4236
+ src,
4237
+ borderRadius
4238
+ } = node.attrs || {};
4250
4239
  const _a = node.attrs || {}, {
4251
4240
  externalLink,
4252
4241
  isExternalLinkVariable,
4253
4242
  isSrcVariable,
4254
- showIfKey
4243
+ showIfKey,
4244
+ aspectRatio: defaultAspectRatio,
4245
+ borderRadius: _,
4246
+ lockAspectRatio
4255
4247
  } = _a, attrs = __objRest(_a, [
4256
4248
  "externalLink",
4257
4249
  "isExternalLinkVariable",
4258
4250
  "isSrcVariable",
4259
- "showIfKey"
4251
+ "showIfKey",
4252
+ "aspectRatio",
4253
+ "borderRadius",
4254
+ "lockAspectRatio"
4260
4255
  ]);
4261
4256
  const hasImageSrc = !!attrs.src;
4262
4257
  const isDroppable = !!onImageUpload && editor.isEditable && !hasImageSrc && !isSrcVariable && status === "idle";
@@ -4303,14 +4298,15 @@ function ImageView(props) {
4303
4298
  return;
4304
4299
  }
4305
4300
  const wrapperWidth = wrapper.offsetWidth;
4306
- const aspectRatio = naturalWidth / naturalHeight;
4301
+ const aspectRatio = getAspectRatio(naturalWidth, naturalHeight);
4307
4302
  const calculatedHeight = Math.min(
4308
- wrapperWidth / aspectRatio,
4303
+ getNewHeight(wrapperWidth, aspectRatio),
4309
4304
  naturalHeight
4310
4305
  );
4311
4306
  updateAttributes2({
4312
4307
  width: Math.min(wrapperWidth, naturalWidth),
4313
- height: Math.min(calculatedHeight, naturalHeight)
4308
+ height: Math.min(calculatedHeight, naturalHeight),
4309
+ aspectRatio
4314
4310
  });
4315
4311
  };
4316
4312
  img.onerror = () => {
@@ -4380,7 +4376,8 @@ function ImageView(props) {
4380
4376
  position: "relative",
4381
4377
  // Weird! Basically tiptap/prose wraps this in a span and the line height causes an annoying buffer.
4382
4378
  lineHeight: "0px",
4383
- display: "block"
4379
+ display: "block",
4380
+ maxWidth: "100%"
4384
4381
  }), {
4385
4382
  center: { marginLeft: "auto", marginRight: "auto" },
4386
4383
  left: { marginRight: "auto" },
@@ -4422,7 +4419,8 @@ function ImageView(props) {
4422
4419
  ref: imgRef,
4423
4420
  style: __spreadProps(__spreadValues({}, resizingStyle), {
4424
4421
  cursor: "default",
4425
- marginBottom: 0
4422
+ marginBottom: 0,
4423
+ borderRadius
4426
4424
  }),
4427
4425
  draggable: editor.isEditable,
4428
4426
  className: cn(
@@ -4774,8 +4772,9 @@ var LogoExtension = import_extension_image.default.extend({
4774
4772
  });
4775
4773
 
4776
4774
  // src/editor/nodes/image/image.ts
4777
- var import_extension_image2 = __toESM(require("@tiptap/extension-image"));
4775
+ var import_extension_image2 = __toESM(require("@tiptap/extension-image"), 1);
4778
4776
  var import_react28 = require("@tiptap/react");
4777
+ var DEFAULT_IMAGE_BORDER_RADIUS = 0;
4779
4778
  var ImageExtension = import_extension_image2.default.extend({
4780
4779
  addAttributes() {
4781
4780
  var _a;
@@ -4839,6 +4838,17 @@ var ImageExtension = import_extension_image2.default.extend({
4839
4838
  };
4840
4839
  }
4841
4840
  },
4841
+ borderRadius: {
4842
+ default: DEFAULT_IMAGE_BORDER_RADIUS,
4843
+ parseHTML: (element) => {
4844
+ return Number(element.getAttribute("data-border-radius"));
4845
+ },
4846
+ renderHTML: (attributes) => {
4847
+ return {
4848
+ "data-border-radius": attributes.borderRadius
4849
+ };
4850
+ }
4851
+ },
4842
4852
  // Later we will remove this attribute
4843
4853
  // and use the `src` attribute instead when implement
4844
4854
  // the URL variable feature
@@ -4856,6 +4866,34 @@ var ImageExtension = import_extension_image2.default.extend({
4856
4866
  };
4857
4867
  }
4858
4868
  },
4869
+ aspectRatio: {
4870
+ default: null,
4871
+ parseHTML: (element) => {
4872
+ return element.getAttribute("data-aspect-ratio") || null;
4873
+ },
4874
+ renderHTML: (attributes) => {
4875
+ if (!(attributes == null ? void 0 : attributes.aspectRatio)) {
4876
+ return {};
4877
+ }
4878
+ return {
4879
+ "data-aspect-ratio": attributes == null ? void 0 : attributes.aspectRatio
4880
+ };
4881
+ }
4882
+ },
4883
+ lockAspectRatio: {
4884
+ default: true,
4885
+ parseHTML: (element) => {
4886
+ return element.getAttribute("data-lock-aspect-ratio") === "true";
4887
+ },
4888
+ renderHTML: (attributes) => {
4889
+ if (!attributes.lockAspectRatio) {
4890
+ return {};
4891
+ }
4892
+ return {
4893
+ "data-lock-aspect-ratio": "true"
4894
+ };
4895
+ }
4896
+ },
4859
4897
  showIfKey: {
4860
4898
  default: DEFAULT_SECTION_SHOW_IF_KEY,
4861
4899
  parseHTML: (element) => {
@@ -4880,7 +4918,7 @@ var ImageExtension = import_extension_image2.default.extend({
4880
4918
  });
4881
4919
 
4882
4920
  // src/editor/nodes/link.ts
4883
- var import_extension_link = __toESM(require("@tiptap/extension-link"));
4921
+ var import_extension_link = __toESM(require("@tiptap/extension-link"), 1);
4884
4922
  var LinkExtension = import_extension_link.default.extend({
4885
4923
  addAttributes() {
4886
4924
  var _a;
@@ -4901,7 +4939,7 @@ var LinkExtension = import_extension_link.default.extend({
4901
4939
  });
4902
4940
 
4903
4941
  // src/editor/nodes/heading/heading.ts
4904
- var import_extension_heading = __toESM(require("@tiptap/extension-heading"));
4942
+ var import_extension_heading = __toESM(require("@tiptap/extension-heading"), 1);
4905
4943
  var HeadingExtension = import_extension_heading.default.extend({
4906
4944
  addAttributes() {
4907
4945
  var _a;
@@ -4925,7 +4963,7 @@ var HeadingExtension = import_extension_heading.default.extend({
4925
4963
  });
4926
4964
 
4927
4965
  // src/editor/nodes/paragraph/paragraph.ts
4928
- var import_extension_paragraph = __toESM(require("@tiptap/extension-paragraph"));
4966
+ var import_extension_paragraph = __toESM(require("@tiptap/extension-paragraph"), 1);
4929
4967
  var ParagraphExtension = import_extension_paragraph.default.extend({
4930
4968
  addAttributes() {
4931
4969
  var _a;
@@ -5178,7 +5216,7 @@ var MailyKit = import_core14.Extension.create({
5178
5216
  });
5179
5217
 
5180
5218
  // src/editor/extensions/placeholder.ts
5181
- var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"));
5219
+ var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"), 1);
5182
5220
  var PlaceholderExtension = import_extension_placeholder.default.configure({
5183
5221
  placeholder: ({ node }) => {
5184
5222
  if (node.type.name === "heading") {
@@ -5197,7 +5235,7 @@ var PlaceholderExtension = import_extension_placeholder.default.configure({
5197
5235
 
5198
5236
  // src/editor/extensions/slash-command/slash-command.ts
5199
5237
  var import_core15 = require("@tiptap/core");
5200
- var import_suggestion2 = __toESM(require("@tiptap/suggestion"));
5238
+ var import_suggestion2 = __toESM(require("@tiptap/suggestion"), 1);
5201
5239
  var SlashCommandExtension = import_core15.Extension.create({
5202
5240
  name: "slash-command",
5203
5241
  addOptions() {
@@ -5220,16 +5258,118 @@ var SlashCommandExtension = import_core15.Extension.create({
5220
5258
  });
5221
5259
 
5222
5260
  // src/editor/extensions/slash-command/slash-command-view.tsx
5223
- var import_react31 = require("@tiptap/react");
5224
- var import_react32 = require("react");
5225
- var import_tippy = __toESM(require("tippy.js"));
5261
+ var import_react32 = require("@tiptap/react");
5262
+ var import_react33 = require("react");
5263
+ var import_tippy = __toESM(require("tippy.js"), 1);
5264
+
5265
+ // src/editor/extensions/slash-command/slash-command-item.tsx
5226
5266
  var import_lucide_react18 = require("lucide-react");
5267
+ var import_react31 = require("react");
5227
5268
  var import_jsx_runtime35 = require("react/jsx-runtime");
5228
- var CommandList = (0, import_react32.forwardRef)(function CommandList2(props, ref) {
5229
- const { items: groups, command, editor } = props;
5230
- const [selectedGroupIndex, setSelectedGroupIndex] = (0, import_react32.useState)(0);
5231
- const [selectedCommandIndex, setSelectedCommandIndex] = (0, import_react32.useState)(0);
5232
- const selectItem = (0, import_react32.useCallback)(
5269
+ function SlashCommandItem(props) {
5270
+ var _a;
5271
+ const {
5272
+ item,
5273
+ groupIndex,
5274
+ commandIndex,
5275
+ selectedGroupIndex,
5276
+ selectedCommandIndex,
5277
+ editor,
5278
+ activeCommandRef,
5279
+ selectItem
5280
+ } = props;
5281
+ const [open, setOpen] = (0, import_react31.useState)(false);
5282
+ const [isHovered, setIsHovered] = (0, import_react31.useState)(false);
5283
+ const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
5284
+ const isSubCommand = item && "commands" in item;
5285
+ const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && (isActive || isHovered);
5286
+ const hasRenderFunction = typeof item.render === "function";
5287
+ const renderFunctionValue = hasRenderFunction ? (_a = item.render) == null ? void 0 : _a.call(item, editor) : null;
5288
+ let value = /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
5289
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "mly-flex mly-h-6 mly-w-6 mly-shrink-0 mly-items-center mly-justify-center", children: item.icon }),
5290
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "mly-grow", children: [
5291
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mly-font-medium", children: item.title }),
5292
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
5293
+ ] }),
5294
+ isSubCommand && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react18.ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
5295
+ ] });
5296
+ if (renderFunctionValue !== null && renderFunctionValue !== true) {
5297
+ value = renderFunctionValue;
5298
+ }
5299
+ const openTimerRef = (0, import_react31.useRef)(0);
5300
+ const handleDelayedOpen = (0, import_react31.useCallback)(() => {
5301
+ window.clearTimeout(openTimerRef.current);
5302
+ const delay = 200;
5303
+ openTimerRef.current = window.setTimeout(() => {
5304
+ setOpen(true);
5305
+ openTimerRef.current = 0;
5306
+ }, delay);
5307
+ }, [setOpen]);
5308
+ (0, import_react31.useEffect)(() => {
5309
+ if (shouldOpenTooltip) {
5310
+ handleDelayedOpen();
5311
+ } else {
5312
+ window.clearTimeout(openTimerRef.current);
5313
+ openTimerRef.current = 0;
5314
+ setOpen(false);
5315
+ }
5316
+ }, [shouldOpenTooltip]);
5317
+ (0, import_react31.useEffect)(() => {
5318
+ return () => {
5319
+ if (openTimerRef.current) {
5320
+ window.clearTimeout(openTimerRef.current);
5321
+ openTimerRef.current = 0;
5322
+ }
5323
+ };
5324
+ }, []);
5325
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Tooltip, { open, children: [
5326
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5327
+ "button",
5328
+ {
5329
+ className: cn(
5330
+ "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",
5331
+ isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
5332
+ ),
5333
+ onClick: () => selectItem(groupIndex, commandIndex),
5334
+ onMouseEnter: () => setIsHovered(true),
5335
+ onMouseLeave: () => setIsHovered(false),
5336
+ type: "button",
5337
+ ref: isActive ? activeCommandRef : null,
5338
+ children: value
5339
+ }
5340
+ ) }),
5341
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5342
+ TooltipContent,
5343
+ {
5344
+ side: "right",
5345
+ sideOffset: 10,
5346
+ className: "mly-w-52 mly-rounded-lg mly-border-none mly-p-1 mly-shadow",
5347
+ children: typeof item.preview === "function" ? item == null ? void 0 : item.preview(editor) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
5348
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("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__ */ (0, import_jsx_runtime35.jsx)(
5349
+ "img",
5350
+ {
5351
+ src: item == null ? void 0 : item.preview,
5352
+ alt: item == null ? void 0 : item.title,
5353
+ className: "mly-absolute mly-inset-0 mly-h-full mly-w-full mly-object-cover"
5354
+ }
5355
+ ) }),
5356
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mly-mt-2 mly-px-0.5 mly-text-gray-500", children: item.description })
5357
+ ] })
5358
+ }
5359
+ )
5360
+ ] }, `${groupIndex}-${commandIndex}`);
5361
+ }
5362
+
5363
+ // src/editor/extensions/slash-command/slash-command-view.tsx
5364
+ var import_jsx_runtime36 = require("react/jsx-runtime");
5365
+ var CommandList = (0, import_react33.forwardRef)(function CommandList2(props, ref) {
5366
+ const { items: groups, command, editor, range, query } = props;
5367
+ const [selectedGroupIndex, setSelectedGroupIndex] = (0, import_react33.useState)(0);
5368
+ const [selectedCommandIndex, setSelectedCommandIndex] = (0, import_react33.useState)(0);
5369
+ const prevQuery = (0, import_react33.useRef)("");
5370
+ const prevSelectedGroupIndex = (0, import_react33.useRef)(0);
5371
+ const prevSelectedCommandIndex = (0, import_react33.useRef)(0);
5372
+ const selectItem = (0, import_react33.useCallback)(
5233
5373
  (groupIndex, commandIndex) => {
5234
5374
  const item = groups[groupIndex].commands[commandIndex];
5235
5375
  if (!item) {
@@ -5239,71 +5379,104 @@ var CommandList = (0, import_react32.forwardRef)(function CommandList2(props, re
5239
5379
  },
5240
5380
  [command]
5241
5381
  );
5242
- (0, import_react32.useImperativeHandle)(ref, () => ({
5382
+ (0, import_react33.useImperativeHandle)(ref, () => ({
5243
5383
  onKeyDown: ({ event }) => {
5244
- var _a, _b;
5245
- const navigationKeys = ["ArrowUp", "ArrowDown", "Enter"];
5384
+ var _a, _b, _c, _d;
5385
+ const navigationKeys = [
5386
+ "ArrowUp",
5387
+ "ArrowDown",
5388
+ "Enter",
5389
+ "ArrowLeft",
5390
+ "ArrowRight"
5391
+ ];
5246
5392
  if (navigationKeys.includes(event.key)) {
5247
- if (event.key === "ArrowUp") {
5248
- if (!groups.length) {
5249
- return false;
5250
- }
5251
- let newCommandIndex = selectedCommandIndex - 1;
5252
- let newGroupIndex = selectedGroupIndex;
5253
- if (newCommandIndex < 0) {
5254
- newGroupIndex = selectedGroupIndex - 1;
5255
- newCommandIndex = ((_a = groups[newGroupIndex]) == null ? void 0 : _a.commands.length) - 1 || 0;
5256
- }
5257
- if (newGroupIndex < 0) {
5258
- newGroupIndex = groups.length - 1;
5259
- newCommandIndex = ((_b = groups[newGroupIndex]) == null ? void 0 : _b.commands.length) - 1 || 0;
5260
- }
5261
- setSelectedGroupIndex(newGroupIndex);
5262
- setSelectedCommandIndex(newCommandIndex);
5263
- return true;
5264
- }
5265
- if (event.key === "ArrowDown") {
5266
- if (!groups.length) {
5267
- return false;
5268
- }
5269
- const commands = groups[selectedGroupIndex].commands;
5270
- let newCommandIndex = selectedCommandIndex + 1;
5271
- let newGroupIndex = selectedGroupIndex;
5272
- if (commands.length - 1 < newCommandIndex) {
5273
- newCommandIndex = 0;
5274
- newGroupIndex = selectedGroupIndex + 1;
5275
- }
5276
- if (groups.length - 1 < newGroupIndex) {
5277
- newGroupIndex = 0;
5278
- }
5279
- setSelectedGroupIndex(newGroupIndex);
5280
- setSelectedCommandIndex(newCommandIndex);
5281
- return true;
5282
- }
5283
- if (event.key === "Enter") {
5284
- if (!groups.length) {
5393
+ let newCommandIndex = selectedCommandIndex;
5394
+ let newGroupIndex = selectedGroupIndex;
5395
+ switch (event.key) {
5396
+ case "ArrowLeft":
5397
+ event.preventDefault();
5398
+ const group = groups == null ? void 0 : groups[selectedGroupIndex];
5399
+ const isInsideSubCommand = group && "id" in group;
5400
+ if (!isInsideSubCommand) {
5401
+ return false;
5402
+ }
5403
+ editor.chain().focus().insertContentAt(range, `/${prevQuery.current}`).run();
5404
+ setTimeout(() => {
5405
+ setSelectedGroupIndex(prevSelectedGroupIndex.current);
5406
+ setSelectedCommandIndex(prevSelectedCommandIndex.current);
5407
+ }, 0);
5408
+ return true;
5409
+ case "ArrowRight":
5410
+ event.preventDefault();
5411
+ const command2 = (_b = (_a = groups == null ? void 0 : groups[selectedGroupIndex]) == null ? void 0 : _a.commands) == null ? void 0 : _b[selectedCommandIndex];
5412
+ const isSelectingSubCommand = command2 && "commands" in command2;
5413
+ if (!isSelectingSubCommand) {
5414
+ return false;
5415
+ }
5416
+ selectItem(selectedGroupIndex, selectedCommandIndex);
5417
+ prevQuery.current = query;
5418
+ prevSelectedGroupIndex.current = selectedGroupIndex;
5419
+ prevSelectedCommandIndex.current = selectedCommandIndex;
5420
+ return true;
5421
+ case "Enter":
5422
+ if (!groups.length) {
5423
+ return false;
5424
+ }
5425
+ selectItem(selectedGroupIndex, selectedCommandIndex);
5426
+ prevQuery.current = query;
5427
+ prevSelectedGroupIndex.current = selectedGroupIndex;
5428
+ prevSelectedCommandIndex.current = selectedCommandIndex;
5429
+ return true;
5430
+ case "ArrowUp":
5431
+ if (!groups.length) {
5432
+ return false;
5433
+ }
5434
+ newCommandIndex = selectedCommandIndex - 1;
5435
+ newGroupIndex = selectedGroupIndex;
5436
+ if (newCommandIndex < 0) {
5437
+ newGroupIndex = selectedGroupIndex - 1;
5438
+ newCommandIndex = ((_c = groups[newGroupIndex]) == null ? void 0 : _c.commands.length) - 1 || 0;
5439
+ }
5440
+ if (newGroupIndex < 0) {
5441
+ newGroupIndex = groups.length - 1;
5442
+ newCommandIndex = ((_d = groups[newGroupIndex]) == null ? void 0 : _d.commands.length) - 1 || 0;
5443
+ }
5444
+ setSelectedGroupIndex(newGroupIndex);
5445
+ setSelectedCommandIndex(newCommandIndex);
5446
+ return true;
5447
+ case "ArrowDown":
5448
+ if (!groups.length) {
5449
+ return false;
5450
+ }
5451
+ const commands = groups[selectedGroupIndex].commands;
5452
+ newCommandIndex = selectedCommandIndex + 1;
5453
+ newGroupIndex = selectedGroupIndex;
5454
+ if (commands.length - 1 < newCommandIndex) {
5455
+ newCommandIndex = 0;
5456
+ newGroupIndex = selectedGroupIndex + 1;
5457
+ }
5458
+ if (groups.length - 1 < newGroupIndex) {
5459
+ newGroupIndex = 0;
5460
+ }
5461
+ setSelectedGroupIndex(newGroupIndex);
5462
+ setSelectedCommandIndex(newCommandIndex);
5463
+ return true;
5464
+ default:
5285
5465
  return false;
5286
- }
5287
- selectItem(selectedGroupIndex, selectedCommandIndex);
5288
- return true;
5289
5466
  }
5290
- return false;
5291
5467
  }
5292
5468
  }
5293
5469
  }));
5294
- (0, import_react32.useEffect)(() => {
5295
- setSelectedGroupIndex(0);
5296
- setSelectedCommandIndex(0);
5297
- }, [groups]);
5298
- const commandListContainer = (0, import_react32.useRef)(null);
5299
- const activeCommandRef = (0, import_react32.useRef)(null);
5300
- (0, import_react32.useLayoutEffect)(() => {
5470
+ const commandListContainer = (0, import_react33.useRef)(null);
5471
+ const activeCommandRef = (0, import_react33.useRef)(null);
5472
+ (0, import_react33.useLayoutEffect)(() => {
5301
5473
  const container = commandListContainer == null ? void 0 : commandListContainer.current;
5302
5474
  const activeCommandContainer = activeCommandRef == null ? void 0 : activeCommandRef.current;
5303
5475
  if (!container || !activeCommandContainer) {
5304
5476
  return;
5305
5477
  }
5306
5478
  const { offsetTop, offsetHeight } = activeCommandContainer;
5479
+ container.style.transition = "none";
5307
5480
  container.scrollTop = offsetTop - offsetHeight;
5308
5481
  }, [
5309
5482
  selectedGroupIndex,
@@ -5311,15 +5484,26 @@ var CommandList = (0, import_react32.forwardRef)(function CommandList2(props, re
5311
5484
  commandListContainer,
5312
5485
  activeCommandRef
5313
5486
  ]);
5314
- return groups.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("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: [
5315
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5487
+ (0, import_react33.useEffect)(() => {
5488
+ setSelectedGroupIndex(0);
5489
+ setSelectedCommandIndex(0);
5490
+ }, [groups]);
5491
+ (0, import_react33.useEffect)(() => {
5492
+ return () => {
5493
+ prevQuery.current = "";
5494
+ prevSelectedGroupIndex.current = 0;
5495
+ prevSelectedCommandIndex.current = 0;
5496
+ };
5497
+ }, []);
5498
+ return groups.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("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: [
5499
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5316
5500
  "div",
5317
5501
  {
5318
5502
  id: "slash-command",
5319
5503
  ref: commandListContainer,
5320
- className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto mly-scroll-smooth",
5321
- children: groups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_react32.Fragment, { children: [
5322
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5504
+ className: "mly-no-scrollbar mly-h-auto mly-max-h-[330px] mly-overflow-y-auto",
5505
+ children: groups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_react33.Fragment, { children: [
5506
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5323
5507
  "span",
5324
5508
  {
5325
5509
  className: cn(
@@ -5329,72 +5513,35 @@ var CommandList = (0, import_react32.forwardRef)(function CommandList2(props, re
5329
5513
  children: group.title
5330
5514
  }
5331
5515
  ),
5332
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "mly-space-y-0.5 mly-p-1", children: group.commands.map((item, commandIndex) => {
5333
- var _a;
5334
- const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
5335
- const isSubCommand = "commands" in item;
5336
- const hasRenderFunction = typeof item.render === "function";
5337
- const renderFunctionValue = hasRenderFunction ? (_a = item.render) == null ? void 0 : _a.call(item, editor) : null;
5338
- let value = /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
5339
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "mly-flex mly-h-6 mly-w-6 mly-shrink-0 mly-items-center mly-justify-center", children: item.icon }),
5340
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "mly-grow", children: [
5341
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mly-font-medium", children: item.title }),
5342
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
5343
- ] }),
5344
- isSubCommand && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react18.ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
5345
- ] });
5346
- if (renderFunctionValue !== null && renderFunctionValue !== true) {
5347
- value = renderFunctionValue;
5348
- }
5349
- const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && isActive;
5350
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Tooltip, { open: shouldOpenTooltip, children: [
5351
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5352
- "button",
5353
- {
5354
- className: cn(
5355
- "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",
5356
- isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
5357
- ),
5358
- onClick: () => selectItem(groupIndex, commandIndex),
5359
- type: "button",
5360
- ref: isActive ? activeCommandRef : null,
5361
- children: value
5362
- }
5363
- ) }),
5364
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5365
- TooltipContent,
5366
- {
5367
- side: "right",
5368
- sideOffset: 10,
5369
- className: "mly-w-52 mly-rounded-lg mly-border-none mly-p-1 mly-shadow",
5370
- children: typeof item.preview === "function" ? item == null ? void 0 : item.preview(editor) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
5371
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("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__ */ (0, import_jsx_runtime35.jsx)(
5372
- "img",
5373
- {
5374
- src: item == null ? void 0 : item.preview,
5375
- alt: item == null ? void 0 : item.title,
5376
- className: "mly-absolute mly-inset-0 mly-h-full mly-w-full mly-object-cover"
5377
- }
5378
- ) }),
5379
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mly-mt-2 mly-px-0.5 mly-text-gray-500", children: item.description })
5380
- ] })
5381
- }
5382
- )
5383
- ] }, commandIndex);
5516
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "mly-space-y-0.5 mly-p-1", children: group.commands.map((item, commandIndex) => {
5517
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5518
+ SlashCommandItem,
5519
+ {
5520
+ item,
5521
+ groupIndex,
5522
+ commandIndex,
5523
+ selectedGroupIndex,
5524
+ selectedCommandIndex,
5525
+ selectItem: () => selectItem(groupIndex, commandIndex),
5526
+ editor,
5527
+ activeCommandRef
5528
+ },
5529
+ commandIndex
5530
+ );
5384
5531
  }) })
5385
5532
  ] }, groupIndex))
5386
5533
  }
5387
5534
  ),
5388
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "mly-border-t mly-border-gray-200 mly-px-1 mly-py-3 mly-pl-4", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "mly-flex mly-items-center", children: [
5389
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
5390
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2191" }),
5391
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("kbd", { className: "mly-ml-1 mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2193" }),
5535
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "mly-border-t mly-border-gray-200 mly-px-1 mly-py-3 mly-pl-4", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "mly-flex mly-items-center", children: [
5536
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
5537
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2191" }),
5538
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("kbd", { className: "mly-ml-1 mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-2 mly-font-medium", children: "\u2193" }),
5392
5539
  " ",
5393
5540
  "to navigate"
5394
5541
  ] }),
5395
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { "aria-hidden": "true", className: "mly-select-none mly-px-1", children: "\xB7" }),
5396
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
5397
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-1.5 mly-font-medium", children: "Enter" }),
5542
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { "aria-hidden": "true", className: "mly-select-none mly-px-1", children: "\xB7" }),
5543
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
5544
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("kbd", { className: "mly-rounded mly-border mly-border-gray-200 mly-p-1 mly-px-1.5 mly-font-medium", children: "Enter" }),
5398
5545
  " ",
5399
5546
  "to select"
5400
5547
  ] })
@@ -5483,7 +5630,7 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
5483
5630
  let popup = null;
5484
5631
  return {
5485
5632
  onStart: (props) => {
5486
- component = new import_react31.ReactRenderer(CommandList, {
5633
+ component = new import_react32.ReactRenderer(CommandList, {
5487
5634
  props,
5488
5635
  editor: props.editor
5489
5636
  });
@@ -5493,28 +5640,41 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
5493
5640
  content: component.element,
5494
5641
  showOnCreate: true,
5495
5642
  interactive: true,
5496
- trigger: "manual"
5643
+ trigger: "manual",
5644
+ placement: "top-start"
5497
5645
  });
5498
5646
  },
5499
5647
  onUpdate: (props) => {
5648
+ var _a;
5649
+ const currentPopup = popup == null ? void 0 : popup[0];
5650
+ if (!currentPopup || ((_a = currentPopup == null ? void 0 : currentPopup.state) == null ? void 0 : _a.isDestroyed)) {
5651
+ return;
5652
+ }
5500
5653
  component == null ? void 0 : component.updateProps(props);
5501
- popup && popup[0].setProps({
5654
+ currentPopup.setProps({
5502
5655
  getReferenceClientRect: props.clientRect
5503
5656
  });
5504
5657
  },
5505
5658
  onKeyDown: (props) => {
5506
- var _a;
5659
+ var _a, _b;
5507
5660
  if (props.event.key === "Escape") {
5508
- popup == null ? void 0 : popup[0].hide();
5661
+ const currentPopup = popup == null ? void 0 : popup[0];
5662
+ if (!((_a = currentPopup == null ? void 0 : currentPopup.state) == null ? void 0 : _a.isDestroyed)) {
5663
+ currentPopup == null ? void 0 : currentPopup.destroy();
5664
+ }
5665
+ component == null ? void 0 : component.destroy();
5509
5666
  return true;
5510
5667
  }
5511
- return (_a = component == null ? void 0 : component.ref) == null ? void 0 : _a.onKeyDown(props);
5668
+ return (_b = component == null ? void 0 : component.ref) == null ? void 0 : _b.onKeyDown(props);
5512
5669
  },
5513
5670
  onExit: () => {
5514
5671
  if (!popup || !(popup == null ? void 0 : popup[0]) || !component) {
5515
5672
  return;
5516
5673
  }
5517
- popup == null ? void 0 : popup[0].destroy();
5674
+ const currentPopup = popup == null ? void 0 : popup[0];
5675
+ if (!currentPopup.state.isDestroyed) {
5676
+ currentPopup.destroy();
5677
+ }
5518
5678
  component == null ? void 0 : component.destroy();
5519
5679
  }
5520
5680
  };
@@ -5523,16 +5683,16 @@ function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
5523
5683
  }
5524
5684
 
5525
5685
  // src/editor/nodes/variable/variable-suggestions.tsx
5526
- var import_react33 = require("@tiptap/react");
5527
- var import_react34 = require("react");
5528
- var import_tippy2 = __toESM(require("tippy.js"));
5529
- var import_jsx_runtime36 = require("react/jsx-runtime");
5530
- var VariableList = (0, import_react34.forwardRef)((props, ref) => {
5686
+ var import_react34 = require("@tiptap/react");
5687
+ var import_react35 = require("react");
5688
+ var import_tippy2 = __toESM(require("tippy.js"), 1);
5689
+ var import_jsx_runtime37 = require("react/jsx-runtime");
5690
+ var VariableList = (0, import_react35.forwardRef)((props, ref) => {
5531
5691
  var _a;
5532
5692
  const { items = [], editor } = props;
5533
- const popoverRef = (0, import_react34.useRef)(null);
5693
+ const popoverRef = (0, import_react35.useRef)(null);
5534
5694
  const VariableSuggestionPopoverComponent = (_a = useVariableOptions(editor)) == null ? void 0 : _a.variableSuggestionsPopover;
5535
- (0, import_react34.useImperativeHandle)(ref, () => ({
5695
+ (0, import_react35.useImperativeHandle)(ref, () => ({
5536
5696
  onKeyDown: ({ event }) => {
5537
5697
  if (!popoverRef.current) {
5538
5698
  return false;
@@ -5555,7 +5715,7 @@ var VariableList = (0, import_react34.forwardRef)((props, ref) => {
5555
5715
  return false;
5556
5716
  }
5557
5717
  }));
5558
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5718
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
5559
5719
  VariableSuggestionPopoverComponent,
5560
5720
  {
5561
5721
  items,
@@ -5588,7 +5748,7 @@ function getVariableSuggestions(char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
5588
5748
  let popup = null;
5589
5749
  return {
5590
5750
  onStart: (props) => {
5591
- component = new import_react33.ReactRenderer(VariableList, {
5751
+ component = new import_react34.ReactRenderer(VariableList, {
5592
5752
  props,
5593
5753
  editor: props.editor
5594
5754
  });
@@ -5636,22 +5796,22 @@ function getVariableSuggestions(char = DEFAULT_VARIABLE_TRIGGER_CHAR) {
5636
5796
  }
5637
5797
 
5638
5798
  // src/editor/nodes/html/html.tsx
5639
- var import_extension_code_block_lowlight = __toESM(require("@tiptap/extension-code-block-lowlight"));
5799
+ var import_extension_code_block_lowlight = __toESM(require("@tiptap/extension-code-block-lowlight"), 1);
5640
5800
  var import_state5 = require("@tiptap/pm/state");
5641
- var import_react37 = require("@tiptap/react");
5642
- var import_xml = __toESM(require("highlight.js/lib/languages/xml"));
5801
+ var import_react38 = require("@tiptap/react");
5802
+ var import_xml = __toESM(require("highlight.js/lib/languages/xml"), 1);
5643
5803
  var import_lowlight = require("lowlight");
5644
5804
 
5645
5805
  // src/editor/nodes/html/html-view.tsx
5646
- var import_react35 = require("@tiptap/react");
5647
- var import_react36 = require("react");
5648
- var import_jsx_runtime37 = require("react/jsx-runtime");
5806
+ var import_react36 = require("@tiptap/react");
5807
+ var import_react37 = require("react");
5808
+ var import_jsx_runtime38 = require("react/jsx-runtime");
5649
5809
  function HTMLCodeBlockView(props) {
5650
5810
  const { node, updateAttributes: updateAttributes2 } = props;
5651
5811
  let { language, activeTab = "code" } = node.attrs;
5652
5812
  activeTab || (activeTab = "code");
5653
5813
  const languageClass = language ? `language-${language}` : "";
5654
- const html2 = (0, import_react36.useMemo)(() => {
5814
+ const html2 = (0, import_react37.useMemo)(() => {
5655
5815
  const text2 = node.content.content.reduce((acc, cur) => {
5656
5816
  if (cur.type.name === "text") {
5657
5817
  return acc + cur.text;
@@ -5668,28 +5828,45 @@ function HTMLCodeBlockView(props) {
5668
5828
  return body.innerHTML;
5669
5829
  }, [activeTab]);
5670
5830
  const isEmpty = html2 === "";
5671
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
5672
- import_react35.NodeViewWrapper,
5831
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
5832
+ import_react36.NodeViewWrapper,
5673
5833
  {
5674
5834
  draggable: false,
5675
5835
  "data-drag-handle": false,
5676
5836
  "data-type": "htmlCodeBlock",
5677
5837
  children: [
5678
- activeTab === "code" && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("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__ */ (0, import_jsx_runtime37.jsx)(
5679
- import_react35.NodeViewContent,
5838
+ activeTab === "code" && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("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__ */ (0, import_jsx_runtime38.jsx)(
5839
+ import_react36.NodeViewContent,
5680
5840
  {
5681
5841
  as: "code",
5682
5842
  className: cn("is-editable", languageClass)
5683
5843
  }
5684
5844
  ) }),
5685
- activeTab === "preview" && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
5845
+ activeTab === "preview" && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
5686
5846
  "div",
5687
5847
  {
5688
5848
  className: cn(
5689
5849
  "mly-not-prose mly-rounded-lg mly-border mly-border-gray-200 mly-p-2",
5690
5850
  isEmpty && "mly-min-h-[42px]"
5691
5851
  ),
5692
- dangerouslySetInnerHTML: { __html: html2 },
5852
+ ref: (node2) => {
5853
+ if (!node2 || (node2 == null ? void 0 : node2.shadowRoot)) {
5854
+ return;
5855
+ }
5856
+ const shadow = node2.attachShadow({ mode: "open" });
5857
+ const sheet = new CSSStyleSheet();
5858
+ sheet.replaceSync(`
5859
+ * { font-family: 'Inter', sans-serif; }
5860
+ blockquote, h1, h2, h3, img, li, ol, p, ul {
5861
+ margin-top: 0;
5862
+ margin-bottom: 0;
5863
+ }
5864
+ `);
5865
+ shadow.adoptedStyleSheets = [sheet];
5866
+ const container = document.createElement("div");
5867
+ container.innerHTML = html2;
5868
+ shadow.appendChild(container);
5869
+ },
5693
5870
  contentEditable: false,
5694
5871
  onClick: () => {
5695
5872
  if (!isEmpty) {
@@ -5733,7 +5910,7 @@ var HTMLCodeBlockExtension = import_extension_code_block_lowlight.default.extend
5733
5910
  });
5734
5911
  },
5735
5912
  addNodeView() {
5736
- return (0, import_react37.ReactNodeViewRenderer)(HTMLCodeBlockView, {
5913
+ return (0, import_react38.ReactNodeViewRenderer)(HTMLCodeBlockView, {
5737
5914
  className: "mly-relative",
5738
5915
  attrs: ({ node }) => {
5739
5916
  var _a;
@@ -5853,4 +6030,4 @@ var HTMLCodeBlockExtension = import_extension_code_block_lowlight.default.extend
5853
6030
  logoSizes,
5854
6031
  useImageUploadOptions
5855
6032
  });
5856
- //# sourceMappingURL=index.js.map
6033
+ //# sourceMappingURL=index.cjs.map