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

Expose spellcheck_platform::CheckSpelling API #22829

Closed
3 tasks done
craftzdog opened this issue Mar 25, 2020 · 7 comments · Fixed by #25060
Closed
3 tasks done

Expose spellcheck_platform::CheckSpelling API #22829

craftzdog opened this issue Mar 25, 2020 · 7 comments · Fixed by #25060

Comments

@craftzdog
Copy link

Hi, thank you for creating such a great framework!
I have a feature request which I think I can contribute, but let me check if you are interested in supporting it.

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem Description

The builtin spellchecker has been supported in #20692.
But it does not allow us to check spells programmatically, like node-spellchecker's isMisspelled method.
Chrome's spellcheck_platform provides CheckSpelling to do that exactly.

Proposed Solution

Add a method to call spellcheck_platform::CheckSpelling like so:

#if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
bool Session::CheckSpelling(const std::string& word) {
  if (spellcheck::UseBrowserSpellChecker()) {
    return spellcheck_platform::CheckSpelling(base::UTF8ToUTF16(word), 0);
  }
  return true;
}
#endif

in shell/browser/api/atom_api_session.cc.

It's simple and won't affect other features.

Alternatives Considered

I don't know.

Additional Information

None

Thanks!

@MarshallOfSound
Copy link
Member

@craftzdog That method is not cross platform, can you clarify your usecase for this method?

@craftzdog
Copy link
Author

@MarshallOfSound Thanks for the reply.

My usecase is that I'm building a Markdown editor based on CodeMirror which browser's spellchecker doesn't work.
So, we have to use a plugin like codemirror-spell-checker which checks spellings in JS.

I found SpellCheck::SpellCheckWord which looks cross platform.
Would it be possible to invoke from Session?

@astoilkov
Copy link
Contributor

@MarshallOfSound On what operating system is the spellcheck_platform::CheckSpelling available? What about SpellCheck::SpellCheckWord?

Exposing the API will benefit a lot of applications using a custom editor. The electron site shows 65 applications that contain "editor" in their description.

We have the same problem at https://caret.io/.

@lishid
Copy link
Contributor

lishid commented May 30, 2020

I have the same setup with CodeMirror. After digging around for a few hours, I did not find any undocumented spellcheck access 😂

The current alternative is to use typo.js and self-manage hunspell libraries downloading from the renderer. Other than having to do all that repeated work, it also doesn't support multiple languages (cfinke/Typo.js#37)

A second alternative is to bring in electron-spellchecker (or a variant of it) which is what we were trying to move away from in the first place with native spellchecker support.

Hoping we can make this a reality. Thanks again for all the hard work!

@abnerlee
Copy link

abnerlee commented Jun 5, 2020

Maybe also expose spellcheck_platform::FillSuggestionList to get suggestions for words that are "misspelled"

@lishid
Copy link
Contributor

lishid commented Aug 20, 2020

@MarshallOfSound I've put down a few hours into exploring the codebase and hooking up a working prototype. Currently having some trouble with how to properly expose the API. Would really appreciate if you have some tips.

As for use case, adding to the others here, I'm working on https://obsidian.md which is also based on CodeMirror.

@craftzdog @astoilkov @abnerlee Also wanted to say hi, big fan of all your work! 😃

@craftzdog
Copy link
Author

@lishid hi 👋 Great to know you made a PR for the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants