Problem/Motivation
After an upgrade to Drupal 10.5.0, or on a fresh 10.5.0 site-install, when the ckeditor_abbreviation module is enabled, and a text format has been configured with a ckeditor_abbreviation toolbar button, the CKEditor widget fails to load (e.g.: on a node/add page). Checking the browser console, CKEditor generates a JS-error:
TypeError: Cannot read properties of undefined (reading 'check')
at new d (abbreviation.js?sy5a3z:1:3972)
at b._createFormView (abbreviation.js?sy5a3z:1:7343)
at b.init (abbreviation.js?sy5a3z:1:5502)
This appears to be related to the upgrade to CKEditor 45.2.0 — in CKEditor 45.0.0, the icons were moved into their own package, @ckeditor5/ckeditor5-icons.
Steps to reproduce
- Install Drupal 10.5.0 with the Standard install profile and ckeditor_abbreviation.
- Enable ckeditor_abbreviation on the Basic HTML text format.
- Go to
/node/add/article— note that CKEditor did not load. Check the browser console.
Proposed resolution
Fix breaking changes from the CKEditor documentation on Updat[ing] to CKEditor 5 v45.x.
Remaining tasks
Write a patch— done by @sunlixCross-compatibility testing and figure out if we need to make a new version— turns out we don't need to make a new versionFix broken tests— done by @mparker17Review and feedback— reviewed by @mparker17- RTBC and feedback
- Commit
- Release
User interface changes
None anticipated.
API changes
To be determined.
Data model changes
None anticipated.
Issue fork ckeditor_abbreviation-3531259
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 #2
sunlixSince ckeditor
45.0.0the icons were moved into its own package@ckeditor5/ckeditor5-iconsTherefore the import has to be adjusted in
abbreviationview.jsFrom
To
But I think this is a breaking change. Maybe we need a new branch with a new drupal core supporting version?
Comment #3
sunlixComment #4
dharmeshbarot commentedHey @sunlix, I've checked this by applying the changes that you have mentioned but issues is still persist, could you please check again?
Comment #5
shaikh sadab commentedThe issue was caused by missing or undefined icon references in the JavaScript build file located at:
`/ckeditor_abbreviation/js/build/abbreviation.js`
I modified the file by replacing the undefined icon references with fallback values.
Changes Made:
Replaced:
e.icons.checkWith:
(e.icons && e.icons.check) || '<svg></svg>'Replaced:
e.icons.cancelWith:
(e.icons && e.icons.cancel) || '<svg></svg>'Replaced:
e.icons.eraserWith:
(e.icons && e.icons.eraser) || '<svg></svg>'These changes ensure the script does not break when the icon is undefined by falling back to a basic empty
'<svg>'element.Comment #7
mlncn commentedPrecise error in console that i was getting with Drupal 11 and CKEditor 45.2:
"TypeError: e.icons is undefined"
Given that the icon package is at play here, that i'm not finding that error message on the internet anywhere, and that CKEditor Abbreviation is the only extra module for CKEditor we have, i think it has to be related.
Comment #8
mlncn commentedThe merge request deletes the built file, resulting in an unsurprising error of this kind: The requested URL /modules/contrib/ckeditor_abbreviation/js/build/abbreviation.js was not found on this server.
Given that it was committed before i presume there is a step committers should take to generate the file and then commit it?
And agree that a new major version release makes sense and we can have it version 6 require Drupal core 10.5 / 11.2 or later.
Really rotten of CKEditor to fail this badly on a breaking change; one thing for the plugin or even CKEditor to not work but for it to blank out all text on save is the worst possible behavior.
Comment #9
sunlixSorry for the deleted build artifact. I messed up with the MR because the default branch is 4.0.x and I oversaw the target branch and rebased like a monkey :D
I added the build artifact with the changes, that should running again. But the tests are failing.
Didnt find out the reason. I will dig in later.
Comment #10
sunlixThe current test piplines are running with Drupal
11.1.7and10.4.7.So the tests are running against ckeditor
44and not45.I added
OPT_IN_TEST_NEXT_MINORto test on11.2.1-devwith ckeditor45.Comment #11
sunlixWith ckeditor
45the tests are green.How to proceed here? Branch a new major and set new version constraint on
5.0.1?Or is there a way to support ckeditor
44and45in parallel?Comment #12
sunlixComment #13
mparker17Maintainer here! Sorry for the delay; it's been a busy few weeks for me.
I have been able to reproduce the problem on Drupal 10.5.0, and can confirm that the code in the patch fixes the issue; but I cannot merge code with broken tests. I also notice some issues in the code: I'll leave some comments in the merge request shortly. For these two reasons I am marking this issue as "Needs Work".
I'll do some more research into compatibility with forward and backward compatibility with Drupal core. There does appear to be some activity in #3523018: Update CKEditor 5 to 45.2.0 (core), and #3531194: D11.2 / D10.5: Uncaught CKEditorError: Cannot read properties of undefined (reading 'viewUid') (editor_advanced_link, another module that integrates with CKEditor) to keep an eye on.
While I was updating the issue summary, I tried to find a link to @ckeditor5/ckeditor5-icons in the NPM Package List, but couldn't. @sunlix, do you have a link to this new package?
Comment #14
sunlix@mparker17
sure.
NPM: https://www.npmjs.com/package/@ckeditor/ckeditor5-icons
GitHub: https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-icons
Please note that this package is new since
45.0.0ofckeditor5.Comment #15
mlncn commented(crosspost)
This is great! Works and the code change is straightforward. I would change to RTBC except for the decision on how to commit and release.
My 2¢ is to do the new major with different version constraints— and hope CKEditor does not make a habit of this level of breaking change!
Comment #16
mparker17@sunlix, thanks I've updated the issue summary.
Comment #17
mparker17My multiple version testing results...
In the table below:
CKEditor error: plugincollection-plugin-not-found {"plugin": null}Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-plugincollection-plugin-not-foundTypeError: can't access property "check", e.icons is undefinedCKEditor error: plugincollection-plugin-not-found {"plugin": null}Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-plugincollection-plugin-not-foundTypeError: can't access property "check", e.icons is undefinedAll four sites were set up identically: Standard install profile; CKEditor Abbreviation added to Basic HTML text format; went to
/node/add/articleto test.... I'll interpret this in another comment; just wanting to save it here.
Comment #18
mparker17Trying to debug the source of the errors led me to a fix!
I've reviewed the changes by @sunlix and I'm satisfied with them. I also contributed to the patch (with my Maintainer hat on), and I'm satisfied with my own changes — but another maintainer (@boromino, @sickness29) should review as well.
Moving to RTBC so another maintainer can review!
Comment #19
mparker17For what it's worth, I'm running the updated patch on an 11.2.0 site, and it seems to work fine for me.
Comment #20
sunlix@mparker17
would you like to have another commit to clean up the
package.jsona bit?I have deleted the unused plugin so the dependencies are smaller and give a proper name and description along with the private flag.
Do you have a meaning?
Comment #21
mparker17@sunlix, Yes, please add another commit to clean up
package.json!Thank you very much!
Comment #22
ryan-l-robinson commentedLatest patch also fixed the problem for me.
Comment #24
boromino commentedI have tested on Drupal 11.2.2 and 10.4.8, the former also with translation. It works on both. Code looks good.
However, there seem to remain unresolved change requests?
Comment #25
mparker17@boromino, oops, thank you! All the threads were resolved but I forgot to /approve the merge request. I've done that now. Sorry for the confusion, and thanks for reviewing!
Comment #27
boromino commentedComment #28
mparker17Awesome, thanks @boromino!
(sorry for the late reply, I was on vacation)