Skip to content

fix: clipboard copy-paste support on Linux and Windows#1268

Open
mgaldamez wants to merge 1 commit into
tw93:mainfrom
mgaldamez:fix/clipboard-linux-windows
Open

fix: clipboard copy-paste support on Linux and Windows#1268
mgaldamez wants to merge 1 commit into
tw93:mainfrom
mgaldamez:fix/clipboard-linux-windows

Conversation

@mgaldamez

Copy link
Copy Markdown
Contributor

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.rs already provides a native Edit menu with PredefinedMenuItem::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 equivalent document.execCommand calls and reading from the OS clipboard through the new tauri-plugin-clipboard-manager plugin for paste.

Changes

File Change
src-tauri/Cargo.toml / Cargo.lock Add tauri-plugin-clipboard-manager = "2.2.0"
src-tauri/src/lib.rs Register tauri_plugin_clipboard_manager::init() in the builder
src-tauri/capabilities/default.json Grant clipboard-manager:allow-read-text
src-tauri/src/inject/event.js Add a Ctrl+C / Ctrl+X / Ctrl+V / Ctrl+A bridge restricted to non-macOS
tests/unit/event-shortcuts.test.js Unit tests covering the bridge and macOS skip path

Verification

  • cargo check --manifest-path src-tauri/Cargo.toml: clean
  • npx vitest run tests/unit/event-shortcuts.test.js: 2/2 passing
  • End-to-end tested on Linux (WebKitGTK) via pnpm run dev:
    • Ctrl+C on selected page text copies to the OS clipboard
    • Ctrl+X cuts the selected text
    • Ctrl+A in a text input selects all
    • Ctrl+V pastes from the OS clipboard into the focused input
  • Existing Pake build pipeline (.deb / .AppImage / .msi) is unchanged: no new build-time options or flags were added.

Closes #1267

@rumwru rumwru left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kay This Is Great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants