Ramesh
Ramesh

Reputation: 1083

How to avoid automatically inserting <p> </p> in CKEditor.?

I am setting the input to CKEditor from back-end. When i give an set of paragraph values, it automatically inserting the <p>&nbsp;</p>. How can i avoid this insertion of tag.

<p>A wolf wants to eat the girl but is afraid to do so in public. He approaches the girl, and she naïvely tells him where she is going. <p>He suggests the girl pick some flowers, which she does. In the meantime, he goes to the grandmother's house and gains entry by pretending to be the girl.</p> He swallows the grandmother whole, and waits for the girl, disguised as the grandmother.</p>

After loading this into editor it's changing into :

<p>
A wolf wants to eat the girl but is afraid to do so in public. He approaches the girl, and she na&iuml;vely tells him where she is going.</p>
<p>
He suggests the girl pick some flowers, which she does. In the meantime, he goes to the grandmother&#39;s house and gains entry by pretending to be the girl.</p>
<p>
He swallows the grandmother whole, and waits for the girl, disguised as the grandmother.</p>
<p>
&nbsp;</p>

I want to avoid that extra <p>&nbsp;</p>.

And i have used the below code but no use.

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

Can any one help me..

Upvotes: 1

Views: 1785

Answers (1)

oleq
oleq

Reputation: 15895

Your HTML is invalid! ;)

HTML doesn't allow nesting paragraphs. Try this one and see that everything is fine (no ghost &nbsp;):

<p>A wolf wants to eat the girl but is afraid to do so in public. He approaches the girl, and she naïvely tells him where she is going.</p>
<p>He suggests the girl pick some flowers, which she does. In the meantime, he goes to the grandmother's house and gains entry by pretending to be the girl.</p> 
<p>He swallows the grandmother whole, and waits for the girl, disguised as the grandmother.</p>

Upvotes: 1

Related Questions