fix(node): 点画布强制退出提示词编辑(iwb:exit-edit 广播,兜 WebView2 不移焦)(v3.26.261)
This commit is contained in:
1 parent
9ecc14bff4
commit
7461004b21
7 files changed
+49
-6
No files matched your search
@@ -20,6 +20,13 @@
|
||||
|
||||
- 历史条目补录:该 tag 当时未在 CHANGELOG 记录(release-records 守卫要求 tag 与条目双向一致),内容按当时提交补一句占位说明。
|
||||
|
||||
## v3.26.261(2026-12-05)点画布强制退出提示词编辑(WebView2 不移焦的兜底)
|
||||
|
||||
- 260 只依赖 blur/focusout 复位编辑态,实测在 WebView2 上有时焦点根本不移走,提示词框仍是第一响应者:文本保持选中,⌘V/Ctrl+V 粘回原框,无法新建提示词节点
|
||||
- 画布在 pointerdown / mousedown 捕获阶段广播 `iwb:exit-edit`(携带被点元素);正在编辑的节点收到后主动 blur、收起选区、复位编辑态
|
||||
- 点在本节点内部(正文↔标题互切)不打断;点其它节点/面板/画布一律退出
|
||||
- 新增 `edit-exit` 诊断面包屑(设置 → 诊断可查),用来确认退出事件是否真的触发
|
||||
|
||||
## v3.26.260(2026-12-05)点画布即退出提示词编辑态(文本粘贴失效的真因)
|
||||
|
||||
- 症状:在提示词节点里编辑后点画布,节点仍停在编辑态、文本保持选中;此时 ⌘V/Ctrl+V 把文字粘回原框,无法新建提示词节点(切换到别的画布才恢复)
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.26.260",
|
||||
"version": "3.26.261",
|
||||
"description": "Browser-based node canvas image workbench",
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js && node scripts/copy-plugins.js",
|
||||
|
||||
Generated
+1
-1
@@ -2014,7 +2014,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.26.260"
|
||||
version = "3.26.261"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.26.260"
|
||||
version = "3.26.261"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.26.260",
|
||||
"version": "3.26.261",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
@@ -533,11 +533,23 @@
|
||||
* 文本保持选中高亮、节点停在编辑态,⌘V 于是把文字粘回那个框里
|
||||
* (用户看到的现象是「文本不能粘贴为提示词节点」)。这里统一兜底:
|
||||
* 点在 input/textarea/contenteditable 上照旧让字段自己接管,其它位置一律 blur。 */
|
||||
const isFieldEl = (n) => !!(n && n.tagName && (n.tagName === 'INPUT' || n.tagName === 'TEXTAREA' || n.tagName === 'SELECT' || n.isContentEditable))
|
||||
const exitEditing = (t) => {
|
||||
// 广播给所有正在编辑的节点:凡是「被点的目标不在自己节点内」的一律退出编辑态。
|
||||
// 不依赖 blur/focusout(WebView2 上实测有时根本不触发),事件里带 target 让节点自己判断。
|
||||
try { window.dispatchEvent(new CustomEvent('iwb:exit-edit', { detail: { target: t } })) } catch (e) { /* ignore */ }
|
||||
try {
|
||||
const C = global.IWBCrashLog
|
||||
if (C && typeof C.breadcrumb === 'function') C.breadcrumb('edit-exit', ((t && t.tagName) || '?') + '.' + String((t && t.className) || '').slice(0, 40) + ' active=' + String((document.activeElement && document.activeElement.tagName) || '?'))
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
const onDocPointerDown = (e) => {
|
||||
const t = e && e.target
|
||||
if (t && t.tagName && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.tagName === 'SELECT' || t.isContentEditable)) return
|
||||
if (isFieldEl(t)) return
|
||||
// 点在非输入控件上:广播退出编辑 + 主动 blur(WebView 有时不移走焦点)
|
||||
exitEditing(t)
|
||||
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()
|
||||
if (a && a !== t && isFieldEl(a) && 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) {
|
||||
@@ -576,6 +588,8 @@
|
||||
window.addEventListener('paste', onPaste)
|
||||
window.addEventListener('blur', onBlur)
|
||||
document.addEventListener('pointerdown', onDocPointerDown, true)
|
||||
// WebView2 兜底:个别版本只派发 mousedown(尤其窗口刚激活的第一次点击)
|
||||
document.addEventListener('mousedown', onDocPointerDown, true)
|
||||
return () => {
|
||||
rafSet.cancel()
|
||||
if (lifecycle) lifecycle.dispose()
|
||||
@@ -588,6 +602,7 @@
|
||||
window.removeEventListener('paste', onPaste)
|
||||
window.removeEventListener('blur', onBlur)
|
||||
document.removeEventListener('pointerdown', onDocPointerDown, true)
|
||||
document.removeEventListener('mousedown', onDocPointerDown, true)
|
||||
// 复制通道绑在 window 上(不在 lifecycle 里):卸载时必须显式摘掉,否则回到首页后
|
||||
// ⌘C 仍会拿已卸载那份 refs 去复制旧画布的选中节点。
|
||||
if (copyMod && copyMod.unbindCopy) copyMod.unbindCopy()
|
||||
|
||||
@@ -68,6 +68,27 @@ function NodeCard(props) {
|
||||
const [editingTitle, setEditingTitle] = useState(false)
|
||||
const [titleDraft, setTitleDraft] = useState('')
|
||||
const [editingBody, setEditingBody] = useState(false)
|
||||
/* 退出编辑(2026-12-05 用户实测):点画布/别的节点/侧栏要能退出,且不能依赖 blur ——
|
||||
* WebView2 上焦点有时根本不移走,文本会一直保持选中,⌘V 于是粘回原框。
|
||||
* 画布在 pointerdown 时广播 iwb:exit-edit(带 target),这里主动 blur + 收起选区。 */
|
||||
useEffect(() => {
|
||||
if (!editingBody && !editingTitle) return undefined
|
||||
const onExit = (e) => {
|
||||
const t = e && e.detail && e.detail.target
|
||||
if (t && elRef.el && elRef.el.contains(t)) return // 点在本节点内(正文↔标题互切)不打断
|
||||
const fields = elRef.el ? elRef.el.querySelectorAll('textarea, input') : []
|
||||
for (let i = 0; i < fields.length; i++) {
|
||||
const f = fields[i]
|
||||
try { if (typeof f.blur === 'function') f.blur() } catch (err) { /* ignore */ }
|
||||
try { const p = f.selectionEnd; if (p != null && typeof f.setSelectionRange === 'function') f.setSelectionRange(p, p) } catch (err) { /* ignore */ }
|
||||
}
|
||||
try { if (typeof window !== 'undefined' && window.getSelection) window.getSelection().removeAllRanges() } catch (err) { /* ignore */ }
|
||||
setEditingBody(false)
|
||||
setEditingTitle(false)
|
||||
}
|
||||
window.addEventListener('iwb:exit-edit', onExit)
|
||||
return () => window.removeEventListener('iwb:exit-edit', onExit)
|
||||
}, [editingBody, editingTitle])
|
||||
const bodyFreezeRef = React.useRef(null) // v3.87.16:缩放期间冻结节点体用
|
||||
// 从剪贴板粘贴图片替换(按钮方式:navigator.clipboard.read)
|
||||
const pasteFromClipboard = () => {
|
||||
|
||||
Reference in new issue
Block a user