2026-01-26 19:21:19 +02:00
|
|
|
const CONTEXT_MENU_ITEMS: Browser.contextMenus.CreateProperties[] = [
|
|
|
|
|
{
|
|
|
|
|
id: "trilium-save-selection",
|
|
|
|
|
title: "Save selection to Trilium",
|
|
|
|
|
contexts: ["selection"]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "trilium-save-cropped-screenshot",
|
2026-01-26 20:10:18 +02:00
|
|
|
title: "Crop screenshot to Trilium",
|
2026-01-26 19:21:19 +02:00
|
|
|
contexts: ["page"]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "trilium-save-whole-screenshot",
|
2026-01-26 20:10:18 +02:00
|
|
|
title: "Save whole screenshot to Trilium",
|
2026-01-26 19:21:19 +02:00
|
|
|
contexts: ["page"]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "trilium-save-page",
|
|
|
|
|
title: "Save whole page to Trilium",
|
|
|
|
|
contexts: ["page"]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "trilium-save-link",
|
|
|
|
|
title: "Save link to Trilium",
|
|
|
|
|
contexts: ["link"]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "trilium-save-image",
|
|
|
|
|
title: "Save image to Trilium",
|
|
|
|
|
contexts: ["image"]
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
2026-01-26 21:00:56 +02:00
|
|
|
export default async function setupContextMenu() {
|
2026-01-26 19:21:19 +02:00
|
|
|
// Context menu items need to be registered only once.
|
|
|
|
|
// https://stackoverflow.com/questions/64318529/cannot-create-item-with-duplicate-context-menu-id-in-extension
|
2026-01-26 21:00:56 +02:00
|
|
|
await browser.contextMenus.removeAll();
|
|
|
|
|
for (const item of CONTEXT_MENU_ITEMS) {
|
|
|
|
|
browser.contextMenus.create(item);
|
|
|
|
|
}
|
2026-01-26 19:21:19 +02:00
|
|
|
}
|