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:
+12
@@ -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 }));
|
||||
});
|
||||
Reference in New Issue
Block a user