I need to add a span at caret position in my application. I could add span at caret position with following code, but could not position the caret inside it, so that if user types in it will go inside the new span.
marker = ed.selection.getBookmark();
ed.selection.moveToBookmark(marker);
tinyMCE.execCommand('mceInsertContent',false,'<span id="mytitle"></span>');
ed.selection.moveToBookmark(marker);
It took me some time to place a cursor myself. You might need to modify it slightly to be used with the span you created, but this should put you intio the right direction: