New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enable builtin spellchecker #20692
Conversation
2e83e4b
to
ce4ddc9
Compare
patches/chromium/remove_usage_of_incognito_apis_in_the_spellchecker.patch
Show resolved
Hide resolved
a050fef
to
7a704bb
Compare
…pellchecker is active
* chore: add code required to use chromes spellchecker * chore: fix linting * chore: manifests needs buildflags now * chore: add dictionarySuggestions to the context menu event when the spellchecker is active * chore: enable by default for windows builds * chore: add patch to remove incognito usage in the spellchecker * chore: add dependencies on spellcheck common and flags * chore: conditionally include spell check panel impl * chore: fix deps for spellcheck feature flags * chore: add patch for electron resources * chore: add dependency on //components/language/core/browser * chore: patches to make hunspell work on windows * build: collect hunspell dictionaries into a zip file and publish * chore: clean up patches * chore: add docs and set spell checker url method * chore: fix error handling * chore: fix hash logic * build: update hunspell filename generator * fix: default spellchecker list to the current system locale if we can * docs: document the language getter * chore: patch IDS_ resources for linux builds * feat: add spellcheck webpref flag to disable the builtin spellchecker * chore: fix docs typo * chore: clean up spellchecker impl as per feedback * remove unneeded deps
@MarshallOfSound has manually backported this PR to "8-x-y", please check out #20897 |
* feat: enable builtin spellchecker (#20692) * chore: add code required to use chromes spellchecker * chore: fix linting * chore: manifests needs buildflags now * chore: add dictionarySuggestions to the context menu event when the spellchecker is active * chore: enable by default for windows builds * chore: add patch to remove incognito usage in the spellchecker * chore: add dependencies on spellcheck common and flags * chore: conditionally include spell check panel impl * chore: fix deps for spellcheck feature flags * chore: add patch for electron resources * chore: add dependency on //components/language/core/browser * chore: patches to make hunspell work on windows * build: collect hunspell dictionaries into a zip file and publish * chore: clean up patches * chore: add docs and set spell checker url method * chore: fix error handling * chore: fix hash logic * build: update hunspell filename generator * fix: default spellchecker list to the current system locale if we can * docs: document the language getter * chore: patch IDS_ resources for linux builds * feat: add spellcheck webpref flag to disable the builtin spellchecker * chore: fix docs typo * chore: clean up spellchecker impl as per feedback * remove unneeded deps * chore: disable spellcheck by default in web prefs
I was very happily surprised to see Electron doing significant improvements to the spellchecker. Congrats on the work! @MarshallOfSound I have a quick question related to the future of spellchecking in Electron. Do you see a path to deprecating the need for node-spellchecker? We are building a text editor where we can't use the spellchecking of HTML elements because we need a more advanced implementation. We need methods to manually check if a text is misspelled. |
@MarshallOfSound - is the spellchecker feature working properly at this moment outside macOS? I have experimentally implement it in my electron-based app and it works only on macOS 10.15. On Windows 10 and Ubuntu linux 19.04 there are no visible results of the spellchecking :/ Initially I thought that I have to set language through Also Tested on the newest beta: 8.0.0-beta.6 |
Please don't drop existing APIs support. |
@MarshallOfSound - to avoid an impact of the third party reasons (my app is quite complex) - I have created a super simple app based on this tutorial for Windows 10: https://electronjs.org/docs/tutorial/first-app based on Electron 8.0.0-beta.6. The only difference - I have add to the Unfortunately spellchecker is not working :( |
Adding to @dziudek. I don't know If we're doing something wrong or if the spellchecker is not working properly on Windows. I left a comment here Using Windows 10 + Electron 8.0.0-beta.5 inside the simple quick start repo with minimal changesI'm not getting anything. + Additional questionUsing Does that mean that this spellchecker will automatically detect the language the user is typing? |
Quick thing folks, commenting on a closed and merged PR is not going to get people to really look at your problem. If you think there's a bug in Electron, raise a new issue with detailed repro steps and it will be triaged appropriately. |
This does all the work to get the spellchecker working on all supported platforms. Testing matrix I'm using is outlined below:
This is behind a build flag that is now enabled by default. The addition of this introduces a few new APIs.
session.setSpellCheckerLanguages(languageCodes: string[])
This set the required pref that tells the spellchecker which languages it should use, example usage is.
session.setSpellCheckLanguages(['en-US', 'fr'])
to enable french and american english. This only impacts hunspell based platforms.session.availableSpellCheckerLanguages: string[]
(Readonly)This is a read only property with an array of supported language codes that you can provide to the set method above.
session.setSpellCheckerDictionaryDownloadURL(url: string)
This is a writeable property that allows you to modify the base URL that Electron will use to download hunspell dictionaries from. By default we will fetch them from the chromium provided CDN, if you don't want your app to do that you can host these yourself and modify this URL here.
For more info on these new APIs check out the new documentation.
Releasing
There is also a new published asset
hunspell_dictionaries.zip
which is published once (identical across platforms) that includes all the dictionary files and their licenses that you would need to host if you wanted to override thedictionarySourceURL
property.Existing APIs?
Personally I think we should remove the
webFrame.setSpellChecker
API as this supersedes in every way it but I'm open to other thoughts there. For now I've added aspellcheck
option in webPreferences to enable / disable the spellchecker. While we make sure this is gonna work for everyone we can keep both code paths with the intention to deprecate and remove the webFrame method at some point in the future.Notes: Added support for the built-in spellchecker. We will use the OS spellchecker on macOS and hunspell on all other platforms.