To reproduce it, in source view, type something and then hit the enter key to do a carriage return, then type something again. Then change to the WYSIWYG view, then change back to the source view and the carriage returns will be removed.
For example, if I type this in the source view:
test
test
Then change to the WYSIWYG view then back to source view it changes to:
<p>test test</p>
There must be some configuration setting that I am missing.
In the fckconfig.js file I tried changing FCKConfig.FormatSource and FCKConfig.FormatOutput to false with no luck.
I am trying to deal with this too, as well as this problem:
FCK Editor replaces any occurence of ...
<BR> <BR/> <BR clear="all"> etc
... with this P tag combo...
<p> </p>
It appears the replacement is happening on the read, not on the write. We can change the html to include the BR tag and it will go into the database, but upon retrieving the html to edit, FCK will replace all BR tags with the P.
I am trying to do some image layouts with the editor and br clear all is very important to not replace.
Also, removing all the chr(13) is frustrating. Makes the html very hard to read.
Thanks for trying to help. From what I have read removing carriage returns is a standard of W3C and so the FCKeditor does this on purpose so I am not sure how this is not happening for you unless you modified the code or you changed some configuration setting. I also tested in a completely new environment using the samples and it has the same behavior.
First thing, \n\r is ONLY for formatting the source, it will make no difference in the actual layout unless it's in a <pre> tag, so I would not worry to much about it. Set the FCKConfig.FormatSource and FCKConfig.FormatOutput both to true and let it format it for you.
I know the carriage return is only in the source and that is the problem. FCKeditor removes it from the source. All I want is for the FCKeditor to not touch the source and leave it as is. You would think there would be a setting such as setting FCKConfig.FormatSource = false; that would do this but this doesn't work, it still removes carriage returns.
For anyone else that is having this problem, I was able to fix this by modifying the FCKeditor Javascript: In these files: fckeditor\editor\js\fckeditorcode_gecko.js fckeditor\editor\js\fckeditorcode_iejs
In the current version (2.6.4.1) on line 26 if you remove replace operations such as: this.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g,'');
You can also do a search for '\n' and '\r'
If you remove all ."replace(...);" it will stop the FCKeditor from removing carriage returns.
If anyone else knows of a more elegant way to do this such as a configuration setting, please let me know.
You can protect any kind of code here, so if you have a custom language for your site, you can put it in here if you configure the regex correctly. For example, if you are using expression engine, you'd use this:
FCKConfig.ProtectedSource.Add( /{exp:[\s\S]*?{\/exp:[^\}]+}/g ) ; // Expression Engine style server side code
Re: How to prevent FCKeditor from removing carriage returns?
I tried but failed to recreate it, my \r\n's are all kept in place
Re: How to prevent FCKeditor from removing carriage returns?
Thanks a lot for taking the time to reply.
To reproduce it, in source view, type something and then hit the enter key to do a carriage return, then type something again. Then change to the WYSIWYG view, then change back to the source view and the carriage returns will be removed.
For example, if I type this in the source view:
Then change to the WYSIWYG view then back to source view it changes to:
There must be some configuration setting that I am missing.
In the fckconfig.js file I tried changing FCKConfig.FormatSource and FCKConfig.FormatOutput to false with no luck.
Re: How to prevent FCKeditor from removing carriage returns?
FCK Editor replaces any occurence of ...
<BR>
<BR/>
<BR clear="all">
etc
... with this P tag combo...
<p> </p>
It appears the replacement is happening on the read, not on the write. We can change the html to include the BR tag and it will go into the database, but upon retrieving the html to edit, FCK will replace all BR tags with the P.
I am trying to do some image layouts with the editor and br clear all is very important to not replace.
Also, removing all the chr(13) is frustrating. Makes the html very hard to read.
Re: How to prevent FCKeditor from removing carriage returns?
http://en.wikipedia.org/wiki/XHTML
Re: How to prevent FCKeditor from removing carriage returns?
Thanks for trying to help. From what I have read removing carriage returns is a standard of W3C and so the FCKeditor does this on purpose so I am not sure how this is not happening for you unless you modified the code or you changed some configuration setting. I also tested in a completely new environment using the samples and it has the same behavior.
I know the carriage return is only in the source and that is the problem. FCKeditor removes it from the source. All I want is for the FCKeditor to not touch the source and leave it as is. You would think there would be a setting such as setting FCKConfig.FormatSource = false; that would do this but this doesn't work, it still removes carriage returns.
For anyone else that is having this problem, I was able to fix this by modifying the FCKeditor Javascript:
In these files:
fckeditor\editor\js\fckeditorcode_gecko.js
fckeditor\editor\js\fckeditorcode_iejs
In the current version (2.6.4.1) on line 26 if you remove replace operations such as: this.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g,'');
You can also do a search for '\n' and '\r'
If you remove all ."replace(...);" it will stop the FCKeditor from removing carriage returns.
If anyone else knows of a more elegant way to do this such as a configuration setting, please let me know.
Re: How to prevent FCKeditor from removing carriage returns?
Re: How to prevent FCKeditor from removing carriage returns?
Pretty simple too, just open up the file fckeditor/fckconfig.js.
Now navigate to around line 57, you will see FCKConfig.ProtectedSource.Add commands.
Now just add this in:
You can also do this for the IMG tag if you don't want it wrapped in the p tag.
You can protect any kind of code here, so if you have a custom language for your site, you can put it in here if you configure the regex correctly. For example, if you are using expression engine, you'd use this:
FCKConfig.ProtectedSource.Add( /{exp:[\s\S]*?{\/exp:[^\}]+}/g ) ; // Expression Engine style server side code