CKEditor 5 not compatible with CKEditor 4

Is it possible to rollback to V4 of CKEditor? As far as i learned it’s currently not possible to define styles with the same effect for multiple elements. In Typo3 V11 (CKEditor 4) i could do this:

editor:
  config:
    stylesSet:
      - { name: "test", element: ["h1", "h2", "h3"], attributes: { class: "text-small" } }

That had the effect, that i could apply utility classes to various elements.

In CKEditor 5 i can only add one element, so i would need to add multiple styles:

editor:
  config:
    style:
      definitions:
        - { name: "test", element: "h1", classes: ["text-small"] }
        - { name: "test", element: "h2", classes: ["text-small"] }
        - { name: "test", element: "h3", classes: ["text-small"] }

But this results in multiple options in the style dropdown. We used this feature quiet extensively.

Does anyone experience the same and how do you deal with it?

Analyzing the ckeditor source code it seems you can use a Regular Expression for the element option.

StyleUtils::normalizeConfig

DataSchema::getDefinitionsForView

So doing something like this might work:

editor:
  config:
    style:
      definitions:
        - { name: "test", element: ^(h1|h2|h3|h4|h5|h6|p)$, classes: ["text-small"] }

So i would need some event to modify the evaluated json before passing the config to ckeditor.

Analyzing the ckeditor typescript file from TYPO3 i found this:

convertPseudoRegExp::convertPseudoRegExp

Seems close but still a miss, i would need to manipulate options.editor.config.style.definitions.*.element

Does anyone have an idea? I could try to “monkeypatch” JSON parsing in the browser or try to override the ckeditor options getter method. I dont see any other option besides waiting for ckeditor to add support for multiple elements and wait for typo3 to include that features… :frowning:

Okay, thats just the tip of the ice-berg. Due to the editor not being a simple iframe anymore (great decision! [NOT]) you can not include the same css in the editor and your frontend. No relative paths will work (absolute paths are not possible due to the new _assets inclusion), @-rules do not work, :root selectors do not work (what about :where(:root) for default variables with low specificity).

All in all CKEditor 5 is no improvement at all IMO, it just changes many things (javascript => typescript, iframe => inline) for the worse.

My best option would be a rollback to CKEditor4, but that’s not a real option i guess so i just have to explain everyone to go f*** themselves but not being able to apply custom styles is much better and hey - TYPESCRIPT (omfg)!

FYI: When using something like url(‘…/Icons/bullet-a.svg’) to reference assets (in my case configurable custom list symbols), you need to add a inline style block to the typo3 backend overwriting the relative paths with absolute paths, that you generate server-side (where you can generate the public path from the EXT:-path). That way you can use the same css for the frontend (where the relative path will work because the stylesheet location stays the same).

@-rules seem to work now, don’t know if there was any problem at all.

I am still unsure about the :root selector, this is all very hard to debug.

In the end i think using an iframe is the better option for such things, its much easier to achieve parity with the frontend.

But i can’t come up with a solution to the styles problem described in the opening post.

Hi Philipp!

I can understand that this change from CKEditor 4 to 5 is causing headaches. CKEditor 4 reached end-of-life status in June 2023, so the new version is the one to use. As far as I can see, your issue is already a known and reported bug in CKEditor 5:

Since TYPO3 is not the vendor of CKEditor, I suggest you ask your question in the CKEditor community.

For optimal results, I recommend that you watch your language in your posts. Whether you’re saying it straight out or hide obscene language in abbreviated or garbled form, everybody understands what it means. :slightly_smiling_face:

Best wishes

Mathias

I can understand that this change from CKEditor 4 to 5 is causing headaches. CKEditor 4 reached end-of-life status in June 2023, so the new version is the one to use. As far as I can see, your issue is already a known and reported bug in CKEditor 5:

Since TYPO3 is not the vendor of CKEditor, I suggest you ask your question in the CKEditor community.

I know, found that myself thank you. I just wanted to check if someone in this community was able to workaround this issue.

For optimal results, I recommend that you watch your language in your posts. Whether you’re saying it straight out or hide obscene language in abbreviated or garbled form, everybody understands what it means. :slightly_smiling_face:

I agree, sorry for my bad language. My frustration level got too high dealing with so many breaking changes at once.

1 Like