CKEditor strip/filter HTML comments?

醉酒当歌 提交于 2019-12-14 02:17:30

问题


I see a lot about this smart Advanced Content Filter, but it's too smart, it handles HTML elements and doesn't let me do custom filtering. I can't figure out how to strip all inserted HTML comments.


回答1:


Advanced Content Filter does not touch comments. It only filters HTML elements, nothing more.

If you want to strip all comments, then using dataProcessor's filters will be the best choice.

For example to filter them out on input:

CKEDITOR.replace( 'editor1', {
    on: {
        pluginsLoaded: function( evt ) {
            evt.editor.dataProcessor.dataFilter.addRules( {
                comment: function() {
                    return false;
                }
            } );
        }
    }
} );


来源:https://stackoverflow.com/questions/19252237/ckeditor-strip-filter-html-comments

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