Adds right-click → Delete on sidebar thread items using Electron's native Menu.popup() when running in desktop, with an imperative DOM fallback for browser environments. The contextMenu.show() API is generic so the returned item id is type-safe based on the items passed. Co-Authored-By: Claude Haiku 4.5 <[email protected]>
13 lines
527 B
TypeScript
13 lines
527 B
TypeScript
import { contextBridge, ipcRenderer } from "electron";
|
|
|
|
const PICK_FOLDER_CHANNEL = "desktop:pick-folder";
|
|
const CONTEXT_MENU_CHANNEL = "desktop:context-menu";
|
|
const wsUrl = process.env.T3CODE_DESKTOP_WS_URL ?? null;
|
|
|
|
contextBridge.exposeInMainWorld("desktopBridge", {
|
|
getWsUrl: () => wsUrl,
|
|
pickFolder: () => ipcRenderer.invoke(PICK_FOLDER_CHANNEL) as Promise<string | null>,
|
|
showContextMenu: (items: { id: string; label: string }[]) =>
|
|
ipcRenderer.invoke(CONTEXT_MENU_CHANNEL, items) as Promise<string | null>,
|
|
});
|