Repository: comic/grand-challenge.org

Issue:
CKeditor 5 swallows custom HTML
Hello,
Thanks for all the fantastic work you put into this framework!

For [our challenge](https://continuousregistration.grand-challenge.org/), some pages use custom HTML for styling. However, when I now click "Edit Page" -> "Source", most of the HTML is gone and there is only the content and a couple of divs left. I know it is still in the database because the pages display correctly.

As a workaround for updating the page, I copy the code from "View Source" into a text editor, make my updates there, and copy the whole thing back into the editor for saving (and if I click "Edit Page" -> "Source" the HTML is gone again).


Discussion:
Thanks for reporting this and sorry about that! I can reproduce this and will try and fix it this week.

Resolving patch:
diff --git a/app/grandchallenge/challenges/migrations/0003_challenge_allow_unfiltered_page_html.py b/app/grandchallenge/challenges/migrations/0003_challenge_allow_unfiltered_page_html.py
new file mode 100644
--- /dev/null
+++ b/app/grandchallenge/challenges/migrations/0003_challenge_allow_unfiltered_page_html.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.11 on 2018-03-27 12:31
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('challenges', '0002_auto_20180321_1247'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='challenge',
+            name='allow_unfiltered_page_html',
+            field=models.BooleanField(default=False, help_text='If true, the page HTML is NOT filtered, allowing the challenge administrator to have full control over the page contents when they edit it in ckeditor.'),
+        ),
+    ]
diff --git a/app/grandchallenge/challenges/models.py b/app/grandchallenge/challenges/models.py
--- a/app/grandchallenge/challenges/models.py
+++ b/app/grandchallenge/challenges/models.py
@@ -356,6 +356,14 @@ class Challenge(models.Model):
             "new users are allowed access immediately"
         ),
     )
+    allow_unfiltered_page_html = models.BooleanField(
+        default=False,
+        help_text= (
+            'If true, the page HTML is NOT filtered, allowing the challenge '
+            'administrator to have full control over the page contents when '
+            'they edit it in ckeditor.'
+        )
+    )
     use_registration_page = models.BooleanField(
         default=True,
         help_text='If true, show a registration page on the challenge site.',
diff --git a/app/grandchallenge/pages/forms.py b/app/grandchallenge/pages/forms.py
--- a/app/grandchallenge/pages/forms.py
+++ b/app/grandchallenge/pages/forms.py
@@ -33,6 +33,14 @@ def __init__(self, *args, **kwargs):
                     ),
                 }
             )
+
+            if self.challenge.allow_unfiltered_page_html:
+                self.fields['html'].widget.config.update(
+                    {
+                        'allowedContent': True,
+                    }
+                )
+
         self.helper = FormHelper(self)
         self.helper.layout.append(Submit('save', 'Save'))
 


Test patch: