How to use <br> instead of <br /> in CKeditor

我与影子孤独终老i 提交于 2019-12-06 22:54:31

Yay, it took some hardcore Googling (hard to phrase the search), but I found the answer! I hope this will help others.

Simply add:

    CKEDITOR.on( 'instanceReady', function( ev ) {
        // Output self-closing tags the HTML5 way, like <br>
        ev.editor.dataProcessor.writer.selfClosingEnd = '>';
    });

What it does, from what I understand, is to wait for the core plugin "HTML Output Writer" to be loaded - and when it is, it modifies the "writer", which is a property of each editor instance. The above way applies the change to all editors, but it could also be done to individual editor instances (though I find it hard to imagine why anyone would want to do the latter.)

For more info, from the CKEditor4 documentation: How Do I Output HTML Instead of XHTML Code Using CKEditor?

All right, CKEditor rocks! :D

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!