Ticket #993 (closed New Feature: fixed)

Opened 7 years ago

Last modified 4 years ago

Preserve formatting of ProtectedSource elements

Reported by: anusha.a.rao Owned by:
Priority: Normal Milestone:
Component: General Version: FCKeditor 2.4.3
Keywords: HasPatch Cc:

Description

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.

Anusha

Attachments

index.html (3.7 KB) - added by anusha.a.rao 7 years ago.
The html page used for testing formatting

Change History

comment:1 Changed 7 years ago by alfonsoml

  • 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 7 years ago by anusha.a.rao

The html page used for testing formatting

comment:2 Changed 7 years ago by anusha.a.rao

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.

Thanks

Anusha

comment:3 Changed 7 years ago by alfonsoml

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 7 years ago by anusha.a.rao

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 ;

Anusha

comment:5 Changed 7 years ago by alfonsoml

  • Keywords Pending removed
  • Summary changed from FCK.GetXHTML() to handle formatting to Preserve 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.
	/<script[\s\S]*?<\/script>\s*/gi,

	// <noscript> tags (get lost in IE and messed up in FF).
	/<noscript[\s\S]*?<\/noscript>\s*/gi,

	// Protect <object> tags. See #359.
	/<object[\s\S]+?<\/object>\s*/gi
] ;

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 7 years ago by w.olchawa

  • Keywords HasPatch added

comment:7 Changed 4 years ago by garry.yao

  • Status changed from new to closed
  • Resolution set to fixed

The protectedSource config is now available in CKEditor.

Note: See TracTickets for help on using tickets.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy