1

似乎 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]

4

1 回答 1

3

你不能。字符串格式不允许这样的定义。您可以指定span[!dir]所有跨度都需要dir属性而不是其他任何东西。通过对象定义,您可以做更多事情,例如使用函数:

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

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

于 2013-06-19T07:31:00.020 回答