Is it possible to automatically add a class to each
<ul> element added to the CKEditor WYSIWYG?
In my project, I decided to not style
ul > li in order to not have to rewrite CSS for each
ul Drupal can display (i.e. menus or contextual links). So, I have only one CSS rule for my unordered lists:
ul.my_custom_class li. I used to add a custom style in CKEditor's Styles dropdown that add this class, but it's not a perfect solution, as some administrators forget to use it (or sometimes, CKEditor does not recognize
a since Drupal 8.4.x, see this thread).
The perfect solution would be that, each time you add an unordered list into the WYSIWYG, instead of having
ul li, you'd have
ul.my_custom_class li. I know I can use an other CSS rules like
.ckeditor ul to make it work, but I want to be able to use this specific class anywhere in the website.
I've found some methods in the CKEditor docs but I don't really know where to use them on Drupal 8.