CKEditor自定义ACF禁用所有插件
我试图在我的ck编辑器中设置一个明确的允许内容列表,但似乎我的列表中包含的内容不够多,因为几乎所有的插件都被禁用了。如果我将ACF设置回自动(删除allowedContent),那么所有插件都会返回。这是我在config.js中的允许内容CKEditor自定义ACF禁用所有插件,ckeditor,ckeditor4.x,Ckeditor,Ckeditor4.x,我试图在我的ck编辑器中设置一个明确的允许内容列表,但似乎我的列表中包含的内容不够多,因为几乎所有的插件都被禁用了。如果我将ACF设置回自动(删除allowedContent),那么所有插件都会返回。这是我在config.js中的允许内容 config.allowedContent = { h1: true, h2: true, h3: true, 'span, p, ul, ol, li,': { styles: 'color, ma
config.allowedContent =
{
h1: true,
h2: true,
h3: true,
'span, p, ul, ol, li,': {
styles: 'color, margin-left, margin-right, font-size'
},
'a[!href,target,name]': true,
b: true,
u: true,
i: true,
}
然而,唯一似乎被启用的按钮是粗体、下划线和斜体。我正试图弄明白为什么我的其他插件不能工作。例如,链接插件具有以下功能:
var allowed = 'a[!href]',
required = 'a[href]';
// Add the link and unlink buttons.
editor.addCommand( 'link', new CKEDITOR.dialogCommand( 'link', {
allowedContent: allowed,
requiredContent: required
} ) );
editor.addCommand( 'anchor', new CKEDITOR.dialogCommand( 'anchor', {
allowedContent: 'a[!name,id]',
requiredContent: 'a[name]'
} ) );
正如您所看到的,我已经定义了带有必要属性的锚点(带有href和名称的锚点),但是按钮没有显示!我已经通过打印CKEDITOR.instances[“editor-1”].filter.allowedContent验证了语法的正确性,它显示了我所期望的对象。我也尝试过添加一些常用元素,比如看看添加其中一个是否能让插件恢复,但事实并非如此。那么我遗漏了什么呢?看来我把对象语法和字符串语法混为一谈了。一旦我纠正了这一点,锚定和字体大小按钮开始出现。以下是我目前掌握的情况:
config.allowedContent =
{
h1: true,
h2: true,
h3: true,
a: {
attributes: ['!href','target','name']
},
b: true,
u: true,
i: true,
// font-size
span: {
styles: { 'font-size': '#(size)' },
overrides: [ { element :'font', attributes: { 'size': null } } ]
}
}
我仍然需要找出字体颜色和其他一些颜色的正确定义,但这只是检查插件代码并了解它们的期望值的问题