mirror of
https://github.com/langgenius/dify.git
synced 2026-07-21 10:38:32 +08:00
20 lines
772 B
TypeScript
20 lines
772 B
TypeScript
import type { Hotkey } from '@tanstack/react-hotkeys'
|
|
import { matchesKeyboardEvent } from '@tanstack/react-hotkeys'
|
|
import { WORKFLOW_CANVAS_SHORTCUTS } from './shortcuts/definitions'
|
|
|
|
export const TEST_RUN_MENU_HOTKEY = 'Alt+R' satisfies Hotkey
|
|
export const VERSION_HISTORY_HOTKEY = 'Mod+Shift+H' satisfies Hotkey
|
|
|
|
const WORKFLOW_BROWSER_DEFAULT_GUARD_HOTKEYS = [
|
|
...WORKFLOW_CANVAS_SHORTCUTS['workflow.duplicate'].hotkeys,
|
|
...WORKFLOW_CANVAS_SHORTCUTS['workflow.undo'].hotkeys,
|
|
...WORKFLOW_CANVAS_SHORTCUTS['workflow.redo'].hotkeys,
|
|
'Mod+S',
|
|
] satisfies readonly Hotkey[]
|
|
|
|
export function shouldPreventWorkflowBrowserDefault(event: KeyboardEvent) {
|
|
return WORKFLOW_BROWSER_DEFAULT_GUARD_HOTKEYS.some((hotkey) =>
|
|
matchesKeyboardEvent(event, hotkey),
|
|
)
|
|
}
|