def test_custom_features_option_on_rich_text_block(self): block = RichTextBlock(editor='custom') form_html = block.render_form(block.to_python("<p>hello</p>"), 'body') # Check that the custom plugin options are being passed in the hallo initialiser self.assertIn('"halloblockquote":', form_html) self.assertIn('"hallowagtailimage":', form_html) self.assertNotIn('"hallowagtailembeds":', form_html) self.assertNotIn('"hallolists":', form_html) # a 'features' list passed on the RichTextBlock # should override the list in OPTIONS block = RichTextBlock(editor='custom', features=['blockquote', 'embed']) form_html = block.render_form(block.to_python("<p>hello</p>"), 'body') self.assertIn('"halloblockquote":', form_html) self.assertIn('"hallowagtailembeds":', form_html) self.assertNotIn('"hallowagtailimage":', form_html) self.assertNotIn('"hallolists":', form_html) # check that media (js/css) from the features is being imported media_html = str(block.media) self.assertIn('testapp/js/hallo-blockquote.js', media_html) self.assertIn('testapp/css/hallo-blockquote.css', media_html) # check that we're NOT importing media for the default features we're not using self.assertNotIn( 'wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js', media_html)
def test_custom_features_option_on_rich_text_block(self): block = RichTextBlock(editor='custom') form_html = block.render_form(block.to_python("<p>hello</p>"), 'body') # Check that the custom plugin options are being passed in the hallo initialiser self.assertIn('"halloblockquote":', form_html) self.assertIn('"hallowagtailimage":', form_html) self.assertNotIn('"hallowagtailembeds":', form_html) self.assertNotIn('"hallolists":', form_html) # a 'features' list passed on the RichTextBlock # should override the list in OPTIONS block = RichTextBlock(editor='custom', features=['blockquote', 'embed']) form_html = block.render_form(block.to_python("<p>hello</p>"), 'body') self.assertIn('"halloblockquote":', form_html) self.assertIn('"hallowagtailembeds":', form_html) self.assertNotIn('"hallowagtailimage":', form_html) self.assertNotIn('"hallolists":', form_html) # check that media (js/css) from the features is being imported media_html = str(block.media) self.assertIn('testapp/js/hallo-blockquote.js', media_html) self.assertIn('testapp/css/hallo-blockquote.css', media_html) # check that we're NOT importing media for the default features we're not using self.assertNotIn('wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js', media_html)
def test_custom_editor_in_rich_text_block(self): block = RichTextBlock(editor='custom') form_html = block.render_form(block.to_python("<p>hello</p>"), 'body') # Check that the custom plugin options are being passed in the hallo initialiser self.assertIn('makeHalloRichTextEditable("body", {"halloheadings": {"formatBlocks": ["p", "h2"]}});', form_html)