fix(editor): use the Tauri clipboard API for Cut and Copy#520
Merged
Conversation
Monaco's built-in Cut/Copy rely on document.execCommand, which returns false inside the WebView on some Linux setups (WebKitGTK 2.52 / Wayland), so both silently did nothing while Ctrl+C and Ctrl+X kept working. Paste was already worked around this way; this applies the same approach to Cut and Copy and extends the context-menu filter to hide all three built-ins instead of just the paste one. With no selection, the actions fall back to the current line to match Monaco's original behaviour.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Reviewed by step-3.7-flash · Input: 72K · Output: 4.6K · Cached: 149.1K |
Collaborator
|
It is working very good from my side, merging it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In the SQL editor's right-click menu, Cut and Copy silently do nothing — nothing reaches the clipboard, and Cut doesn't remove the text either. Ctrl+C and Ctrl+X work fine, so it's specific to the context-menu actions.
Reproduced on Kubuntu 26.04, Wayland, WebKitGTK 2.52.3.
Cause
Monaco's built-in Cut/Copy go through
document.execCommand, which fails inside the WebView on this setup. Confirmed directly in the devtools console with a selection active:This isn't a Tauri configuration issue — wry already calls
set_javascript_can_access_clipboard(true)on the WebKitGTK settings. It looks like a platform-level limitation, so working around it in the app is the practical option.The codebase already does exactly that for Paste:
SqlEditorWrapper.tsxregisters atauri.clipboardPasteaction using the plugin'sreadText, and filters the built-in out of the context menu, with the comment "doesn't work in Tauri". Cut and Copy just never got the same treatment.Fix
Same approach, applied symmetrically:
tauri.clipboardCut/tauri.clipboardCopyusingwriteTextNotes
_getMenuActions. That was already the case for Paste — this PR doesn't introduce the hack, it extends it — but worth knowing it could break on a Monaco upgrade.Tested on Kubuntu 26.04 / Wayland: Copy, Cut, Paste all work from the context menu, keyboard shortcuts still work, no duplicate entries in the menu.
npx tsc --noEmitpasses.