我想在 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。用任何已知标签(如强标签)替换标签 CP:CP_B 效果很好。
我的配置正确吗?
我使用的是最新版本的ckeditor 4.4.1。还尝试了版本 4.4.0 和 4.2
谢谢
最佳答案
CKEditor 是 HTML 文本编辑器,而不是 XML 编辑器。不要指望它支持所有 XML 功能,例如命名空间。使用 data-foo
属性来区分自定义内容和标准数据。
关于javascript - CkEditor - 将 allowedContent 设置为 true 不会禁用 ACF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24269892/