@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/blocks/index.d.cts +1 -1
- package/dist/blocks/index.d.ts +1 -1
- package/dist/extensions/index.cjs +3177 -3133
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +4 -4
- package/dist/extensions/index.d.ts +4 -4
- package/dist/extensions/index.mjs +3216 -3172
- package/dist/extensions/index.mjs.map +1 -1
- package/dist/index.cjs +177 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +7 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +189 -105
- package/dist/index.mjs.map +1 -1
- package/package.json +32 -33
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 =
|
|
2120
|
-
var DEFAULT_SECTION_PADDING_RIGHT =
|
|
2121
|
-
var DEFAULT_SECTION_PADDING_BOTTOM =
|
|
2122
|
-
var DEFAULT_SECTION_PADDING_LEFT =
|
|
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
|
|
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 +
|
|
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
|
|
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
|
|
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,
|
|
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,
|
|
4997
|
+
getNewWidth(height, currentAspectRatio)
|
|
4973
4998
|
)
|
|
4974
4999
|
} : {})).run();
|
|
4975
5000
|
}
|
|
@@ -7787,13 +7812,16 @@ function SlashCommandItem(props) {
|
|
|
7787
7812
|
selectedCommandIndex,
|
|
7788
7813
|
editor,
|
|
7789
7814
|
activeCommandRef,
|
|
7790
|
-
selectItem
|
|
7815
|
+
selectItem,
|
|
7816
|
+
hoveredItemKey,
|
|
7817
|
+
onHover
|
|
7791
7818
|
} = props;
|
|
7792
7819
|
const [open, setOpen] = (0, import_react55.useState)(false);
|
|
7793
|
-
const [isHovered, setIsHovered] = (0, import_react55.useState)(false);
|
|
7794
7820
|
const isActive = groupIndex === selectedGroupIndex && commandIndex === selectedCommandIndex;
|
|
7795
|
-
const
|
|
7796
|
-
const
|
|
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);
|
|
7797
7825
|
const hasRenderFunction = typeof item.render === "function";
|
|
7798
7826
|
const renderFunctionValue = hasRenderFunction ? (_a = item.render) == null ? void 0 : _a.call(item, editor) : null;
|
|
7799
7827
|
let value = /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
@@ -7802,7 +7830,7 @@ function SlashCommandItem(props) {
|
|
|
7802
7830
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("p", { className: "mly-font-medium", children: item.title }),
|
|
7803
7831
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("p", { className: "mly-text-xs mly-text-gray-400", children: item.description })
|
|
7804
7832
|
] }),
|
|
7805
|
-
|
|
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]" }) })
|
|
7806
7834
|
] });
|
|
7807
7835
|
if (renderFunctionValue !== null && renderFunctionValue !== true) {
|
|
7808
7836
|
value = renderFunctionValue;
|
|
@@ -7842,8 +7870,8 @@ function SlashCommandItem(props) {
|
|
|
7842
7870
|
isActive ? "mly-bg-gray-100 mly-text-gray-900" : "mly-bg-transparent"
|
|
7843
7871
|
),
|
|
7844
7872
|
onClick: () => selectItem(groupIndex, commandIndex),
|
|
7845
|
-
onMouseEnter: () =>
|
|
7846
|
-
onMouseLeave: () =>
|
|
7873
|
+
onMouseEnter: () => onHover(true),
|
|
7874
|
+
onMouseLeave: () => onHover(false),
|
|
7847
7875
|
type: "button",
|
|
7848
7876
|
ref: isActive ? activeCommandRef : null,
|
|
7849
7877
|
children: value
|
|
@@ -7871,12 +7899,94 @@ function SlashCommandItem(props) {
|
|
|
7871
7899
|
] }, `${groupIndex}-${commandIndex}`);
|
|
7872
7900
|
}
|
|
7873
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
|
+
|
|
7874
7983
|
// src/editor/extensions/slash-command/slash-command-view.tsx
|
|
7875
7984
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
7876
|
-
var CommandList = (0, import_react57.forwardRef)(
|
|
7985
|
+
var CommandList = (0, import_react57.forwardRef)((props, ref) => {
|
|
7877
7986
|
const { items: groups, command, editor, range, query } = props;
|
|
7878
7987
|
const [selectedGroupIndex, setSelectedGroupIndex] = (0, import_react57.useState)(0);
|
|
7879
7988
|
const [selectedCommandIndex, setSelectedCommandIndex] = (0, import_react57.useState)(0);
|
|
7989
|
+
const [hoveredItemKey, setHoveredItemKey] = (0, import_react57.useState)(null);
|
|
7880
7990
|
const prevQuery = (0, import_react57.useRef)("");
|
|
7881
7991
|
const prevSelectedGroupIndex = (0, import_react57.useRef)(0);
|
|
7882
7992
|
const prevSelectedCommandIndex = (0, import_react57.useRef)(0);
|
|
@@ -8006,7 +8116,10 @@ var CommandList = (0, import_react57.forwardRef)(function CommandList2(props, re
|
|
|
8006
8116
|
prevSelectedCommandIndex.current = 0;
|
|
8007
8117
|
};
|
|
8008
8118
|
}, []);
|
|
8009
|
-
|
|
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: [
|
|
8010
8123
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
8011
8124
|
"div",
|
|
8012
8125
|
{
|
|
@@ -8025,6 +8138,7 @@ var CommandList = (0, import_react57.forwardRef)(function CommandList2(props, re
|
|
|
8025
8138
|
}
|
|
8026
8139
|
),
|
|
8027
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}`;
|
|
8028
8142
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
8029
8143
|
SlashCommandItem,
|
|
8030
8144
|
{
|
|
@@ -8035,9 +8149,11 @@ var CommandList = (0, import_react57.forwardRef)(function CommandList2(props, re
|
|
|
8035
8149
|
selectedCommandIndex,
|
|
8036
8150
|
selectItem: () => selectItem(groupIndex, commandIndex),
|
|
8037
8151
|
editor,
|
|
8038
|
-
activeCommandRef
|
|
8152
|
+
activeCommandRef,
|
|
8153
|
+
hoveredItemKey,
|
|
8154
|
+
onHover: (isHovered) => setHoveredItemKey(isHovered ? itemKey : null)
|
|
8039
8155
|
},
|
|
8040
|
-
|
|
8156
|
+
itemKey
|
|
8041
8157
|
);
|
|
8042
8158
|
}) })
|
|
8043
8159
|
] }, groupIndex))
|
|
@@ -8057,77 +8173,12 @@ var CommandList = (0, import_react57.forwardRef)(function CommandList2(props, re
|
|
|
8057
8173
|
"to select"
|
|
8058
8174
|
] })
|
|
8059
8175
|
] }) })
|
|
8060
|
-
] }) })
|
|
8176
|
+
] }) });
|
|
8061
8177
|
});
|
|
8062
8178
|
function getSlashCommandSuggestions(groups = DEFAULT_SLASH_COMMANDS) {
|
|
8063
8179
|
return {
|
|
8064
8180
|
items: ({ query, editor }) => {
|
|
8065
|
-
|
|
8066
|
-
let newGroups = groups;
|
|
8067
|
-
let search = query.toLowerCase();
|
|
8068
|
-
const subCommandIds = newGroups.map((group) => {
|
|
8069
|
-
return group.commands.filter((item) => "commands" in item).map((item) => item == null ? void 0 : item.id.toLowerCase());
|
|
8070
|
-
}).flat().map((id) => `${id}.`);
|
|
8071
|
-
const shouldEnterSubCommand = subCommandIds.some(
|
|
8072
|
-
(id) => search.startsWith(id)
|
|
8073
|
-
);
|
|
8074
|
-
if (shouldEnterSubCommand) {
|
|
8075
|
-
const subCommandId = subCommandIds.find((id) => search.startsWith(id));
|
|
8076
|
-
const sanitizedSubCommandId = subCommandId == null ? void 0 : subCommandId.slice(0, -1);
|
|
8077
|
-
const group = (_a = newGroups.find((group2) => {
|
|
8078
|
-
return group2.commands.some(
|
|
8079
|
-
// @ts-ignore
|
|
8080
|
-
(item) => {
|
|
8081
|
-
var _a2;
|
|
8082
|
-
return ((_a2 = item == null ? void 0 : item.id) == null ? void 0 : _a2.toLowerCase()) === sanitizedSubCommandId;
|
|
8083
|
-
}
|
|
8084
|
-
);
|
|
8085
|
-
})) == null ? void 0 : _a.commands.find(
|
|
8086
|
-
// @ts-ignore
|
|
8087
|
-
(item) => {
|
|
8088
|
-
var _a2;
|
|
8089
|
-
return ((_a2 = item == null ? void 0 : item.id) == null ? void 0 : _a2.toLowerCase()) === sanitizedSubCommandId;
|
|
8090
|
-
}
|
|
8091
|
-
);
|
|
8092
|
-
if (!group) {
|
|
8093
|
-
return groups;
|
|
8094
|
-
}
|
|
8095
|
-
search = search.replace(subCommandId || "", "");
|
|
8096
|
-
newGroups = [
|
|
8097
|
-
__spreadProps(__spreadValues({}, group), {
|
|
8098
|
-
commands: (group == null ? void 0 : group.commands) || []
|
|
8099
|
-
})
|
|
8100
|
-
];
|
|
8101
|
-
}
|
|
8102
|
-
const filteredGroups = newGroups.map((group) => {
|
|
8103
|
-
return __spreadProps(__spreadValues({}, group), {
|
|
8104
|
-
commands: group.commands.filter((item) => {
|
|
8105
|
-
var _a2;
|
|
8106
|
-
if (typeof query === "string" && query.length > 0) {
|
|
8107
|
-
const show = (_a2 = item == null ? void 0 : item.render) == null ? void 0 : _a2.call(item, editor);
|
|
8108
|
-
if (show === null) {
|
|
8109
|
-
return false;
|
|
8110
|
-
}
|
|
8111
|
-
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(
|
|
8112
|
-
(term) => term.includes(search)
|
|
8113
|
-
);
|
|
8114
|
-
}
|
|
8115
|
-
return true;
|
|
8116
|
-
}).map((item) => {
|
|
8117
|
-
const isSubCommandItem = "commands" in item;
|
|
8118
|
-
if (isSubCommandItem) {
|
|
8119
|
-
item = __spreadProps(__spreadValues({}, item), {
|
|
8120
|
-
command: (options) => {
|
|
8121
|
-
const { editor: editor2, range } = options;
|
|
8122
|
-
editor2.chain().focus().insertContentAt(range, `/${item.id}.`).run();
|
|
8123
|
-
}
|
|
8124
|
-
});
|
|
8125
|
-
}
|
|
8126
|
-
return item;
|
|
8127
|
-
})
|
|
8128
|
-
});
|
|
8129
|
-
}).filter((group) => group.commands.length > 0);
|
|
8130
|
-
return filteredGroups;
|
|
8181
|
+
return filterSlashCommands({ query, editor, groups });
|
|
8131
8182
|
},
|
|
8132
8183
|
allow: ({ editor }) => {
|
|
8133
8184
|
const isInsideHTMLCodeBlock = editor.isActive("htmlCodeBlock");
|
|
@@ -8610,7 +8661,7 @@ function TurnIntoBlock(props) {
|
|
|
8610
8661
|
{
|
|
8611
8662
|
onClick: option.onClick,
|
|
8612
8663
|
variant: "ghost",
|
|
8613
|
-
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",
|
|
8614
8665
|
children: [
|
|
8615
8666
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(option.icon, { className: "mly-size-[15px] mly-shrink-0" }),
|
|
8616
8667
|
option.label
|
|
@@ -8823,6 +8874,37 @@ function VariableBubbleMenu(props) {
|
|
|
8823
8874
|
);
|
|
8824
8875
|
}
|
|
8825
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
|
+
|
|
8826
8908
|
// src/editor/extensions/index.tsx
|
|
8827
8909
|
function extensions(props) {
|
|
8828
8910
|
const { blocks, extensions: extensions2 = [] } = props;
|
|
@@ -8836,7 +8918,8 @@ function extensions(props) {
|
|
|
8836
8918
|
}),
|
|
8837
8919
|
HTMLCodeBlockExtension,
|
|
8838
8920
|
InlineImageExtension,
|
|
8839
|
-
PlaceholderExtension
|
|
8921
|
+
PlaceholderExtension,
|
|
8922
|
+
SelectionExtension
|
|
8840
8923
|
].filter((ext) => {
|
|
8841
8924
|
return !extensions2.some((e) => e.name === ext.name);
|
|
8842
8925
|
});
|
|
@@ -8880,6 +8963,7 @@ function Editor13(props) {
|
|
|
8880
8963
|
contentClassName = "",
|
|
8881
8964
|
bodyClassName = "",
|
|
8882
8965
|
hasMenuBar = true,
|
|
8966
|
+
hideContextMenu = false,
|
|
8883
8967
|
spellCheck = false,
|
|
8884
8968
|
autofocus = "end",
|
|
8885
8969
|
immediatelyRender = false
|
|
@@ -8965,7 +9049,7 @@ function Editor13(props) {
|
|
|
8965
9049
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_react66.EditorContent, { editor }),
|
|
8966
9050
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SectionBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
8967
9051
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ColumnsBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
8968
|
-
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ContentMenu, { editor }),
|
|
9052
|
+
!hideContextMenu && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ContentMenu, { editor }),
|
|
8969
9053
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(VariableBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
8970
9054
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(RepeatBubbleMenu, { editor, appendTo: menuContainerRef }),
|
|
8971
9055
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(HTMLBubbleMenu, { editor, appendTo: menuContainerRef }),
|