Wagtail / Hallo.js - Adding plugins but modified content is not saved

纵饮孤独 提交于 2019-12-10 20:09:12

问题


I'm running on Wagtail 1.3.1, Django 1.7.11.

I have activated hallohtml and hallojustify plugins and they appear in toolbar (without icons but buttons are here).

The buttons can be used and the modifications are seen in the textarea (I mean that I can center a field for example and I see it).

When I publish the page, the modifications made by either hallojustify or hallohtml are not saved whereas I can still use the bold/italic buttons and save the content. It looks like the html is cleaned up...

I should miss something but...

@hooks.register('insert_editor_js')
def editor_js():
js_files = [
]
js_includes = format_html_join('\n', '',
((settings.STATIC_URL, filename) for filename in js_files)
)

return js_includes + format_html(
        """
        <script>
          registerHalloPlugin('hallojustify');
          registerHalloPlugin('hallohtml');
        </script>
        """
    )

回答1:


By design, Wagtail only allows a subset of HTML tags and attributes, and strips out any that are not on its whitelist. This is done for several reasons: it prevents editors from inserting malicious content (such as <script> tags), and encourages site developers to keep content and presentation separate. (You shouldn't really be including formatting information such as left/right/centre alignment inside rich text content - that should be defined inside your template and CSS.)

You can customise the HTML whitelisting rules using the construct_whitelister_element_rules hook - however, I'd encourage you to reconsider whether you really need to overload the rich text editor with so much functionality, or whether there's a more structured way of achieving what you want (such as StreamField).



来源:https://stackoverflow.com/questions/38096682/wagtail-hallo-js-adding-plugins-but-modified-content-is-not-saved

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