2ik / django-editorjs-fields

Django plugin for using Editor.js
MIT License
133 stars 33 forks source link

Adding another plugin #38

Closed gfunch closed 2 years ago

gfunch commented 2 years ago

Hi, I am interested in using editorjs-tooltip (https://github.com/kommitters/editorjs-tooltip) as a plugin in django-editorjs-fields my application, but am having difficulties including it.

Since the plugin does not appear to be supported via cdn, I downloaded the plugin and added the js file in the dist directory to the same directory as django-editorjs-fields.js. I then appended the file via js_list.append('django-editorjs-fields/js/editorjs-tooltip.js'). Unfortunately, this did not enable the plugin.

Any advice would be appreciated.

2ik commented 2 years ago

Hi, try:

class Post(models.Model):
    body_custom = EditorJsJSONField(
        plugins=[
            "editorjs-tooltip",
        ],
        tools={
            "Tooltip": {
                "class": "Tooltip",
                "config": {
                    "holder": "id_body_custom_editorjs_holder",  # id_{name_field}_editorjs_holder
                    "location": 'left',
                    "highlightColor": '#FFEFD5',
                    "underline": True,
                    "backgroundColor": '#154360',
                    "textColor": '#FDFEFE',
                }
            },
....

you don't need to add js files to the project. Everything is loaded from npm))

gfunch commented 2 years ago

Thank you very much! I'll give that a try.

michalpulpan commented 2 years ago

Thank you very much! I'll give that a try.

Hi, did you manage to make it work? Configuration above mentioned by @2ik doesn't seem to work for me. I'm not adding any js files localy to the project.

Edit: I'm sorry, I specified wrong holder parameter. It works flawlessly. Thanks!