fix: Improve ranking of results in editor menus when filtering using command-score

This commit is contained in:
Tom Moor
2023-04-05 18:37:50 -04:00
parent 9a7ecd7403
commit 99e4b458df
3 changed files with 7 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
import commandScore from "command-score";
import { capitalize } from "lodash";
import { findParentNode } from "prosemirror-utils";
import * as React from "react";
@@ -397,10 +398,9 @@ function SuggestionsMenu<T extends MenuItem>(props: Props<T>) {
return filterExcessSeparators(
filtered.sort((item) => {
return searchInput &&
(item.title || "").toLowerCase().startsWith(searchInput)
? -1
: 1;
return searchInput && item.title
? commandScore(item.title, searchInput)
: 0;
})
);
}, [commands, props]);