Switch to native Electron context menu

Replaces the custom HTML context menu with a native Electron menu for webview and window areas. Adds context menu handling in main and preload scripts, relays commands to renderer, and updates renderer logic to support new menu actions. Improves integration and user experience by leveraging platform-native menus.
This commit is contained in:
2025-08-15 18:49:09 +12:00
parent 1e32a4e7a4
commit f319384fdc
4 changed files with 123 additions and 54 deletions
+12
View File
@@ -63,6 +63,13 @@ const electronAPI = {
console.error('IPC openLocalFile error:', err);
return null;
}
},
showContextMenu: (params) => {
try {
return ipcRenderer.invoke('show-context-menu', params);
} catch (err) {
console.error('IPC showContextMenu error:', err);
}
}
};
@@ -105,4 +112,9 @@ contextBridge.exposeInMainWorld('bookmarksAPI', bookmarksAPI);
// Minimal about API for settings page
contextBridge.exposeInMainWorld('aboutAPI', {
getInfo: () => ipcRenderer.invoke('get-about-info')
});
// Relay context-menu commands from main to active renderer context (open new tabs etc.)
ipcRenderer.on('context-menu-command', (event, payload) => {
window.dispatchEvent(new CustomEvent('nebula-context-command', { detail: payload }));
});