2012-10-04 103 views
1

我從後端設置CKEditor的輸入。當我給出一組段落值時,它會自動插入<p>&nbsp;</p>。我如何避免這種標籤的插入。如何避免在CKEditor中自動插入<p> </p>?

<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> 

加載到編輯器之後它改變成:

<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> 

我想避免額外的<p>&nbsp;</p>

而我已經使用下面的代碼,但沒有用。

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

任何一個可以幫助我..

回答

2

你的HTML是無效的! ;)

HTML不允許嵌套段落。嘗試這一個,看到一切都很好(沒有幽靈&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> 
+0

謝謝你的答案。 – Ramesh

相關問題