From 3565b5aec296c32eb9b8cdef7ffc74e6c5ae4e74 Mon Sep 17 00:00:00 2001 From: qiqi Date: Sun, 22 Nov 2026 20:50:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(canvas):=20=E6=8B=96=E5=85=A5=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=90=8E=E6=B8=85=E7=90=86=E6=AE=8B=E7=95=99=E6=89=8B?= =?UTF-8?q?=E5=8A=BF=E7=8A=B6=E6=80=81=EF=BC=88=E9=A6=96=E6=AC=A1=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E4=B8=8D=E5=86=8D=E8=A2=AB=E5=BD=93=E6=88=90=E6=94=B6?= =?UTF-8?q?=E5=B0=BE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/runtime-workbench-logic.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/runtime-workbench-logic.js b/src/runtime-workbench-logic.js index c3075cf..f4baa4b 100644 --- a/src/runtime-workbench-logic.js +++ b/src/runtime-workbench-logic.js @@ -887,6 +887,14 @@ commitCanvas(refs.nodes.concat(moved), refs.edges.concat(es), refs.groups.concat(gs)) } else { setSel([]) + // 拖入后清掉宿主的临时手势状态:原生拖放期间鼠标事件被浏览器吞掉, + // pointerup 可能没走到画布,refs.bodyDown/box 会残留 ⇒ 第一次点击节点被当成「收尾」。 + try { + refs.bodyDown = null; refs.groupDown = null; refs.drag = null; refs.box = null; refs.pan = null + const ae = document.activeElement + if (ae && typeof ae.blur === 'function') ae.blur() + if (window.getSelection) window.getSelection().removeAllRanges() + } catch (e) { /* ignore */ } setNotice({ type: 'ok', text: '✓ 已导入 ' + ns.length + ' 个节点 / ' + es.length + ' 条连线' }) commitCanvas(ns, es, gs) } @@ -1105,6 +1113,14 @@ commitCanvas(refs.nodes.concat([node]), undefined, undefined) // 插入后不选中:选中态下模板节点的变量输入框可编辑,点它就无法拖节点 setSel([]) + // 原生拖放期间浏览器的鼠标事件被吞掉,pointerup 不会走到画布: + // refs.bodyDown/box 等临时手势会残留,导致「第一次点节点」被当成收尾(点不动/选中文本)。 + try { + refs.bodyDown = null; refs.groupDown = null; refs.drag = null; refs.box = null; refs.pan = null + const ae = document.activeElement + if (ae && typeof ae.blur === 'function') ae.blur() + if (window.getSelection) window.getSelection().removeAllRanges() + } catch (e) { /* ignore */ } setNotice({ type: 'ok', text: (hasVars ? '已插入提示词模板:' : '已插入提示词:') + (obj.name || '') }) return } catch (err) { /* 非本应用拖入 */ }