fix(frontend): guard startup and loading shortcuts

This commit is contained in:
zipg authored and GitHub committed 2026-08-03 16:57:26 +08:00
1 parent 246dfad018
commit 658e3d16ad
17 files changed
+420 -15

No files matched your search

+5
View File
@@ -58,6 +58,7 @@ interface NativeClipboardSelectionEnvironment {
const EDITABLE_CLIPBOARD_TARGET_SELECTOR = "input, textarea, [contenteditable='true'], [role='textbox']";
const NATIVE_CLIPBOARD_REGION_SELECTOR = "[data-native-clipboard]";
const DATA_GRID_ROOT_SELECTOR = "[data-grid-root]";
let clipboardWriteRevision = 0;
export function getClipboardWriteRevision(): number {
@@ -86,6 +87,10 @@ export function isPlainClipboardShortcut(event: ClipboardShortcutEvent, key: str
return !!(event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey && event.key.toLowerCase() === key;
}
export function shouldBlockAppNativeSelectAll(event: ClipboardShortcutEvent): boolean {
return isPlainClipboardShortcut(event, "a") && !eventTargetUsesNativeClipboard(event) && !closestElement(event.target, DATA_GRID_ROOT_SELECTOR);
}
export function hasNativeClipboardSelection(env: NativeClipboardSelectionEnvironment = globalThis as unknown as NativeClipboardSelectionEnvironment): boolean {
const selection = env.getSelection?.();
if (!selection || selection.isCollapsed) return false;