springload / wagtaildraftail

🐦📝🍸 Draft.js editor for Wagtail, built upon Draftail and draftjs_exporter
https://pypi.python.org/pypi/wagtaildraftail
MIT License
24 stars 3 forks source link

Add default configuration for both editor and exporter #38

Open loicteixeira opened 7 years ago

loicteixeira commented 7 years ago

Just like you can use a RichTextField/RichTextBlock in Wagtail (powered by hallo) without the need to configure it, wagtaildraftail should ship with proper defaults (all the default entities, blocks and styles in the editor and the corresponding exporter config).

For the exporter, everything can happen in wagtaildraftail.utils.get_exporter_config.

For the editor, this might be a bit more complex. If a widget doesn't not receive any options upon initialisation, we could add some defaults, but for the widget to be instantiated in the first place, it needs to be present in the WAGTAILADMIN_RICH_TEXT_EDITORS settings (which is used by wagtail.wagtailadmin.rich_text.get_rich_text_editor_widget which both our field and block use to load the widget). I'm not too keen to hijack the settings to inject ours, so maybe we could have a intermediary utility function which first try to load "the Wagtail way", but failing that (catch KeyErrors) would return our default widget.