And I’m feeeeeeeeeeling… good!
Officially conquered the non-IE browsers today, including the highlighting feature. Struggled with the implementation of the highlighting feature in IE, but got the barebones of it working by the end of the day. The IE implementation, however, has an odd intermittent bug that I haven’t quite nailed down reproduction steps for yet that basically boils down to a character offset being like 5-6 characters off — completely unacceptable in the final implementation, of course.
Going to try to work that one out tonight so that I can show off the prototype tomorrow (per my manager and director’s individual requests).
There are unresolved issues in all browsers, mainly the “line break” dilemma.
Turns out this has to do with moving a TextRange along. If you want to move by characters and the next character (or first character to be in the range) is a space, it gets all screwed up. Investigating workarounds….
Came up with a [thus far] consistently working hack of a workaround. Basically, when the range’s selection and the currentNode’s nodeValue do not match, I recollapse to the start and then try to grab the whole nodeValue plus an arbitrary amount of characters (currently 10) to push the buffer along farther. Once it’s moved, I then see how many characters the range encompasses and then move the end point backward by the difference in the expected range versus actual range.
The more annoying part about the TextRange.move/moveStart/moveEnd functions is that they are supposed to return the actual number of characters moved. Turns out they just seem to repeat back the number of characters they were supposed to move (presumably unless you are at the end of the document)… with the padding I added, mine was moving 3 less characters than it should have, but still reporting that it moved the whole span.