diff --git a/frontend/src/components/CommandPalette.jsx b/frontend/src/components/CommandPalette.jsx index 10d8001..24ea182 100644 --- a/frontend/src/components/CommandPalette.jsx +++ b/frontend/src/components/CommandPalette.jsx @@ -17,6 +17,9 @@ import { * Command Palette - глобальный поиск по командам (Ctrl+K) * Простой подход со встроенным backdrop (как в HistoryModal) */ +// Создаем контекст для управления открытием/закрытием Command Palette +const CommandPaletteContext = { open: null }; + function CommandPalette() { const [isOpen, setIsOpen] = useState(false) const [searchTerm, setSearchTerm] = useState('') @@ -24,6 +27,14 @@ function CommandPalette() { const navigate = useNavigate() const inputRef = useRef(null) + // Сохраняем функцию открытия в контекст + useEffect(() => { + CommandPaletteContext.open = () => setIsOpen(true); + return () => { + CommandPaletteContext.open = null; + }; + }, []) + // Список команд const commands = [ { icon: IconHome, label: 'Главная', description: 'Панель управления', action: () => navigate('/dashboard'), keywords: ['главная', 'панель', 'dashboard'] }, @@ -185,4 +196,27 @@ function CommandPalette() { ) } +/** + * Кнопка для открытия Command Palette через клик + */ +export function KeyboardShortcutsButton({ className = '' }) { + const handleClick = (e) => { + e.preventDefault(); + if (CommandPaletteContext.open) { + CommandPaletteContext.open(); + } + }; + + return ( + + + + ); +} + export default CommandPalette