Skip to content

fix(editor): use the Tauri clipboard API for Cut and Copy#520

Merged
debba merged 2 commits into
TabularisDB:mainfrom
gcapellib:fix/editor-copy-cut-clipboard
Jul 24, 2026
Merged

fix(editor): use the Tauri clipboard API for Cut and Copy#520
debba merged 2 commits into
TabularisDB:mainfrom
gcapellib:fix/editor-copy-cut-clipboard

Conversation

@gcapellib

Copy link
Copy Markdown
Contributor

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:

document.execCommand('copy')  // → false

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.tsx registers a tauri.clipboardPaste action using the plugin's readText, 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:

  • register tauri.clipboardCut / tauri.clipboardCopy using writeText
  • extend the context-menu filter to hide all three built-ins instead of only the paste one
  • with no selection, both fall back to the current line, matching Monaco's original behaviour

Notes

  • The menu filter still relies on Monaco's internal _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.
  • Only touches the SQL editor. The result grid has its own separate issues (no context menu, no click-and-drag selection) which I've left out of this PR.

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 --noEmit passes.

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.
@kilo-code-bot

kilo-code-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • src/components/ui/SqlEditorWrapper.tsx

Reviewed by step-3.7-flash · Input: 72K · Output: 4.6K · Cached: 149.1K

@debba

debba commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

It is working very good from my side, merging it

@debba
debba merged commit e4d98fd into TabularisDB:main Jul 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants