防止 CKEditor 添加 <p> 标签到内容
Preventing CKEditor from adding <p> tags to content
我正在为我的 HTML 页面使用 CKEditor。加载页面后,我单击 div 并使其可编辑。但问题是它会自动添加一些 p 标签和一些 another 标签。
例如
点击前
<div style="width:100%;" class="homeHead editor ">
<i>My content.</i>
</div>
但点击后
<div contenteditable="true" style="width: 100%; position: relative;" class="homeHead editor cke_editable cke_editable_inline cke_contents_ltr cke_show_borders" tabindex="0" spellcheck="false" role="textbox" aria-label="Rich Text Editor, editor1" title="Rich Text Editor, editor1" aria-describedby="cke_53">
<p><em>Affordable. Simple.</em></p>
</div>
如何保持以前的状态HTML
将 "CKEDITOR.config.enterMode" 和 "config.allowedContent" 放入您的 config.js 文件中,如下所示 -
CKEDITOR.editorConfig = function( config ) {
CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
config.allowedContent = true;
};
这个有助于解决您的问题
CKEDITOR.editorConfig = function( config )
{
config.enterMode = CKEDITOR.ENTER_BR;
};
"config.enterMode = CKEDITOR.ENTER_BR" 标签将 "p" 标签更改为 "br" 标签。
我正在为我的 HTML 页面使用 CKEditor。加载页面后,我单击 div 并使其可编辑。但问题是它会自动添加一些 p 标签和一些 another 标签。
例如 点击前
<div style="width:100%;" class="homeHead editor ">
<i>My content.</i>
</div>
但点击后
<div contenteditable="true" style="width: 100%; position: relative;" class="homeHead editor cke_editable cke_editable_inline cke_contents_ltr cke_show_borders" tabindex="0" spellcheck="false" role="textbox" aria-label="Rich Text Editor, editor1" title="Rich Text Editor, editor1" aria-describedby="cke_53">
<p><em>Affordable. Simple.</em></p>
</div>
如何保持以前的状态HTML
将 "CKEDITOR.config.enterMode" 和 "config.allowedContent" 放入您的 config.js 文件中,如下所示 -
CKEDITOR.editorConfig = function( config ) {
CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
config.allowedContent = true;
};
这个有助于解决您的问题
CKEDITOR.editorConfig = function( config )
{
config.enterMode = CKEDITOR.ENTER_BR;
};
"config.enterMode = CKEDITOR.ENTER_BR" 标签将 "p" 标签更改为 "br" 标签。