Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can’t configure plug-ins #27

Closed
brtchkv opened this issue Nov 5, 2021 · 4 comments
Closed

Can’t configure plug-ins #27

brtchkv opened this issue Nov 5, 2021 · 4 comments

Comments

@brtchkv
Copy link

brtchkv commented Nov 5, 2021

Hi, I'm trying to add plugins. However, Editor js doesn't show new tools and plugins, only the default ones. I checked network (cdn) and it does download them.

Here is my settings.py for Editor.js.

Could you check it out and suggest what is going wrong?

@2ik
Copy link
Owner

2ik commented Nov 5, 2021

problem was due to editorjs-change-case

I also found a bug that didn't take default tools. Will fix it in the next version

I fixed the configuration with comments (config in field):

from django_editorjs_fields import EditorJsJSONField
from django.urls import reverse_lazy


class Post(models.Model):
    body_custom = EditorJsJSONField(
        plugins=[
            '@editorjs/paragraph',
            '@editorjs/image',
            '@editorjs/header',
            '@editorjs/list',
            '@editorjs/checklist',
            '@editorjs/quote',
            '@editorjs/raw',
            '@editorjs/code',
            '@editorjs/inline-code',
            '@editorjs/embed',
            '@editorjs/delimiter',
            '@editorjs/warning',
            '@editorjs/link',
            '@editorjs/marker',
            # '@editorjs/table', # duplicate
            'editorjs-alert',
            'editorjs-table',
            # 'editorjs-change-case', # it looks like a plugin bug
            '@editorjs/personality',
            'editorjs-drag-drop',
            'editorjs-undo',
            # you need to write to the author of the plugin so that he replaces <button> tag with <div> or adds type="button" for alignment buttons
            # because the buttons send the form in the admin panel
            'editorjs-text-alignment-blocktune'
        ],
        tools={
            'Image': {
                'class': 'ImageTool',
                'inlineToolbar': True,
                "config": {
                    "endpoints": {
                        "byFile": reverse_lazy('editorjs_image_upload'),
                        "byUrl": reverse_lazy('editorjs_image_by_url')
                    }
                },
            },
            'Header': {
                'class': 'Header',
                'inlineToolbar': True,
                'config': {
                    'placeholder': 'Enter a header',
                    'levels': [2, 3, 4],
                    'defaultLevel': 2,
                    'tunes': ['BlockTune'],
                },
            },
            'Checklist': {'class': 'Checklist', 'inlineToolbar': True},
            'List': {'class': 'List', 'inlineToolbar': True},
            'Quote': {'class': 'Quote', 'inlineToolbar': True},
            'Raw': {'class': 'RawTool'},
            'Code': {'class': 'CodeTool'},
            'InlineCode': {'class': 'InlineCode'},
            'Embed': {'class': 'Embed'},
            'Delimiter': {'class': 'Delimiter'},
            'Warning': {'class': 'Warning', 'inlineToolbar': True},
            'LinkTool': {
                'class': 'LinkTool',
                'config': {
                    'endpoint': reverse_lazy('editorjs_linktool'),
                }
            },
            'Marker': {'class': 'Marker', 'inlineToolbar': True},
            # 'Table': {'class': 'Table', 'inlineToolbar': True}, # duplicate
            'alert': {
                'class': 'Alert',
                'inlineToolbar': True,
                'shortcut': 'CMD+SHIFT+A',
                'config': {
                    'defaultType': 'primary',
                    'messagePlaceholder': 'Enter something',
                },
            },
            'table': {
                'class': 'Table',
            },
            # 'anchorTune': {  # plugin is not included
            #     'class': 'AnchorBlockTune'
            # },
            # 'changeCase': { # bug
            #     'class': 'ChangeCase',
            #     'config': {
            #         'showLocaleOption': True,
            #         'locale': 'tr'
            #     }
            # },
            'personality': {
                'class': 'Personality',
                'config': {
                    'endpoint': '/upload/image/'
                }
            },
            # 'carousel': {  # plugin is not included
            #     'class': 'Carousel',
            #     'config': {
            #         'endpoints': {
            #             'byFile': '/upload/image/',
            #         }
            #     }
            # },
            'BlockTune': {
                'class': 'AlignmentBlockTune',
                'config': {
                    'default': "right",
                    'blocks': {
                        'header': 'center',
                        'list': 'right'
                    }
                },
            },
            'paragraph': {
                'class': 'Paragraph',
                'inlineToolbar': False,
                'tunes': ['BlockTune'],
            },
        },
        null=True,
        blank=True,
    )

@2ik
Copy link
Owner

2ik commented Nov 5, 2021

upgrade to 0.2.6

@brtchkv
Copy link
Author

brtchkv commented Nov 6, 2021

Thank you for such a quick reply! You’re really saving us from failing deadlines!

Later today will try the config. :)

@brtchkv
Copy link
Author

brtchkv commented Nov 7, 2021

Everything is great! Thanks a lot!

@brtchkv brtchkv closed this as completed Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants