在 CKEditor 4.x 中,有没有办法在初始化后获取允许的标签列表?

In CKEditor 4.x is there a way to get the list of allowed tags after initialization?

有没有办法在 CKEDitor 4.x(准确地说是 4.4.7) 编辑器初始化后获得所有允许的标签列表插件,所有 allowedContentRulesdisallowedContentRules 或任何其他数据过滤器都已应用?

我想要这个列表,以便我可以将它传递给我们的后端以列入白名单。我知道 CKEditor 已经有一个白名单插件,它允许我在前端和后端指定相同的白名单,但我担心我可能会错过某些插件中使用的一些标签,这可能会削弱它们。

可能CKEDITOR.filter.allowedContent is what you're looking for. It can be accessed from the editor.filter property. Small example of how to do it: https://jsfiddle.net/Comandeer/tb6f0g8r/

CKEDITOR.replace( 'editor1', {
    on: {
        instanceReady: function( evt ) {
            // It returns the array of all rules,
            //so if you want to send it to the server,
            // you'll probably need to "JSON-ify" it.
            var allowedContent = evt.editor.filter.allowedContent;
            console.log( JSON.stringify( allowedContent, null, '\t' ) );
        }
    }
} );

也许这种格式不如简单的字符串那么友好,但它传达了您需要的所有信息。