1

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.

PG04
  • 21
  • 2
  • Do you want this class to be added to every `
      ` without exception, or do you want this to be the default *option*, but allow for other markup?
    – Tiny Lincoln Jun 03 '21 at 22:42
  • @TinyLincoln Of course it would be perfect if this is the default option with the possibility to change BUT also the option to add this to every
      without exception is fine for me at this point...
    – PG04 Jun 06 '21 at 13:56

1 Answers1

0

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' }
     ]
Bloops
  • 744
  • 1
  • 11
  • 15