Problem/Motivation

Core themes (Seven, Claro, Umami, Olivero and Bartik) ship with CSS that is loaded inside the CKEditor iframe. Since CKEditor 4 is being deprecated, we need to decide what to do about these styles as the module is being moved to contrib.

Proposed resolution

  1. Option 1: Provide a generic set of CSS in CKEditor 4 module which is able to cater all themes not providing CKEditor 4 styles.
  2. Option 2: Continue to include CKEditor 4 in core themes even when CKEditor 4 is in contrib.
  3. Option 3: Move all of the CSS to CKEditor 4 module and load dynamically based on which theme is the default theme.
  4. Option 4: For Bartik and Seven, leave the CSS in the respective themes which will also be moving to contrib, then the contrib themes can provide support for the contrib module. Then Claro and Olivero CSS could be dropped when ckeditor4 is moved out.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

lauriii created an issue. See original summary.

lauriii’s picture

I'm personally in favor of option 1. In its simplest form, it should be simple to implement and maintain. It would also be consistent with what we are aiming to do with CKEditor 5.

wim leers’s picture

we need to decide what to do about these styles as the module is being moved to contrib.

Actually … are we moving it to contrib? 🤔 Should we? CKEditor 4's security support will end, so …

I'm personally in favor of option 1. In its simplest form, it should be simple to implement and maintain. It would also be consistent with what we are aiming to do with CKEditor 5.

💯

lauriii’s picture

Actually … are we moving it to contrib? 🤔 Should we? CKEditor 4's security support will end, so …

Linking to the issue which states that CKEditor 4 would be moved to contrib since I believe that would be a good place to discuss that.

catch’s picture

For Bartik and Seven, it seems easiest to leave the CSS in the respective themes which will also be moving to contrib, then the contrib themes can provide support for the contrib module. Then Claro and Olivero CSS could be dropped when ckeditor4 is moved out.

Having said that option #1 sounds good if it's not too much effort.

lauriii’s picture

Status: Active » Needs review

#5 seems reasonable given that the styles are related to minor adjustments to make the editor content resemble the frontend theme styles. All of the CSS that is required for the editor to remain functional is already in the CKEditor module, including the styles to make the CKEditor functional in Off Canvas.

nod_’s picture

Not sure I understand what option 1 means. It would be sort of a normalize.css for CKE content when there is no CSS declared? how is that different to leaving everything to CKE4 default styles? are the CKE4 default styles not good enough?

lauriii’s picture

Issue summary: View changes
StatusFileSize
new176.55 KB
new228.83 KB

@nod_ I think the normalize.css analogy is pretty accurate. I don't think we necessarily need to do anything. It is just that the styles are pretty basic and rely on browser default styles. Even though I proposed adding some default CSS, I don't think it would be strictly required and I think we would be most definitely fine with the default styles.

Olivero before:

Olivero after:

nod_’s picture

Thanks for the explanation.

Givent that I'd add normalize.css in CKE by default and stop there. All the core themes depend on it so that would make for a good default baseline IMO

lauriii’s picture

Issue summary: View changes

Added option 4 from #5 which I think is the most straight forward to implement.

nod_’s picture

About the files that are not inside the CKE iframe editor here is a list of what's happening in core themes regarding CKE libraries extension/overrides:

Classy

// INFO YML
libraries-extend:
  media/media_embed_ckeditor_theme:
    - classy/media_embed_ckeditor_theme

// LIBRARIES
media_embed_ckeditor_theme:
    js/media_embed_ckeditor.theme.js: {}

// JS FILE 
Drupal.theme.mediaEmbedPreviewError = () => 

Bartik

Same override as classy

Claro

Only CSS additions + the classy copy/paste

The CSS is used to make sure the CKE area has focus styles in the content editing, that the CKE dialogs follow the claro theme and not the default CKE styling, and to add a focus style to the CKE text format admin interface.

// INFO YML
libraries-extend:
  ckeditor/drupal.ckeditor:
    - claro/ckeditor-editor
  ckeditor/drupal.ckeditor.admin:
    - claro/ckeditor-admin
  core/ckeditor:
    - claro/ckeditor-dialog

// LIBRARIES
ckeditor-editor:
      css/theme/ckeditor-editor.css: {}
ckeditor-admin:
      css/theme/ckeditor.admin.css: {}
ckeditor-dialog:
      css/theme/ckeditor-dialog.css: {}

Olivero

Single CSS addition

// INFO YML 
libraries-extend:
  core/ckeditor:
    - olivero/cke-dialog

// LIBRARIES
cke-dialog:
      css/components/cke-dialog.css: {}

Seven

Couple of CSS extension + the classy copy/paste

Focus styles for editor buttons in the text format admin interface + CKE dialog styling

// INFO YML
libraries-extend:
  core/ckeditor:
    - seven/ckeditor-dialog
    - seven/ckeditor-admin

// LIBRARIES
ckeditor-admin:
      css/theme/ckeditor-admin.css: {}
ckeditor-dialog:
      css/theme/ckeditor-dialog.css: {}

Stable

Bunch of CSS files overrides, custom CKE theme based on CKE "moono"

CSS files are copy/paste from the CKE module. I guess it's to make sure stable is indeed stable should the CKE module CSS change.

