I am working on a customized rich text editor and I am wondering if it is possible to place my cursor somewhere and discover what commands (i.e. bold, italic, justifyCenter, etc.) are currently active/toggled. Obviously, the browser, while in designMode, is keeping track of this. For example, if I have text inside of the iframe like this:
hello world!
and then i place my cursor inside of the word “world”, is there any way to figure out that ‘bold’ is currently toggled without parsing the string and discovering that I am between tags?
The reason I want something like this is so that I can detect a selectionchange event on the editor and then highlight the appropriate button(s) corresponding to what is currently toggled at that position
The
queryCommandState()method ofdocumentdoes this:See MDC, MSDN and Dottoro.