2ik / django-editorjs-fields

Django plugin for using Editor.js
MIT License
133 stars 33 forks source link

The editor.js is not initiated when used inside of inlines #32

Closed archatas closed 2 years ago

archatas commented 2 years ago

This problem occurs in Django administration and in frontend forms with dynamically addable inlines.

archatas commented 2 years ago

Ideally there could be a custom event to trigger that would reinitiate all widgets that haven't been initiated. Probably where you can pass the container element where to look for the textareas.

Also there should be multiple textareas allowed with the dynamically added formsets.

2ik commented 2 years ago

can you give an example?

plugin in inlines are working in the admin panel, you can see example

archatas commented 2 years ago

If the admin inline has more than one Editor.js fields, only the first one gets initiated, and others are ignored and show textareas with the value "null".

You can see the problem from this line of code, when only the 0th textarea is initiated.

For inlines in the frontend, there is no way to trigger re-initiation, because the initation function initEditorJsField() is within a JavaScript closure – so no access to it at all.