Is there something better than document.execCommand? Is there something better than document.execCommand? javascript javascript

Is there something better than document.execCommand?


There is one alternative to using execCommand - implementing the whole interaction of an editor including blinking of a cursor. And it has been done. Google does it in docs, but there's something free and open-source too. Cloud9 IDE http://c9.io has an implementation. AFAIK, github uses that editor for some time now. And you surely can do anything under that, because there's no native code involved - like in execCommand

The repo is here: https://github.com/ajaxorg/cloud9 (it contains the whole IDE, you will need to find the code for the editor. )

Also - dom mutation events are deprecated. If you can drop support for old browsers, try mutation observer. If not - try to avoid detecting DOM changes at all and intercept changes in the editor's implementation. It might be the way to go for the new browsers too.


There is Trix rich text editor, from their description it looks like avoiding inconsistent execCommand is the whole point of the project.


It seems the new standard will be Input Events Level 2. To me it looks like it will be a revised improved version of execCommand.