hvlads / django-ckeditor-5

Django CKEditor 5 integration.
Other
152 stars 60 forks source link

word count gets removed when CKEditor5Widget is used in forms #249

Closed jaredmdunn closed 1 month ago

jaredmdunn commented 1 month ago

The "word-count" span is getting removed when the CKEditor5Widget is used in a Django form.

This occurs on line 58 in app.js in createEditors:

editorEl.nextSibling.remove();

You can see that the "word-count" span is the next element by looking at the widgets.html file:

<textarea  name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>
{% if widget.value %}{{ widget.value }}{% endif %}</textarea>
<span class="word-count" id="{{script_id}}-word-count"></span>

For some reason, this does not affect the CKEditor5Field used in Django Admin.

What is this line for?

jaredmdunn commented 1 month ago

This also seems to prevent ckeditor instances from being added to window.editors

goapunk commented 1 month ago

@jaredmdunn I can't seem to reproduce it (neither in the example app in this repo nor in our other projects), the word count shows up fine outside of the django-admin. Do you have an example code or steps to reproduce it?

jaredmdunn commented 1 month ago

@goapunk I am having difficulty replicating this outside of our project repo. We are using a lot of custom JavaScript and CSS much of which I didn't write to it is hard to find what could be conflicting. We decided to use our own version of django-ckeditor-5 so that we could get around the errors we were seeing. It's okay with me to close this issue.