Route terminal clipboard through tauri-plugin-clipboard-manager; bump to 0.2.3
navigator.clipboard.readText() triggers WebView2's "Allow clipboard access?"
permission prompt on every paste. The plugin goes through IPC + the OS
clipboard directly, so the prompt never fires.
Wired the Rust plugin, granted clipboard-manager:allow-{read,write}-text in
the capabilities manifest, swapped XtermPane's copy/paste handler to use
the plugin's readText/writeText.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e94d2499d1
commit
29b15f19c1
7 changed files with 29 additions and 9 deletions
|
|
@ -2,6 +2,10 @@ import { useRef, useEffect } from "react";
|
|||
import { Terminal } from "@xterm/xterm";
|
||||
import { FitAddon } from "@xterm/addon-fit";
|
||||
import type { UnlistenFn } from "@tauri-apps/api/event";
|
||||
import {
|
||||
readText as clipboardReadText,
|
||||
writeText as clipboardWriteText,
|
||||
} from "@tauri-apps/plugin-clipboard-manager";
|
||||
import {
|
||||
spawnPane,
|
||||
writeToPane,
|
||||
|
|
@ -174,23 +178,25 @@ export default function XtermPane({
|
|||
// Ctrl+V (which would otherwise inject ^V into the PTY). term.paste()
|
||||
// routes through onData → writeToPane, so broadcasting and bracketed
|
||||
// paste both keep working for free.
|
||||
//
|
||||
// Uses tauri-plugin-clipboard-manager instead of navigator.clipboard so
|
||||
// WebView2 doesn't surface its native "Allow clipboard access?" prompt.
|
||||
term?.attachCustomKeyEventHandler((e) => {
|
||||
if (e.type !== "keydown") return true;
|
||||
if (!e.ctrlKey || !e.shiftKey || e.altKey) return true;
|
||||
if (e.code === "KeyC") {
|
||||
const sel = term?.getSelection();
|
||||
if (sel) {
|
||||
void navigator.clipboard
|
||||
.writeText(sel)
|
||||
.catch((err) => console.warn("clipboard write failed:", err));
|
||||
void clipboardWriteText(sel).catch((err) =>
|
||||
console.warn("clipboard write failed:", err),
|
||||
);
|
||||
}
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
if (e.code === "KeyV") {
|
||||
e.preventDefault();
|
||||
navigator.clipboard
|
||||
.readText()
|
||||
clipboardReadText()
|
||||
.then((text) => {
|
||||
if (text && term) term.paste(text);
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue