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
- Install Drupal using the minimal installation profile.
- Enable ckeditor5 and field_ui modules.
- Create a content type and add a body field using CKEditor 5.
- 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.)
- 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.
- 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
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
Comment #3
jeroentComment #4
jeroentComment #5
smustgrave commentedCan the MR be updated for 11.x
Also steps to reproduce this? May be we need to add a test case.
Comment #8
jeroentAFAIS 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.
Comment #9
smustgrave commentedI see no harm in loading the library. Will ask the committer if this needs a test though.
Comment #10
lauriiiI'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? 🤔
Comment #11
neclimdulI think it does use ajax though unless I'm reading this incorrectly:
https://git.drupalcode.org/project/drupal/-/blob/cb65aa9db0e42b0e0685fec...
Comment #12
jeroentI 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.
Comment #17
lauriiiThanks 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.
Comment #19
wim leers🤯
How the hell did we miss this?! 😅🙈
Thanks, great catch!
Comment #20
neclimdul🙌 Love that easy fix!