blob: e77ff23265c430987208dfc03ab269e6fad55915 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import { remote } from "electron";
import { ContextMenuBuilder, ContextMenuListener } from "electron-spellchecker";
const webContents = remote.getCurrentWebContents();
export default async function setupContextMenu(handler) {
const processMenu = (menu, menuInfo) => {
if (
menuInfo.editFlags.canPaste &&
!menuInfo.linkText &&
!menuInfo.hasImageContents
) {
menu.insert(
3,
new remote.MenuItem({
label: "Paste as plain text",
accelerator: "CommandOrControl+Shift+V",
click: () => webContents.pasteAndMatchStyle()
})
);
}
if (menuInfo.linkURL) {
menu.insert(
2,
new remote.MenuItem({
label: "Open Link in Ferdi",
click: () => {
window.location.href = menuInfo.linkURL;
}
})
);
}
return menu;
};
const contextMenuBuilder = new ContextMenuBuilder(
handler,
null,
true,
processMenu
);
// eslint-disable-next-line no-new
new ContextMenuListener(info => {
contextMenuBuilder.showPopupMenu(info);
});
}
|