1

我想在ckeditor上禁用ACF,正如许多帖子和文档所建议的那样,我通过以下方式将allowedcontent设置为true,仍然过滤掉我的html。

CKEDITOR.config.allowedContent = true;

CKEDITOR.editorConfig = function( config ) {

config.allowedContent = true;

// also tried CKEDITOR.allowedContent = true; and CKEDITOR.config.allowedContent = true;

 };

我试图在我的插件代码中插入我的自定义标签,如下所示。

CKEDITOR.plugins.add('MakeCPBold', {
 init: function (editor) {
     editor.addCommand('MakeCPBoldCommand', {           
         exec: function (editor) {              
             editor.insertHtml('<CP:CP_B>Sample Content</CP:CP_B>');                               
         }
     });         
     editor.ui.addButton('MakeCPBold', {
         label: 'Make CP Bold',
         command: 'MakeCPBoldCommand',
         icon: this.path + 'images/makeabbr.gif',
         toolbar: 'Basic'

    });
 }

});

insertHtml 只是插入“示例内容”并过滤自定义标签 CP:CP_B。用任何已知标签(如 strong)替换标签 CP:CP_B 可以正常工作。

我是否正确配置它?

我正在使用最新版本的 ckeditor 4.4.1。还尝试了 4.4.0 和 4.2 版本

谢谢

4

1 回答 1

0

CKEditor 是 HTML文本编辑器,而不是 XML 编辑器。不要期望它支持所有的 XML 特性,比如命名空间。使用data-foo属性将自定义内容与标准数据区分开来。

于 2014-06-18T09:58:19.970 回答