@haklex/rich-plugin-slash-menu 0.32.0 → 0.33.0
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 +17 -14
- package/package.json +21 -21
package/dist/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { collectCommandItems } from "@haklex/rich-editor/commands";
|
|
|
13
13
|
import { PortalThemeWrapper } from "@haklex/rich-style-token";
|
|
14
14
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
15
15
|
import { createPortal } from "react-dom";
|
|
16
|
-
//#region \0@oxc-project+runtime@0.
|
|
16
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/typeof.js
|
|
17
17
|
function _typeof(o) {
|
|
18
18
|
"@babel/helpers - typeof";
|
|
19
19
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -23,7 +23,7 @@ function _typeof(o) {
|
|
|
23
23
|
}, _typeof(o);
|
|
24
24
|
}
|
|
25
25
|
//#endregion
|
|
26
|
-
//#region \0@oxc-project+runtime@0.
|
|
26
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPrimitive.js
|
|
27
27
|
function toPrimitive(t, r) {
|
|
28
28
|
if ("object" != _typeof(t) || !t) return t;
|
|
29
29
|
var e = t[Symbol.toPrimitive];
|
|
@@ -35,13 +35,13 @@ function toPrimitive(t, r) {
|
|
|
35
35
|
return ("string" === r ? String : Number)(t);
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
|
-
//#region \0@oxc-project+runtime@0.
|
|
38
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPropertyKey.js
|
|
39
39
|
function toPropertyKey(t) {
|
|
40
40
|
var i = toPrimitive(t, "string");
|
|
41
41
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
|
-
//#region \0@oxc-project+runtime@0.
|
|
44
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/defineProperty.js
|
|
45
45
|
function _defineProperty(e, r, t) {
|
|
46
46
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
47
47
|
value: t,
|
|
@@ -363,9 +363,20 @@ function SlashMenuPlugin({ items, extraItems, triggerChar = "/" }) {
|
|
|
363
363
|
editor
|
|
364
364
|
]);
|
|
365
365
|
const filteredItems = useMemo(() => filterItems(queryString ?? "", allItems), [queryString, allItems]);
|
|
366
|
+
const checkForTriggerMatch = useBasicTypeaheadTriggerMatch(triggerChar, { minLength: 0 });
|
|
367
|
+
const onSelectOption = useCallback((option, textNodeContainingQuery, closeMenu, matchingString) => {
|
|
368
|
+
editor.update(() => {
|
|
369
|
+
if (textNodeContainingQuery) {
|
|
370
|
+
const selection = $getSelection();
|
|
371
|
+
if ($isRangeSelection(selection)) textNodeContainingQuery.remove();
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
closeMenu();
|
|
375
|
+
option.onSelect(editor, matchingString);
|
|
376
|
+
}, [editor]);
|
|
366
377
|
return /* @__PURE__ */ jsx(LexicalTypeaheadMenuPlugin, {
|
|
367
378
|
options: filteredItems,
|
|
368
|
-
triggerFn:
|
|
379
|
+
triggerFn: checkForTriggerMatch,
|
|
369
380
|
menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
|
370
381
|
const anchorElement = anchorElementRef.current;
|
|
371
382
|
if (!anchorElement || filteredItems.length === 0) return null;
|
|
@@ -378,15 +389,7 @@ function SlashMenuPlugin({ items, extraItems, triggerChar = "/" }) {
|
|
|
378
389
|
}) }), anchorElement);
|
|
379
390
|
},
|
|
380
391
|
onQueryChange: setQueryString,
|
|
381
|
-
onSelectOption
|
|
382
|
-
editor.update(() => {
|
|
383
|
-
if (textNodeContainingQuery) {
|
|
384
|
-
if ($isRangeSelection($getSelection())) textNodeContainingQuery.remove();
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
closeMenu();
|
|
388
|
-
option.onSelect(editor, matchingString);
|
|
389
|
-
}, [editor])
|
|
392
|
+
onSelectOption
|
|
390
393
|
});
|
|
391
394
|
}
|
|
392
395
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-plugin-slash-menu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Slash command menu plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,35 +24,35 @@
|
|
|
24
24
|
"@floating-ui/react-dom": "^2.1.9"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@lexical/list": "^0.
|
|
28
|
-
"@lexical/react": "^0.
|
|
29
|
-
"@lexical/rich-text": "^0.
|
|
30
|
-
"@lexical/selection": "^0.
|
|
31
|
-
"@lexical/table": "^0.
|
|
32
|
-
"@types/react": "^19.2.
|
|
33
|
-
"@types/react-dom": "^19.2.
|
|
34
|
-
"@vanilla-extract/css": "^1.21.
|
|
35
|
-
"@vanilla-extract/vite-plugin": "^5.2.
|
|
36
|
-
"lexical": "^0.
|
|
37
|
-
"lucide-react": "^1.
|
|
27
|
+
"@lexical/list": "^0.49.0",
|
|
28
|
+
"@lexical/react": "^0.49.0",
|
|
29
|
+
"@lexical/rich-text": "^0.49.0",
|
|
30
|
+
"@lexical/selection": "^0.49.0",
|
|
31
|
+
"@lexical/table": "^0.49.0",
|
|
32
|
+
"@types/react": "^19.2.18",
|
|
33
|
+
"@types/react-dom": "^19.2.4",
|
|
34
|
+
"@vanilla-extract/css": "^1.21.2",
|
|
35
|
+
"@vanilla-extract/vite-plugin": "^5.2.6",
|
|
36
|
+
"lexical": "^0.49.0",
|
|
37
|
+
"lucide-react": "^1.28.0",
|
|
38
38
|
"react": "^19.2.8",
|
|
39
39
|
"react-dom": "^19.2.8",
|
|
40
40
|
"typescript": "^7.0.2",
|
|
41
41
|
"unplugin-dts": "^1.0.3",
|
|
42
|
-
"vite": "^8.
|
|
42
|
+
"vite": "^8.2.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@lexical/list": "^0.
|
|
46
|
-
"@lexical/react": "^0.
|
|
47
|
-
"@lexical/rich-text": "^0.
|
|
48
|
-
"@lexical/selection": "^0.
|
|
49
|
-
"@lexical/table": "^0.
|
|
50
|
-
"lexical": "^0.
|
|
45
|
+
"@lexical/list": "^0.49.0",
|
|
46
|
+
"@lexical/react": "^0.49.0",
|
|
47
|
+
"@lexical/rich-text": "^0.49.0",
|
|
48
|
+
"@lexical/selection": "^0.49.0",
|
|
49
|
+
"@lexical/table": "^0.49.0",
|
|
50
|
+
"lexical": "^0.49.0",
|
|
51
51
|
"lucide-react": "^1.0.0",
|
|
52
52
|
"react": ">=19",
|
|
53
53
|
"react-dom": ">=19",
|
|
54
|
-
"@haklex/rich-
|
|
55
|
-
"@haklex/rich-
|
|
54
|
+
"@haklex/rich-editor": "^0.33.0",
|
|
55
|
+
"@haklex/rich-style-token": "^0.33.0"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|