Open kerdosa opened 10 years ago
The reason why it does not work as expected is that the text is not in a text-field, so the browser does not recognize the text as inserted text. Perhaps a workaround is possible by making the whole document content-editable for the time of spell-checking. If that does not help we should probably employ some 3rd party library and feed the contents in.
I tried to make the whole body editable using the following script that I got from http://urbanoalvarez.es/blog/2008/09/14/use-firefox-to-spell-check-your-website/. javascript:document.body.contentEditable='true'; document.designMode='on'; void 0;
This make spelling check works, but brings a big problem. This create two editors (or cursors), the formating or style is not preserved when a document is modified in this mode.
I had a quick look at this, and was able to get spellcheck working by setting contenteditable='true'
and readonly='true'
on the div
with id='canvas'
using the inspector.
This exhibited none of the dual cursor problems or issues as shown in the above comment and seemed to work fine.
I haven't tested this properly though and do not know what (if anything) breaks.
Amazing! This works greatly! Thanks a lot.
Good to hear that it worked.
Leaving this issue open for now, till a tested Pull Request appears and gets merged. :-)
i propose to limit that editable+readonly state to the actual spell-checking (if possible). then a change for that to webodf is quite non-invasive.
so what we need is a spell-check mode, do we need to disable normal editing during that?
The fix works very well in FireFox, but in Chrome it works sometimes. In Chrome, it seems the spelling checking typically works when the element gets the mouse focus. Does the webodf change the focus?
FYI for others who find themselves here and are wondering how to get spell checking working as described above...
I used the callback function (second arg) in openDocumentFromUrl
(as the document is fully loaded by that time) to apply the attributes like this:
var $container = $webodfeditor.find("document").parent();
$container.attr("contenteditable", "true");
$container.attr("readonly", "true");
Where $webodfeditor
is a jQuery object pointing to the container I use for the editor
(and yes, the attr
calls could be chained). It seems that the id
names have changed from the comments above as there is no div
with id=canvas
, hence my selector to find the document
node then back up to its .parent()
.
The callback function (second arg) in openDocumentFromUrl
isn't just onError, but rather onLoad flagging if an err
or occurs during the document load (would be nice if the docs mentioned this ;).
A fairly strong disclaimer: using the content editable approach is almost guaranteed to break things in document editing. There is a cache that will go out of sync when the document text changes without notification.
Agh... [four-letter-word] [four-letter-word] [four-letter-word]... ;)
How would I go about notifying the editor that changes have been made? Somehow I think the ghetto "add then remove a character via JS" would get me into similar strife?
It seems I can hook the event and ensure the notification goes thru, just need to know how to broadcast and what to broadcast on the event.
EDIT: Adding this line:
$editorContainer.on("input", function() { /*stuff*/ });
...fires the event twice as described in the linked SO posting, so with a means of broadcasting the change to WebODF I should be mostly ok?
@campbeln I can relate to that feeling!
There are some possible workarounds, but best place to discuss would be on IRC or via email. I work in the AU timezone (UTC+10), and other core devs work on UTC+1 (I think)... please feel free to come by ask :-).
@peitschie You're not in Canberra, are you? If so let's do coffee ;)
I'll hit you up tomorrow (as our work day is done, after all!)
@peitschie would love to email or IRC re: getting this feature up and running via a single back to WebODF on change, please let me know how to contact you.
@campbeln IRC is probably still best. I'm online there right now if you drop by.
@peitschie Stoopid question; which channel? It's been a good 10 years since I've IRC'd.
@campbeln from http://www.webodf.org/community/: #webodf on freenode. Alternatively, you can access it via webchat at http://webchat.freenode.net/?nick=webodfcurious&channels=webodf
@peitschie sorry for the delay! I got pulled off on other tasks but I'll be hitting this come Monday so hopefully I'll hunt you down in IRC then ;)
Looks like http://www.webodf.org/docs/symbols/src/gui_TextController.js.html might have some insights into the spellcheck replace(?).
The browser spelling check does not work in the webodf editor. An plan to address this issue in the future?