feat: implement getSelectedText function

Previously, this function was a shell that always rejected. This commit implements the schemas for a new get-selected-text command and updates the SidecarMessageWithPluginsSchema to include the new message type.
This commit is contained in:
ByteAtATime 2025-06-17 12:01:50 -07:00
parent c91a800e80
commit a5a39a5b7d
No known key found for this signature in database
7 changed files with 493 additions and 42 deletions

View file

@ -1,5 +1,6 @@
use freedesktop_file_parser::{parse, EntryType};
use rayon::prelude::*;
use selection::get_text;
use serde::{Deserialize, Serialize};
use std::{
collections::{HashMap, HashSet},
@ -236,13 +237,22 @@ fn launch_app(exec: String) -> Result<(), String> {
Ok(())
}
#[tauri::command]
fn get_selected_text() -> String {
get_text()
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_clipboard_manager::init())
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![get_installed_apps, launch_app])
.invoke_handler(tauri::generate_handler![
get_installed_apps,
launch_app,
get_selected_text
])
.setup(|_app| {
thread::spawn(|| {
thread::sleep(Duration::from_secs(60));