【问题标题】:How to avoid automatically inserting <p>&nbsp;</p> in CKEditor.?如何避免在CKEditor中自动插入<p> </p>。?
【发布时间】:2012-10-04 08:05:45
【问题描述】:

我正在从后端将输入设置为 CKEditor。当我给出一组段落值时,它会自动插入&lt;p&gt;&amp;nbsp;&lt;/p&gt;。我怎样才能避免这种标签的插入。

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

我想避免额外的&lt;p&gt;&amp;nbsp;&lt;/p&gt;

我已经使用了下面的代码但没有用。

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

谁能帮帮我..

【问题讨论】:

    标签: javascript ckeditor


    【解决方案1】:

    您的 HTML 无效! ;)

    HTML 不允许嵌套段落。试试这个,看看一切都好(没有鬼&amp;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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-06
      • 1970-01-01
      • 1970-01-01
      • 2011-01-05
      相关资源
      最近更新 更多