我想向带有span-size style属性的块中添加一个类。我能够发现当前块是否具有fontSize
属性的跨度,但无法向该块添加/删除类。
我已覆盖FontSize插件,并添加了一些代码,例如
// Adding the class.
view.document.registerPostFixer(writer => {
const selection = editor.model.document.selection;
const parent = Array.from(selection.getSelectedBlocks())[0];
var itemfound = false;
for ( const item of parent.getChildren() ) {
if (item.hasAttribute('fontSize')) {
itemfound = true;
// How to add a class to parent here
// writer.setAttribute('class', 'aaa', parent);
break;
}
}
if (!itemfound) {
// How to remove above added class from parent here
// writer.removeAttribute('class', parent);
}
});