SOLFIND
Web Lens
Portal home

SpellChecker | Electron

https://www.electronjs.org/docs/latest/tutorial/spellchecker • 56 KB fetched
Open original page


SpellChecker | Electron Skip to main content Electron Docs API Blog Tools * Electron Forge * Electron Fiddle Community * Governance * Showcase * Resources Releases English * English * Deutsch * Español * Français * 日本語 * Português * Русский * 中文 Search * Get Started * Processes in Electron * Best Practices * Examples * Dark Mode * Device Access * In-App Purchases * * Keyboard Shortcuts * Deep Links * Desktop Launcher Actions * * Menus * Multithreading * Native File Drag & Drop * Navigation History * Notifications * Offscreen Rendering * Online/Offline Event Detection * Progress Bars * Recent Documents * * * Representing Files in a BrowserWindow * * SpellChecker * Web Embeds * Taskbar Customization * * Window Customization * Development * Native Node Modules * Distribution * Testing And Debugging * References * Contributing * * Examples * SpellChecker On this page SpellChecker Electron has built-in support for Chromium's spellchecker since Electron 8. On Windows and Linux this is powered by Hunspell dictionaries, and on macOS it makes use of the native spellchecker APIs. How to enable the spellchecker? ​ For Electron 9 and higher the spellchecker is enabled by default. For Electron 8 you need to enable it in webPreferences . const myWindow = new BrowserWindow ( { webPreferences : { spellcheck : true } } ) How to set the languages the spellchecker uses? ​ On macOS as we use the native APIs there is no way to set the language that the spellchecker uses. By default on macOS the native spellchecker will automatically detect the language being used for you. For Windows and Linux there are a few Electron APIs you should use to set the languages for the spellchecker. // Sets the spellchecker to check English US and French myWindow . webContents . session . setSpellCheckerLanguages ( [ 'en-US' , 'fr' ] ) // An array of all available language codes const possibleLanguages = myWindow . webContents . session . availableSpellCheckerLanguages By default the spellchecker will enable the language matching the current OS locale. How do I put the results of the spellchecker in my context menu? ​ All the required information to generate a context menu is provided in the context-menu event on each webContents instance. A small example of how to make a context menu with this information is provided below. const { Menu , MenuItem } = require ( 'electron' ) myWindow . webContents . on ( 'context-menu' , ( event , params ) => { const menu = new Menu ( ) // Add each spelling suggestion for ( const suggestion of params . dictionarySuggestions ) { menu . append ( new MenuItem ( { label : suggestion , click : ( ) => myWindow . webContents . replaceMisspelling ( suggestion ) } ) ) } // Allow users to add the misspelled word to the dictionary if ( params . misspelledWord ) { menu . append ( new MenuItem ( { label : 'Add to dictionary' , click : ( ) => myWindow . webContents . session . addWordToSpellCheckerDictionary ( params . misspelledWord ) } ) ) } menu . popup ( ) } ) Does the spellchecker use any Google services? ​ Although the spellchecker itself does not send any typings, words or user input to Google services the hunspell dictionary files are downloaded from a Google CDN by default. If you want to avoid this you can provide an alternative URL to download the dictionaries from. myWindow . webContents . session . setSpellCheckerDictionaryDownloadURL ( 'https://example.com/dictionaries/' ) Check out the docs for session.setSpellCheckerDictionaryDownloadURL for more information on where to get the dictionary files from and how you need to host them. Edit this page Previous Representing Files in a BrowserWindow Next Web Embeds * How to enable the spellchecker? * How to set the languages the spellchecker uses? * How do I put the results of the spellchecker in my context menu? * Does the spellchecker use any Google services? Docs * Getting Started * API Reference Checklists * Performance * Security Tools * Electron Forge * Electron Fiddle Community * Governance * Resources * Bluesky * X * Mastodon * Stack Overflow More * GitHub * Open Collective * Infrastructure Dashboard Copyright OpenJS Foundation and Electron contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation , please see our Trademark Policy and Trademark List . Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them. The OpenJS Foundation | Terms of Use | Privacy Policy | Bylaws | Code of Conduct | Trademark Policy | Trademark List | Cookie Policy Hosting and infrastructure graciously provided by

Links found on this page

  1. Skip to main content [direct]
  2. Electron [direct]
  3. Docs [direct]
  4. API [direct]
  5. Blog [direct]
  6. Electron Forge [direct]
  7. Electron Fiddle [direct]
  8. Governance [direct]
  9. Showcase [direct]
  10. Resources [direct]
  11. Releases [direct]
  12. Deutsch [direct]
  13. Español [direct]
  14. Français [direct]
  15. 日本語 [direct]
  16. Português [direct]
  17. Русский [direct]
  18. 中文 [direct]
  19. Processes in Electron [direct]
  20. Best Practices [direct]
  21. Examples [direct]
  22. Dark Mode [direct]
  23. Device Access [direct]
  24. In-App Purchases [direct]
  25. Keyboard Shortcuts [direct]
  26. Deep Links [direct]
  27. Desktop Launcher Actions [direct]
  28. Menus [direct]
  29. Multithreading [direct]
  30. Native File Drag & Drop [direct]
  31. Navigation History [direct]
  32. Notifications [direct]
  33. Offscreen Rendering [direct]
  34. Online/Offline Event Detection [direct]
  35. Progress Bars [direct]
  36. Recent Documents [direct]
  37. Representing Files in a BrowserWindow [direct]
  38. Web Embeds [direct]
  39. Taskbar Customization [direct]
  40. Window Customization [direct]
  41. Development [direct]
  42. Native Node Modules [direct]
  43. Distribution [direct]
  44. Testing And Debugging [direct]
  45. References [direct]
  46. Contributing [direct]
  47. context-menu [direct]
  48. session.setSpellCheckerDictionaryDownloadURL [direct]
  49. Edit this page [direct]
  50. Security [direct]
  51. Bluesky [direct]
  52. X [direct]
  53. Mastodon [direct]
  54. Stack Overflow [direct]
  55. GitHub [direct]
  56. Open Collective [direct]
  57. Infrastructure Dashboard [direct]
  58. OpenJS Foundation [direct]
  59. Trademark Policy [direct]
  60. Trademark List [direct]
  61. Terms of Use [direct]
  62. Privacy Policy [direct]
  63. Bylaws [direct]
  64. Code of Conduct [direct]
  65. Cookie Policy [direct]