mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-25 00:54:52 +00:00
Draftail was failing to initialise with defined options in settings
This commit is contained in:
parent
e889cd2424
commit
cae33c006c
3 changed files with 43 additions and 0 deletions
|
|
@ -272,6 +272,7 @@ Contributors
|
|||
* Mary Kate Fain
|
||||
* Dário Marcelino
|
||||
* Dan Dietz
|
||||
* Todd Dembrey
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class DraftailRichTextArea(WidgetWithScript, widgets.HiddenInput):
|
|||
def __init__(self, *args, **kwargs):
|
||||
# note: this constructor will receive an 'options' kwarg taken from the WAGTAILADMIN_RICH_TEXT_EDITORS setting,
|
||||
# but we don't currently recognise any options from there (other than 'features', which is passed here as a separate kwarg)
|
||||
kwargs.pop('options', None)
|
||||
self.options = {}
|
||||
|
||||
self.features = kwargs.pop('features', None)
|
||||
|
|
|
|||
|
|
@ -377,6 +377,47 @@ class TestHalloJsWithFeaturesKwarg(BaseRichTextEditHandlerTestCase, WagtailTestU
|
|||
self.assertNotIn('wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js', media_html)
|
||||
|
||||
|
||||
@override_settings(WAGTAILADMIN_RICH_TEXT_EDITORS={
|
||||
'default': {
|
||||
'WIDGET': 'wagtail.admin.rich_text.DraftailRichTextArea',
|
||||
'OPTIONS': {
|
||||
'features': ['h2', 'image']
|
||||
}
|
||||
|
||||
},
|
||||
})
|
||||
class TestDraftailWithFeatureOptions(BaseRichTextEditHandlerTestCase, WagtailTestUtils):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
# Find root page
|
||||
self.root_page = Page.objects.get(id=2)
|
||||
|
||||
self.login()
|
||||
|
||||
def test_settings_features_option_on_rich_text_field(self):
|
||||
response = self.client.get(reverse(
|
||||
'wagtailadmin_pages:add', args=('tests', 'defaultrichtextfieldpage', self.root_page.id)
|
||||
))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, '"type": "header-two"')
|
||||
self.assertContains(response, '"type": "IMAGE"')
|
||||
self.assertNotContains(response, '"type": "ordered-list-item"')
|
||||
|
||||
def test_features_option_on_rich_text_block(self):
|
||||
# a 'features' list passed on the RichTextBlock
|
||||
# should override the list in OPTIONS
|
||||
block = RichTextBlock(features=['h2', 'embed'])
|
||||
|
||||
form_html = block.render_form(block.to_python("<p>hello</p>"), 'body')
|
||||
|
||||
self.assertIn('"type": "header-two"', form_html)
|
||||
self.assertIn('"type": "EMBED"', form_html)
|
||||
self.assertNotIn('"type": "IMAGE""', form_html)
|
||||
self.assertNotIn('"type": "ordered-list-item""', form_html)
|
||||
|
||||
|
||||
@override_settings(WAGTAILADMIN_RICH_TEXT_EDITORS={
|
||||
'default': {
|
||||
'WIDGET': 'wagtail.admin.rich_text.HalloRichTextArea',
|
||||
|
|
|
|||
Loading…
Reference in a new issue