Skip to main content

EditorJS as a widget for Wagtail, with Page- and Image chooser support

Project description

wagtail_editorjs

Check out Awesome Wagtail for more awesome packages and resources from the Wagtail community.

A Wagtail EditorJS widget with page/image chooser support, document support and more!

Add features:

Quick start

  1. Add 'wagtail_editorjs' to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
    ...,
    'wagtail_editorjs',
    ]
    
  2. Add the HTML to your template:

    <link rel="stylesheet" href="{% static 'wagtail_editorjs/css/frontend.css' %}">
    {% load editorjs %}
    
    {# CSS files for features #}
    {% editorjs_static "css" %}
    
    {% editorjs self.editor_field %}
    
     {# JS files for features #}
     {% editorjs_static "js" %}
    
  3. Add the field to your model:

    ...
    from wagtail_editorjs.fields import EditorJSField
    from wagtail_editorjs.blocks import EditorJSBlock
    
    
    class HomePage(Page):
        content_panels = [
            FieldPanel("editor_field"),
            FieldPanel("content"),
        ]
        editor_field = EditorJSField(
            # All supported features
            features=[
                'attaches',
                'background-color-tune',
                'button',
                'checklist',
                'code',
                'delimiter',
                'document',
                'drag-drop',
                'header',
                'image',
                'images',
                'inline-code',
                'link',
                'link-autocomplete',
                'marker',
                'nested-list',
                'paragraph',
                'quote',
                'raw',
                'table',
                'text-alignment-tune',
                'text-color-tune',
                'text-variant-tune',
                'tooltip',
                'underline',
                'undo-redo',
                'warning'
             ],
            blank=True,
            null=True,
        )
    
        # Or as a block
        content = fields.StreamField([
            ('editorjs', EditorJSBlock(features=[
                # ... same as before
            ])),
        ], blank=True, use_json_field=True)
    

List features

This readme might not fully reflect which features are available.

To find this out - you can:

  1. start the python shell

    py ./manage.py shell
    
  2. Print all the available features:

    from wagtail_editorjs.registry import EDITOR_JS_FEATURES
    print(EDITOR_JS_FEATURES.keys())
    dict_keys([... all registered features ...])
    

Settings

EDITORJS_CLEAN_HTML

Default: True Clean the HTML output on rendering. This happens every time the field is rendered. It might be smart to set up some sort of caching mechanism. Optionally; cleaning can be FORCED by passing clean=True or False to the render_editorjs_html function.

EDITORJS_ADD_BLOCK_ID

Default: true Add a block ID to each editorJS block when rendering. This is useful for targeting the block with JavaScript, or possibly creating some link from frontend to admin area.

EDITORJS_BLOCK_ID_ATTR

Default: data-editorjs-block-id The attribute name to use for the block ID. This is only used if ADD_BLOCK_ID is True.

EDITORJS_USE_FULL_URLS

Default: False Use full urls if the request is available in the EditorJS rendering context.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail_editorjs-1.6.1.tar.gz (236.3 kB view details)

Uploaded Source

File details

Details for the file wagtail_editorjs-1.6.1.tar.gz.

File metadata

  • Download URL: wagtail_editorjs-1.6.1.tar.gz
  • Upload date:
  • Size: 236.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for wagtail_editorjs-1.6.1.tar.gz
Algorithm Hash digest
SHA256 9200b9c25c137e63b6ec2e53020c4aa9ea50c24125a89f73455fe25a86de5c6e
MD5 4ac5334ee8d3c15be477d6ed497e70fa
BLAKE2b-256 4b7a96a8e2df12a488fdc86df42cf777f1ae71ab3e188a03c58e92c37264ddb1

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page