Opened 15 years ago

Closed 14 years ago

Last modified 14 years ago

#3260 closed Bug (invalid)

Extra line is getting added after <p> tag

Reported by: Senthil Owned by:
Priority: Normal Milestone:
Component: Core : Output Data Version: 3.1
Keywords: Cc: Senthil

Description

After <p> tag, there is an extra line added for the text entered by the user. This was not happening in 2.6.x release thus this new behavior breaks our code.

Change History (9)

comment:1 Changed 15 years ago by Frederico Caldeira Knabben

Can you please give us an example of the HTML you are having with it?

comment:2 Changed 15 years ago by Senthil

After the <p> tag, user typed words are displayed in the next line instead of displaying it in the same line. In 2.6.x text were displayed in the same line. Because of this new behavior our functionality is broken.

Example text: <p>

This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>

comment:3 Changed 15 years ago by Frederico Caldeira Knabben

Resolution: invalid
Status: newclosed

This is actually a feature in the editor regarding the output formatting for readability, and it's customizable.

To do that when creating an editor instance:

CKEDITOR.replace( 'editor1',
	{
		on :
		{
			instanceReady : function( ev )
			{
				this.dataProcessor.writer.setRules( 'p',
					{
						indent : false,
						breakBeforeOpen : true,
						breakAfterOpen : false,
						breakBeforeClose : false,
						breakAfterClose : true
					});
			}
		}
	});

... or, make it in a way that it affects all instances, by declaring the following after the editor script:

CKEDITOR.on( 'instanceReady', function( ev )
	{
		ev.editor.dataProcessor.writer.setRules( 'p',
			{
				indent : false,
				breakBeforeOpen : true,
				breakAfterOpen : false,
				breakBeforeClose : false,
				breakAfterClose : true
			});
	});

comment:4 Changed 15 years ago by Frederico Caldeira Knabben

#3277 has been marked as DUP

comment:5 Changed 14 years ago by Ted Wood

Component: GeneralCore : Output Data
Keywords: Oracle removed
Priority: HighNormal
Resolution: invalid
Status: closedreopened
Type: New FeatureBug
Version: 3.1

With the latest version of CKEditor (3.1), I continue to have the problems described by this bug report. It seems like the *default* is for these extra lines to be inserted after several tags. It's great that this behavior is configurable, but I vote for the extra break tags *not* be inserted by default. Let developers decide if they want them.

Right now, I have all of my editors configured with the following:

ev.editor.dataProcessor.writer.setRules('p',
	{
		indent			: false,
		breakBeforeOpen	: false,
		breakAfterOpen	: false,
		breakBeforeClose: false,
		breakAfterClose	: false
	}
);
ev.editor.dataProcessor.writer.setRules('ol',
	{
		indent			: false,
		breakBeforeOpen	: false,
		breakAfterOpen	: false,
		breakBeforeClose: false,
		breakAfterClose	: false
	}
);
ev.editor.dataProcessor.writer.setRules('ul',
	{
		indent			: false,
		breakBeforeOpen	: false,
		breakAfterOpen	: false,
		breakBeforeClose: false,
		breakAfterClose	: false
	}
);
ev.editor.dataProcessor.writer.setRules('li',
	{
		indent			: true,
		breakBeforeOpen	: false,
		breakAfterOpen	: false,
		breakBeforeClose: false,
		breakAfterClose	: false
	}
);

To repeat that code for every other tag that's being affected by these defaults seems a little overkill. Currently, it's still affecting all heading tags (h1 through h6).

At the very least, I'd like to know why these defaults are in place and why one must override them to avoid the extra break tags being inserted. CKEditor is actually generating invalid code as a result of the defaults. It's generating code, such as the following:

<ul>
    <li>Item One</li>
    <br>
    <li>Item Two</li>
</ul>

That extra break tag doesn't belong between two list items, but CKEditor's default configuration is inserting it there. Very frustrating to have to override the defaults just to fix this strange behavior.

I want to express my sincere appreciation for the developers' hard work on CKEditor, but this issue has been plaguing my installations for several months, and it's been very difficult to find a solution. Am I doing something wrong?

comment:6 Changed 14 years ago by Ted Wood

Milestone: CKEditor 3.0CKEditor 3.x

comment:7 in reply to:  5 Changed 14 years ago by Alfonso Martínez de Lizarrondo

Milestone: CKEditor 3.x
Resolution: invalid
Status: reopenedclosed

Replying to coolfactor:

Am I doing something wrong?

Yes. You are converting new lines (\r\n) to <br>

comment:8 Changed 14 years ago by Ted Wood

That seems to be what's happening, yes, but how do I fix it? Again, this issue exists in a vanilla installation of CKEditor 3.1. I haven't done anything to explicitly cause this conversion.

The <br> are being inserted for every \r\n in the HTML source. What is the reasoning behind why this is a feature when editing the raw HTML?

I appreciate your further assistance, as I haven't found a documented solution to this issue. Thank you for telling me I'm doing something wrong, but please provide a reference to the solution at the same time for the benefit of others reading this bug post. :-)

comment:9 Changed 14 years ago by Ted Wood

Okay, solved... thanks to alfonsoml's suggestion, I found the problem. I was using PHP's nl2br() function on the output of the CKEditor's content... that explains the extra <br> tags that being added.

I still want to know why the default configuration inserts breaks in strange places, particularly after an opening tag, when viewing the HTML source.

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