djangocms-text-ckeditor icon indicating copy to clipboard operation
djangocms-text-ckeditor copied to clipboard

Ckeditor fail to be initialized in newly added inline item (InlineModelAdmin)

Open sveetch opened this issue 1 year ago • 1 comments

Summary

I'm facing the same old issue than #465 that was resolved years ago in #472. In summary when adding a new InlineModelAdmin item inside a plugin, the CKEditor fail to be initialized and the field is just a raw textarea.

Environment

  • Python: 3.10
  • Django: 5.0.7
  • DjangoCMS: 3.11.6
  • djangocms-text-ckeditor: 5.1.5

To Reproduce

  1. Create a plugin with models Foo and FooItem where FooItem is related to Foo with a foreign keys, contain a field for a CKEditor content (with widget TextEditorWidget) and managed with InlineModelAdmin;
  2. Add an object of this plugin in a page;
  3. Open plugin edition;
  4. Add a new item into plugin;
  5. The CKeditor content field in newly added FooItem object is still a textarea;

Here is a simple video for demonstration:

record.webm

This results to this error in browser console:

error

With debugger just before error (using a debug breakpoint):

debugger_breakpoint

And in inspector for the newly added object:

inspector

We can see the JavaScript code attempts to use a id attribute but the payload from object is just an Array.

Expected behavior

Newly added inline admin items should have CKEditor properly initialized.

From what i have searched, it seems the commits from #472 was working well, it did not expected an id attribute to resolve field name:

https://github.com/vxsx/djangocms-text-ckeditor/blob/2364627726dfb1682aeefa1f7ab2d4972155e9f1/djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/cms.ckeditor.js#L217

Opposed to master branch code that is expecting the attribute:

https://github.com/django-cms/djangocms-text-ckeditor/blob/master/djangocms_text_ckeditor/static/djangocms_text_ckeditor/js/cms.ckeditor.js#L431

I tried to patch my local bundle for the id attribute against Array, it worked but then it broke because of further code that attempt to reach other attributes like toolbar.

sveetch avatar Aug 29 '24 23:08 sveetch

@sveetch Thanks for mentioning this! Will take a look.

fsbraun avatar Sep 04 '24 19:09 fsbraun

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 04 '24 04:12 stale[bot]

@fsbraun sorry to ping you directly, but i know about the djangocms-text initiative and i was thinking it was probably the modern and futur official way to embed editor, do you confirm ? And do you think it would work better with "inline item" ?

sveetch avatar Dec 04 '24 13:12 sveetch

@sveetch I have not come around to reproducing this, but this would need to work for both djangocms-text and djangocms-text-ckeditor. djangocms-text is the future ~~and afaik this works~~ will need to be fixed there, too :-( .

fsbraun avatar Dec 04 '24 14:12 fsbraun

@sveetch Fixed for djangocms-text 0.4+

fsbraun avatar Dec 10 '24 16:12 fsbraun

You are wonderful !

sveetch avatar Dec 10 '24 17:12 sveetch

💡 Developers looking at this should know they can easily migrate to djangocms-text with the 'ckeditor4' editor enabled, compatibility should be complete and without almost anything to do, except if they were providing custom ckeditor4 plugins since the ckeditor stuff in static sources has changed a little bit but it is easy to change.

sveetch avatar Dec 10 '24 17:12 sveetch

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 13 '25 04:03 stale[bot]

This issue will not be fixed any more. Please use djangocms-text (see https://github.com/django-cms/djangocms-text-ckeditor/issues/680#issuecomment-2532362063).

fsbraun avatar Mar 13 '25 10:03 fsbraun