关闭封闭 <p>CKEditor 3.0 中的标签

2022-01-18 00:00:00 tags html ckeditor paragraph

是否有可能关闭所有书面内容的自动封闭在<p></p>在 CKEditor 3.x 中?

Is there a possibility to turn off the automatic enclosing of all written content within <p></p> in CKEditor 3.x?

我试过了

  CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;

但这只是将内联换行符更改为 <br/>同时离开封闭的段落.

but this just changes the inline linebreaks to <br /> while leaving the enclosing paragraph.

当前编写测试"会产生此输出

Currently writing "Test" produces this output

<p>
    Test</p>

但我希望它是简单的

Test

是否有为此的配置属性,或者是否有其他内联编辑器更适合此?

Is there a configuration property for this or would another inline editor to be better suited for this?

推荐答案

CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR; - 这对我来说非常适合.您是否尝试过清除浏览器缓存 - 这有时是个问题.
您也可以使用 jQuery 适配器查看它:

CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR; - this works perfectly for me. Have you tried clearing your browser cache - this is an issue sometimes.
You can also check it out with the jQuery adapter:

<script type="text/javascript" src="/js/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/js/ckeditor/adapters/jquery.js"></script>
<script type="text/javascript">
$(function() {
    $('#your_textarea').ckeditor({
        toolbar: 'Full',
        enterMode : CKEDITOR.ENTER_BR,
        shiftEnterMode: CKEDITOR.ENTER_P
    });
});
</script>


根据@Tomkay 的评论更新:

从 CKEditor 3.6 版开始,您可以配置是否要使用 <p></p> 等标签自动包装内联内容.这是正确的设置:

Since version 3.6 of CKEditor you can configure if you want inline content to be automatically wrapped with tags like <p></p>. This is the correct setting:

CKEDITOR.config.autoParagraph = false;

来源:http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.autoParagraph

相关文章