SOLVE:
I know this is not the most elegant solution, but it works for me.
Before opening a popup, I insert a "span" with a specific identifier, for example:
var sel = tinyMCE.activeEditor.selection; sel.setContent('<span id="_math_marker"> </span>');
Then, when the popup closes and the text is sent back to the editor, I look at the range with a marker, then I select it and call setContent :
var ed = tinyMCE.activeEditor; var marker = ed.dom.get('_math_marker'); ed.selection.select(marker, false); ed.selection.setContent("TEXT TO INSERT");
This works for all browsers! Remember to delete the range if the popup is closed without inserting anything so as not to leave garbage in the editor.
:-)
source share