Closed nattyg93 closed 1 year ago
I've gone ahead and applied the changes to a fork https://github.com/nattyg93/django-ckeditor-5/tree/feature/django-nested-admin-support
Please let me know if you would accept this as a PR?
I've also identified another issue with the initialisation script which I've also fixed.
Hi, thanks for the issue, I couldn't test it, I don't think we need to change the compatibility code with each django add-on, but I'll think in the future how to make this code universal
Hi folks,
I'm trying to use this package with django-nested-admin. Due to the way nested admin's js handles replacing
__prefix__
when adding inlines (relevant source), it misses django-ckeditor5's ids.This is by no means a bug in django-ckeditor5, but I'm hoping we could update django-ckeditor5 to make it compatible.
There are two issues that would need to be addressed.
Firstly, nested admin will only replace
__prefix__
when the attrs' values start withid_....
source for the full regex. So the work around to make it compatible is to simply change the prefixes used in django-ckeditor5 to suffixes, e.g.<input type="hidden" id="ck-editor-5-upload-url-{{script_id}}"....
would become<input type="hidden" id="{{script_id}}-ck-editor-5-upload-url"....
etc.Secondly, nested admin has an allowlist of element selectors it uses to decide whether to update the attrs' values.
div
andscript
are not in that allowlist, so those ids are skipped even after updating the prefix to be a suffix. The workaround here is to replace:<div class="word-count" id="{{ script_id }}-word-count"></div>
with<span class="word-count" id="{{ script_id }}-word-count"></span>
{{ config|json_script:script_id }}
with<span id="{{ script_id }}">{{ config|json_script }}</span>
Finally,
app.js
would need to be updated to look for the new ids.I'm happy to create a PR for this if you're open to it.
Cheers, Nat
PS. Love this package and thanks for all the hard work!