mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
29 lines
855 B
TypeScript
29 lines
855 B
TypeScript
|
// Copyright 2024, Command Line Inc.
|
||
|
// SPDX-License-Identifier: Apache-2.0
|
||
|
|
||
|
const { ipcRenderer } = require("electron");
|
||
|
|
||
|
document.addEventListener("contextmenu", (event) => {
|
||
|
console.log("contextmenu event", event);
|
||
|
if (event.target == null) {
|
||
|
return;
|
||
|
}
|
||
|
const targetElement = event.target as HTMLElement;
|
||
|
// Check if the right-click is on an image
|
||
|
if (targetElement.tagName === "IMG") {
|
||
|
setTimeout(() => {
|
||
|
if (event.defaultPrevented) {
|
||
|
return;
|
||
|
}
|
||
|
event.preventDefault();
|
||
|
const imgElem = targetElement as HTMLImageElement;
|
||
|
const imageUrl = imgElem.src;
|
||
|
ipcRenderer.send("webview-image-contextmenu", { src: imageUrl });
|
||
|
}, 50);
|
||
|
return;
|
||
|
}
|
||
|
// do nothing
|
||
|
});
|
||
|
|
||
|
console.log("loaded wave preload-webview.ts");
|