mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 09:46:25 +02:00
implement replace handler with clipboard swap and paste-back
This commit is contained in:
parent
6e74f462a2
commit
5bb4f5c084
1 changed files with 17 additions and 0 deletions
|
|
@ -118,6 +118,23 @@ export function registerQuickAsk(): void {
|
|||
pendingText = '';
|
||||
return text;
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.REPLACE_TEXT, async (_event, text: string) => {
|
||||
if (process.platform !== 'darwin' || !sourceApp) return;
|
||||
|
||||
clipboard.writeText(text);
|
||||
hideQuickAsk();
|
||||
|
||||
try {
|
||||
execSync(`osascript -e 'tell application "${sourceApp}" to activate'`);
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
execSync('osascript -e \'tell application "System Events" to keystroke "v" using command down\'');
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
clipboard.writeText(savedClipboard);
|
||||
} catch {
|
||||
clipboard.writeText(savedClipboard);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function unregisterQuickAsk(): void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue