Score:0

How do I configure the styles dropdown in CKEditor 5?

br flag
WRD

I've got a fresh, standard install of Drupal 9.5-RC, and have added the Styles plugin to the Basic HTML text editor. The styles are set up like so:

p.test|Test P style
h2.test|Test H2 style
ul.test|Test UL style
ol.test|Test OL style
li.test|Test li style
blockquote.test|Test blockquote style
a.test|Test link style

If I select any text at all except an h2, the styles menu shows "Test P style" and "Test link style" available. Selecting "Test link style" applies an tag around the selected text, as well as the "test" class. I would expect that the "Test link style" option would only be available if I had selected text that is already linked.

If I select an h2, then the "Test H2 style" and "Test link style" options are available, and all others are disabled.

If I select a blockquote, then "Test blockquote style" is enabled along with the P and Link styles.

If I select the contents of a list, either OL or UL, only the P and Link styles are available -- not the OL, UL, or LI styles.

In CKE4, I would expect to have to solve these issues by adjusting my allowed HTML tags and attributes in the text format. But of course with CKE5, the allowed HTML field is read-only. It does seem to be automatically set up to allow the necessary tags and attributes:

<br> <p class="test"> <h2 class="test"> <h3> <h4> <h5> <h6> <ul class="test"> <ol class="test" reversed start> <li class="test"> <blockquote class="test"> <a class="test" href> <strong> <em> <drupal-media data-entity-type data-entity-uuid alt data-caption data-align>

I've tried also enabling the Source plugin and duplicating the tags but allowing any class, e.g. <ul class> or <ul class="*">, but to no avail.

Can anyone tell me what I've done wrong here?

vg flag
You could enable the CKEditor 4 Module, as quick-fix.
WRD avatar
br flag
WRD
I've still got it enabled -- I was trying to figure out if we could upgrade, since CKE4 is rapidly approaching EOL, and with CKE5 being the default editor for 9.5, I figured it should be ready for use. But perhaps I haven't done anything wrong, and it's just not working properly yet...didn't want to open an issue on it until I know it's not my error, though.
Adrained avatar
gb flag
I just came across a problem that feels like it is in the same genre. I added DIV with the source plugin. I then added some styles for DIVs, but selecting content in a DIV, the options for those styles don't show up... although I could have sworn they did a couple of weeks ago, so wondering if recent changes might have mucked things up.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.