Problem/Motivation

While working in #3367194: [Entity Browser] Tests are failing on D10 I ran into an error where CKEditor5 stopped working because of the following error:
Drupal.ajax is not a function

I noticed that the library internal.drupal.ckeditor5 doesn't have an dependency on core/drupal.ajax, but is using the function Drupal.ajax

Steps to reproduce

  1. Install Drupal using the minimal installation profile.
  2. Enable ckeditor5 and field_ui modules.
  3. Create a content type and add a body field using CKEditor 5.
  4. Move all fields, except title and body out of the form display (authored by uses Ajax, so adding this field will result in drupal.ajax being loaded.)
  5. Add a CKEditor5 plugin that calls the openDialog method. In my case I used Entity embed. So I enabled the entity_embed module and added the default "Node" embed button.
  6. Create a new node, click on the embed button. The dialog doesn't open.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3367204

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

JeroenT created an issue. See original summary.

jeroent’s picture

Issue summary: View changes
jeroent’s picture

Status: Active » Needs review
smustgrave’s picture

Version: 10.1.x-dev » 11.x-dev
Status: Needs review » Needs work
Issue tags: +Needs steps to reproduce

Can the MR be updated for 11.x

Also steps to reproduce this? May be we need to add a test case.

jeroent’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs steps to reproduce

AFAIS the media library embed button is the only CKEditor 5 button that opens in a dialog. But the media library js files add a dependency on drupal/core.ajax, so you can't reproduce this with this a different CKEditor5 plugin. I ran into this issue while running tests for the entity_embed module.

  1. Install Drupal using the minimal installation profile.
  2. Enable ckeditor5 and field_ui modules.
  3. Create a content type and add a body field using CKEditor 5.
  4. Move all fields, except title and body out of the form display (authored by uses Ajax, so adding this field will result in drupal.ajax being loaded.)
  5. Add a CKEditor5 plugin that calls the openDialog method. In my case I used Entity embed. So I enabled the entity_embed module and added the default "Node" embed button.
  6. Create a new node, click on the embed button. The dialog doesn't open.
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

I see no harm in loading the library. Will ask the committer if this needs a test though.

lauriii’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

I'm not sure why we would have to make this change in core. Shouldn't entity_embed set it as a dependency, not the core CKEditor 5 module? 🤔

neclimdul’s picture

Status: Postponed (maintainer needs more info) » Needs review

I think it does use ajax though unless I'm reading this incorrectly:
https://git.drupalcode.org/project/drupal/-/blob/cb65aa9db0e42b0e0685fec...

jeroent’s picture

I ran into this problem while using entity_embed. But ckeditor5.js is the file that calls Drupal.ajax. So this library should be added here.

  • lauriii committed 9c505099 on 11.x
    Issue #3367204 by JeroenT, smustgrave, neclimdul: [CKEditor5] Missing...

  • lauriii committed 164f2f98 on 10.0.x
    Issue #3367204 by JeroenT, smustgrave, neclimdul: [CKEditor5] Missing...

  • lauriii committed d4b0f150 on 10.1.x
    Issue #3367204 by JeroenT, smustgrave, neclimdul: [CKEditor5] Missing...

  • lauriii committed 52f026be on 9.5.x
    Issue #3367204 by JeroenT, smustgrave, neclimdul: [CKEditor5] Missing...
lauriii’s picture

Version: 11.x-dev » 9.5.x-dev
Status: Needs review » Fixed

Thanks for pointing that out! I had a false memory that we removed it from CKEditor 5... but looks like that isn't the case. 😅 Thanks for the additional information, this makes now total sense 👍

Committed 9c50509 and pushed to 11.x. Thanks! Backported all the way to 9.5.x.

wim leers’s picture

Issue tags: +Ajax

🤯

How the hell did we miss this?! 😅🙈

Thanks, great catch!

neclimdul’s picture

🙌 Love that easy fix!

Status: Fixed » Closed (fixed)

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