通过cdn禁用ckeditor中的auto <p> </p>

时间:2017-03-12 05:14:22

标签: javascript ckeditor

我通过CDN链接实现了CKeditor 4.5.7版。如何在文本区域中禁用自动<p></p>标记。我已经按照这里的stackoverflow发布了一些建议。通过使用代码:

创建config.js文件
CKEDITOR.editorConfig = function( config ) {

    config.enterMode = 2; //disabled <p> completely
    config.enterMode = CKEDITOR.ENTER_BR // pressing the ENTER KEY input <br/>
    config.shiftEnterMode = CKEDITOR.ENTER_P; //pressing the SHIFT + ENTER KEYS input <p>
    config.autoParagraph = false; // stops automatic insertion of <p> on focus
};

这仍然没有帮助。

1 个答案:

答案 0 :(得分:1)

我无法从你的代码片中得出任何结论,说明为什么它不起作用。有几种方法可以配置CKEDITOR,其中一种方法可以解决您的问题 -

我将enterMode替换为br的2。 Workking JSBin在这里 - http://jsbin.com/xukebeyefo/1/edit?html,output

<script src="https://cdn.ckeditor.com/4.6.2/standard/ckeditor.js"></script>
<textarea name="editor1"></textarea>
<script>
  CKEDITOR.replace('editor1', {
    enterMode: Number(2),
  });

</script>