Extending Hallojs in Django Wagtail With Edit Source Button

流过昼夜 提交于 2019-12-12 18:52:37

问题


I've been abel to add an an 'Edit Html' source button to my editor with the following hook:

@hooks.register('insert_editor_js')
def enable_source():
    return format_html(
        """
        <script>
            registerHalloPlugin('hallohtml');
        </script>
        """
    )

It adds a button, but I can't figure out how to add an icon - see screenshot below with no icon.

All buttons except no icon make the source editor work great. Thank you for your help.


回答1:


Use the insert_editor_css hook to provide additional CSS files to the editor.

@hooks.register('insert_editor_css')
def editor_css():
    return format_html(
        '<link rel="stylesheet" href="{}">',
        static('demo/css/editor-overrides.css')
    )

In your hallohtml plugin JS, assign icon-hallohtml to the button and use the following CSS to style it with an H character:

.hallotoolbar .halloformat .ui-button-text .icon-hallohtml:before {
    content:'H';
}


来源:https://stackoverflow.com/questions/38250432/extending-hallojs-in-django-wagtail-with-edit-source-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!