fix(node): 点画布即退出提示词编辑态,文本粘贴不再粘回原框(v3.26.260)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m39s
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m39s
This commit is contained in:
1 parent
2c694d180f
commit
9ecc14bff4
7 files changed
+36
-4
No files matched your search
@@ -528,6 +528,17 @@
|
||||
if (hit('rename')) { const rn = sel.length === 1 ? refs.nodes.find((x) => x.id === sel[0]) : null; if (rn) { e.preventDefault(); wRenameNodeDialog(rn, td, updateNode) } return } // F2 改名(第 3 入口,与气泡铅笔/右键菜单同一实现);仅单选生效,多选有歧义不猜
|
||||
}
|
||||
const onBlur = () => { refs.drag = null; refs.bodyDown = null; refs.groupDown = null; refs.resize = null; refs.groupResize = null; refs.groupPadLive = null; refs.connFrom = null; refs.pan = null; refs.box = null; refs.spaceDown = false; refs.edgeHover = null; refs.edgeHoverKey = null; refs.altDown = false; setEdgeHover(null); setConn(null); setConnTarget(null); setBoxSel(null) }
|
||||
/* 点非输入控件 → 主动把焦点从输入框里挪走(2026-12-05 用户实测)。
|
||||
* WebView 在部分情况下点画布/别的节点不会移走焦点:提示词框仍是第一响应者,
|
||||
* 文本保持选中高亮、节点停在编辑态,⌘V 于是把文字粘回那个框里
|
||||
* (用户看到的现象是「文本不能粘贴为提示词节点」)。这里统一兜底:
|
||||
* 点在 input/textarea/contenteditable 上照旧让字段自己接管,其它位置一律 blur。 */
|
||||
const onDocPointerDown = (e) => {
|
||||
const t = e && e.target
|
||||
if (t && t.tagName && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.tagName === 'SELECT' || t.isContentEditable)) return
|
||||
const a = (typeof document !== 'undefined') ? document.activeElement : null
|
||||
if (a && a !== t && a.tagName && (a.tagName === 'INPUT' || a.tagName === 'TEXTAREA' || a.isContentEditable) && typeof a.blur === 'function') a.blur()
|
||||
}
|
||||
const lifecycle = RuntimeLifecycle && typeof RuntimeLifecycle.addDisposer === 'function' && typeof window !== 'undefined' && typeof window.IWBRuntimeLifecycleFactory === 'function' ? window.IWBRuntimeLifecycleFactory() : null
|
||||
if (lifecycle) {
|
||||
lifecycle.addEvent(window, 'pointermove', onMove)
|
||||
@@ -564,6 +575,7 @@
|
||||
if (copyMod && copyMod.bindCopy) copyMod.bindCopy(pasteCtx)
|
||||
window.addEventListener('paste', onPaste)
|
||||
window.addEventListener('blur', onBlur)
|
||||
document.addEventListener('pointerdown', onDocPointerDown, true)
|
||||
return () => {
|
||||
rafSet.cancel()
|
||||
if (lifecycle) lifecycle.dispose()
|
||||
@@ -575,6 +587,7 @@
|
||||
window.removeEventListener('keyup', onKeyUp)
|
||||
window.removeEventListener('paste', onPaste)
|
||||
window.removeEventListener('blur', onBlur)
|
||||
document.removeEventListener('pointerdown', onDocPointerDown, true)
|
||||
// 复制通道绑在 window 上(不在 lifecycle 里):卸载时必须显式摘掉,否则回到首页后
|
||||
// ⌘C 仍会拿已卸载那份 refs 去复制旧画布的选中节点。
|
||||
if (copyMod && copyMod.unbindCopy) copyMod.unbindCopy()
|
||||
|
||||
@@ -266,6 +266,16 @@ function NodeCard(props) {
|
||||
title: connInfo && !connInfo.valid ? connInfo.reason : undefined,
|
||||
style: { transform: 'translate(' + node.x + 'px, ' + node.y + 'px)', width: w, background: (bgHexOf(node) || undefined), '--iwb-node-color': (bgHexOf(node) || undefined), minHeight: (node.type === 'gen' && node.data && node.data.collapsed) ? 56 : (node.h || (node.type === 'out' ? NODE_H.out : 56)), height: 'auto', borderTopColor: 'color-mix(in srgb, ' + color + ' 70%, transparent)', left: 0, top: 0 },
|
||||
ref: (el0) => { elRef.el = el0 },
|
||||
onBlur: (e) => {
|
||||
/* 焦点离开整个节点(点画布 / 别的节点 / 侧栏/面板)→ 退出编辑态。
|
||||
* 2026-12-05(用户实测):以前 editingBody 只在双击进入、从不复位,提示词框一直
|
||||
* 保持可编辑且文本选中;⌘V 于是粘回原框,看起来「文本不能粘贴为提示词节点」。
|
||||
* relatedTarget 还在本节点里(比如从正文切到标题输入)就不算离开。 */
|
||||
const to = e && e.relatedTarget
|
||||
if (to && elRef.el && elRef.el.contains(to)) return
|
||||
if (editingBody) setEditingBody(false)
|
||||
if (editingTitle) setEditingTitle(false)
|
||||
},
|
||||
onPointerDown: (e) => {
|
||||
if (e.button !== 0) return
|
||||
e.stopPropagation()
|
||||
|
||||
Reference in new issue
Block a user