@maily-to/core 0.2.6 → 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.cjs CHANGED
@@ -2116,10 +2116,10 @@ var DEFAULT_SECTION_MARGIN_TOP = 0;
2116
2116
  var DEFAULT_SECTION_MARGIN_RIGHT = 0;
2117
2117
  var DEFAULT_SECTION_MARGIN_BOTTOM = 0;
2118
2118
  var DEFAULT_SECTION_MARGIN_LEFT = 0;
2119
- var DEFAULT_SECTION_PADDING_TOP = 5;
2120
- var DEFAULT_SECTION_PADDING_RIGHT = 5;
2121
- var DEFAULT_SECTION_PADDING_BOTTOM = 5;
2122
- var DEFAULT_SECTION_PADDING_LEFT = 5;
2119
+ var DEFAULT_SECTION_PADDING_TOP = 0;
2120
+ var DEFAULT_SECTION_PADDING_RIGHT = 0;
2121
+ var DEFAULT_SECTION_PADDING_BOTTOM = 0;
2122
+ var DEFAULT_SECTION_PADDING_LEFT = 0;
2123
2123
  var DEFAULT_SECTION_SHOW_IF_KEY = null;
2124
2124
  var SectionExtension = import_core5.Node.create({
2125
2125
  name: "section",
@@ -2582,6 +2582,7 @@ function getNewWidth(height, aspectRatio) {
2582
2582
  var import_jsx_runtime17 = require("react/jsx-runtime");
2583
2583
  var MIN_WIDTH = 20;
2584
2584
  var IMAGE_MAX_WIDTH = 600;
2585
+ var IMAGE_MAX_HEIGHT = 400;
2585
2586
  function ImageView(props) {
2586
2587
  const { node, updateAttributes: updateAttributes2, selected, editor } = props;
2587
2588
  const [status, setStatus] = (0, import_react18.useState)("idle");
@@ -2606,11 +2607,13 @@ function ImageView(props) {
2606
2607
  event.preventDefault();
2607
2608
  const direction = event.currentTarget.dataset.direction || "--";
2608
2609
  const initialXPosition = event.clientX;
2610
+ const initialYPosition = event.clientY;
2609
2611
  const currentWidth = imgRef.current.width;
2610
2612
  const currentHeight = imgRef.current.height;
2611
2613
  let newWidth = currentWidth;
2612
2614
  let newHeight = currentHeight;
2613
- const transform = direction[1] === "w" ? -1 : 1;
2615
+ const transformX = direction[1] === "w" ? -1 : 1;
2616
+ const transformY = direction[0] === "n" ? -1 : 1;
2614
2617
  const removeListeners = () => {
2615
2618
  window.removeEventListener("mousemove", mouseMoveHandler);
2616
2619
  window.removeEventListener("mouseup", removeListeners);
@@ -2620,13 +2623,22 @@ function ImageView(props) {
2620
2623
  };
2621
2624
  const mouseMoveHandler = (event2) => {
2622
2625
  newWidth = Math.max(
2623
- currentWidth + transform * (event2.clientX - initialXPosition),
2626
+ currentWidth + transformX * (event2.clientX - initialXPosition),
2627
+ MIN_WIDTH
2628
+ );
2629
+ newHeight = Math.max(
2630
+ currentHeight + transformY * (event2.clientY - initialYPosition),
2624
2631
  MIN_WIDTH
2625
2632
  );
2626
2633
  if (newWidth > imageParentWidth) {
2627
2634
  newWidth = imageParentWidth;
2628
2635
  }
2629
- newHeight = newWidth / currentWidth * currentHeight;
2636
+ if (newHeight > IMAGE_MAX_HEIGHT) {
2637
+ newHeight = IMAGE_MAX_HEIGHT;
2638
+ }
2639
+ if (node.attrs.lockAspectRatio) {
2640
+ newHeight = getNewHeight(newWidth, node.attrs.aspectRatio);
2641
+ }
2630
2642
  setResizingStyle({ width: newWidth, height: newHeight });
2631
2643
  if (!event2.buttons) {
2632
2644
  return removeListeners();
@@ -2851,8 +2863,11 @@ function ImageView(props) {
2851
2863
  ref: imgRef,
2852
2864
  style: __spreadProps(__spreadValues({}, resizingStyle), {
2853
2865
  cursor: "default",
2866
+ objectFit: "fill",
2854
2867
  marginBottom: 0,
2855
- borderRadius: borderRadius2
2868
+ borderRadius: borderRadius2,
2869
+ width: (resizingStyle == null ? void 0 : resizingStyle.width) ? `${resizingStyle.width}px` : width ? `${width}px` : "auto",
2870
+ height: (resizingStyle == null ? void 0 : resizingStyle.height) ? `${resizingStyle.height}px` : height ? `${height}px` : "auto"
2856
2871
  }),
2857
2872
  draggable: editor.isEditable,
2858
2873
  className: cn(
@@ -3102,6 +3117,7 @@ function LogoView(props) {
3102
3117
 
3103
3118
  // src/editor/nodes/logo/logo.ts
3104
3119
  var allowedLogoSize = ["sm", "md", "lg"];
3120
+ var allowedLogoAlignment = ["left", "center", "right"];
3105
3121
  var DEFAULT_ALIGNMENT = "left";
3106
3122
  var DEFAULT_LOGO_SIZE = "sm";
3107
3123
  var logoSizes = {
@@ -3235,7 +3251,10 @@ var import_tippy4 = require("tippy.js");
3235
3251
  var import_lucide_react11 = require("lucide-react");
3236
3252
  var import_jsx_runtime19 = require("react/jsx-runtime");
3237
3253
  function AlignmentSwitch(props) {
3238
- const { alignment = "left", onAlignmentChange } = props;
3254
+ const { alignment: rawAlignment, onAlignmentChange } = props;
3255
+ const alignment = allowedLogoAlignment.includes(
3256
+ rawAlignment
3257
+ ) ? rawAlignment : "left";
3239
3258
  const alignments = {
3240
3259
  left: {
3241
3260
  icon: import_lucide_react11.AlignLeft,
@@ -4666,7 +4685,7 @@ function LinkInputPopover(props) {
4666
4685
  variant: "ghost",
4667
4686
  size: "sm",
4668
4687
  type: "button",
4669
- className: "mly-size-7",
4688
+ className: "!mly-size-7",
4670
4689
  "data-state": !!defaultValue,
4671
4690
  children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Icon, { className: "mly-h-3 mly-w-3 mly-shrink-0 mly-stroke-[2.5] mly-text-midnight-gray" })
4672
4691
  }
@@ -4948,11 +4967,14 @@ function ImageBubbleMenu(props) {
4948
4967
  value: (_c = state == null ? void 0 : state.width) != null ? _c : "",
4949
4968
  onValueChange: (value) => {
4950
4969
  const width = Math.min(Number(value) || 0, IMAGE_MAX_WIDTH);
4970
+ const currentHeight = Number(state.height) || 0;
4971
+ const currentWidth = Number(state.width) || 0;
4972
+ const currentAspectRatio = state.aspectRatio || currentWidth / currentHeight || 1;
4951
4973
  editor == null ? void 0 : editor.chain().updateAttributes("image", __spreadValues({
4952
4974
  width: String(width)
4953
4975
  }, lockAspectRatio && value ? {
4954
4976
  height: String(
4955
- getNewHeight(width, state.aspectRatio)
4977
+ getNewHeight(width, currentAspectRatio)
4956
4978
  )
4957
4979
  } : {})).run();
4958
4980
  }
@@ -4965,11 +4987,14 @@ function ImageBubbleMenu(props) {
4965
4987
  value: (_d = state == null ? void 0 : state.height) != null ? _d : "",
4966
4988
  onValueChange: (value) => {
4967
4989
  const height = Number(value) || 0;
4990
+ const currentHeight = Number(state.height) || 0;
4991
+ const currentWidth = Number(state.width) || 0;
4992
+ const currentAspectRatio = state.aspectRatio || currentWidth / currentHeight || 1;
4968
4993
  editor == null ? void 0 : editor.chain().updateAttributes("image", __spreadValues({
4969
4994
  height: String(height)
4970
4995
  }, lockAspectRatio && value ? {
4971
4996
  width: String(
4972
- getNewWidth(height, state.aspectRatio)
4997
+ getNewWidth(height, currentAspectRatio)
4973
4998
  )
4974
4999
  } : {})).run();
4975
5000
  }
@@ -7304,8 +7329,10 @@ function HTMLCodeBlockView(props) {
7304
7329
  }, "");
7305
7330
  const htmlParser = new DOMParser();
7306
7331
  const htmlDoc = htmlParser.parseFromString(text2, "text/html");
7332
+ const style = htmlDoc.querySelectorAll("style");
7307
7333
  const body = htmlDoc.body;
7308
- return body.innerHTML;
7334
+ const combinedStyle = Array.from(style).map((s) => s.innerHTML).join("\n");
7335
+ return `<style>${combinedStyle}</style>${body.innerHTML}`;
7309
7336
  }, [activeTab]);
7310
7337
  const isEmpty = html2 === "";
7311
7338
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
@@ -7785,13 +7812,16 @@ function SlashCommandItem(props) {
7785
7812
  selectedCommandIndex,
7786
7813
  editor,
7787
7814
  activeCommandRef,
7788
- selectItem
7815
+ selectItem,
7816
+ hoveredItemKey,
7817
+ onHover
7789
7818
  } = props;
7790
7819
  const [open, setOpen] = (0, import_react55.useState)(false);
7791
- const [isHovered, setIsHovered] = (0, import_react55.useState)(false);
7792
7820
  const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
7793
- const isSubCommand = item && "commands" in item;
7794
- const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && (isActive || isHovered);
7821
+ const itemKey = `${groupIndex}-${commandIndex}`;
7822
+ const isHovered = hoveredItemKey === itemKey;
7823
+ const isSubCommand2 = item && "commands" in item;
7824
+ const shouldOpenTooltip = !!(item == null ? void 0 : item.preview) && (isHovered || isActive && !hoveredItemKey);
7795
7825
  const hasRenderFunction = typeof item.render === "function";
7796
7826
  const renderFunctionValue = hasRenderFunction ? (_a = item.render) == null ? void 0 : _a.call(item, editor) : null;
7797
7827
  let value = /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
@@ -7800,7 +7830,7 @@ function SlashCommandItem(props) {
7800
7830
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("p", { className: "mly-font-medium", children: item.title }),
7801
7831
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
7802
7832
  ] }),
7803
- isSubCommand && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_lucide_react28.ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
7833
+ isSubCommand2 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "mly-block mly-px-1 mly-text-gray-400", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_lucide_react28.ChevronRightIcon, { className: "mly-size-3.5 mly-stroke-[2.5]" }) })
7804
7834
  ] });
7805
7835
  if (renderFunctionValue !== null && renderFunctionValue !== true) {
7806
7836
  value = renderFunctionValue;
@@ -7840,8 +7870,8 @@ function SlashCommandItem(props) {
7840
7870
  isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
7841
7871
  ),
7842
7872
  onClick: () => selectItem(groupIndex, commandIndex),
7843
- onMouseEnter: () => setIsHovered(true),
7844
- onMouseLeave: () => setIsHovered(false),
7873
+ onMouseEnter: () => onHover(true),
7874
+ onMouseLeave: () => onHover(false),
7845
7875
  type: "button",
7846
7876
  ref: isActive ? activeCommandRef : null,
7847
7877
  children: value
@@ -7869,12 +7899,94 @@ function SlashCommandItem(props) {
7869
7899
  ] }, `${groupIndex}-${commandIndex}`);
7870
7900
  }
7871
7901
 
7902
+ // src/editor/extensions/slash-command/slash-command-search.tsx
7903
+ function filterSlashCommands(options) {
7904
+ const { groups, query, editor } = options;
7905
+ const newGroups = [...groups];
7906
+ let searchQuery = query == null ? void 0 : query.toLowerCase();
7907
+ const subCommandMatch = searchQuery.match(/^([^.]+)\./);
7908
+ if (subCommandMatch) {
7909
+ const [match, subCommandId] = subCommandMatch;
7910
+ const subCommandGroup = findSubCommandGroup(groups, subCommandId);
7911
+ if (subCommandGroup) {
7912
+ const remainingSearch = searchQuery.slice(match.length);
7913
+ const filteredCommands = subCommandGroup.commands.filter(
7914
+ (item) => !remainingSearch || isCommandMatch(item, remainingSearch)
7915
+ );
7916
+ return filteredCommands.length ? [
7917
+ __spreadProps(__spreadValues({}, subCommandGroup), {
7918
+ commands: filteredCommands
7919
+ })
7920
+ ] : [];
7921
+ }
7922
+ }
7923
+ const filteredGroups = newGroups.map((group) => {
7924
+ return __spreadProps(__spreadValues({}, group), {
7925
+ commands: group.commands.flatMap(
7926
+ (item) => processCommand({ item, search: searchQuery, editor })
7927
+ )
7928
+ });
7929
+ }).filter((group) => group.commands.length > 0);
7930
+ return filteredGroups;
7931
+ }
7932
+ function findSubCommandGroup(groups, subCommandId) {
7933
+ return groups.flatMap((group) => group.commands).find(
7934
+ (item) => {
7935
+ var _a;
7936
+ return "commands" in item && ((_a = item.id) == null ? void 0 : _a.toLowerCase()) === subCommandId.toLowerCase();
7937
+ }
7938
+ );
7939
+ }
7940
+ function containsText(text2, search) {
7941
+ if (!text2) {
7942
+ return false;
7943
+ }
7944
+ return text2.toLowerCase().includes(search.toLowerCase());
7945
+ }
7946
+ function isCommandMatch(item, search) {
7947
+ var _a, _b;
7948
+ 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);
7949
+ }
7950
+ function isSubCommand(item) {
7951
+ return "commands" in item && Array.isArray(item.commands) && !!item.id;
7952
+ }
7953
+ function processCommand(options) {
7954
+ var _a, _b, _c, _d;
7955
+ const { item, search, editor } = options;
7956
+ const show = (_a = item == null ? void 0 : item.render) == null ? void 0 : _a.call(item, editor);
7957
+ if (show === null) {
7958
+ return [];
7959
+ }
7960
+ const isSearching = search.length > 0;
7961
+ if (isSubCommand(item)) {
7962
+ const navigableCommand = __spreadProps(__spreadValues({}, item), {
7963
+ command: (options2) => {
7964
+ const { editor: editor2, range } = options2;
7965
+ editor2.chain().focus().insertContentAt(range, `/${item.id}.`).run();
7966
+ }
7967
+ });
7968
+ const matched = isCommandMatch(navigableCommand, search);
7969
+ if (matched) {
7970
+ return [navigableCommand];
7971
+ }
7972
+ const hasMatchingCommands = (_c = (_b = navigableCommand == null ? void 0 : navigableCommand.commands) == null ? void 0 : _b.some(
7973
+ (command) => isCommandMatch(command, search)
7974
+ )) != null ? _c : false;
7975
+ if (!hasMatchingCommands) {
7976
+ return [];
7977
+ }
7978
+ return (_d = navigableCommand == null ? void 0 : navigableCommand.commands) != null ? _d : [];
7979
+ }
7980
+ return !isSearching || isCommandMatch(item, search) ? [item] : [];
7981
+ }
7982
+
7872
7983
  // src/editor/extensions/slash-command/slash-command-view.tsx
7873
7984
  var import_jsx_runtime54 = require("react/jsx-runtime");
7874
- var CommandList = (0, import_react57.forwardRef)(function CommandList2(props, ref) {
7985
+ var CommandList = (0, import_react57.forwardRef)((props, ref) => {
7875
7986
  const { items: groups, command, editor, range, query } = props;
7876
7987
  const [selectedGroupIndex, setSelectedGroupIndex] = (0, import_react57.useState)(0);
7877
7988
  const [selectedCommandIndex, setSelectedCommandIndex] = (0, import_react57.useState)(0);
7989
+ const [hoveredItemKey, setHoveredItemKey] = (0, import_react57.useState)(null);
7878
7990
  const prevQuery = (0, import_react57.useRef)("");
7879
7991
  const prevSelectedGroupIndex = (0, import_react57.useRef)(0);
7880
7992
  const prevSelectedCommandIndex = (0, import_react57.useRef)(0);
@@ -8004,7 +8116,10 @@ var CommandList = (0, import_react57.forwardRef)(function CommandList2(props, re
8004
8116
  prevSelectedCommandIndex.current = 0;
8005
8117
  };
8006
8118
  }, []);
8007
- return groups.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime54.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: [
8119
+ if (!groups || groups.length === 0) {
8120
+ return null;
8121
+ }
8122
+ return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime54.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: [
8008
8123
  /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
8009
8124
  "div",
8010
8125
  {
@@ -8023,6 +8138,7 @@ var CommandList = (0, import_react57.forwardRef)(function CommandList2(props, re
8023
8138
  }
8024
8139
  ),
8025
8140
  /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "mly-space-y-0.5 mly-p-1", children: group.commands.map((item, commandIndex) => {
8141
+ const itemKey = `${groupIndex}-${commandIndex}`;
8026
8142
  return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
8027
8143
  SlashCommandItem,
8028
8144
  {
@@ -8033,9 +8149,11 @@ var CommandList = (0, import_react57.forwardRef)(function CommandList2(props, re
8033
8149
  selectedCommandIndex,
8034
8150
  selectItem: () => selectItem(groupIndex, commandIndex),
8035
8151
  editor,
8036
- activeCommandRef
8152
+ activeCommandRef,
8153
+ hoveredItemKey,
8154
+ onHover: (isHovered) => setHoveredItemKey(isHovered ? itemKey : null)
8037
8155
  },
8038
- commandIndex
8156
+ itemKey
8039
8157
  );
8040
8158
  }) })
8041
8159
  ] }, groupIndex))
@@ -8055,77 +8173,12 @@ var CommandList = (0, import_react57.forwardRef)(function CommandList2(props, re
8055
8173
  "to select"
8056
8174
  ] })
8057
8175
  ] }) })
