CKEDITOR - Is there anyway to prevent formatting code in SOURCE mode?
- by Lev
I've spent the good portion of my day trying to figure this out, and I figured I'd finally just give in and ask.
How can you prevent ANY automatic formatting when in SOURCE mode?
I like to edit HTML source code directly instead of using the WYSIWYG interface, but whenever I write new lines, or layout tags how I would indent them, it all gets formatted when I switch to WYSIWYG mode and then back to SOURCE mode again.
I stumbled upon this earlier:
http://dev.fckeditor.net/ticket/993
That alluded to a setting which may have existed once upon a time which would be exactly what I'm after. I just want to know how I can completely turn off all automatic formatting when editing in SOURCE mode.
After browsing this site for hours on end and finding absolutely nothing on here or on Google, I came up with a solution I thought would be foolproof (albeit not a pleasant one).
I learned about the "protectedSource" setting, so I thought, well maybe I can just use that and create an HTML comment tag before all my HTML and another after it and then push a regular expression finding the comment tags into the protectedSource array, but even that (believe it or not) doesn't work. I've tried my expression straight up in the browser outside of CKEDITOR and it is working, but CKEDITOR doesn't protect the code as expected (which I suspect is a bug involving comment tags, since I can get it to work with other strings). In case you are wondering, this is what I had hoped would work as a work-around, but doesn't:
config.protectedSource.push( /<!-- src -->[\s\S]*<!-- end src-->/gi );
.. and what I planned on doing (for what appears to be the lack of a setting to disable formatting in SOURCE mode) was to nest all my HTML within the commented tags like this:
<!-- src -->
<div>some code that shouldn't be messed with (but is)</div>
<!-- end src -->
I'd love to hear if you anyone has any suggestions for this scenario, or knows of a setting which I have described, or even if someone can just fill me in as to why I can't get protectedSource to work properly with two comment tags. I really thing it's gotta be a bug because I can get so many other expressions to work fine, and I can even protect HTML within the area of a single comment tag, but I simply cannot get HTML within two different comment tags to stay untouched.
:(
I've wasted about 6-7 hours on this so far today so if anyone can shed any light on it I would be very grateful!
Thanks for reading! ;)