Skip to content

Expose spellcheck_platform::CheckSpelling API #22829

Closed

Description

@craftzdog

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!

Activity

  1. MarshallOfSound commented on Mar 25, 2020

    @MarshallOfSound
    Member

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

  2. craftzdog commented on Mar 26, 2020

    @craftzdog
    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?

  3. astoilkov commented on Apr 25, 2020

    @astoilkov
    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/.

  4. lishid commented on May 30, 2020

    @lishid
    Contributor

    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!

  5. abnerlee commented on Jun 5, 2020

    @abnerlee

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

  6. lishid commented on Aug 20, 2020

    @lishid
    Contributor

    @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! 😃

  7. craftzdog commented on Aug 21, 2020

    @craftzdog
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions