Still trying to understand the internals of ckeditor and I am stumped as to why the event object for toHtml has a data attribute that may be:
dataValue : String/CKEDITOR.htmlParser.fragment/CKEDITOR.htmlParser.element
??? Is there any good examples of code that uses the toHtml event handler? Why may it be String sometimes and other times a CKEDITOR.htmlParser.fragment or CKEDITOR.htmlParser.element.
All I am trying to do is apply filters whenever someone types into the editor and manipulate the final HTML being rendered (by changing and then calling setData), but holy crap, Batman it is not as easy to figure this out as I would have expected.
The explanation is here: http
The explanation is here: http://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-toHtml
There are few steps when content is processed. First, the content comes as a String, then with priority 5 there's a listener which transform this content from String to a lightweight DOM format which in this case is kept in CKEDITOR.htmlParser.fragment, then content is filtered, processed and with priority 15 that lightweight DOM is written down back to a String.
What are priorities? They allow to order listeners in any way you want. If you'll add listener with priority 4 you'll get data as a String, with priority 6 you'll get CKEDITOR.htmlParser.fragment.
BTW. if you want to process output data, then the correct event will be toDataFormat, not toHtml.
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+