Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(desktop): add spellcheck suggestions to context menu #500

Mergedchuks-qua(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/500/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 1 changed file with 28 additions and 0 deletions.

x
0 of 1 viewed, 1 left
28 additions and 0 deletionsapps/desktop/src/main.tsModified
View file
@@ -1114,6 +1114,34 @@
+ window.webContents.on("context-menu", (event, params) => {
+ event.preventDefault();
+​
+ const menuTemplate: MenuItemConstructorOptions[] = [];
+​
+ if (params.misspelledWord) {
+ for (const suggestion of params.dictionarySuggestions.slice(0, 5)) {
+ menuTemplate.push({
+ label: suggestion,
+ click: () => window.webContents.replaceMisspelling(suggestion),
+ });
+ }
+ if (params.dictionarySuggestions.length === 0) {
+ menuTemplate.push({ label: "No suggestions", enabled: false });
+ }
+ menuTemplate.push({ type: "separator" });
+ }
+​
+ menuTemplate.push(
+ { role: "cut", enabled: params.editFlags.canCut },
+ { role: "copy", enabled: params.editFlags.canCopy },
+ { role: "paste", enabled: params.editFlags.canPaste },
+ { role: "selectAll", enabled: params.editFlags.canSelectAll },
+ );
+​
+ Menu.buildFromTemplate(menuTemplate).popup({ window });