django-fluent / django-fluent-contents

A widget engine to display various content on Django pages
http://django-fluent.org/
Apache License 2.0
149 stars 39 forks source link

Admin errors unless text plugin is included #81

Closed heldinz closed 7 years ago

heldinz commented 8 years ago

If fluent_contents.plugins.text is not installed and included in the list of plugins for a PlaceholderField, a JavaScript ReferenceError occurs in the admin interface.

Trace:

Uncaught ReferenceError: django_wysiwyg is not defined   cp_widgets.js:39
cp_widgets.enable_wysiwyg             @ cp_widgets.js:39
cp_plugins.enable_pageitem            @ cp_plugins.js:813
cp_plugins._move_item_to              @ cp_plugins.js:256
cp_plugins.move_items_to_pane         @ cp_plugins.js:217
cp_plugins.move_items_to_placeholders @ cp_plugins.js:124
cp_plugins.post_init                  @ cp_plugins.js:88
onReady                               @ cp_admin.js:30
fire                                  @ jquery.js:3099
self.fireWith                         @ jquery.js:3211
jQuery.extend.ready                   @ jquery.js:3417
completed                             @ jquery.js:3433

I'm working around this by including the Text plugin so that django_wysiwyg is loaded, but it doesn't seem right to assume that this will always be present.

vdboor commented 8 years ago

You are completely correct about this issue. The wysiwyg logic was originally part of the text plugin, which moved to the core with the PluginHtmlField option.

The curlpit is the admin_init_template = "admin/fluent_contents/plugins/text/admin_init.html" in the text plugin, which adds the wysiwyg editor. The wysiwyg initialization should off course be placed in the standard HTML templates, when a plugin includes the PluginHtmlField in the form.

If you can provide a pull request for this, I'd be happy to accept it! That would be the fastest way to solve it properly (or you'd have to wait until we have time to fix it).

heldinz commented 8 years ago

Thanks for getting back to me! I'll try to get to it in the next few days.

m-sanders commented 7 years ago

Hello. I have just came up against this issue as well. I do not want a dependency on django-wsyiswg. Could a simple check in enable_wysiwyg and disable_wysiwyg suffice for now?

if (typeof django_wysiwyg === "undefined") return; 

Happy to submit a PR.

vdboor commented 7 years ago

@m-sanders: thanks, that is a good point. I'd be happy to accept a PR on this!

seroy commented 7 years ago

Hello. What about my PR #88?

vdboor commented 7 years ago

Sorry, it's merged now!