chore(client/ts): port menus/image_context_menu

This commit is contained in:
Elian Doran 2024-12-22 17:46:30 +02:00
parent eb9a55bf4f
commit a14d112a5c
No known key found for this signature in database

View File

@ -5,7 +5,7 @@ import imageService from "../services/image.js";
const PROP_NAME = "imageContextMenuInstalled";
function setupContextMenu($image) {
function setupContextMenu($image: JQuery<HTMLElement>) {
if (!utils.isElectron() || $image.prop(PROP_NAME)) {
return;
}
@ -37,9 +37,13 @@ function setupContextMenu($image) {
const nativeImage = utils.dynamicRequire('electron').nativeImage;
const clipboard = utils.dynamicRequire('electron').clipboard;
const response = await fetch(
$image.attr('src')
);
const src = $image.attr('src');
if (!src) {
console.error("Missing src");
return;
}
const response = await fetch(src);
const blob = await response.blob();
clipboard.writeImage(