Closed wapsi closed 3 years ago
I think we can't copy the exact behavior of the in-built spell checker. The best we can do is not to spell check the word under the cursor or near the cursor.
Yeah, but I think that should be enough. At least we'll get rid of the immediately highlighting of the words that I'm still typing :)
Well, that was easy if it works now. I pushed a commit to the same branch.
Ok, I just compiled the new version and the initial tests are looking good! I'll try to write some more if any issues are found...
I think it works mostly now. But there is a case if I change (mistype) the word and move the cursor away it won't trigger the spell checking. I have to hit enter or put space or something else to trigger the spell checking. I made a screen record about the issue (it's easier to see what I mean from there): https://user-images.githubusercontent.com/11405096/105880229-cb7ff700-600b-11eb-98a2-a97ce7aae0ab.mp4
I have to add handler for click events to change that. Seems like it's an easy fix and I don't see anything negative happening if I do that.
The same thing happens if you move the cursor with keyboard, so click event handler doesn't solve this entirely.
Using a keydown event, for example, solves this but then the text isn't spell checked when you paste text with a mouse. Pasting with a mouse doesn't dispatch click event. And we can't have a listener for an input and a key* events because then text is spell checked twice. Looks like we have to choose what to support. Which one you would like to have?
Hmm, OK I undestand. I assume there is no possibility to listen changes of the textarea/input value / its content somehow?
I take that back. There's a paste event, so I think changing input to keyup and adding click and paste event handlers the text is spell checked in every case. So we don't have to choose.
Every corner case should now be covered in the newest commit.
Yes, I agree with you. I think it's perfect now (or at least all my test cases were working just fine). Thanks!
I think this issue / feature request can be closed if you want to? I can confirm that this functionality is added and tested, thanks!
Now the spell checker check the word I'm writing immediately there are something to spell check, like:
Tämä on tes|
It whill highlight that "tes" word there even I haven't finished it:testiä
.There have been som discussion already about this on another issue, here: https://github.com/fluks/fin-spell/issues/3#issuecomment-765249622