django-cms / djangocms-text-ckeditor

Text Plugin for django CMS using CKEditor 4
https://www.django-cms.org/en/repositories-plugins/
BSD 3-Clause "New" or "Revised" License
167 stars 185 forks source link

Inline editing possible on extended plugins? #646

Closed imagescape closed 7 months ago

imagescape commented 1 year ago

I noticed an issue where my plugins subclassing TextPlugin were not rendering the correct template in edit mode. Eventually realized this was due to the conditional in this get_render_template method. The plugins render with the inline.html template even without TEXT_INLINE_EDITING = True.

Seems that a fix may be needed for that template conditional but I decided to just try enabling inline editing and make my own inline template version for the custom plugin following the same structure as the template here: https://github.com/django-cms/djangocms-text-ckeditor/blob/master/djangocms_text_ckeditor/templates/cms/plugins/inline.html

This doesn't seem to work, however. Inline editing is there for standard text plugins but not my extended plugins. Is there something else needed to get this working?

Using: django-cms 3.11.3 djangocms-text-ckeditor 5.1.2

fsbraun commented 1 year ago

Your approach seems reasonable to me. Can you share what goes wrong?

imagescape commented 11 months ago

@fsbraun Inline editing is not present for those extended plugins. One thing I've noticed is a conditional in the js explicitly checks for plugin type TextPlugin which would explain at least that portion of it being missing.

Would love to get it working for those but could be that it's just not feasible to add inline editing to extended plugins (or plugins that use HTMLField). In that case, may just need to adjust the conditional I mentioned above in get_render_template to only return self.inline_editing_template when plugin type is TextPlugin and TEXT_INLINE_EDITING=True.

fsbraun commented 11 months ago

Your analysis makes sense. The JS side does not know about plugin inheritance and can only make decisions on plugin names. I'll have to think about this. Would you be willing to test a potential solution?

imagescape commented 11 months ago

@fsbraun Definitely. I was experimenting with hard-coding the name of my custom plugin in the javascript and it actually works as far as editing and saving though it's buggy as it's wrapping all the fields in the editor as opposed to just the one using ckeditor. I can see that identifying and targeting just the ckeditor field could be a challenge. Let me know any way I can assist.

imagescape commented 11 months ago

Thinking about how one might identify which fields should be inline-editable, I don't think it would be unreasonable to require some kind of additional configuration within a custom plugin's inline_editing_template. Just one thought.

stale[bot] commented 8 months ago

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] commented 7 months ago

This will now be closed due to inactivity, but feel free to reopen it.