mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? - Brand new hook APIs for registering shortcuts using tanstack hotkeys - Support for command menu injection when shortcut is added <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Centralized keyboard shortcuts system with per‑shortcut registration and per‑user enable/disable preferences stored locally * Added a "Copy results as Markdown" shortcut (Mod+Shift+M) * Shortcuts can be surfaced in the Command Menu with a visual shortcut badge for discoverability * **Documentation** * Legacy keyboard shortcut hooks marked as deprecated and documentation updated to point to the new shortcut API <!-- end of auto-generated comment: release notes by coderabbit.ai -->
21 lines
815 B
TypeScript
21 lines
815 B
TypeScript
import type { ShortcutId } from './registry'
|
|
import { useShortcutPreferences } from './state'
|
|
|
|
/**
|
|
* Reactive check for whether a shortcut is currently enabled for the user.
|
|
*
|
|
* Subscribes the calling component to the shortcut preferences query so it
|
|
* re-renders when the user toggles this shortcut in Account → Preferences.
|
|
*
|
|
* For one-off, non-reactive checks outside render (event handlers, module-level
|
|
* code), use the plain `isShortcutEnabled(id)` function from `./state` instead.
|
|
*
|
|
* @example
|
|
* const isEnabled = useIsShortcutEnabled(SHORTCUT_IDS.AI_ASSISTANT_TOGGLE)
|
|
* return <Tooltip>{isEnabled && <KeyboardShortcut keys={['Meta', 'I']} />}</Tooltip>
|
|
*/
|
|
export function useIsShortcutEnabled(id: ShortcutId): boolean {
|
|
const { disabled } = useShortcutPreferences()
|
|
return !disabled[id]
|
|
}
|