From c7da1a004b67d9579fb33f85642d3c132f574333 Mon Sep 17 00:00:00 2001 From: caojia <1301869380@qq.com> Date: Sat, 10 Oct 2026 18:04:09 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E6=8B=96=E9=80=89=E6=96=87=E5=AD=97=20Ctrl+C=20=E5=81=B6?= =?UTF-8?q?=E5=8F=91=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bms-front/src/directive/common/textDragCopy.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bms-front/src/directive/common/textDragCopy.js b/bms-front/src/directive/common/textDragCopy.js index 00a55684..c451608d 100644 --- a/bms-front/src/directive/common/textDragCopy.js +++ b/bms-front/src/directive/common/textDragCopy.js @@ -250,10 +250,18 @@ function handleClick(event) { suppressClickRoot = null } +function handleFocusIn(event) { + if (!activeSelection) return + const target = event.target instanceof Element ? event.target : event.target?.parentElement + if (!target) return + + if (!activeSelection.context.el.contains(target) || target.closest(EDITABLE_SELECTOR)) { + clearSelection() + } +} + function handleCopy(event) { if (!activeSelection || dragging || !event.clipboardData) return - const target = event.target instanceof Element ? event.target : event.target?.parentElement - if (target?.closest(EDITABLE_SELECTOR)) return const text = selectedTextSegments().map(segment => segment.text).join('\n') if (!text) return @@ -268,6 +276,7 @@ function installListeners() { document.addEventListener('mouseup', handleMouseUp) document.addEventListener('dblclick', handleDoubleClick) document.addEventListener('click', handleClick, true) + document.addEventListener('focusin', handleFocusIn, true) document.addEventListener('copy', handleCopy, true) listenersInstalled = true } @@ -279,6 +288,7 @@ function removeListeners() { document.removeEventListener('mouseup', handleMouseUp) document.removeEventListener('dblclick', handleDoubleClick) document.removeEventListener('click', handleClick, true) + document.removeEventListener('focusin', handleFocusIn, true) document.removeEventListener('copy', handleCopy, true) listenersInstalled = false }