termix / src /modules /explorer /lib /contextActions.ts
lekmikdok's picture
Prepare Terax for web deployment
50fe3c9 verified
Raw
History Blame Contribute Delete
663 Bytes
import { revealItemInDir } from "@tauri-apps/plugin-opener";
export async function copyToClipboard(text: string): Promise<void> {
try {
await navigator.clipboard.writeText(text);
} catch {
// Best-effort; ignore in environments without clipboard permission.
}
}
export function relativePath(rootPath: string, path: string): string {
if (path === rootPath) return ".";
if (path.startsWith(`${rootPath}/`)) return path.slice(rootPath.length + 1);
return path;
}
export async function revealInFinder(path: string): Promise<void> {
try {
await revealItemInDir(path);
} catch (e) {
console.error("revealItemInDir failed:", e);
}
}