hvlads / django-ckeditor-5

Django CKEditor 5 integration.
Other
130 stars 50 forks source link

Add General HTML Support #68

Closed jsolly closed 2 years ago

jsolly commented 2 years ago

Context

It would be great if we had more control over what elements are allowed within CKeditor In the current version, I can't add an \<iframe>. This seems like a natural progression since source editing was turned on recently.

According to the ckeditor docs:

The General HTML Support (“GHS”) feature allows developers to easily enable HTML features that are not explicitly supported by any other dedicated CKEditor 5 plugins. It acts similarly to Advanced Content Filter (ACF) from CKEditor 4, a feature that filters incoming HTML content by transforming and deleting disallowed elements, attributes, classes and styles. GHS allows for adding this kind of markup to the source and prevents it from being filtered from the editor window and the output.

Things to consider

There are security implications, but I think it makes sense to provide users a way to enable these elements and assume the risks themselves.

hvlads commented 2 years ago

I added the GeneralHtmlSupport plugin in version 0.1.4

jsolly commented 2 years ago

For anyone reading this, you can enable it by adding this to your CKeditor config

   "extends": {
        "htmlSupport": {
            "allow": [
                {"name": "/.*/", "attributes": True, "classes": True, "styles": True}
            ]
        },

This is coming straight from the ckeditor docs https://ckeditor.com/docs/ckeditor5/latest/features/general-html-support.html