From Wagtail 1.7 (maybe?) options will be passed to the widget when instantiated. See https://github.com/torchbox/wagtail/commit/5732e215b0774c22d8e9bf210aa1491353595406
Given the following config:
WAGTAILADMIN_RICH_TEXT_EDITORS = {
'default': {
'WIDGET': 'wagtail.wagtailadmin.rich_text.HalloRichTextArea'
},
'simple_editor': {
'WIDGET': 'core.rich_text.CustomisableRichTextArea',
'OPTIONS': { ... }
},
'advanced_editor': {
'WIDGET': 'core.rich_text.CustomisableRichTextArea',
'OPTIONS': { ... }
}
}
So it is possible to use the same "editor" with different configurations.
The RichTextBlock will simply need to be defined as follow RichTextBlock(editor='advanced_editor')
to use that specific config and CustomisableRichTextArea
will be passed an id and the options.
CustomisableRichTextArea
should handle the upgrade gracefully (if the implementation does not change)
but the config will need to be updated as shown above.
In the meantime, it is needed to subclass CustomisableRichTextArea
and define editor_name
so the corresponding options can be fetched. Each "editor" will have a corresponding class.
The config will then look like this:
WAGTAILADMIN_RICH_TEXT_EDITORS = {
'default': {
'WIDGET': 'wagtail.wagtailadmin.rich_text.HalloRichTextArea'
},
'simple_editor': {
'WIDGET': 'core.rich_text.SimpleRichTextArea',
'OPTIONS': { ... }
},
'advanced_editor': {
'WIDGET': 'core.rich_text.AdvancedRichTextArea',
'OPTIONS': { ... }
}
}
Other useful discussions around this topic:
- wagtail/wagtail#1284 (this has been implemented in https://github.com/springload/wagtailblocks/)
- wagtail/wagtail#2175
With Wagtail 1.7, the
CustomisableRichTextArea
won't need to callget_options
since the options will be passed directly to it but is still needed because theHalloRichTextArea
still don't accept options.