fix(frontend): guard startup and loading shortcuts
This commit is contained in:
17 files changed
+420
-15
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user