Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// here, we additionally set a CSS style property inline. In the real world, you probably would
// not do this, but instead style the class using your CSS.
//
// NOTE: when removing the style definition here, the style tags are automatically removed when a
// <span style="..." class="example-class"></span> is encountered.
styles: {
'background-color': 'green',
}
}
};
this.editor.conversion.attributeToElement(config);
// Finally, we need to add a new command to apply this attribute.
// "highlightCommand" is the identifier of the command now
this.editor.commands.add('highlightCommand', new AttributeCommand(this.editor, 'exampleAttribute'));
}
}
init() {
const config = {
model: attributeName,
view: {
name: formatting.tag,
classes: formatting.classes,
styles: formatting.styles
}
};
this.editor.model.schema.extend('$text', {allowAttributes: attributeName});
this.editor.conversion.attributeToElement(config);
this.editor.commands.add(commandName, new AttributeCommand(this.editor, attributeName));
}
}