mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
fix: add standard context menu items to prevent empty right-click menu (#5616)
Signed-off-by: sheikhlimon <sheikhlimon404@gmail.com>
This commit is contained in:
+48
-11
@@ -614,29 +614,63 @@ const createChat = async (
|
||||
mainWindow.webContents.session.setSpellCheckerLanguages(['en-US', 'en-GB']);
|
||||
mainWindow.webContents.on('context-menu', (_event, params) => {
|
||||
const menu = new Menu();
|
||||
const hasSpellingSuggestions = params.dictionarySuggestions.length > 0 || params.misspelledWord;
|
||||
|
||||
// Add each spelling suggestion
|
||||
for (const suggestion of params.dictionarySuggestions) {
|
||||
if (hasSpellingSuggestions) {
|
||||
for (const suggestion of params.dictionarySuggestions) {
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: suggestion,
|
||||
click: () => mainWindow.webContents.replaceMisspelling(suggestion),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (params.misspelledWord) {
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: 'Add to dictionary',
|
||||
click: () =>
|
||||
mainWindow.webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (params.selectionText) {
|
||||
menu.append(new MenuItem({ type: 'separator' }));
|
||||
}
|
||||
}
|
||||
if (params.selectionText) {
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: suggestion,
|
||||
click: () => mainWindow.webContents.replaceMisspelling(suggestion),
|
||||
label: 'Cut',
|
||||
accelerator: 'CmdOrCtrl+X',
|
||||
role: 'cut',
|
||||
})
|
||||
);
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: 'Copy',
|
||||
accelerator: 'CmdOrCtrl+C',
|
||||
role: 'copy',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// Allow users to add the misspelled word to the dictionary
|
||||
if (params.misspelledWord) {
|
||||
// Only show paste in editable fields (text inputs)
|
||||
if (params.isEditable) {
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: 'Add to dictionary',
|
||||
click: () =>
|
||||
mainWindow.webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord),
|
||||
label: 'Paste',
|
||||
accelerator: 'CmdOrCtrl+V',
|
||||
role: 'paste',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
menu.popup();
|
||||
if (menu.items.length > 0) {
|
||||
menu.popup();
|
||||
}
|
||||
});
|
||||
|
||||
// Handle new window creation for links
|
||||
@@ -681,7 +715,10 @@ const createChat = async (
|
||||
}
|
||||
if (
|
||||
appPath === '/' &&
|
||||
(recipe !== undefined || recipeDeeplink !== undefined || recipeId !== undefined || initialMessage)
|
||||
(recipe !== undefined ||
|
||||
recipeDeeplink !== undefined ||
|
||||
recipeId !== undefined ||
|
||||
initialMessage)
|
||||
) {
|
||||
appPath = '/pair';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user