diff --git a/apps/desktop/package.json b/apps/desktop/package.json index b909e8b..a0e3b94 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -32,6 +32,7 @@ "svelte-radix": "^2.0.1", "svelte-sonner": "^0.3.28", "sveltekit-superforms": "^2.20.0", + "tauri-plugin-clipboard-api": "^2.1.11", "uuid": "^11.0.2" }, "devDependencies": { diff --git a/apps/desktop/src-tauri/capabilities/default.json b/apps/desktop/src-tauri/capabilities/default.json index 176a04d..7c82d9b 100644 --- a/apps/desktop/src-tauri/capabilities/default.json +++ b/apps/desktop/src-tauri/capabilities/default.json @@ -23,6 +23,7 @@ "core:path:default", "core:event:default", "core:window:default", + "core:window:allow-set-size", "core:window:allow-start-dragging", "core:window:allow-set-focus", "core:window:allow-toggle-maximize", diff --git a/apps/desktop/src/lib/cmds/builtin.ts b/apps/desktop/src/lib/cmds/builtin.ts index f6b3a01..d17b71e 100644 --- a/apps/desktop/src/lib/cmds/builtin.ts +++ b/apps/desktop/src/lib/cmds/builtin.ts @@ -6,6 +6,7 @@ import { WebviewWindow } from "@tauri-apps/api/webviewWindow" import { exit } from "@tauri-apps/plugin-process" import { goto } from "$app/navigation" import { toast } from "svelte-sonner" +import * as clipboard from "tauri-plugin-clipboard-api" import { v4 as uuidv4 } from "uuid" export const builtinCmds: BuiltinCmd[] = [ @@ -202,6 +203,29 @@ export const builtinCmds: BuiltinCmd[] = [ appState.clearSearchTerm() } }, + { + name: "Pin Current Screenshot", + iconifyIcon: "material-symbols:screenshot-monitor-outline", + description: "Pin the current screenshot", + function: async () => { + appState.clearSearchTerm() + if (!(await clipboard.hasImage())) { + toast.error("No screenshot in clipboard") + return + } + const window = new WebviewWindow(`main:pinned-screenshot-${uuidv4()}`, { + url: "/extension/pin-screenshot", + title: "Pinned Screenshot", + hiddenTitle: true, + titleBarStyle: "transparent", + decorations: false, + visible: false + }) + setTimeout(() => { + window.show() + }, 2_000) + } + }, { name: "Toggle Hide On Blur", iconifyIcon: "ri:toggle-line", diff --git a/apps/desktop/src/routes/extension/pin-screenshot/+page.svelte b/apps/desktop/src/routes/extension/pin-screenshot/+page.svelte new file mode 100644 index 0000000..215f378 --- /dev/null +++ b/apps/desktop/src/routes/extension/pin-screenshot/+page.svelte @@ -0,0 +1,88 @@ + + + { + if (e.key === "Escape") { + appWin.close() + } + }} +/> + appWin.close()} + > + + {#if image} + + {:else} + + No image found in clipboard + + {/if} + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 31977e7..0058baf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -168,6 +168,9 @@ importers: sveltekit-superforms: specifier: ^2.20.0 version: 2.20.0(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@4.0.0(svelte@5.1.9)(vite@5.4.10(@types/node@22.8.7)(terser@5.36.0)))(svelte@5.1.9)(vite@5.4.10(@types/node@22.8.7)(terser@5.36.0)))(@types/json-schema@7.0.15)(svelte@5.1.9)(typescript@5.6.3) + tauri-plugin-clipboard-api: + specifier: ^2.1.11 + version: 2.1.11(typescript@5.6.3) uuid: specifier: ^11.0.2 version: 11.0.2
No image found in clipboard