focusNode is being taken away by a click outside a contenteditable div
Posted on 2013-06-03
I have a div where I've set contenteditable=true. After selecting some text in the div I'm able to execute things like document.execCommand('bold', false, false); and get the desired result.
But when I try this with document.execCommand('forecolor', false, color); nothing happens and I can see that the reason is that when I go off to my color picker to click a color box, : window.getSelection() shows on return that focusNode is now the color box .
I've done a jQuery .focus() on the original text div but that didn't bring focusNode back to the selected text. Could someone point out where I'm going wrong? It seems that if you click on something that doesn't have contenteditable=true, like my color box, it shouldn't move focusNode. I'm working with the FireFox browser.
Thanks for any suggestions.