Search code examples
ckeditorckeditor5

CKEDITOR 5 set body `id`


Is there a way to set the id attribute of the body of a CKEDITOR 5 ClassicEditor?

In cke4, there was a config option BodyID you could set when creating the editor instance, but I was unable to find something similar for cke5 in the docs or on SO.

I need to attach Countable.js to the editor to perform wordcount and feed that info to other parts of the code (over which I have no control)

I may have multiple editors active on the page at once.


Solution

  • Apparently, CKE5 does not play well with CountableJS when deleting text using the backspace key. The live wordcount does not get updated as it would in a normal textarea.

    I used a different solution:

    editor.document.on('changesDone`, (evt,data) => {
      Countable.once(editorelement,callback())
    });
    

    This seems to work for backspace/delete as well as text input and setData().