Anything written in page editor "source" mode is deleted when saved

I am trying to use a css class I implemented in the custom css file but I am unable to use it in when editing pages in an indico event.

I have noticed that I cannot use any tags at all, for instance if I were to write

<p> some text </p>

this is deleted when I save the page. If I were to just write some text in the regular editor mode and then switch to source, it is exactly as I tried to write manually (<p> some text </p>)

Is there a reason for this, and is there a way I can use custom html, css and js elements in custom pages of an event?

I am using indico 2.0

I just checked, our HTML sanitizer allows the class attribute. But possibly CKEditor strips it? (pinging @pferreir, you are more familiar with it)

In any case, keep in mind that when using source mode you have to switch back to normal mode before saving - otherwise your changes to the source aren’t preserved.

No, and we do not plan to support this - while as an admin you are trusted, just imagine if “normal” event managers could add custom JavaScript… only a matter of time before someone tries to do something fishy, like stealing cookies.

Yes, disallowing custom JavaScript makes perfect sense!

Either saving or switching back to normal mode deletes anything I have written in the view source mode. Maybe I can modify the configuration of CKEditor?

Thanks for your help.

I can confirm that CKeditor has a taste for removing HTML attributes. I’m not sure whether that can be configured, I’d expect so.

Yes, this filtering can be configured.
Default is to only accept things that can also be set through the wysiwyg-Interface.
See https://docs.ckeditor.com/ckeditor4/latest/guide/dev_advanced_content_filter.html for the full glory of options…

This would need to be set in indico/htdocs/js/indico/widgets/ckeditor_widget.js most probably.

You can try to add:

extraAllowedContent: 'p ; div; span; pre; h1; h2; h3; *(*)', // allow additional classes + span

to the config array in indico/htdocs/js/indico/Core/Widgets/RichText.js to allow setting additional classes and allow div and span elements in addition.

I think this may even be an acceptable default?

What does *(*) actually mean?

According to the docs:
Allow any class on allowed elements.
There are separate rules for attributes [] and online styles {}
See docs.ckeditor.com/ckeditor4/latest/guide/dev_allowed_content_rules.html#string-format

OK, that seems reasonable to me.