Home > OS >  wagtail can't add ckeditor to blocks
wagtail can't add ckeditor to blocks

Time:03-06

I'm using wagtail and trying to use ckeditor inside blocks but seems not working the field with ckeditor not showing in admin when I try to create or edit a page I want to use ckeditor because I can use the option source to insert div and class inside text my code for blocks is :

from ckeditor.fields import RichTextField

class widgetBodyBlock(blocks.StructBlock):
    heading = blocks.CharBlock(required=False, label=_('Heading'))
    text = RichTextField(null=True, blank=True)
    image = ImageChooserBlock()

    class Meta:
        template = '_template/blocks/body_block.html'
        icon = 'edit'
        label = _('Widget Body')

but in admin the field not showing like in picture it's show only heading and image enter image description here

CodePudding user response:

When using fields that require JavaScript to work, you will need to ensure that StreamField knows how to run that JavaScript.

https://docs.wagtail.org/en/stable/advanced_topics/customisation/streamfield_blocks.html#additional-javascript-on-structblock-forms

The docs explain how to do this, you will need to create a Telepath adaptor. This is so that when the field is added dynamically in the front-end, your custom inner field can be initialised in the browser.

  • Related