django-cms editors and HTML data attribute cleaned up

末鹿安然 提交于 2019-12-12 14:00:03

问题


Using django-cms 2.4 I need to create pages that contain bootstrap code, but the html5lib used cleans data-* attributes. No matter if you specify valid_element in TINYMCE_DEFAULT_CONFIG. (I still looking for a similar option for Wymeditor), because this is done in #plugins/text/models (clean_html function: https://github.com/divio/django-cms/issues/1529 )

Github issue: https://github.com/divio/django-cms/issues/1529

What could it be a possible workaround? How can I extend the text plugin in the admin part?

Thanks!


回答1:


i belive the removing of the fields is done by html5lib that the cms uses as python package, you'll need to open html5lib folder and open sanitizer.py, in line 184 where the code is:

if name in self.allowed_attributes])

change to:

if name in self.allowed_attributes or re.match( r'data-.*',name)]) 

this will allow all data-(whatever) attributes

for WYMeditor the data-(whatever) attribute is already allowed



来源:https://stackoverflow.com/questions/14774076/django-cms-editors-and-html-data-attribute-cleaned-up

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