CKEditor - 使用“高级内容过滤器”规则指定值

时间:2013-06-18 12:58:03

标签: filter ckeditor rules

似乎CKEditor的某些插件指定了属性值。例如,从左到右插件具有以下规则:

{
  "styles":null,
  "requiredStyles":null,
  "classes":null,
  "requiredClasses":null,
  "attributes":{
    "dir":"ltr"
  },
  "requiredAttributes":{
    "dir":true
  },
  "elements":{
    "span":true
  },
  "featureName":"styles",
  "propertiesOnly":false,
  "match":null
},

如何使用字符串格式规则指定值? 类似于span[!dir=ltr]

1 个答案:

答案 0 :(得分:3)

你做不到。字符串格式不允许这样的定义。您可以指定span[!dir],以便所有跨度都需要dir属性,而不需要其他内容。使用对象定义,您可以执行更多操作,例使用功能:

...
'ul, li: true,
'$0': {
    match: function( el ) {
        return el.name == 'b';
    },
    propertiesOnly: true,
    attributes: 'dir'
}
'$1': {
...

为什么坚持使用字符串格式?您可以使用对象并将其存储为JSON。