ckeditor5
ckeditor5 copied to clipboard
select a text with moues highlighting and when click on button it replaces the highlighted text with html element with custom is
is there a way to give the created span here a custom classes?
onReplaceWord(editor) {
const random = Math.floor(Math.random() * 100) + 1;
editor.conversion.attributeToElement({
model: 'isSpan', view: {
name: 'span',
classes: `${random}`
},
converterPriority: 'hight',
});
editor.model.change(writer => {
var selection = editor.model.document.selection;
var position = selection.getFirstPosition();
writer.insertText('Foo', { 'isSpan': 'true', class: 'test' }, position);
});
}
}
converterPriority: 'hight',
hight -> high :)