mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-25 19:52:44 +01:00
implement keyboar shortcut search #1646
This commit is contained in:
parent
743d190369
commit
1157694c03
@ -1,6 +1,6 @@
|
||||
import React, { memo, Fragment, useEffect, useMemo, useCallback, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { PlusIcon, InlineAlert, UndoIcon, Paragraph, TakeActionIcon, IconButton, Button, DeleteIcon, AddIcon, Heading, Text, Dialog } from 'evergreen-ui';
|
||||
import { SearchInput, PlusIcon, InlineAlert, UndoIcon, Paragraph, TakeActionIcon, IconButton, Button, DeleteIcon, AddIcon, Heading, Text, Dialog } from 'evergreen-ui';
|
||||
import { FaMouse, FaPlus, FaStepForward, FaStepBackward } from 'react-icons/fa';
|
||||
import Mousetrap from 'mousetrap';
|
||||
import groupBy from 'lodash/groupBy';
|
||||
@ -511,8 +511,11 @@ const KeyboardShortcuts = memo(({
|
||||
}, [actionsMap, keyBindings, setKeyBindings]);
|
||||
|
||||
const [creatingBinding, setCreatingBinding] = useState();
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
|
||||
const categoriesWithActions = useMemo(() => Object.entries(groupBy(Object.entries(actionsMap), ([, { category }]) => category)), [actionsMap]);
|
||||
const actionEntries = useMemo(() => Object.entries(actionsMap).filter(([, { name }]) => !searchQuery || name.toLowerCase().includes(searchQuery.toLowerCase())), [actionsMap, searchQuery]);
|
||||
|
||||
const categoriesWithActions = useMemo(() => Object.entries(groupBy(actionEntries, ([, { category }]) => category)), [actionEntries]);
|
||||
|
||||
const onDeleteBindingClick = useCallback(({ action, keys }) => {
|
||||
// eslint-disable-next-line no-alert
|
||||
@ -558,6 +561,10 @@ const KeyboardShortcuts = memo(({
|
||||
return (
|
||||
<>
|
||||
<div style={{ color: 'black' }}>
|
||||
<div>
|
||||
<SearchInput value={searchQuery} onChange={(e) => setSearchQuery(e.target.value)} placeholder="Search" width="100%" />
|
||||
</div>
|
||||
|
||||
{categoriesWithActions.map(([category, actionsInCategory]) => (
|
||||
<div key={category}>
|
||||
{category !== 'undefined' && <Heading marginTop={30} marginBottom={14}>{category}</Heading>}
|
||||
|
Loading…
Reference in New Issue
Block a user