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

  1. Install Drupal 10.5.0 with the Standard install profile and ckeditor_abbreviation.
  2. Enable ckeditor_abbreviation on the Basic HTML text format.
  3. 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

  1. Write a patch — done by @sunlix
  2. Cross-compatibility testing and figure out if we need to make a new version — turns out we don't need to make a new version
  3. Fix broken tests — done by @mparker17
  4. Review and feedback — reviewed by @mparker17
  5. RTBC and feedback
  6. Commit
  7. Release

User interface changes

None anticipated.

API changes

To be determined.

Data model changes

None anticipated.

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

harkonn created an issue. See original summary.

sunlix’s picture

Since ckeditor 45.0.0 the icons were moved into its own package @ckeditor5/ckeditor5-icons

Therefore the import has to be adjusted in abbreviationview.js

From

import { icons } from 'ckeditor5/src/core';

To

import { icons } from 'ckeditor5/src/icons';

But I think this is a breaking change. Maybe we need a new branch with a new drupal core supporting version?

sunlix’s picture

Priority: Normal » Major
dharmeshbarot’s picture

Hey @sunlix, I've checked this by applying the changes that you have mentioned but issues is still persist, could you please check again?

shaikh sadab’s picture

The 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.check
With:
(e.icons && e.icons.check) || '<svg></svg>'

Replaced:
e.icons.cancel
With:
(e.icons && e.icons.cancel) || '<svg></svg>'

Replaced:
e.icons.eraser
With:
(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.

mlncn’s picture

Version: 5.0.0 » 5.0.x-dev

Precise 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.

mlncn’s picture

The 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.

sunlix’s picture

Sorry 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.

sunlix’s picture

The current test piplines are running with Drupal 11.1.7 and 10.4.7.
So the tests are running against ckeditor 44 and not 45.

I added OPT_IN_TEST_NEXT_MINOR to test on 11.2.1-dev with ckeditor 45.

sunlix’s picture

With ckeditor 45 the 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 44 and 45 in parallel?

sunlix’s picture

Status: Active » Needs review
mparker17’s picture

Issue summary: View changes
Status: Needs review » Needs work

Maintainer 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?

sunlix’s picture

@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.0 of ckeditor5.

mlncn’s picture

(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!

mparker17’s picture

Issue summary: View changes

@sunlix, thanks I've updated the issue summary.

mparker17’s picture

My multiple version testing results...

In the table below:

  • ✅ means that I was able to see the CKEditor on the node/edit page, I was able to enter an abbreviation using the CKEditor Abbreviation button, and the abbreviation worked on the node/view page
  • ❌ means CKEditor did not load on the node/edit page, and thus I was not able to proceed further with testing. I've listed the error shown in the console (but not the stack trace, in part because my JS was minified)
  5.0.x (commit 3249dd6) 3531259-incompatible-with-drupal (commit 6587b5c)
drupal/core:10.4.8
CKEditor error: plugincollection-plugin-not-found {"plugin": null}
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-plugincollection-plugin-not-found
drupal/core:10.5.0
TypeError: can't access property "check", e.icons is undefined
drupal/core:11.1.8
CKEditor error: plugincollection-plugin-not-found {"plugin": null}
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-plugincollection-plugin-not-found
drupal/core:11.2.0
TypeError: can't access property "check", e.icons is undefined

All four sites were set up identically: Standard install profile; CKEditor Abbreviation added to Basic HTML text format; went to /node/add/article to test.

... I'll interpret this in another comment; just wanting to save it here.

mparker17’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community

Trying 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!

mparker17’s picture

For what it's worth, I'm running the updated patch on an 11.2.0 site, and it seems to work fine for me.

sunlix’s picture

@mparker17

would you like to have another commit to clean up the package.json a 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?

  "name": "drupal-ckeditor-abbreviation",
  "private": true,
  "version": "5.0.1",
  "description": "Drupal CKEditor 5 integration for abbreviation plugin",

  ...

  "dependencies": {
    "@ckeditor/ckeditor5-core": "~45.2.0",
    "@ckeditor/ckeditor5-icons": "~45.2.0",
    "@ckeditor/ckeditor5-typing": "~45.2.0",
    "@ckeditor/ckeditor5-ui": "~45.2.0",
    "@ckeditor/ckeditor5-utils": "~45.2.0"
  }
mparker17’s picture

@sunlix, Yes, please add another commit to clean up package.json!

Thank you very much!

ryan-l-robinson’s picture

Latest patch also fixed the problem for me.

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

boromino’s picture

I 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?

mparker17’s picture

@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!

  • boromino committed f25f29ea on 5.0.x authored by sunlix
    Issue #3531259 by sunlix, mparker17, boromino, mlncn, harkonn, shaikh...
boromino’s picture

Status: Reviewed & tested by the community » Fixed
mparker17’s picture

Awesome, thanks @boromino!

(sorry for the late reply, I was on vacation)

Status: Fixed » Closed (fixed)

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