1

有没有办法防止嵌套的同类型元素自动继承父级的属性?

例如:

<div class='border'>
  <div class='shade'></div>
  <div class='shade'></div>
</div>

自动翻译为:

<div class='border'>
  <div class='border shade'></div>
  <div class='border shade'></div>
</div>

插件摘录:

editor.model.schema.register ('div', {
  inheritAllFrom: '$root',
  allowWhere: '$block',
  isLimit: true,
  allowAttributes: ['border', 'shade'],
} );

editor.conversion.elementToElement (
  { model: 'div', view: 'div', }
);

editor.conversion.attributeToAttribute ( { model: 'border', view: { key: 'class', value: 'border' } } );
editor.conversion.attributeToAttribute ( { model: 'shade', view: { key: 'class', value: 'shade' } } );
4

0 回答 0