Portapapeles
Lee y escribe en el portapapeles del sistema utilizando el plugin de portapapeles.
This plugin requires a Rust version of at least 1.77.2
| Platform | Level | Notes |
|---|---|---|
| windows | ||
| linux | ||
| macos | ||
| android | | Only plain-text content support |
| ios | | Only plain-text content support |
Instala el plugin de portapapeles para comenzar.
Usa el gestor de paquetes de tu proyecto para añadir la dependencia:
npm run tauri add clipboard-manageryarn run tauri add clipboard-managerpnpm tauri add clipboard-managerdeno task tauri add clipboard-managerbun tauri add clipboard-managercargo tauri add clipboard-manager-
Ejecuta el siguiente comando en la carpeta
src-tauripara añadir el plugin a las dependencias del proyecto enCargo.toml:cargo add tauri-plugin-clipboard-manager -
Modifica
lib.rspara inicializar el plugin:src-tauri/src/lib.rs #[cfg_attr(mobile, tauri::mobile_entry_point)]pub fn run() {tauri::Builder::default().plugin(tauri_plugin_clipboard_manager::init()).run(tauri::generate_context!()).expect("error al ejecutar la aplicación tauri");} -
Si deseas gestionar el portapapeles en JavaScript, también debes instalar el paquete de npm:
npm install @tauri-apps/plugin-clipboard-manageryarn add @tauri-apps/plugin-clipboard-managerpnpm add @tauri-apps/plugin-clipboard-managerdeno add npm:@tauri-apps/plugin-clipboard-managerbun add @tauri-apps/plugin-clipboard-manager
El plugin de portapapeles está disponible tanto en JavaScript como en Rust.
import { writeText, readText } from '@tauri-apps/plugin-clipboard-manager';// cuando uses `"withGlobalTauri": true`, deberías usar// const { writeText, readText } = window.__TAURI__.clipboardManager;
// Escribe contenido al portapapelesawait writeText('¡Tauri es increíble!');
// Leer contenido del portapapelesconst content = await readText();console.log(content);// Imprime "¡Tauri es increíble!" en la consolause tauri_plugin_clipboard_manager::ClipboardExt;
app.clipboard().write_text("¡Tauri es increíble!".to_string()).unwrap();
// Leer contenido del portapapeleslet content = app.clipboard().read_text();println!("{:?}", content.unwrap());// Muestra "¡Tauri es increíble!" en la terminalDefault Permission
No features are enabled by default, as we believe the clipboard can be inherently dangerous and it is application specific if read and/or write access is needed.
Clipboard interaction needs to be explicitly enabled.
Permission Table
| Identifier | Description |
|---|---|
|
|
Enables the clear command without any pre-configured scope. |
|
|
Denies the clear command without any pre-configured scope. |
|
|
Enables the read_image command without any pre-configured scope. |
|
|
Denies the read_image command without any pre-configured scope. |
|
|
Enables the read_text command without any pre-configured scope. |
|
|
Denies the read_text command without any pre-configured scope. |
|
|
Enables the write_html command without any pre-configured scope. |
|
|
Denies the write_html command without any pre-configured scope. |
|
|
Enables the write_image command without any pre-configured scope. |
|
|
Denies the write_image command without any pre-configured scope. |
|
|
Enables the write_text command without any pre-configured scope. |
|
|
Denies the write_text command without any pre-configured scope. |
© 2025 Tauri Contributors. CC-BY / MIT