ckeditor / ckeditor5

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.
https://ckeditor.com/ckeditor-5
Other
9.36k stars 3.68k forks source link

Is having `definitions.xxx.classes` mandatory by intention? #16737

Open garvinhicking opened 2 months ago

garvinhicking commented 2 months ago

📝 Ask a question

Having a configuration like this (asking for the context of a default TYPO3 implementation):

editor:
  config:
    style:
      definitions:
        # block level styles
        - { name: 'Orange title H2', element: 'h2', classes: ['orange'] }
        - { name: 'Orange title H3', element: 'h3', classes: ['orange'] }
        - { name: 'Quote / Citation', element: 'blockquote', classes: [''] }
        - { name: 'Code block', element: 'code', classes: ['']  }
        # Inline styles
        - { name: 'Yellow marker', element: 'span', classes: ['yellow-marker'] }

it seems that classes is a required attribute. Also https://ckeditor.com/docs/ckeditor5/latest/api/module_style_styleconfig-StyleDefinition.html does not really mention it as being optional. Leaving such an attribute out leads to the dropdown for styles not getting opened.

If the attribute is required, I wonder how one could implement an empty <code> element. Currently, always <code class=""> is emitted.

Also, when using classes: [] to indicate an empty array, the element is not choosable at all. Using classes: false|null|true only leads to having <code class="false|null|true">.

So I wonder, am I missing something here, or would it classify as a bug?

Witoso commented 2 days ago

For now Style dropdown doesn't insert elements, it just adds classes to existing elements. Most likely, you would want it to insert as well, +1 the following ticket #14372.