Skip to content
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

Merged
merged 25 commits into from Oct 31, 2019
Merged

feat: enable builtin spellchecker #20692

merged 25 commits into from Oct 31, 2019

Conversation

MarshallOfSound
Copy link
Member

@MarshallOfSound MarshallOfSound commented Oct 22, 2019

This does all the work to get the spellchecker working on all supported platforms. Testing matrix I'm using is outlined below:

  • Windows 10
  • Windows 8.1
  • Windows 7
  • Ubuntu 18.04
  • Fedora
  • RHEL
  • macOS 10.14
  • macOS 10.15

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 the dictionarySourceURL 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 a spellcheck 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.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Oct 22, 2019
@MarshallOfSound MarshallOfSound requested a review from a team as a code owner October 23, 2019 18:44
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Oct 23, 2019
@MarshallOfSound MarshallOfSound requested a review from a team as a code owner October 25, 2019 20:36
@MarshallOfSound MarshallOfSound changed the title chore: add code required to use chromes spellchecker feat: enable builtin spellchecker Oct 25, 2019
@MarshallOfSound MarshallOfSound added the semver/minor backwards-compatible functionality label Oct 25, 2019
docs/api/session.md Outdated Show resolved Hide resolved
MarshallOfSound added a commit that referenced this pull request Oct 31, 2019
* 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
@trop
Copy link
Contributor

trop bot commented Oct 31, 2019

@MarshallOfSound has manually backported this PR to "8-x-y", please check out #20897

MarshallOfSound added a commit that referenced this pull request Oct 31, 2019
* 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
@astoilkov
Copy link
Contributor

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.

@dziudek
Copy link

dziudek commented Jan 15, 2020

@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 session.setSpellCheckerLanguages (as it is dedicated to the hunspell platforms), but I have discovered that session.getSpellCheckerLanguages returns ['en-US'] at start, so it shouldn't be a reason.

Also session.availableSpellCheckerLanguages returns 50 items, so the dictionaries seems to be available (and there is a new output directory called "Dictionaries" on Windows 10).

Tested on the newest beta: 8.0.0-beta.6

@vladimiry
Copy link

Existing APIs?

Please don't drop existing APIs support.

@dziudek
Copy link

dziudek commented Jan 15, 2020

@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 webPreferences option spellcheck: true

Unfortunately spellchecker is not working :(

Screenshot 2020-01-15 at 21 15 23

@aabuhijleh
Copy link

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 changes

I'm not getting anything.

+ Additional question

Using session.setSpellCheckerLanguages => we can add a list of supported spellchecker languages.

Does that mean that this spellchecker will automatically detect the language the user is typing?

@MarshallOfSound
Copy link
Member Author

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.

@electron electron locked as off-topic and limited conversation to collaborators Jan 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
semver/minor backwards-compatible functionality
Projects
No open projects
8.2.x
Fixed in 8.0.0-beta.2
Development

Successfully merging this pull request may close these issues.

None yet

9 participants