@maily-to/core 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -53,7 +53,7 @@ var __async = (__this, __arguments, generator) => {
53
53
 
54
54
  // src/editor/index.tsx
55
55
  import { EditorContent, useEditor } from "@tiptap/react";
56
- import { useMemo as useMemo14, useRef as useRef13 } from "react";
56
+ import { useMemo as useMemo13, useRef as useRef13 } from "react";
57
57
 
58
58
  // src/editor/components/column-menu/columns-bubble-menu.tsx
59
59
  import { BubbleMenu } from "@tiptap/react";
@@ -108,7 +108,7 @@ function isTextSelected(editor) {
108
108
  // src/editor/utils/columns.ts
109
109
  import { Fragment } from "@tiptap/pm/model";
110
110
  import { TextSelection } from "@tiptap/pm/state";
111
- import { v4 as uuid2 } from "uuid";
111
+ import { v4 as uuidv42 } from "uuid";
112
112
  import { findParentNode } from "@tiptap/core";
113
113
 
114
114
  // src/editor/utils/update-attribute.ts
@@ -147,7 +147,7 @@ function updateAttributes(type, attrs) {
147
147
 
148
148
  // src/editor/nodes/columns/column.ts
149
149
  import { Node, mergeAttributes } from "@tiptap/core";
150
- import { v4 as uuid } from "uuid";
150
+ import { v4 as uuidv4 } from "uuid";
151
151
  var DEFAULT_COLUMN_WIDTH = "auto";
152
152
  var DEFAULT_COLUMN_VERTICAL_ALIGN = "top";
153
153
  var ColumnExtension = Node.create({
@@ -158,11 +158,11 @@ var ColumnExtension = Node.create({
158
158
  return {
159
159
  columnId: {
160
160
  default: null,
161
- parseHTML: (element) => element.getAttribute("data-column-id") || uuid(),
161
+ parseHTML: (element) => element.getAttribute("data-column-id") || uuidv4(),
162
162
  renderHTML: (attributes) => {
163
163
  if (!attributes.columnId) {
164
164
  return {
165
- "data-column-id": uuid()
165
+ "data-column-id": uuidv4()
166
166
  };
167
167
  }
168
168
  return {
@@ -319,7 +319,7 @@ function addColumnByIndex(editor, index = -1) {
319
319
  const newColumn = state.schema.nodes.column.create(
320
320
  {
321
321
  width: DEFAULT_COLUMN_WIDTH,
322
- columnId: uuid2()
322
+ columnId: uuidv42()
323
323
  },
324
324
  state.schema.nodes.paragraph.create(null)
325
325
  );
@@ -2106,10 +2106,10 @@ var DEFAULT_SECTION_MARGIN_TOP = 0;
2106
2106
  var DEFAULT_SECTION_MARGIN_RIGHT = 0;
2107
2107
  var DEFAULT_SECTION_MARGIN_BOTTOM = 0;
2108
2108
  var DEFAULT_SECTION_MARGIN_LEFT = 0;
2109
- var DEFAULT_SECTION_PADDING_TOP = 5;
2110
- var DEFAULT_SECTION_PADDING_RIGHT = 5;
2111
- var DEFAULT_SECTION_PADDING_BOTTOM = 5;
2112
- var DEFAULT_SECTION_PADDING_LEFT = 5;
2109
+ var DEFAULT_SECTION_PADDING_TOP = 0;
2110
+ var DEFAULT_SECTION_PADDING_RIGHT = 0;
2111
+ var DEFAULT_SECTION_PADDING_BOTTOM = 0;
2112
+ var DEFAULT_SECTION_PADDING_LEFT = 0;
2113
2113
  var DEFAULT_SECTION_SHOW_IF_KEY = null;
2114
2114
  var SectionExtension = Node3.create({
2115
2115
  name: "section",
@@ -2577,6 +2577,7 @@ function getNewWidth(height, aspectRatio) {
2577
2577
  import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
2578
2578
  var MIN_WIDTH = 20;
2579
2579
  var IMAGE_MAX_WIDTH = 600;
2580
+ var IMAGE_MAX_HEIGHT = 400;
2580
2581
  function ImageView(props) {
2581
2582
  const { node, updateAttributes: updateAttributes2, selected, editor } = props;
2582
2583
  const [status, setStatus] = useState4("idle");
@@ -2601,11 +2602,13 @@ function ImageView(props) {
2601
2602
  event.preventDefault();
2602
2603
  const direction = event.currentTarget.dataset.direction || "--";
2603
2604
  const initialXPosition = event.clientX;
2605
+ const initialYPosition = event.clientY;
2604
2606
  const currentWidth = imgRef.current.width;
2605
2607
  const currentHeight = imgRef.current.height;
2606
2608
  let newWidth = currentWidth;
2607
2609
  let newHeight = currentHeight;
2608
- const transform = direction[1] === "w" ? -1 : 1;
2610
+ const transformX = direction[1] === "w" ? -1 : 1;
2611
+ const transformY = direction[0] === "n" ? -1 : 1;
2609
2612
  const removeListeners = () => {
2610
2613
  window.removeEventListener("mousemove", mouseMoveHandler);
2611
2614
  window.removeEventListener("mouseup", removeListeners);
@@ -2615,13 +2618,22 @@ function ImageView(props) {
2615
2618
  };
2616
2619
  const mouseMoveHandler = (event2) => {
2617
2620
  newWidth = Math.max(
2618
- currentWidth + transform * (event2.clientX - initialXPosition),
2621
+ currentWidth + transformX * (event2.clientX - initialXPosition),
2622
+ MIN_WIDTH
2623
+ );
2624
+ newHeight = Math.max(
2625
+ currentHeight + transformY * (event2.clientY - initialYPosition),
2619
2626
  MIN_WIDTH
2620
2627
  );
2621
2628
  if (newWidth > imageParentWidth) {
2622
2629
  newWidth = imageParentWidth;
2623
2630
  }
2624
- newHeight = newWidth / currentWidth * currentHeight;
2631
+ if (newHeight > IMAGE_MAX_HEIGHT) {
2632
+ newHeight = IMAGE_MAX_HEIGHT;
2633
+ }
2634
+ if (node.attrs.lockAspectRatio) {
2635
+ newHeight = getNewHeight(newWidth, node.attrs.aspectRatio);
2636
+ }
2625
2637
  setResizingStyle({ width: newWidth, height: newHeight });
2626
2638
  if (!event2.buttons) {
2627
2639
  return removeListeners();
@@ -2846,8 +2858,11 @@ function ImageView(props) {
2846
2858
  ref: imgRef,
2847
2859
  style: __spreadProps(__spreadValues({}, resizingStyle), {
2848
2860
  cursor: "default",
2861
+ objectFit: "fill",
2849
2862
  marginBottom: 0,
2850
- borderRadius: borderRadius2
2863
+ borderRadius: borderRadius2,
2864
+ width: (resizingStyle == null ? void 0 : resizingStyle.width) ? `${resizingStyle.width}px` : width ? `${width}px` : "auto",
2865
+ height: (resizingStyle == null ? void 0 : resizingStyle.height) ? `${resizingStyle.height}px` : height ? `${height}px` : "auto"
2851
2866
  }),
2852
2867
  draggable: editor.isEditable,
2853
2868
  className: cn(
@@ -3097,6 +3112,7 @@ function LogoView(props) {
3097
3112
 
3098
3113
  // src/editor/nodes/logo/logo.ts
3099
3114
  var allowedLogoSize = ["sm", "md", "lg"];
3115
+ var allowedLogoAlignment = ["left", "center", "right"];
3100
3116
  var DEFAULT_ALIGNMENT = "left";
3101
3117
  var DEFAULT_LOGO_SIZE = "sm";
3102
3118
  var logoSizes = {
@@ -3230,7 +3246,10 @@ import { sticky as sticky3 } from "tippy.js";
3230
3246
  import { AlignCenter as AlignCenter2, AlignLeft as AlignLeft2, AlignRight as AlignRight2 } from "lucide-react";
3231
3247
  import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
3232
3248
  function AlignmentSwitch(props) {
3233
- const { alignment = "left", onAlignmentChange } = props;
3249
+ const { alignment: rawAlignment, onAlignmentChange } = props;
3250
+ const alignment = allowedLogoAlignment.includes(
3251
+ rawAlignment
3252
+ ) ? rawAlignment : "left";
3234
3253
  const alignments = {
3235
3254
  left: {
3236
3255
  icon: AlignLeft2,
@@ -4691,7 +4710,7 @@ function LinkInputPopover(props) {
4691
4710
  variant: "ghost",
4692
4711
  size: "sm",
4693
4712
  type: "button",
4694
- className: "mly-size-7",
4713
+ className: "!mly-size-7",
4695
4714
  "data-state": !!defaultValue,
4696
4715
  children: /* @__PURE__ */ jsx35(Icon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-midnight-gray" })
4697
4716
  }
@@ -4973,11 +4992,14 @@ function ImageBubbleMenu(props) {
4973
4992
  value: (_c = state == null ? void 0 : state.width) != null ? _c : "",
4974
4993
  onValueChange: (value) => {
4975
4994
  const width = Math.min(Number(value) || 0, IMAGE_MAX_WIDTH);
4995
+ const currentHeight = Number(state.height) || 0;
4996
+ const currentWidth = Number(state.width) || 0;
4997
+ const currentAspectRatio = state.aspectRatio || currentWidth / currentHeight || 1;
4976
4998
  editor == null ? void 0 : editor.chain().updateAttributes("image", __spreadValues({
4977
4999
  width: String(width)
4978
5000
  }, lockAspectRatio && value ? {
4979
5001
  height: String(
4980
- getNewHeight(width, state.aspectRatio)
5002
+ getNewHeight(width, currentAspectRatio)
4981
5003
  )
4982
5004
  } : {})).run();
4983
5005
  }
@@ -4990,11 +5012,14 @@ function ImageBubbleMenu(props) {
4990
5012
  value: (_d = state == null ? void 0 : state.height) != null ? _d : "",
4991
5013
  onValueChange: (value) => {
4992
5014
  const height = Number(value) || 0;
5015
+ const currentHeight = Number(state.height) || 0;
5016
+ const currentWidth = Number(state.width) || 0;
5017
+ const currentAspectRatio = state.aspectRatio || currentWidth / currentHeight || 1;
4993
5018
  editor == null ? void 0 : editor.chain().updateAttributes("image", __spreadValues({
4994
5019
  height: String(height)
4995
5020
  }, lockAspectRatio && value ? {
4996
5021
  width: String(
4997
- getNewWidth(height, state.aspectRatio)
5022
+ getNewWidth(height, currentAspectRatio)
4998
5023
  )
4999
5024
  } : {})).run();
5000
5025
  }
@@ -6016,7 +6041,7 @@ function SpacerBubbleMenu(props) {
6016
6041
  // src/editor/nodes/columns/columns.ts
6017
6042
  import { mergeAttributes as mergeAttributes5 } from "@tiptap/core";
6018
6043
  import { Node as Node6 } from "@tiptap/core";
6019
- import { v4 as uuid3 } from "uuid";
6044
+ import { v4 as uuidv43 } from "uuid";
6020
6045
  var DEFAULT_COLUMNS_GAP = 8;
6021
6046
  var ColumnsExtension = Node6.create({
6022
6047
  name: "columns",
@@ -6066,7 +6091,7 @@ var ColumnsExtension = Node6.create({
6066
6091
  {
6067
6092
  type: "column",
6068
6093
  attrs: {
6069
- columnId: uuid3()
6094
+ columnId: uuidv43()
6070
6095
  },
6071
6096
  content: [
6072
6097
  {
@@ -6077,7 +6102,7 @@ var ColumnsExtension = Node6.create({
6077
6102
  {
6078
6103
  type: "column",
6079
6104
  attrs: {
6080
- columnId: uuid3()
6105
+ columnId: uuidv43()
6081
6106
  },
6082
6107
  content: [
6083
6108
  {
@@ -7823,13 +7848,16 @@ function SlashCommandItem(props) {
7823
7848
  selectedCommandIndex,
7824
7849
  editor,
7825
7850
  activeCommandRef,
7826
- selectItem
7851
+ selectItem,
7852
+ hoveredItemKey,
7853
+ onHover
7827
7854
  } = props;
7828
7855
  const [open, setOpen] = useState10(false);
7829
- const [isHovered, setIsHovered] = useState10(false);
7830
7856
  const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
7831
- const isSubCommand = item && "commands" in item;
7832
- const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && (isActive || isHovered);
7857
+ const itemKey = `${groupIndex}-${commandIndex}`;
7858
+ const isHovered = hoveredItemKey === itemKey;
7859
+ const isSubCommand2 = item && "commands" in item;
7860
+ const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && (isHovered || isActive && !hoveredItemKey);
7833
7861
  const hasRenderFunction = typeof item.render === "function";
7834
7862
  const renderFunctionValue = hasRenderFunction ? (_a = item.render) == null ? void 0 : _a.call(item, editor) : null;
7835
7863
  let value = /* @__PURE__ */ jsxs31(Fragment6, { children: [
@@ -7838,7 +7866,7 @@ function SlashCommandItem(props) {
7838
7866
  /* @__PURE__ */ jsx53("p", { className: "mly-font-medium", children: item.title }),
7839
7867
  /* @__PURE__ */ jsx53("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
7840
7868
  ] }),
7841
- isSubCommand && /* @__PURE__ */ jsx53("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ jsx53(ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
7869
+ isSubCommand2 && /* @__PURE__ */ jsx53("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ jsx53(ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
7842
7870
  ] });
7843
7871
  if (renderFunctionValue !== null && renderFunctionValue !== true) {
7844
7872
  value = renderFunctionValue;
@@ -7878,8 +7906,8 @@ function SlashCommandItem(props) {
7878
7906
  isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
7879
7907
  ),
7880
7908
  onClick: () => selectItem(groupIndex, commandIndex),
7881
- onMouseEnter: () => setIsHovered(true),
7882
- onMouseLeave: () => setIsHovered(false),
7909
+ onMouseEnter: () => onHover(true),
7910
+ onMouseLeave: () => onHover(false),
7883
7911
  type: "button",
7884
7912
  ref: isActive ? activeCommandRef : null,
7885
7913
  children: value
@@ -7907,12 +7935,94 @@ function SlashCommandItem(props) {
7907
7935
  ] }, `${groupIndex}-${commandIndex}`);
7908
7936
  }
7909
7937
 
7938
+ // src/editor/extensions/slash-command/slash-command-search.tsx
7939
+ function filterSlashCommands(options) {
7940
+ const { groups, query, editor } = options;
7941
+ const newGroups = [...groups];
7942
+ let searchQuery = query == null ? void 0 : query.toLowerCase();
7943
+ const subCommandMatch = searchQuery.match(/^([^.]+)\./);
7944
+ if (subCommandMatch) {
7945
+ const [match, subCommandId] = subCommandMatch;
7946
+ const subCommandGroup = findSubCommandGroup(groups, subCommandId);
7947
+ if (subCommandGroup) {
7948
+ const remainingSearch = searchQuery.slice(match.length);
7949
+ const filteredCommands = subCommandGroup.commands.filter(
7950
+ (item) => !remainingSearch || isCommandMatch(item, remainingSearch)
7951
+ );
7952
+ return filteredCommands.length ? [
7953
+ __spreadProps(__spreadValues({}, subCommandGroup), {
7954
+ commands: filteredCommands
7955
+ })
7956
+ ] : [];
7957
+ }
7958
+ }
7959
+ const filteredGroups = newGroups.map((group) => {
7960
+ return __spreadProps(__spreadValues({}, group), {
7961
+ commands: group.commands.flatMap(
7962
+ (item) => processCommand({ item, search: searchQuery, editor })
7963
+ )
7964
+ });
7965
+ }).filter((group) => group.commands.length > 0);
7966
+ return filteredGroups;
7967
+ }
7968
+ function findSubCommandGroup(groups, subCommandId) {
7969
+ return groups.flatMap((group) => group.commands).find(
7970
+ (item) => {
7971
+ var _a;
7972
+ return "commands" in item && ((_a = item.id) == null ? void 0 : _a.toLowerCase()) === subCommandId.toLowerCase();
7973
+ }
7974
+ );
7975
+ }
7976
+ function containsText(text2, search) {
7977
+ if (!text2) {
7978
+ return false;
7979
+ }
7980
+ return text2.toLowerCase().includes(search.toLowerCase());
7981
+ }
7982
+ function isCommandMatch(item, search) {
7983
+ var _a, _b;
7984
+ return containsText(item.title, search) || containsText(item.description, search) || ((_b = (_a = item.searchTerms) == null ? void 0 : _a.some((term) => containsText(term, search))) != null ? _b : false);
7985
+ }
7986
+ function isSubCommand(item) {
7987
+ return "commands" in item && Array.isArray(item.commands) && !!item.id;
7988
+ }
7989
+ function processCommand(options) {
7990
+ var _a, _b, _c, _d;
7991
+ const { item, search, editor } = options;
7992
+ const show = (_a = item == null ? void 0 : item.render) == null ? void 0 : _a.call(item, editor);
7993
+ if (show === null) {
7994
+ return [];
7995
+ }
7996
+ const isSearching = search.length > 0;
7997
+ if (isSubCommand(item)) {
7998
+ const navigableCommand = __spreadProps(__spreadValues({}, item), {
7999
+ command: (options2) => {
8000
+ const { editor: editor2, range } = options2;
8001
+ editor2.chain().focus().insertContentAt(range, `/${item.id}.`).run();
8002
+ }
8003
+ });
8004
+ const matched = isCommandMatch(navigableCommand, search);
8005
+ if (matched) {
8006
+ return [navigableCommand];
8007
+ }
8008
+ const hasMatchingCommands = (_c = (_b = navigableCommand == null ? void 0 : navigableCommand.commands) == null ? void 0 : _b.some(
8009
+ (command) => isCommandMatch(command, search)
8010
+ )) != null ? _c : false;
8011
+ if (!hasMatchingCommands) {
8012
+ return [];
8013
+ }
8014
+ return (_d = navigableCommand == null ? void 0 : navigableCommand.commands) != null ? _d : [];
8015
+ }
8016
+ return !isSearching || isCommandMatch(item, search) ? [item] : [];
8017
+ }
8018
+
7910
8019
  // src/editor/extensions/slash-command/slash-command-view.tsx
7911
8020
  import { jsx as jsx54, jsxs as jsxs32 } from "react/jsx-runtime";
7912
- var CommandList = forwardRef8(function CommandList2(props, ref) {
8021
+ var CommandList = forwardRef8((props, ref) => {
7913
8022
  const { items: groups, command, editor, range, query } = props;
7914
8023
  const [selectedGroupIndex, setSelectedGroupIndex] = useState11(0);
7915
8024
  const [selectedCommandIndex, setSelectedCommandIndex] = useState11(0);
8025
+ const [hoveredItemKey, setHoveredItemKey] = useState11(null);
7916
8026
  const prevQuery = useRef11("");
7917
8027
  const prevSelectedGroupIndex = useRef11(0);
7918
8028
  const prevSelectedCommandIndex = useRef11(0);
@@ -8042,7 +8152,10 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
8042
8152
  prevSelectedCommandIndex.current = 0;
8043
8153
  };
8044
8154
  }, []);
8045
- return groups.length > 0 ? /* @__PURE__ */ jsx54(TooltipProvider, { children: /* @__PURE__ */ jsxs32("div", { className: "mly-z-50 mly-w-72 mly-overflow-hidden mly-rounded-md mly-border mly-border-gray-200 mly-bg-white mly-shadow-md mly-transition-all", children: [
8155
+ if (!groups || groups.length === 0) {
8156
+ return null;
8157
+ }
8158
+ return /* @__PURE__ */ jsx54(TooltipProvider, { children: /* @__PURE__ */ jsxs32("div", { className: "mly-z-50 mly-w-72 mly-overflow-hidden mly-rounded-md mly-border mly-border-gray-200 mly-bg-white mly-shadow-md mly-transition-all", children: [
8046
8159
  /* @__PURE__ */ jsx54(
8047
8160
  "div",
8048
8161
  {
@@ -8061,6 +8174,7 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
8061
8174
  }
8062
8175
  ),
8063
8176
  /* @__PURE__ */ jsx54("div", { className: "mly-space-y-0.5 mly-p-1", children: group.commands.map((item, commandIndex) => {
8177
+ const itemKey = `${groupIndex}-${commandIndex}`;
8064
8178
  return /* @__PURE__ */ jsx54(
8065
8179
  SlashCommandItem,
8066
8180
  {
@@ -8071,9 +8185,11 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
8071
8185
  selectedCommandIndex,
8072
8186
  selectItem: () => selectItem(groupIndex, commandIndex),
8073
8187
  editor,
8074
- activeCommandRef
8188
+ activeCommandRef,
8189
+ hoveredItemKey,
8190
+ onHover: (isHovered) => setHoveredItemKey(isHovered ? itemKey : null)
8075
8191
  },
8076
- commandIndex
8192
+ itemKey
8077
8193
  );
8078
8194
  }) })
8079
8195
  ] }, groupIndex))
@@ -8093,77 +8209,12 @@ var CommandList = forwardRef8(function CommandList2(props, ref) {
8093
8209
  "to select"
8094
8210
  ] })
8095
8211
  ] }) })
8096
- ] }) }) : null;
8212
+ ] }) });
8097
8213
  });
8098
8214
  function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
8099
8215
  return {
8100
8216
  items: ({ query, editor }) => {
8101
- var _a;
8102
- let newGroups = groups;
8103
- let search = query.toLowerCase();
8104
- const subCommandIds = newGroups.map((group) => {
8105
- return group.commands.filter((item) => "commands" in item).map((item) => item == null ? void 0 : item.id.toLowerCase());
8106
- }).flat().map((id) => `${id}.`);
8107
- const shouldEnterSubCommand = subCommandIds.some(
8108
- (id) => search.startsWith(id)
8109
- );
8110
- if (shouldEnterSubCommand) {
8111
- const subCommandId = subCommandIds.find((id) => search.startsWith(id));
8112
- const sanitizedSubCommandId = subCommandId == null ? void 0 : subCommandId.slice(0, -1);
8113
- const group = (_a = newGroups.find((group2) => {
8114
- return group2.commands.some(
8115
- // @ts-ignore
8116
- (item) => {
8117
- var _a2;
8118
- return ((_a2 = item == null ? void 0 : item.id) == null ? void 0 : _a2.toLowerCase()) === sanitizedSubCommandId;
8119
- }
8120
- );
8121
- })) == null ? void 0 : _a.commands.find(
8122
- // @ts-ignore
8123
- (item) => {
8124
- var _a2;
8125
- return ((_a2 = item == null ? void 0 : item.id) == null ? void 0 : _a2.toLowerCase()) === sanitizedSubCommandId;
8126
- }
8127
- );
8128
- if (!group) {
8129
- return groups;
8130
- }
8131
- search = search.replace(subCommandId || "", "");
8132
- newGroups = [
8133
- __spreadProps(__spreadValues({}, group), {
8134
- commands: (group == null ? void 0 : group.commands) || []
8135
- })
8136
- ];
8137
- }
8138
- const filteredGroups = newGroups.map((group) => {
8139
- return __spreadProps(__spreadValues({}, group), {
8140
- commands: group.commands.filter((item) => {
8141
- var _a2;
8142
- if (typeof query === "string" && query.length > 0) {
8143
- const show = (_a2 = item == null ? void 0 : item.render) == null ? void 0 : _a2.call(item, editor);
8144
- if (show === null) {
8145
- return false;
8146
- }
8147
- return item.title.toLowerCase().includes(search) || (item == null ? void 0 : item.description) && (item == null ? void 0 : item.description.toLowerCase().includes(search)) || item.searchTerms && item.searchTerms.some(
8148
- (term) => term.includes(search)
8149
- );
8150
- }
8151
- return true;
8152
- }).map((item) => {
8153
- const isSubCommandItem = "commands" in item;
8154
- if (isSubCommandItem) {
8155
- item = __spreadProps(__spreadValues({}, item), {
8156
- command: (options) => {
8157
- const { editor: editor2, range } = options;
8158
- editor2.chain().focus().insertContentAt(range, `/${item.id}.`).run();
8159
- }
8160
- });
8161
- }
8162
- return item;
8163
- })
8164
- });
8165
- }).filter((group) => group.commands.length > 0);
8166
- return filteredGroups;
8217
+ return filterSlashCommands({ query, editor, groups });
8167
8218
  },
8168
8219
  allow: ({ editor }) => {
8169
8220
  const isInsideHTMLCodeBlock = editor.isActive("htmlCodeBlock");
@@ -8613,13 +8664,13 @@ function TextBubbleContent(props) {
8613
8664
 
8614
8665
  // src/editor/components/text-menu/turn-into-block.tsx
8615
8666
  import { ChevronDownIcon as ChevronDownIcon2, PilcrowIcon } from "lucide-react";
8616
- import { useMemo as useMemo13 } from "react";
8667
+ import { useMemo as useMemo12 } from "react";
8617
8668
  import { jsx as jsx57, jsxs as jsxs34 } from "react/jsx-runtime";
8618
8669
  var isOption = (option) => option.type === "option";
8619
8670
  var isCategory = (option) => option.type === "category";
8620
8671
  function TurnIntoBlock(props) {
8621
8672
  const { options } = props;
8622
- const activeItem = useMemo13(
8673
+ const activeItem = useMemo12(
8623
8674
  () => options.find((option) => option.type === "option" && option.isActive()),
8624
8675
  [options]
8625
8676
  );
@@ -8654,7 +8705,7 @@ function TurnIntoBlock(props) {
8654
8705
  {
8655
8706
  onClick: option.onClick,
8656
8707
  variant: "ghost",
8657
- className: "mly-h-auto mly-justify-start mly-gap-2 !mly-rounded mly-px-2 mly-py-1 mly-text-sm mly-font-normal mly-text-midnight-gray",
8708
+ className: "mly-mb-0.5 mly-h-auto mly-justify-start mly-gap-2 !mly-rounded mly-px-2 mly-py-1 mly-text-sm mly-font-normal mly-text-midnight-gray",
8658
8709
  children: [
8659
8710
  /* @__PURE__ */ jsx57(option.icon, { className: "mly-size-[15px] mly-shrink-0" }),
8660
8711
  option.label
@@ -8875,6 +8926,37 @@ function VariableBubbleMenu(props) {
8875
8926
  );
8876
8927
  }
8877
8928
 
8929
+ // src/editor/extensions/selection/selection.ts
8930
+ import { Extension as Extension4 } from "@tiptap/core";
8931
+ import { Plugin as Plugin4, PluginKey as PluginKey5 } from "@tiptap/pm/state";
8932
+ import { Decoration, DecorationSet } from "@tiptap/pm/view";
8933
+ var SelectionExtension = Extension4.create({
8934
+ name: "selection",
8935
+ addProseMirrorPlugins() {
8936
+ const { editor } = this;
8937
+ return [
8938
+ new Plugin4({
8939
+ key: new PluginKey5("selection"),
8940
+ props: {
8941
+ decorations(state) {
8942
+ if (state.selection.empty) {
8943
+ return null;
8944
+ }
8945
+ if (editor.isFocused === true) {
8946
+ return null;
8947
+ }
8948
+ return DecorationSet.create(state.doc, [
8949
+ Decoration.inline(state.selection.from, state.selection.to, {
8950
+ class: "selection mly-bg-blue-200 mly-inline mly-py-1"
8951
+ })
8952
+ ]);
8953
+ }
8954
+ }
8955
+ })
8956
+ ];
8957
+ }
8958
+ });
8959
+
8878
8960
  // src/editor/extensions/index.tsx
8879
8961
  function extensions(props) {
8880
8962
  const { blocks, extensions: extensions2 = [] } = props;
@@ -8888,7 +8970,8 @@ function extensions(props) {
8888
8970
  }),
8889
8971
  HTMLCodeBlockExtension,
8890
8972
  InlineImageExtension,
8891
- PlaceholderExtension
8973
+ PlaceholderExtension,
8974
+ SelectionExtension
8892
8975
  ].filter((ext) => {
8893
8976
  return !extensions2.some((e) => e.name === ext.name);
8894
8977
  });
@@ -8932,6 +9015,7 @@ function Editor13(props) {
8932
9015
  contentClassName = "",
8933
9016
  bodyClassName = "",
8934
9017
  hasMenuBar = true,
9018
+ hideContextMenu = false,
8935
9019
  spellCheck = false,
8936
9020
  autofocus = "end",
8937
9021
  immediatelyRender = false
@@ -8945,7 +9029,7 @@ function Editor13(props) {
8945
9029
  editable = true,
8946
9030
  placeholderUrl = DEFAULT_PLACEHOLDER_URL
8947
9031
  } = props;
8948
- const formattedContent = useMemo14(() => {
9032
+ const formattedContent = useMemo13(() => {
8949
9033
  if (contentJson) {
8950
9034
  const json = (contentJson == null ? void 0 : contentJson.type) === "doc" ? contentJson : {
8951
9035
  type: "doc",
@@ -9017,7 +9101,7 @@ function Editor13(props) {
9017
9101
  /* @__PURE__ */ jsx60(EditorContent, { editor }),
9018
9102
  /* @__PURE__ */ jsx60(SectionBubbleMenu, { editor, appendTo: menuContainerRef }),
9019
9103
  /* @__PURE__ */ jsx60(ColumnsBubbleMenu, { editor, appendTo: menuContainerRef }),
9020
- /* @__PURE__ */ jsx60(ContentMenu, { editor }),
9104
+ !hideContextMenu && /* @__PURE__ */ jsx60(ContentMenu, { editor }),
9021
9105
  /* @__PURE__ */ jsx60(VariableBubbleMenu, { editor, appendTo: menuContainerRef }),
9022
9106
  /* @__PURE__ */ jsx60(RepeatBubbleMenu, { editor, appendTo: menuContainerRef }),
9023
9107
  /* @__PURE__ */ jsx60(HTMLBubbleMenu, { editor, appendTo: menuContainerRef }),