有没有办法获取 CKEditor 4.x(准确地说是 4.4.7)中所有允许标签的列表after编辑器已使用所有插件进行初始化,并且所有allowedContentRules
and disallowedContentRules
或已应用任何其他数据过滤器?
我想要这个列表,以便我可以将其传递到我们的后端进行白名单。我知道 CKEditor 已经有一个白名单插件,它允许我在前端和后端指定相同的白名单,但我担心我可能会错过某些插件中使用的一些标签,这可能会削弱它们。
大概CKEDITOR.filter.allowedContent http://docs.ckeditor.com/#!/api/CKEDITOR.filter-property-allowedContent这就是您正在寻找的。可以从以下位置访问它editor.filter
财产。如何做到这一点的小例子:https://jsfiddle.net/Comandeer/tb6f0g8r/ 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' ) );
}
}
} );
也许这种格式不如简单的字符串那么友好,但它传达了您需要的所有信息。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)