1. The normal text background highlight
2. The strike-through highlight
3. The spelling mistake highlight like that of Microsoft word

Then I went on investigating an idea of wrapping selections with a specific tag like "span" and setting its class attribute or id attribute to a description of the selection like "key=added&id=10". But when setting the html text it gets reevaluated and so any unknown tags are cleared.
I also tried to use empty tags like to wrap boundaries. Again the dummy htmltext property clears and empty tags. I didn't want to fall back to adding square brackets in those tags so finally I settled to the following:
a. Spelling mistakes: search for words and highlight whenever a change in text occurs
b. Add and Delete: assuming they never overlap, I wrapped them in link with href="event:key-add". I handled the link event and stoped propagation.
To optimize even further I included a timer to validate so as multiple changes result in one update to the textarea. So far it works but i know there is room for some further improvement.
I also added function to select next spelling mistake or next change(added/deleted). Furthermore as seen in the snapshot above, spelling errors can be provided with a list of suggested keywords to replace the clicked word.
Source may be downloaded from http://code.google.com/p/flexlighter/
No comments:
Post a Comment