From cb7045c00bb7bbeba4b70d3a1806069878a456f3 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 13 Jan 2024 19:05:01 +0100 Subject: [PATCH] WebContextMenus: use vesktop native clipboard - fixes some permission issues --- src/plugins/webContextMenus.web/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/webContextMenus.web/index.ts b/src/plugins/webContextMenus.web/index.ts index 50a1b90a7..bb98c61d7 100644 --- a/src/plugins/webContextMenus.web/index.ts +++ b/src/plugins/webContextMenus.web/index.ts @@ -182,6 +182,12 @@ export default definePlugin({ ], async copyImage(url: string) { + if (IS_VESKTOP && VesktopNative.clipboard) { + const data = await fetch(url).then(r => r.arrayBuffer()); + VesktopNative.clipboard.copyImage(data, url); + return; + } + // Clipboard only supports image/png, jpeg and similar won't work. Thus, we need to convert it to png // via canvas first const img = new Image();