There is one addition to ckeditor.css, stable adds a rule for CKE styling when used with quickedit.

// INFO YML
libraries-override:
  ckeditor/drupal.ckeditor:
        css/ckeditor.css: css/ckeditor/ckeditor.css
  ckeditor/drupal.ckeditor.plugins.drupalimagecaption:
        css/plugins/drupalimagecaption/ckeditor.drupalimagecaption.css: css/ckeditor/plugins/drupalimagecaption/ckeditor.drupalimagecaption.css
  ckeditor/drupal.ckeditor.plugins.language:
        css/plugins/language/ckeditor.language.css: css/ckeditor/plugins/language/ckeditor.language.css
  ckeditor/drupal.ckeditor.admin:
        css/ckeditor.admin.css: css/ckeditor/ckeditor.admin.css

Stable 9

Bunch of CSS files overrides, same as Stable theme. CSS is the same as the stable theme.

libraries-override:
  ckeditor/drupal.ckeditor:
        css/ckeditor.css: css/ckeditor/ckeditor.css
  ckeditor/drupal.ckeditor.plugins.drupalimagecaption:
        css/plugins/drupalimagecaption/ckeditor.drupalimagecaption.css: css/ckeditor/plugins/drupalimagecaption/ckeditor.drupalimagecaption.css
  ckeditor/drupal.ckeditor.plugins.language:
        css/plugins/language/ckeditor.language.css: css/ckeditor/plugins/language/ckeditor.language.css
  ckeditor/drupal.ckeditor.admin:
        css/ckeditor.admin.css: css/ckeditor/ckeditor.admin.css
lauriii’s picture

@nod_ did you have a chance to reassess what those libraries are altering? That would likely impact how we'd like to approach removing them.

nod_’s picture

added some details in the comment above. Most rules are about styling the CKE dialogs, and there are a couple of rules to make sure the focus is styled in a couple of cases.

lauriii’s picture

We should check if the CKE dialogs are usable without styles from themes.

It also sounds like, we might have to add few lines of CSS to the CKEditor module to ensure that the focus styles are accessible even without the CSS additions from themes.

nod_’s picture

the dialogs are very much usable without the styles overrides, just pretty different visually than the rest of the themes.

lauriii’s picture

StatusFileSize
new576 bytes

Here's a patch which we could use for ensuring that there's a visible focus outline. It seems like for example FF is missing focus outline at the moment when not using Claro or Seven.

nod_’s picture

That works for the admin config interface, still missing focus style when using the cke in an edit form.

lauriii’s picture

Status: Needs review » Needs work

For #17.

lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new981 bytes
new405 bytes
nod_’s picture

Status: Needs review » Reviewed & tested by the community

That works for me, this also adds a focus style to CKE4 on olivero (wrong color for olivero but better than nothing) :)

bnjmnm’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new86.79 KB
  1. +++ b/core/modules/ckeditor/css/ckeditor.admin.css
    @@ -210,6 +210,8 @@
     }
    

    On HEAD, with FF and Chrome, I tested button focus in the admin form with every core theme (including Stark and Classy) and the focus ring was visible in each. I'm not sure this is necessary for the admin form, I may be missing something here...

  2. +++ b/core/modules/ckeditor/css/ckeditor.css
    @@ -210,6 +210,8 @@
    +  outline: 5px auto -webkit-focus-ring-color;
    

    It was mentioned in an earlier comment that it was noticed FF wasn't getting focus rings in some themes, but the color here is not recognized by FF. The color on the dash outline isn't that distinct from the borders.

I agree with @nod_ that dialogs look fine and are plenty usable without the theme styling:

lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new23.19 KB
new1.02 KB
new916 bytes

#21.1: It is needed to make the focus ring visible on Claro.

Here's a patch that improves the FF focus ring:

nod_’s picture

Status: Needs review » Reviewed & tested by the community

I'm happy with it. Resolves an issue in olivero too so extra bonus :)

lauriii’s picture

Removing the needs product/release manager review tags since I originally tagged this with those tags. I think the scope of this was smaller than I anticipated and I believe we don't need reviews from them besides what we already got in #5.

  • bnjmnm committed cc4a1b4 on 10.1.x
    Issue #3285049 by lauriii, nod_, catch, Wim Leers: Decide what to do...

  • bnjmnm committed 68ba52f on 10.0.x
    Issue #3285049 by lauriii, nod_, catch, Wim Leers: Decide what to do...
bnjmnm’s picture

Version: 10.0.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed to 10.1.x and cherry picked to 10.0.x and 9.5.x.

This is a nice solution as it acknowledges that CKEditor 4 is near EOL / Core exclusion so it does not attempt to provide a pixel-perfect means of continuing use of an EOL, but it does address issues that would compromise accessibility / feature access.

  • bnjmnm committed 741593c on 9.5.x
    Issue #3285049 by lauriii, nod_, catch, Wim Leers: Decide what to do...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

leo liao’s picture

StatusFileSize
new94.34 KB
new92.87 KB
new95.29 KB

Cursor is blocked on chrome.

leo liao’s picture

StatusFileSize
new382 bytes
bnjmnm’s picture

@leo liao If you're hoping to see this change added to Drupal core it's best to create a new issue. It won't see any progress added to something that was closed several months ago.