ckeditor5 icon indicating copy to clipboard operation
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

Open khaled6mmd opened this issue 4 years ago • 1 comments

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);
    });
  }
}

khaled6mmd avatar Aug 02 '22 21:08 khaled6mmd

converterPriority: 'hight',

hight -> high :)

Reinmar avatar Aug 05 '22 07:08 Reinmar