Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve command palette with fuzzy search #1727

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"dayjs": "^1.11.6",
"defu": "^6.1.2",
"dexie": "^3.2.3",
"fuzzaldrin-plus": "^0.6.0",
"html2canvas": "^1.4.1",
"idb": "^7.0.2",
"js-base64": "^3.7.5",
Expand Down
11 changes: 6 additions & 5 deletions src/content/commandPalette/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ import {
} from 'vue';
import browser from 'webextension-polyfill';
import cloneDeep from 'lodash.clonedeep';
import { filter } from 'fuzzaldrin-plus';
import workflowParameters from '@business/parameters';
import { sendMessage } from '@/utils/message';
import { debounce, parseJSON } from '@/utils/helper';
Expand Down Expand Up @@ -226,11 +227,11 @@ const paramsState = reactive({

const rootElement = inject('rootElement');

const workflows = computed(() =>
state.workflows.filter((workflow) =>
workflow.name.toLocaleLowerCase().includes(state.query.toLocaleLowerCase())
)
);
const workflows = computed(() => {
if (!state.query) return state.workflows;

return filter(state.workflows, state.query, { key: 'name' });
});

function getReadableShortcut(str) {
const list = {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4035,6 +4035,11 @@ functions-have-names@^1.2.3:
resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834"
integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==

fuzzaldrin-plus@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/fuzzaldrin-plus/-/fuzzaldrin-plus-0.6.0.tgz#832f6489fbe876769459599c914a670ec22947ee"
integrity sha512-srIDThJHkdp3aPwJpR/HNzYZCRJwm07b/igxseoHSB7qR8e/gQp4F6lMGknE3TQI1Aq14TiFf/wzrHOp9LY/EA==

gensync@^1.0.0-beta.2:
version "1.0.0-beta.2"
resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0"
Expand Down