mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
use fewer const
This commit is contained in:
parent
cfc32a14e0
commit
9204f0735c
@ -29,15 +29,21 @@ function setupContextMenu($image) {
|
||||
imageService.copyImageReferenceToClipboard($image);
|
||||
} else if (command === 'copyImageToClipboard') {
|
||||
try {
|
||||
const imageUrl = $image.attr('src');
|
||||
const response = await fetch(imageUrl);
|
||||
const blob = await response.blob();
|
||||
const arrayBuffer = await blob.arrayBuffer();
|
||||
const buffer = Buffer.from(arrayBuffer);
|
||||
const nativeImage = utils.dynamicRequire('electron').nativeImage;
|
||||
const clipboard = utils.dynamicRequire('electron').clipboard;
|
||||
const image = nativeImage.createFromBuffer(buffer);
|
||||
clipboard.writeImage(image);
|
||||
|
||||
const response = await fetch(
|
||||
$image.attr('src')
|
||||
);
|
||||
const blob = await response.blob();
|
||||
|
||||
clipboard.writeImage(
|
||||
nativeImage.createFromBuffer(
|
||||
Buffer.from(
|
||||
await blob.arrayBuffer()
|
||||
)
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Failed to copy image to clipboard:', error);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user