ckeditor:htmlFilter / dataFilter的addRules忽略某些标签

时间:2019-04-26 20:42:25

标签: javascript ckeditor ckeditor4.x

我正在尝试在图形标签上添加htmlFilter / dataFilter规则,但是它似乎被忽略了(其他标签也被忽略,例如img)。代码如下。如果我将标签引用更改为p,则它会被识别,并且样式会按预期应用。但是,Figure,img和其他一些标签将被忽略。为什么会这样?

CKEDITOR.on('instanceReady', function (ev) {
  //console.log('ev: ', ev);

  ev.editor.dataProcessor.htmlFilter.addRules({
    elements: {
      figure: function( el ) {
        //console.log('el: ', el);
        var style = el.attributes.style;
        el.attributes.style = 'margin-inline-start: 5px; margin-inline-end: 5px;' + style;
      }
    }
  });

  ev.editor.dataProcessor.dataFilter.addRules({
    elements: {
      figure: function( el ) {
        //console.log('el: ', el);
        var style = el.attributes.style;
        el.attributes.style = 'margin-inline-start: 5px; margin-inline-end: 5px;' + style;
      }
    }
  });
});

0 个答案:

没有答案