@maily-to/core 0.1.0 → 0.1.2

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,
@@ -2973,8 +2974,8 @@ function Select(props) {
2973
2974
  iconClassName
2974
2975
  } = props;
2975
2976
  const selectId = `mly${(0, import_react11.useId)()}`;
2976
- const content = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "relative", children: [
2977
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("label", { htmlFor: selectId, className: "sr-only", children: label }),
2977
+ const content = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "mly-relative", children: [
2978
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("label", { htmlFor: selectId, className: "mly-sr-only", children: label }),
2978
2979
  Icon && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "mly-pointer-events-none mly-absolute mly-inset-y-0 mly-left-2 mly-z-20 mly-flex mly-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Icon, { className: cn("mly-size-3", iconClassName) }) }),
2979
2980
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2980
2981
  "select",
@@ -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,39 +4739,60 @@ 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
  }
4758
4780
  ),
4759
4781
  /* @__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: [
4760
4782
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
4761
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("kbd", { className: "mly-rounded mly-border mly-p-1 mly-px-2 mly-font-medium", children: "\u2191" }),
4762
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("kbd", { className: "mly-ml-1 mly-rounded mly-border mly-p-1 mly-px-2 mly-font-medium", children: "\u2193" }),
4783
+ /* @__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" }),
4784
+ /* @__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" }),
4763
4785
  " ",
4764
4786
  "to navigate"
4765
4787
  ] }),
4766
4788
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { "aria-hidden": "true", className: "mly-select-none mly-px-1", children: "\xB7" }),
4767
4789
  /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "mly-text-center mly-text-xs mly-text-gray-400", children: [
4768
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("kbd", { className: "mly-rounded mly-border mly-p-1 mly-px-1.5 mly-font-medium", children: "Enter" }),
4790
+ /* @__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" }),
4769
4791
  " ",
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 {