@maily-to/core 0.1.0 → 0.1.1

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.
@@ -10,6 +10,7 @@ type BlockItem = {
10
10
  searchTerms: string[];
11
11
  icon?: JSX.Element;
12
12
  render?: (editor: Editor) => JSX.Element | null | true;
13
+ preview?: string | ((editor: Editor) => JSX.Element | null);
13
14
  } & ({
14
15
  command: (options: CommandProps) => void;
15
16
  id?: never;
@@ -10,6 +10,7 @@ type BlockItem = {
10
10
  searchTerms: string[];
11
11
  icon?: JSX.Element;
12
12
  render?: (editor: Editor) => JSX.Element | null | true;
13
+ preview?: string | ((editor: Editor) => JSX.Element | null);
13
14
  } & ({
14
15
  command: (options: CommandProps) => void;
15
16
  id?: never;
@@ -51,6 +51,7 @@ type BlockItem = {
51
51
  searchTerms: string[];
52
52
  icon?: JSX.Element;
53
53
  render?: (editor: Editor) => JSX.Element | null | true;
54
+ preview?: string | ((editor: Editor) => JSX.Element | null);
54
55
  } & ({
55
56
  command: (options: CommandProps) => void;
56
57
  id?: never;
@@ -51,6 +51,7 @@ type BlockItem = {
51
51
  searchTerms: string[];
52
52
  icon?: JSX.Element;
53
53
  render?: (editor: Editor) => JSX.Element | null | true;
54
+ preview?: string | ((editor: Editor) => JSX.Element | null);
54
55
  } & ({
55
56
  command: (options: CommandProps) => void;
56
57
  id?: never;
@@ -2395,6 +2395,7 @@ var DEFAULT_SLASH_COMMANDS = [
2395
2395
  description: "Add pre-designed headers block",
2396
2396
  searchTerms: ["header", "headers"],
2397
2397
  icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react9.Heading1, { className: "mly-h-4 mly-w-4" }),
2398
+ preview: "https://cdn.usemaily.com/previews/header-preview-xyz.png",
2398
2399
  commands: [
2399
2400
  headerLogoWithTextVertical,
2400
2401
  headerLogoWithTextHorizontal,
@@ -4703,7 +4704,7 @@ var CommandList = (0, import_react30.forwardRef)(function CommandList2(props, re
4703
4704
  commandListContainer,
4704
4705
  activeCommandRef
4705
4706
  ]);
4706
- return groups.length > 0 ? /* @__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: [
4707
+ 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: [
4707
4708
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4708
4709
  "div",
4709
4710
  {
@@ -4721,7 +4722,7 @@ var CommandList = (0, import_react30.forwardRef)(function CommandList2(props, re
4721
4722
  children: group.title
4722
4723
  }
4723
4724
  ),
4724
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "mly-p-1", children: group.commands.map((item, commandIndex) => {
4725
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "mly-space-y-0.5 mly-p-1", children: group.commands.map((item, commandIndex) => {
4725
4726
  var _a;
4726
4727
  const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
4727
4728
  const isSubCommand = "commands" in item;
@@ -4738,20 +4739,41 @@ var CommandList = (0, import_react30.forwardRef)(function CommandList2(props, re
4738
4739
  if (renderFunctionValue !== null && renderFunctionValue !== true) {
4739
4740
  value = renderFunctionValue;
4740
4741
  }
4741
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4742
- "button",
4743
- {
4744
- className: cn(
4745
- "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",
4746
- isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
4747
- ),
4748
- onClick: () => selectItem(groupIndex, commandIndex),
4749
- type: "button",
4750
- ref: isActive ? activeCommandRef : null,
4751
- children: value
4752
- },
4753
- commandIndex
4754
- );
4742
+ const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && isActive;
4743
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Tooltip, { open: shouldOpenTooltip, children: [
4744
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4745
+ "button",
4746
+ {
4747
+ className: cn(
4748
+ "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",
4749
+ isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
4750
+ ),
4751
+ onClick: () => selectItem(groupIndex, commandIndex),
4752
+ type: "button",
4753
+ ref: isActive ? activeCommandRef : null,
4754
+ children: value
4755
+ }
4756
+ ) }),
4757
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4758
+ TooltipContent,
4759
+ {
4760
+ side: "right",
4761
+ sideOffset: 10,
4762
+ className: "mly-w-52 mly-rounded-lg mly-border-none mly-p-1 mly-shadow",
4763
+ children: typeof item.preview === "function" ? item == null ? void 0 : item.preview(editor) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
4764
+ /* @__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)(
4765
+ "img",
4766
+ {
4767
+ src: item == null ? void 0 : item.preview,
4768
+ alt: item == null ? void 0 : item.title,
4769
+ className: "mly-absolute mly-inset-0 mly-h-full mly-w-full mly-object-cover"
4770
+ }
4771
+ ) }),
4772
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "mly-mt-2 mly-px-0.5 mly-text-gray-500", children: item.description })
4773
+ ] })
4774
+ }
4775
+ )
4776
+ ] }, commandIndex);
4755
4777
  }) })
4756
4778
  ] }, groupIndex))
4757
4779
  }
@@ -4770,7 +4792,7 @@ var CommandList = (0, import_react30.forwardRef)(function CommandList2(props, re
4770
4792
  "to select"
4771
4793
  ] })
4772
4794
  ] }) })
4773
- ] }) : null;
4795
+ ] }) }) : null;
4774
4796
  });
4775
4797
  function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
4776
4798
  return {