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
TextPlugin removes source code HTML on save #667
Comments
djangocms-text-ckeditor sanitizes any HTML before safe. You might need to configure the sanitizer. See here: https://github.com/django-cms/djangocms-text-ckeditor#configurable-sanitizer |
It seems like it would certainly be the root cause, but I can't seem to get the settings to take effect: I managed to get the global setting, TEXT_HTML_SANITIZE = False to turn it off altogether to work (i.e. keep list styles), but I suspect I want a bit more precision. Specifically providing "style" inside the settings.py did not preserve the style attributes. TEXT_ADDITIONAL_ATTRIBUTES = ('style',) So, now I'm trying the custom parser. I have it successfully hooked up, because I can see its print statements when made within the parse function from djangocms_text_ckeditor.sanitizer import AllowTokenParser
Keep = bool
class ListAttributeParser(AllowTokenParser):
def parse(self, attribute: str, val: str) -> Keep:
if attribute == "style":
print(val) # --> list-style-type:lower-roman
return True
else: return False I did add: 'basicEntities': False,
'entities': False, (They are not duplicate keys) |
Does it work? I must say, I am not an expert of |
I have not gotten the custom parser to work, no. Switching True/False with each other didn't seem to have an effect. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I have had something similar occur in two separate projects.
In one, I was making modifications to the source HTML, like adding another style attribute to a tag, and my new attribute would be gone on save, leaving only the previous state of the tag.
In the current one, all tag attributes are getting purged on TextPlugin save.
In both these cases the TextPlugins were created within placeholder fields in the following manner:
Where
block['body']
contains HTML elements, including some<ol style="list-style-type:lower-alpha">
.Before:
<ol style="list-style-type:lower-roman">
After:
<ol>
djangocms-text-ckeditor 5.1.5
The text was updated successfully, but these errors were encountered: