编辑区右键菜单粘贴无效
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
- 在程序外部或内部复制任意文本
- 右击编辑区点击粘贴菜单项
- 没能粘贴出复制的内容
Expected behavior [A clear and concise description of what you expected to happen.] 能够把复制的内内容粘贴出来。
Screenshots [If applicable, add screenshots to help explain your problem.]
Device
- OS: Windows 10 LTSC 21H2
- Version: 19044.7417
- App Version: v2.6.11
Additional context Add any other context about the problem here.
Addressed by #266 (v2.6.14). The cause was the app's own context menu: it called preventDefault() before checking whether the click was inside the editor, and its full-screen overlay then sat on top of Monaco's native menu — so clicking Paste hit the overlay. The handler now returns early inside the editor and Monaco's own menu is no longer covered.
I can't verify the rest from macOS: Monaco's Paste goes through navigator.clipboard.readText(), and whether WebView2 permits that read is a Windows question. Could you try again on v2.6.14 or later and say whether Paste works now?
The menu half is fixed, in v2.6.14 rather than v2.7.0 (#266): Markpad's own context menu called preventDefault() before checking whether the click was inside the editor, and its full-viewport overlay then covered Monaco's native menu, so clicking Paste hit the overlay. The handler now returns early inside the editor. I still can't verify the clipboard half from macOS — Monaco's Paste goes through navigator.clipboard.readText(), and whether WebView2 allows that read is a Windows question. Could you retest and say whether Paste works now?
Fixed in #548, and this closed with it. @Bluewind0303 — the next release after 2.7.2 will have it; no need to retest a build, the cause turned out to be something that could be read off the source once we knew where to look.
Recording what it was, because the diagnosis went one layer deeper than the report and the first fix was wrong.
Two separate bugs wore the same symptom
The menu was covered. Markpad's own context menu called preventDefault()
before checking whether the click was inside the editor, and its full-viewport
overlay then sat on top of Monaco's native menu, so clicking Paste hit the
overlay. That was #266, in v2.6.14.
The clipboard was refused. With the menu no longer covered, Paste reached Monaco's own implementation, which reads the clipboard through the webview. Monaco decides whether to offer a Paste item by asking whether the API exists:
const supportsPaste = (typeof navigator.clipboard === 'undefined' || isFirefox)
? document.queryCommandSupported('paste') : true;
navigator.clipboard is an object in any Chromium-based webview, so the item
was drawn — the check is never for permission. WebView2 then refused the read,
readText() rejected, Monaco caught it two layers down and substituted an
empty string, and its if (clipboardText !== '') declined to paste. No error,
no message, nothing: exactly what you described.
Ctrl+V kept working the whole time because that one is bound to a command of Markpad's own that reads the clipboard through Rust rather than through the webview. Same menu, same document, two different clipboards.
The fix that did not work
wry leaves the webview's clipboard attribute off, which on Windows is what
stops the CLIPBOARD_READ permission handler from ever being registered.
Enabling it is the obvious fix, and the plumbing is intact all the way down.
Built it, ran it on Windows, right-clicked Paste: still nothing.
tauri-apps/tauri#12007 has been open since December 2024 on exactly this.
What shipped
Cut, copy and paste all go through Rust now, and the editor's context menu is drawn by Markpad rather than by Monaco — so the menu item and the keyboard shortcut run the same code, on every platform, with no webview permission involved. Verified by hand on Windows and macOS.
Thank you for the report, and for the version number: "v2.6.11" is what made it possible to tell the two bugs apart at all.