fix: clipboard copy-paste support on Linux and Windows#1268
Open
mgaldamez wants to merge 1 commit into
Open
Conversation
2 tasks
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.
Description
Resolves the limitation where keyboard shortcuts for clipboard operations (
Ctrl+C,Ctrl+X,Ctrl+V,Ctrl+A) did not work inside Pake webviews on Linux and Windows.On macOS,
src-tauri/src/app/menu.rsalready provides a nativeEditmenu withPredefinedMenuItem::copy/cut/paste/select_all, and the OS routes the accelerators to the focused webview. Linux and Windows have no such native menu, so the system never translated the accelerator and the webview never saw the event.This PR adds a small JS keyboard-event bridge in the injected bundle (
src-tauri/src/inject/event.js) that is gated to non-macOS platforms and intercepts the same accelerators, dispatching the equivalentdocument.execCommandcalls and reading from the OS clipboard through the newtauri-plugin-clipboard-managerplugin for paste.Changes
src-tauri/Cargo.toml/Cargo.locktauri-plugin-clipboard-manager = "2.2.0"src-tauri/src/lib.rstauri_plugin_clipboard_manager::init()in the buildersrc-tauri/capabilities/default.jsonclipboard-manager:allow-read-textsrc-tauri/src/inject/event.jsCtrl+C/Ctrl+X/Ctrl+V/Ctrl+Abridge restricted to non-macOStests/unit/event-shortcuts.test.jsVerification
cargo check --manifest-path src-tauri/Cargo.toml: cleannpx vitest run tests/unit/event-shortcuts.test.js: 2/2 passingpnpm run dev:Ctrl+Con selected page text copies to the OS clipboardCtrl+Xcuts the selected textCtrl+Ain a text input selects allCtrl+Vpastes from the OS clipboard into the focused input.deb/.AppImage/.msi) is unchanged: no new build-time options or flags were added.Closes #1267