views:

188

answers:

2

I am working on modifying an existing spell check plugin for TinyMCE.

This is what is supposed to happen: 1. User hits "space" and the spell check runs. 2. If the word is spelled wrong the word gets wrapped with a span and gets a red underline

what I find happening is that when the user hits space bar the word does get spell checked but the cursor pops back to the end of the word just typed (instead of to where the space is) (you can see this in action at http://mail.solidhouse.com/webmail2/test.html)

here is my pseudcode: var b = this.editor.selection.getBookmark(); //for each node node.nodeValue.replace(r5, '$1$2'); this.editor.selection.moveToBookmark(b);

what I am suspecting is that moveToBookmark keeps the cursor within the element but I have no idea what to do to remedy this.

(I have tried incrementing b.start and b.end but that did not work)

I know this is hard to explain. Any thoughts on this are greatly appreciated.

A: 

Can you get yourself out of the element by grabbing its parent?

this.parentNode.moveToBookmark(b);

Or something like that.

Jon Smock
+1  A: 

try incrementing the bookmark start/end by 2 instead of 1 if you haven't already. since the underline adds a tag around the mispelled words, that's an additional 2 places that need to be accounted for in the bookmark: 1 for each side of the span.

adam.wulf