I managed to fix this issue. I essentially store the selection while my popup is open, then restore it when I'm closing it. Here's the code:
getSelection = function() {
var c = document.getElementById('cuteEditor1');
if(c){
return c.GetSelection();
}
}
createRange = function() {
var selection = getSelection();
if(selection){
if(selection.createRange) {
return selection.createRange();
}
if(selection.rangeCount && selection.getRangeAt) {
return selection.getRangeAt(0);
}
}
return null;
}
select = function(range) {
if(range.select)
range.select();
else {
var selection = getSelection();
if(selection.removeAllRanges && selection.addRange){
selection.removeAllRanges();
selection.addRange(range);
}
}
}
restoreSelection = function() {
if(window.range)
select(window.range);
}
storeSelection = function() {
window.range = createRange();
}
I basically call storeSelection when my popup is being opened. Then, before my popup closes I restore selection to the editor using restoreSelection.
Hope this helps someone out.