8058
- ] }) }) : null;
8176
+ ] }) });
8059
8177
  });
8060
8178
  function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
8061
8179
  return {
8062
8180
  items: ({ query, editor }) => {
8063
- var _a;
8064
- let newGroups = groups;
8065
- let search = query.toLowerCase();
8066
- const subCommandIds = newGroups.map((group) => {
8067
- return group.commands.filter((item) => "commands" in item).map((item) => item == null ? void 0 : item.id.toLowerCase());
8068
- }).flat().map((id) => `${id}.`);
8069
- const shouldEnterSubCommand = subCommandIds.some(
8070
- (id) => search.startsWith(id)
8071
- );
8072
- if (shouldEnterSubCommand) {
8073
- const subCommandId = subCommandIds.find((id) => search.startsWith(id));
8074
- const sanitizedSubCommandId = subCommandId == null ? void 0 : subCommandId.slice(0, -1);
8075
- const group = (_a = newGroups.find((group2) => {
8076
- return group2.commands.some(
8077
- // @ts-ignore
8078
- (item) => {
8079
- var _a2;
8080
- return ((_a2 = item == null ? void 0 : item.id) == null ? void 0 : _a2.toLowerCase()) === sanitizedSubCommandId;
8081
- }
8082
- );
8083
- })) == null ? void 0 : _a.commands.find(
8084
- // @ts-ignore
8085
- (item) => {
8086
- var _a2;
8087
- return ((_a2 = item == null ? void 0 : item.id) == null ? void 0 : _a2.toLowerCase()) === sanitizedSubCommandId;
8088
- }
8089
- );
8090
- if (!group) {
8091
- return groups;
8092
- }
8093
- search = search.replace(subCommandId || "", "");
8094
- newGroups = [
8095
- __spreadProps(__spreadValues({}, group), {
8096
- commands: (group == null ? void 0 : group.commands) || []
8097
- })
8098
- ];
8099
- }
8100
- const filteredGroups = newGroups.map((group) => {
8101
- return __spreadProps(__spreadValues({}, group), {
8102
- commands: group.commands.filter((item) => {
8103
- var _a2;
8104
- if (typeof query === "string" && query.length > 0) {
8105
- const show = (_a2 = item == null ? void 0 : item.render) == null ? void 0 : _a2.call(item, editor);
8106
- if (show === null) {
8107
- return false;
8108
- }
8109
- 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(
8110
- (term) => term.includes(search)
8111
- );
8112
- }
8113
- return true;
8114
- }).map((item) => {
8115
- const isSubCommandItem = "commands" in item;
8116
- if (isSubCommandItem) {
8117
- item = __spreadProps(__spreadValues({}, item), {
8118
- command: (options) => {
8119
- const { editor: editor2, range } = options;
8120
- editor2.chain().focus().insertContentAt(range, `/${item.id}.`).run();
8121
- }
8122
- });
8123
- }
8124
- return item;
8125
- })
8126
- });
8127
- }).filter((group) => group.commands.length > 0);
8128
- return filteredGroups;
8181
+ return filterSlashCommands({ query, editor, groups });
8129
8182
  },
8130
8183
  allow: ({ editor }) => {
8131
8184
  const isInsideHTMLCodeBlock = editor.isActive("htmlCodeBlock");
@@ -8608,7 +8661,7 @@ function TurnIntoBlock(props) {
8608
8661
  {
8609
8662
  onClick: option.onClick,
8610
8663
  variant: "ghost",
8611
- 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",
8664
+ 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",
8612
8665
  children: [
8613
8666
  /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(option.icon, { className: "mly-size-[15px] mly-shrink-0" }),
8614
8667
  option.label
@@ -8821,6 +8874,37 @@ function VariableBubbleMenu(props) {
8821
8874
  );
8822
8875
  }
8823
8876
 
8877
+ // src/editor/extensions/selection/selection.ts
8878
+ var import_core19 = require("@tiptap/core");
8879
+ var import_state8 = require("@tiptap/pm/state");
8880
+ var import_view = require("@tiptap/pm/view");
8881
+ var SelectionExtension = import_core19.Extension.create({
8882
+ name: "selection",
8883
+ addProseMirrorPlugins() {
8884
+ const { editor } = this;
8885
+ return [
8886
+ new import_state8.Plugin({
8887
+ key: new import_state8.PluginKey("selection"),
8888
+ props: {
8889
+ decorations(state) {
8890
+ if (state.selection.empty) {
8891
+ return null;
8892
+ }
8893
+ if (editor.isFocused === true) {
8894
+ return null;
8895
+ }
8896
+ return import_view.DecorationSet.create(state.doc, [
8897
+ import_view.Decoration.inline(state.selection.from, state.selection.to, {
8898
+ class: "selection mly-bg-blue-200 mly-inline mly-py-1"
8899
+ })
8900
+ ]);
8901
+ }
8902
+ }
8903
+ })
8904
+ ];
8905
+ }
8906
+ });
8907
+
8824
8908
  // src/editor/extensions/index.tsx
8825
8909
  function extensions(props) {
8826
8910
  const { blocks, extensions: extensions2 = [] } = props;
@@ -8834,7 +8918,8 @@ function extensions(props) {
8834
8918
  }),
8835
8919
  HTMLCodeBlockExtension,
8836
8920
  InlineImageExtension,
8837
- PlaceholderExtension
8921
+ PlaceholderExtension,
8922
+ SelectionExtension
8838
8923
  ].filter((ext) => {
8839
8924
  return !extensions2.some((e) => e.name === ext.name);
8840
8925
  });
@@ -8878,6 +8963,7 @@ function Editor13(props) {
8878
8963
  contentClassName = "",
8879
8964
  bodyClassName = "",
8880
8965
  hasMenuBar = true,
8966
+ hideContextMenu = false,
8881
8967
  spellCheck = false,
8882
8968
  autofocus = "end",
8883
8969
  immediatelyRender = false
@@ -8963,7 +9049,7 @@ function Editor13(props) {
8963
9049
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_react66.EditorContent, { editor }),
8964
9050
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SectionBubbleMenu, { editor, appendTo: menuContainerRef }),
8965
9051
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ColumnsBubbleMenu, { editor, appendTo: menuContainerRef }),
8966
- /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ContentMenu, { editor }),
9052
+ !hideContextMenu && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ContentMenu, { editor }),
8967
9053
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(VariableBubbleMenu, { editor, appendTo: menuContainerRef }),
8968
9054
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(RepeatBubbleMenu, { editor, appendTo: menuContainerRef }),
8969
9055
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(HTMLBubbleMenu, { editor, appendTo: menuContainerRef }),