I can easily do execcommand on a contenteditable selection if using a button. However using any other element fails.
http://jsbin.com/atike/edit
Why is this and
Most, if not all, of the WYSIWYG editors out there use an iframe
element in order to not lose the selection. Another approach, although I haven't tried it, would be to store each selection made on that page after the mouseup
event triggers.
Take a look at this page about Midas, Gecko's built-in rich text editor.