ExTauri.Clipboard (ex_tauri v0.2.0)
View SourceRead and write the system clipboard from your LiveView.
Bridges to tauri-plugin-clipboard-manager via the LiveView hook.
Requirements
tauri-plugin-clipboard-managermust be installed (see Plugin Setup below)- The
TauriHookmust be mounted in your LiveView (seeExTauri.Hook)
Plugin Setup
mix ex_tauri.add clipboardThis adds the Cargo dependency, registers the plugin in main.rs, and adds
the read/write-text capabilities. See Mix.Tasks.ExTauri.Add for details.
Examples
# Write to clipboard
def handle_event("copy", %{"text" => text}, socket) do
socket = ExTauri.Clipboard.write(socket, text)
{:noreply, socket}
end
# Read from clipboard
def handle_event("paste", _params, socket) do
socket = ExTauri.Clipboard.read(socket)
{:noreply, socket}
end
# Handle the response
def handle_event("tauri_response", %{"command" => "clipboard_read", "text" => text}, socket) do
{:noreply, assign(socket, :clipboard_text, text)}
end