Issue Bug Closed

#107321Issue with table in CKEditor 5 when using dark mode

Sébastien LeBlanc 08/22/25, 05:23 updated 08/22/25, 19:11

Description

CKEditor 5 styles are overwritten by Typo3 styles, causing the background of a `` to be dark instead of light.

The specificity for `.table>:not(caption)>*>*` is higher than `#data_tt_content__1519__bodytext_ckeditor5 .ck-content table` which cause the background-color value to be `light-dark(#f7f7f7, #141414)` from `var(—typo3-table-bg)` instead of `#fff`

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Files 2

History 3

  1. Sébastien LeBlanc commented 08/22/25, 17:32

    Actually, something added `html, body { background-color: #fff }`, but I did not understand where it came from because CKEditor is not an iframe, but and customElement, so there is no `html` nor `body` tag in the component ! Something seem to be converting `html, body` property to a Constructed Stylesheet on the root `.ck` element.

    I could not find how to close this issue, I can’t update the status, the dropdown only list “New” as an option

  2. Garvin Hicking commented and changed category status New Closed 08/22/25, 18:48

    Hey Sebastien,

    in v14 we’ve already better implemented dark/light mode in CKEditor 5 without the forced white background color. This is in place in earlier versions to be not breaking custom CSS rules of implementations.

    Indeed for the application of custom contentCSS, TYPO3 employs a technique “CSS prefixing” which is performed via Build/Sources/TypeScript/rte-ckeditor/css-prefixer.ts (in the css-prefix.js file after building). This takes care to transpose all CSS rules that would affect the “body” of an iframe to be applied to our custom web component.

    I’m closing the issue as requested, since you seem to have figured our a solution for you, right?

  3. Sébastien LeBlanc commented and changed attached screenshot-2025-08-22-15-06-24.png 08/22/25, 19:11

    The CKEditor in not white in dark-mode ! It was my custom CSS that this did.
    We import Foundation for Sites and it’s part of the default to set `html, body { backgroud-color: #fff }` but I didn’t understand because there is no `<html><body> tag, just a `<typo3-rte-ckeditor-ckeditor5>` customElement and somehow it coverts `html, body` to this selector `#data_tt_content__1519__bodytext_ckeditor5 .ck-content`.</typo3-rte-ckeditor-ckeditor5></body></html>

    Now by removing this the Foundation for Sites import, my background is dark, and I added forced a white background to my ``. No need to wait for Typo3 v14 as you can see in the attached screenshot.