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

Add browser-based Spell Check #1720

Closed
wants to merge 1 commit into from
Closed

Add browser-based Spell Check #1720

wants to merge 1 commit into from

Conversation

Gazook89
Copy link
Collaborator

@Gazook89 Gazook89 commented Sep 29, 2021

Looking for options to cover spell checking, as mentioned in #312 and #517, and resolves #611.

One Option:

Option used in this PR: set the codeMirror options inputStyle : contentEditable, spellcheck : true, from this SO answer. Seems to work for both FF and Chrome. From the CodeMirror 5 manual:

inputStyle: string
Selects the way CodeMirror handles input and focus. The core library defines the "textarea" and "contenteditable" input models. On mobile browsers, the default is "contenteditable". On desktop browsers, the default is "textarea". Support for IME and screen readers is better in the "contenteditable" model. The intention is to make it the default on modern desktop browsers in the future.

spellcheck: boolean
Specifies whether or not spellcheck will be enabled on the input.

image

Minor complaint

  • I think it is annoying that the words are highlighted as typos as they are being typed, but I'm not sure what can be done about that using a browser spell checker.

Another Option

Use typo.js as suggested a few places, here but it seems this might have issues outside a few languages.

@calculuschild calculuschild added the P2 - minor feature or not urgent Minor bugs or less-popular features label Oct 7, 2021
@calculuschild
Copy link
Member

calculuschild commented Dec 3, 2021

It seems to function fine, but I have some thoughts after playing around:

  • Spellcheck on a markdown / CSS document is going to be cluttered with detected "typos" whenever there's "code" bits (on our curly divs, etc). This starts to get overwhelming pretty quickly and I don't know if users want them in their browser "dictionaries". I'm not aware of an obvious way to avoid spellchecking certain parts though.
  • Spellcheck probably shouldn't be on the Style Tab at all.
  • Perhaps we need a toggle button to turn it on and off. Some people probably don't want annoying squiggles on everything.
  • I also don't like the marking on partially-typed words but I'm not sure of any way around that.
  • The typo lines flash with each keystroke.

image

Edit: We may be able to use this guy's extension as a template to make our own spellchecker. https://github.com/sparksuite/codemirror-spell-checker

We can see the logic where he determines which words to check in here. It's not that complicated, but perhaps it's getting in over our heads.

Thoughts @jeddai , @G-Ambatte , @ericscheid ?

@jeddai
Copy link
Collaborator

jeddai commented Dec 3, 2021

Perhaps we need a toggle button to turn it on and off

I would be willing to argue that this should be a requirement before this goes out. I also think it should default to off, but could have its own icon in the editor menu bar.

On a related note, I'm actually about to open an issue brought to me by the DOMT team about having user editor settings that persist across documents, maybe that could be the solution for this concern.

We may be able to use this guy's extension as a template to make our own spellchecker. https://github.com/sparksuite/codemirror-spell-checker

That's certainly an option, but I think one of the biggest benefits of the browser spell check is the ability to add words to the dictionary. Replicating that functionality is possible, but would require some work.

@G-Ambatte
Copy link
Collaborator

On a related note, I'm actually about to open an issue brought to me by the DOMT team about having user editor settings that persist across documents

This was part of the UserInfo framework (#1672). The idea behind it was that some user specific information could be stored; in the immediate future, items like editor preferences, but in the longer term, it offers the potential for things such as storing Users "liked" brews, and intra-User messaging (which could potentially be useful for user notifications, for required messages like DMCA takedown processes).

However the framework is still very much WIP.

@G-Ambatte
Copy link
Collaborator

* Spellcheck probably shouldn't be on the Style Tab at all.

Agreed.

* Perhaps we need a toggle button to turn it on and off. Some people probably don't want annoying squiggles on everything.

Absolutely, I almost never use spelchking.

* I also don't like the marking on partially-typed words but I'm not sure of any way around that.

* The typo lines flash with each keystroke.

If we can debounce the checking functioning, it could potentially resolve both of these issues. However, I haven't had a chance to dig in to see if this is actually possible.

@calculuschild calculuschild added the 🔍 R2 - Reviewed - Needs Help 🫱 PR is okayed but is stuck on an obstacle label Dec 11, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 - minor feature or not urgent Minor bugs or less-popular features 🔍 R2 - Reviewed - Needs Help 🫱 PR is okayed but is stuck on an obstacle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE]: Spell Checker
4 participants