mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-02 05:02:27 +08:00
chore(client/ts): port menus/image_context_menu
This commit is contained in:
parent
eb9a55bf4f
commit
a14d112a5c
@ -5,7 +5,7 @@ import imageService from "../services/image.js";
|
|||||||
|
|
||||||
const PROP_NAME = "imageContextMenuInstalled";
|
const PROP_NAME = "imageContextMenuInstalled";
|
||||||
|
|
||||||
function setupContextMenu($image) {
|
function setupContextMenu($image: JQuery<HTMLElement>) {
|
||||||
if (!utils.isElectron() || $image.prop(PROP_NAME)) {
|
if (!utils.isElectron() || $image.prop(PROP_NAME)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -37,9 +37,13 @@ function setupContextMenu($image) {
|
|||||||
const nativeImage = utils.dynamicRequire('electron').nativeImage;
|
const nativeImage = utils.dynamicRequire('electron').nativeImage;
|
||||||
const clipboard = utils.dynamicRequire('electron').clipboard;
|
const clipboard = utils.dynamicRequire('electron').clipboard;
|
||||||
|
|
||||||
const response = await fetch(
|
const src = $image.attr('src');
|
||||||
$image.attr('src')
|
if (!src) {
|
||||||
);
|
console.error("Missing src");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(src);
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
|
|
||||||
clipboard.writeImage(
|
clipboard.writeImage(
|
Loading…
x
Reference in New Issue
Block a user