Steps to reproduce:

  1. Open configuration page for some text format, i.e. Full HTML
  2. Drag and drop Style button to active toolbar
  3. Select Style tab under CKEditor5 plugin settings
  4. Put samle value "h1.title|Title" from the textarea description
  5. Sumbit the form

The following error message appears.

Enable at least one style, otherwise disable the Style plugin.

Furthermore, the Style tab disappears from the "CKEditor5 plugin settings" widget.

Screenshot of CKEditor configuration form

Issue fork drupal-3309585

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

Chi created an issue. See original summary.

wim leers’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)
StatusFileSize
new574.32 KB

I cannot reproduce this. 😔

Are you sure that step 4 (Put samle value "h1.title|Title" from the textarea description) should be in the steps to reproduce?

If I skip that one step, I see this:

→ the validation error you mentioned, but the Style tab still is present.

wim leers’s picture

Title: CKEditor5 now way to configure style plugin » CKEditor 5 no way to configure style plugin
drupgirl’s picture

Try deselecting "Limit allowed HTML tags and correct faulty HTML" and then adding the styles.

wim leers’s picture

Title: CKEditor 5 no way to configure style plugin » "change" event not triggered for Style plugin's <textarea> when saving immediately
Status: Postponed (maintainer needs more info) » Active
Issue tags: +JavaScript, +Needs tests

After trying several more times, I was now able to reproduce this.

The root cause is that the JS change event does not get triggered for the <textarea> that contains the Style configuration if you immediately click the Save button. If you click anywhere else in the UI, it works fine.

I'd swear we have test coverage for pretty much exactly this 😬

Wim Leers credited bnjmnm.

wim leers’s picture

Thanks @bnjmnm for pointing out in chat that we did in fact work on this ~6 months ago: #3265626: Changes to "Manually editable HTML tags" lost if form is submitted without triggering AJAX.

We even have explicit tests for it.

But … it looks like we may need to generalize that solution to a generic one — that solved it specifically for SourceEditing.

I think that we should just add an event handler to the Save button that forces the change event to be triggered if something did just change, and if so, disable that button, wait for the AJAX response, and then retrigger the button. 🙈

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

mingsong’s picture

Issue tags: -JavaScript +JavaScript

I came across this issue too.

The work around suggested in #5 did not work in my case. Even I click anywhere else in the UI before clicking the save button, it still did not work.

The reason is that I have a contribute module called 'Events Log Track' installed which adds a submit handler function to every single form including the format config form. This causes following code at line 686 in Drupal\ckeditor5\Plugin\Editor::CKEditor5 failed to recognise it is a special AJAX updates.

      // Special case: AJAX updates that do not submit the form (that cannot
      // result in configuration being saved).
      if ($form_state->getSubmitHandlers() === ['editor_form_filter_admin_format_editor_configure']) {

If I change that line to:

if (in_array('editor_form_filter_admin_format_editor_configure', $form_state->getSubmitHandlers())) {

then it works.

mingsong’s picture

Title: "change" event not triggered for Style plugin's <textarea> when saving immediately » CKEditor 5 Style plugin configuration tab does not appear
Issue tags: -JavaScript +JavaScript

mingsong’s picture

Status: Active » Needs review
wim leers’s picture

Priority: Normal » Minor
Status: Needs review » Reviewed & tested by the community
Issue tags: -JavaScript, -Needs tests +Ajax

That seems like a reasonable change!

Thanks for tracking that down 😊👏

mingsong’s picture

StatusFileSize
new926 bytes

The patch from the MR. In case anyone need it to test with your site.

mingsong’s picture

StatusFileSize
new923 bytes

Sorry the #14 patch is failed to apply to 10.0.x branch.
Here is the new patch.

mingsong’s picture

  • lauriii committed fc024f35 on 11.x
    Issue #3309585 by Mingsong, Wim Leers, Chi: CKEditor 5 Style plugin...

  • lauriii committed 3e7580e2 on 10.1.x
    Issue #3309585 by Mingsong, Wim Leers, Chi: CKEditor 5 Style plugin...

  • lauriii committed e3400399 on 10.0.x
    Issue #3309585 by Mingsong, Wim Leers, Chi: CKEditor 5 Style plugin...

  • lauriii committed 8309943e on 9.5.x
    Issue #3309585 by Mingsong, Wim Leers, Chi: CKEditor 5 Style plugin...
lauriii’s picture

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

Committed fc024f3 and pushed to 11.x. Thanks! Cherry-picked all the way to 9.5.x since this is a non-disruptive bug fix.

Status: Fixed » Closed (fixed)

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

Augusto182’s picture

Hello. I'm reopening this issue because I'm facing a issue that seems related.

Core: 10.1.2 (also in 10.0.9 )

Steps to reproduce:

1. Open configuration page for some text format, i.e. Full HTML
2. Drag and drop Style button to active toolbar

Expected result:

- Show up a "Select Style tab" under CKEditor5 plugin settings, to be able to edit such styles.

Current result:

Nothing happen. "Select Style tab" missing.
Also, if configuration is summited, show up this error: "Enable at least one style, otherwise disable the Style plugin. "

Not sure if this could be addressed here, or a new issue should be created.

mably’s picture

Facing same problem on Drupal 10.2.1. Any solution?
EDIT: as specified in a previous comment, you just need to disable the "Limit allowed HTML tags and correct incorrect HTML" setting. You can re-enable it after defining your styles.

dehacker’s picture

Same as #24 in 10.2, but I had to disable all filters in order to add styles.

drupaldope’s picture

Same problem in 10.2.5

Re-opening this.

drupaldope’s picture

Version: 9.5.x-dev » 10.2.x-dev
juc1’s picture

I am having the same problem in 11.1 😒

Disabling other filters does not help.

markwittens’s picture

I just had this issue in 11.1.3, it seems to be related to the "Heading" dropdown.

The workaround that worked for me was to place the Style dropdown behind the Heading dropdown in the toolbar, and then save it. Once saved successfully it can be moved wherever without further issues.

bnjmnm’s picture

I noticed there is activity from several people on this issue after a fix was committed and the issue closed.

If anyone above are hoping their comments result in additional changes to Drupal core, the chances of that happening are infinitely higher if it's reported in a new issue.

It is very rare that an issue is truly "reopened", and in those rare instances it's pretty much always within a few days of it being closed.

tripodcreative’s picture

This error is still persisting. No matter what you place in the "Styles" option, saving it both hides the styles entry element and an error message appears "Enable at least one style, otherwise disable the Style plugin."

As it exists, there is no way to make styles work with CKEditor5. On Drupal 11.2