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 greatful! ![]()
Mon, 05/17/2010 - 18:49
#1

Re: Is there anyway to prevent formatting code in SOURCE mod
Re: Is there anyway to prevent formatting code in SOURCE mod
Thanks for the clarification on the comments - I figured it had to be something specific to comment tags with the protectedSource option.

But how about the main goal - is it even possible to prevent to prevent automatic formatting when editing in SOURCE mode? I am very anal about how I like my indentions and where I put new lines, but if I edit in SOURCE mode and add 5 new lines or whatever, switching to WYSIWYG mode and then back to SOURCE mode will completely remove the new lines (which I presume is because it is applying the specified output formatting rules).
It looked like such a setting did once exist in FKEditor, but that option doesn't seem to be present anymore (judging from the API documentation and what I can see in the source code).
For now, the only viable solution for me has been to add a button outside of the editor allowing me to destroy the editor and edit in a traditional textarea, since this at least ensures my code remains how I want it. But I'll admit that it's not a solution I am too keen on, so if there is another work around I'd love to give that a try!
And thank you for taking the time to respond - much appreciated! I wasn't expecting a response, much less how quick it came.
Re: Is there anyway to prevent formatting code in SOURCE mod
You can search the forums for other posts explaining some of the issues.
Re: Is there anyway to prevent formatting code in SOURCE mod
I don't know if what i think can be usefull to you but here i go.
?
I had an issue with the editor as it would convert all my html tags and withespaces in the   ; or < characters. I looked for the solution on the forum/s and net but couldnt find anything so i used a few methods to decode my data after i removed the editor and did a editor.getData() command. Now it seems to work fine and it preserves all my formating just the way I put/want it.
Does this help you at all