fix(clipboard): mac ⌘C/⌘V 一条命令贴一切(copy 事件主通道 + keydown 主动粘贴)
mac 的 WKWebView 只在第一响应者可编辑时派发 paste 事件;Menu::default() 的 Edit>Copy/Paste 又永远 enabled,所以「焦点在输入框/有选区」时 keydown 到不了 JS —— 复制节点组静默失败、 ⌘V 只剩一句「请按 Ctrl+Shift+V」。本次把两条通道都换掉: - 复制:DOM copy 事件里同步 clipboardData.setData(text/html 带标记 + text/plain 摘要), keydown 留 80ms 兜底,Workbench 卸载时摘监听(否则回首页 ⌘C 会复制旧画布)。 - 粘贴:⌘V keydown 主动粘贴,指针在画布即接管,逐级降级(系统剪贴板富读取 → 原生文本 → 原生图片 → 应用内剪贴板);150ms 内等到 paste 事件就让给事件通道,一次按键只贴一份。 - 输入框内:指针在画布 → 改贴画布;只有「N 个节点」摘要 → 拦下不进输入框; 带提示词全文 → 放行原生。 - 标记双写注释 + data-iwb-graph 属性(WKWebView 会剥注释);decode 两处都找。 - 未选中节点复制、复制/粘贴失败都有提示;notice 的 err/info 5.2s 自动消失。 门禁:clipboard-graph 56 项 / clipboard-paste 100 项,e2e 用例 5、19 按新语义更新 (e2e 已知红与基线一致:7 条,均为无头环境剪贴板限制)。
This commit is contained in:
1 parent
9c27a8178b
commit
18eaeb96f2
11 files changed
+573
-131
No files matched your search
@@ -56,9 +56,18 @@
|
||||
* 返回:notice / setNotice / toast / setToast / showToast
|
||||
*/
|
||||
function useNotifications (opts) {
|
||||
const [notice, setNotice] = useState(null)
|
||||
const [notice, setNoticeState] = useState(null)
|
||||
const [toast, setToast] = useState(null)
|
||||
const toastTimer = useRef(null)
|
||||
const noticeTimer = useRef(null)
|
||||
/* 错误/进行中提示 5.2s 自动收(2026-11-26)。
|
||||
* 旧行为只有 toast 会消失,notice 会一直挂在状态栏 —— 粘贴失败那句"剪贴板里没有可粘贴的内容"
|
||||
* 粘在顶部不动,用户过一会儿再看会以为功能坏了。成功提示(ok)保持常驻,它是"最后一次操作结果"。 */
|
||||
const setNotice = (n) => {
|
||||
clearTimeout(noticeTimer.current)
|
||||
setNoticeState(n)
|
||||
if (n && n.type && n.type !== 'ok') noticeTimer.current = setTimeout(() => setNoticeState(null), 5200)
|
||||
}
|
||||
const showToast = (text, type) => {
|
||||
clearTimeout(toastTimer.current)
|
||||
setToast({ text, type: type || 'ok' })
|
||||
|
||||
Reference in new issue
Block a user