htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0 - Add-Ons:
I got the SpellerPages spellchecker to work with htmlArea finally


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


brockb
Novice

May 2, 2004, 8:04 PM

Post #1 of 8 (45232 views)
Shortcut
I got the SpellerPages spellchecker to work with htmlArea finally Can't Post

Greetings all,
I have seen several inquiries as to getting spellerpages to work with htmlArea (I've had a couple of posts on here about the same thing myself). Since I haven't seen anybody post on here yet how to get the two to work together, I thought I'd post what I have figured out so far. It is far from perfect... but I do believe it is a step in the right direction. And because I'm sure I will need one of your help someday, I'll help out with this as much as I can. Wink

Most people's problems with getting speller pages to work with htmlArea is getting the corrected results from speller pages back into htmlArea. I have finally figured this out.

Another problem people will probably have once they get speller pages to talk back to htmlArea, is they will notice that it is spellchecking the content in the "view html source" section, not what is on the WYSIWYG section. It isn't fun having to spellcheck anchor tags and font tags. I have this one figured out as well.

And probably my biggest concern, was once I got it to send the corrected results back to the WYSIWYG section, it replaced EVERYTHING that was in there with the text from speller pages, thus you lost any & ALL of your formatting that may have been in place before beginning the spell checker. OUCH!!! Unsure I have that fixed also.

What I did is interfaced spellerpages with Luis' "find and replace" functions. Well, one of the functions. I used his ReplaceAllTxt() function. I couldn't get his ReplaceTxt() function to work correctly yet because when calling the FindTxT function, it seems to always want to start at the bottom of the page, thus requiring you to confirm starting over at the beginning of the page. Because of this, the way I have spellerpages set up right now, it replaces ALL instances of a misspelled word instead of just the instance being called. I may try and rework the FindTxt() function so we can replace one instance of the misspelled word instead of all. If somebody else reworks that before I do, I'd appreciate seeing how you did it.

So in the editor.js file, I commented out Luis' call to spell and created a call to our on spell as follows:

Code
   

// SpellerPages Spellchecker
else if (cmdID.toLowerCase() == 'spell') {
if (editdoc.body.createTextRange().htmlText != "") {
window.clipboardData.clearData();
editdoc.execCommand('SelectAll');
editdoc.execCommand('copy');
editdoc.execCommand('Unselect');
setGlobalVar ("_editor_field",objname);
var TxtRange = editor_obj.contentWindow.document.body.createTextRange();
showModalDialog(_editor_url + "popups/spellchecker.php",window, "resizable: no; help: no; status: no; scroll: no; ");
return;
}
else { alert('\nEditor is empty.\n\nThere are no words in the editor to spellcheck!'); }
}



This stores all of the content of the WYSIWYG section of the editor into your clipboard and then calls the spellchecker.php file (I don't even think I have any PHP in this file... you can probably just rename it to spellchecker.html if you want).

I've included my spellchecker.php file in this post.

The following code needs to be at the very top of the script. Starts at line 9.


Code
      var TxtRange;      
TxtRange = dialogArguments.document.selection.createRange();



Some things to note:

I've got a form at the bottom of the script called "set" which holdes the hidden textarea "content" which is where I store the info from the clipboard when the page is loaded:


Code
      document.set.content.value = window.clipboardData.getData("Text");  //Line 14



Speller pages then thinks it is calling from and writing to this textarea (content) throughout the script.

I took Luis' ReplaceAllTxt() function and added it to this page (starting at line 23)


Code
      function ReplaceAllTxt(badword, goodword) {      
var searchval = badword;
var wordcount = 0;
var msg="";
TxtRange.expand("textedit");
TxtRange.collapse();
TxtRange.select();
while (TxtRange.findText(searchval, 1000000000, 2)) {
TxtRange.select();
TxtRange.text = goodword;
wordcount++;
}}



I then went into the heart of the spellerpages script and added the following lines to the replaceWord() function and replaceAll() function


Code
      var s_word_to_repl = this.wordWin.getTextVal( ti, wi); // line 221      





ReplaceAllTxt(s_word_to_repl, newspell); // lines 226 & 267





What this does is as it is checking each word in spellerpages, whenever you click on the "Replace" or "Replace All" buttons, it calls the ReplaceAllTxt function, searches through the WYSIWYG portion of the editor, and replaces all of the instances of the "bad word" with the "good word".

Now if I can only create a function that replaces the ONE INSTANCE of the bad word that you are currently spellchecking and attach it to replaceWord(), and I fix the "UNDO" feature... I'll be all set.

The way I've got it setup here, it keeps all of your formatting intact by doing a search and replace of the misspelled words instead of just highlighting everything, spell checking, and overwriting everything that was highlited... thus loosing your formatting.

I hope this helps some of you people out. I know I was getting kind of frustrated when I wasn't getting any assistance on the same problem... but since my work insisted on htmlArea having a spellchecker, and they were willing to give me the time to work on it... here is a good running start for a lot of you who are looking for the same thing.

Since I don't have it up on a server outside of our office LAN yet, I'll throw in some screenshots below so you can see how it works.


http://www.geocities.com/mark_6_martin/spellchecker.html


(This post was edited by brockb on May 4, 2004, 11:21 AM)
Attachments: spellchecker.php (15.2 KB)


Luis
Veteran

Sep 21, 2004, 9:58 PM

Post #2 of 8 (44654 views)
Shortcut
Re: [brockb] I got the SpellerPages spellchecker to work with htmlArea finally [In reply to] Can't Post

Hi brockb:

Where can I download the whole spellchecker package?

I've not been able to find it.

I'll appreciate any tip. Greetings


Don't give up!!
http://webstationone.com/test/htmlarea


brockb
Novice

Sep 22, 2004, 12:53 AM

Post #3 of 8 (44651 views)
Shortcut
Re: [Luis] I got the SpellerPages spellchecker to work with htmlArea finally [In reply to] Can't Post

Luis... here are the two packages you will need:

SpellerPages: http://sourceforge.net/projects/spellerpages/

GNU Aspell: http://aspell.net/

The way I got it to work with htmlArea (with my limited knowledge) isn't probably the best way to get it to work... but it is working just fine for how we need it. I'd be interested to see what you do with it Luis. I've been so impressed with all of your work so far. Let me know how it turns out.

-Brock


Luis
Veteran

Sep 22, 2004, 11:41 AM

Post #4 of 8 (44643 views)
Shortcut
Re: [brockb] I got the SpellerPages spellchecker to work with htmlArea finally [In reply to] Can't Post

Thanks a lot brockb.


Don't give up!!
http://webstationone.com/test/htmlarea


mmjaeger
Novice

Oct 2, 2004, 3:38 AM

Post #5 of 8 (44561 views)
Shortcut
Re: [brockb] I got the SpellerPages spellchecker to work with htmlArea finally [In reply to] Can't Post

very interesting, however, I still don't see how you get the changed content back into the htmlarea editor - any hints are very much appreciated.



thank you


brockb
Novice

Oct 2, 2004, 12:06 PM

Post #6 of 8 (44546 views)
Shortcut
Re: [mmjaeger] I got the SpellerPages spellchecker to work with htmlArea finally [In reply to] Can't Post

Just take a look at the top of this post where I mention:

"I took Luis' ReplaceAllTxt() function and added it to this page (starting at line 23)"

AND

"I then went into the heart of the spellerpages script and added the following lines to the replaceWord() function and replaceAll() function"

---------------------------------------------------

The second part there... the replaceWord() & replaceALL() functions call Luis' ReplaceAllTxt(). In these two variables, the word that is going to be replaced is held in the variable "s_word_to_repl", and the word that you are replacing it with is held in the variable "newspell".

These two words are sent to Luis' ReplaceAllTxt() function as "badword", and "goodword" respectively. Luis' ReplaceAllTxt() function is what is putting the content back into the htmlArea editor, but you have to call that function with the spell checkers replaceWord() & replaceAll() functions like I mentioned at the top of the post to get ReplaceAllTxt() it to do all the work.

Hope that helps! Smile

-Brock


esthera
User

Feb 12, 2005, 12:41 PM

Post #7 of 8 (43613 views)
Shortcut
Re: [brockb] I got the SpellerPages spellchecker to work with htmlArea finally [In reply to] Can't Post

from what I understand aspell is something that needs to be installed on the server. Is this correct?
I need to put this on a hosted server (where I can't really install anything on the server) Is there anyway to do this?


Aaronzo
New User

Feb 13, 2005, 12:22 PM

Post #8 of 8 (43585 views)
Shortcut
Re: [esthera] I got the SpellerPages spellchecker to work with htmlArea finally [In reply to] Can't Post

Forget all of the Spell Checker add-ons to this program. They are all difficult and time consuming to work with. One of the best FREE spell checkers I've seen for forms, blogs, forums, chats and such is http://www.iespell.com/ It only works in the Internet Explorer browser at the moment, but it does a great, fast job. I've had my clients use it for a few weeks and they love it.

Aaron

===========================
Aaron Weiler
Producer/Director
www.aaronweiler.com

 
 
 


Search for (options)