From e7d8c8814d525d2f8d2bf6af992cdb7c9ec454a6 Mon Sep 17 00:00:00 2001 From: Xinrea Date: Sat, 1 Nov 2025 20:44:27 +0800 Subject: [PATCH] fix: shortcut key conflicts with input (#212) * fix: shortcut key conflicts with input * Update src/lib/components/VideoPreview.svelte Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --------- Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- src/lib/components/VideoPreview.svelte | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/components/VideoPreview.svelte b/src/lib/components/VideoPreview.svelte index c53f352..3d8963f 100644 --- a/src/lib/components/VideoPreview.svelte +++ b/src/lib/components/VideoPreview.svelte @@ -809,8 +809,16 @@ function handleKeydown(event: KeyboardEvent) { if (!show || !isVideoLoaded) return; - // 如果在输入框中,不处理某些快捷键 - const isInInput = (event.target as HTMLElement)?.tagName === "INPUT"; + const target = event.target as HTMLElement | null; + const tagName = target?.tagName; + + // 如果当前焦点位于可编辑元素内,则跳过快捷键处理 + const isInInput = + (!!tagName && ["INPUT", "TEXTAREA", "SELECT"].includes(tagName)) || + !!target?.isContentEditable || + !!target?.closest( + "input, textarea, select, [contenteditable='true'], [data-hotkey-block]" + ); switch (event.key) { case "【":