Opened 16 years ago

Closed 13 years ago

#993 closed New Feature (fixed)

Preserve formatting of ProtectedSource elements

Reported by: Anusha Owned by:
Priority: Normal Milestone:
Component: General Version: FCKeditor 2.4.3
Keywords: HasPatch Cc:


The FCK.GetXHTML() displays the content in a dirty format(no new line characters). It is different from what the user actually sees in the actual file. It would be good if FCK editor did not mess around with the format of the file and leave the content as it is. This can be enabled as a configurable property in the FCKConfig.js file so that any user who wants the editor to handle formatting can enable it too.


Attachments (1)

index.html (3.7 KB) - added by Anusha 16 years ago.
The html page used for testing formatting

Download all attachments as: .zip

Change History (8)

comment:1 Changed 16 years ago by Alfonso Martínez de Lizarrondo

Keywords: Pending added; FCK.GetXHTML() removed

You might have messed something up, because those settings already exist and they default to format properly the source code:

FCKConfig.FormatSource		= true ;
FCKConfig.FormatOutput		= true ;

Changed 16 years ago by Anusha

Attachment: index.html added

The html page used for testing formatting

comment:2 Changed 16 years ago by Anusha

Hi alfonso,

Thanks for the reply. I have these property already set in FCKConfig.js. I have attached the file I have been using to test the formatting with this ticket. I have the property FCKConfig.FullPage = false ;. I guess this property is invovled in the formattting function too. I have also tried this on the FCK demo site and switching between source mode and wysiwyg mode messes the format.



comment:3 Changed 16 years ago by Alfonso Martínez de Lizarrondo

The only problem that I see is that the new lines after the comments aren't preserved, but I'm not sure that treating all comments as block elements in the formatting would please everybody as some comments might be placed inline.

The rest of the content looks like it has been properly formatted (although it might not be what the user set initially, but it's impossible to keep the original format and doing a WYSIWYG edition based on a browser)

comment:4 Changed 16 years ago by Anusha

The file that i attached when edited by the editor messes up all the content format. Apart from the commented lines, the body content also gets messed up.. There is no alignment at all(Neither what the user set nor does the editor set any format). So what do the following properties do?

FCKConfig.FormatSource = true ; FCKConfig.FormatOutput = true ;


comment:5 Changed 16 years ago by Alfonso Martínez de Lizarrondo

Keywords: Pending removed
Summary: FCK.GetXHTML() to handle formattingPreserve formatting of ProtectedSource elements

I had an idea about this. The regexp for protected source could be modified to include any extra whitespaces after those elements:

// Initialize the regex array with the default ones.
FCKConfig.ProtectedSource.RegexEntries = [
	// First of any other protection, we must protect all comments to avoid
	// loosing them (of course, IE related).
	/<!--[\s\S]*?-->\s*/g ,

	// Script tags will also be forced to be protected, otherwise IE will execute them.

	// <noscript> tags (get lost in IE and messed up in FF).

	// Protect <object> tags. See #359.
] ;

That way after reverting them they will keep their original new lines if they had them, so several scripts in different lines will look fine. But now the problem is that after one of those scripts with the preserved new lines, a <p> will generate an extra new line, so the code formatter would need to be adjusted to don't format tags that are just before or after a comment. And now I don't have the time to check the proper change.

comment:6 Changed 16 years ago by Wojciech Olchawa

Keywords: HasPatch added

comment:7 Changed 13 years ago by Garry Yao

Resolution: fixed
Status: newclosed

The protectedSource config is now available in CKEditor.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy