I have the following content in a TinyMCE instance:
<p><span id="span1">Test</span><span id="span2">Bla</span></p>
When the user places the cursor in front of βBβ and starts typing, I want the text to be entered in the second interval. Google Chrome (I use Chromium 11.0.696.65 to be precise) sets the cursor to the end of the first range, which you can check using the following code:
document.body.innerHTML = '<p><span id="span1">Test</span><span id="span2">Bla</span></p>';
document.designMode = "on";
var sel = document.getSelection();
alert(sel.baseNode.data);
Unfortunately, it is not possible to set the focus to the beginning of the second range manually:
var span = document.getElementById("span2");
sel.setBaseAndExtent(span, 0, span, 0);
alert(sel.baseNode.data);
sel.setBaseAndExtent(span, 1, span, 1);
alert(sel.baseNode.data);
Google Chrome seems to be moving the cursor back to the end of the previous node. I also tried changing the Range object, but this led to the same problem.
I do not think of any solution to this problem, does anyone have an idea what causes this and how to fix it?
Cheers,