How to specifiy default CSS class for list <ul> in TinyMCE?

810 Views Asked by At

In TinyMCE, how can I pre-define CSS class for unordered list <ul>.

The idea is that I write my article in TinyMCE editor, then once the content is saved, the final HTML is:

<ul class="class_a">
...
</ul>

I'm using django-tinymce.

1

There are 1 best solutions below

0
Bloops On

The only solution seems to create a plugin, but it's very complex to keep the DOM values. So I found this alternative solution.

  1. Style the default ul and ol in your CSS (put class_a styles into them, without class applied)

  2. Add styleselect in your TinyMCE toolbar

  3. Add style_formats option to style your ul and ol like this for example:

    style_formats: [
         { title: 'Unstyled list', selector: 'ul,ol', classes: 'list-none' }
     ]