Problem/Motivation

#3205565: Add language of parts plugin brought #1993928: Language of parts: Introduce a language toolbar button to CKEditor 5. Yay!

But #1993928: Language of parts: Introduce a language toolbar button had a crucial UX improvement on top of what CKEditor 5 provides, by adding some CSS.

See for yourself:

CKEditor 4
CKEditor 5

This was done through core/modules/ckeditor/css/plugins/language/ckeditor.language.css, whose contents are trivial:

/**
 * Show the user that a 'lang' tag has been applied by adding a thin dotted
 * border. We also append the value of the tag between brackets, for example:
 * '(en)'. Since the html element has a 'lang' attribute too we only target
 * elements within the html scope.
 */
html [lang] {
  outline: 1px dotted gray;
}
html [lang]:after {
  content: " ("attr(lang)")";
  color: #666;
  font-size: 10px;
}

Unfortunately, we cannot simply replicate this in CKEditor 5, because the CKEditor 5 architecture is completely different. We cannot load any CSS into a CKEditor 5 instance! (In that sense, #3194084: Support functionality equivalent to ckeditor_stylesheets is related too.)

Steps to reproduce

TBD

Proposed resolution

Before

After

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Issue fork ckeditor5-3215603

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Status: Active » Postponed
Reinmar’s picture

Unfortunately, we cannot simply replicate this in CKEditor 5, because the CKEditor 5 architecture is completely different.

CKEditor 5 also allows you to style the content via a stylesheet. There's no concept of `config.contentsCss` because it's unnecessary now. Since we don't use an iframe anymore, your page's stylesheets affect CKE5 directly.

You can read more in https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/con.... But the short story is – add `.ck-content span[lang]` to your page's stylesheet and that will affect how the language parts are styled in the editor.

wim leers’s picture

Status: Postponed » Active
Issue tags: -Needs upstream feature

Thank you! 😊

We'll give that a try!

wim leers’s picture

And YAY, @lauriii just pointed out that thanks to the different architecture in CKEditor 5, we don't need any new infrastructure here, we can just add it to the asset library that loads the language plugin! 🥳

wim leers’s picture

Issue summary: View changes
Status: Active » Needs review
Issue tags: +CSS
StatusFileSize
new1.12 MB
new1.13 MB

Yay for not needing \Drupal\ckeditor\CKEditorPluginCssInterface anymore! 🥳

lauriii’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed the MR and tested manually and all looks good 👌

zrpnr made their first commit to this issue’s fork.

  • zrpnr committed 2e586e8 on 1.0.x authored by lauriii
    Issue #3215603 by Wim Leers, Reinmar, lauriii: Follow-up for #3205565:...
zrpnr’s picture

Status: Reviewed & tested by the community » Fixed

This matches the css in ckeditor.language.css but scoped for ckeditor5 with .ck-content.
Thanks!

Status: Fixed » Closed (fixed)

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