typo3ckeditor4.x

How to add Custom text sizes as classes in CKEditor4?


I am using CKEditor4 in TYPO3, and I want to customise the font size list to have my own preset sizes as classes instead of inline styles.

In my configuration Yaml file I have been trying variations on this:

fontSize_style: 
    - { name: "Small", element: "span", attributes: { class: "small"} }
    - { name: "Large", element: "span", attributes: { class: "large"} }

How can I make this work?

Secondly, if for example, I am applying the size to an h1, can I have the class be added to the h1 instead of using a span?


Solution

  • I was using the fontSize_style incorrectly. It should only have 1 entry to define the formatting:

    fontSize_style: {element: 'span', attributes: { 'class': '#(size)' } }
    

    This uses the variable #(size) to insert the class.

    Then you just populate the dropdown list with the sizes you want:

    fontSize_sizes: 'Small/small;Medium/medium;Large/large;'
    

    Each size entry composing of List Label / Class Name

    The second part of the question can only be done using the style dropdown as expained in the other answers.