After updating to latest Drupal 10.0.6 (which introduces a new release of ckeditor5) ckeditor5 doesn't work anymore when the Editor Advanced Link plugin is enabled.

The problem is reproducible on a clean Drupal 10.0.6 installation with both 2.1.1 and 2.1-dev version of Editor Advanced Link.

The error logged on the browser console is:

TypeError: this.editor.plugins.get(...).formView is null
    _changeFormToVertical https://example.ddev.site/modules/contrib/editor_advanced_link/js/build/editorAdvancedLink.js?v=10.0.6:1
    init https://example.ddev.site/modules/contrib/editor_advanced_link/js/build/editorAdvancedLink.js?v=10.0.6:1
    promise callback*./packages/ckeditor5-core/src/index.ts/init/p/< https://example.ddev.site/core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js?v=36.0.1:5
    p https://example.ddev.site/core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js?v=36.0.1:5
    init https://example.ddev.site/core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js?v=36.0.1:5
    initPlugins https://example.ddev.site/core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js?v=36.0.1:5
    create https://example.ddev.site/core/assets/vendor/ckeditor5/editor-classic/editor-classic.js?v=36.0.1:4
    create https://example.ddev.site/core/assets/vendor/ckeditor5/editor-classic/editor-classic.js?v=36.0.1:4
    attach https://example.ddev.site/core/modules/ckeditor5/js/ckeditor5.js?rs17v0:371
    editorAttach https://example.ddev.site/core/modules/editor/js/editor.js?v=10.0.6:300
    attach https://example.ddev.site/core/modules/editor/js/editor.js?v=10.0.6:224
    attach https://example.ddev.site/core/modules/editor/js/editor.js?v=10.0.6:207
    attachBehaviors https://example.ddev.site/core/misc/drupal.js?v=10.0.6:166
    attachBehaviors https://example.ddev.site/core/misc/drupal.js?v=10.0.6:162
    <anonymous> https://example.ddev.site/core/misc/drupal.init.js?v=10.0.6:32
    listener https://example.ddev.site/core/misc/drupal.init.js?v=10.0.6:20
    domReady https://example.ddev.site/core/misc/drupal.init.js?v=10.0.6:26
    <anonymous> https://example.ddev.site/core/misc/drupal.init.js?v=10.0.6:31
    <anonymous> https://example.ddev.site/core/misc/drupal.init.js?v=10.0.6:34
ckeditor5.js:427:19
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

FiNeX created an issue. See original summary.

jmouse888’s picture

I can confirm the same error after Drupal 9.5.6 upgrade. (TypeError.... formView is null)

Also tried 2.1.1+1-dev and no luck. Same error.

mark_fullmer’s picture

Title: Editor Advanced Link breaks Ckeditor5 after update to Drupal 10.0.6 » Editor Advanced Link breaks Ckeditor5 after update to Drupal 10.1.x

The update to CKEditor5 that caused the issue, introduced in 9.5.6 and 10.0.6, has been reverted in https://www.drupal.org/project/drupal/releases/9.5.7 and https://www.drupal.org/project/drupal/releases/10.0.7

This issue should remain open for compatibility with 10.1.x, which retains the CKEditor update.

mark_fullmer’s picture

Note the proximate trigger is const linkFormView = this.editor.plugins.get( 'LinkUI' ).formView; , https://git.drupalcode.org/project/editor_advanced_link/-/blob/2.x/js/ck... , which returns a null value.

Potential reference for refactoring: https://github.com/ckeditor/ckeditor5/issues/4836#issuecomment-1422740830

jmouse888’s picture

Confirmed Editor Advanced Link 2.1.1 is working with Drupal 9.5.7.

finex’s picture

Thank you very much!

wim leers’s picture

Title: Editor Advanced Link breaks Ckeditor5 after update to Drupal 10.1.x » CKEditor 5 ^36 compatibility — necessary for Drupal 10.1.x
Priority: Critical » Major
Related issues: +#3317769: Add support for linking to entities in CKEditor 5

I spent hours on this over at #3317769.

See #3317769-33: Add support for linking to entities in CKEditor 5 and https://git.drupalcode.org/project/drupal/-/merge_requests/2909/diffs?co... for the exact root cause + solution. That solution also removes one hack:

+++ b/js/ckeditor5_plugins/editorAdvancedLink/src/editoradvancedlinkui.js
@@ -0,0 +1,93 @@
+    // This is a hack. Thic could be potentially improved by detecting when the
+    // form is added by checking the collection of the ContextualBalloon plugin.
+    editor.plugins.get( 'ContextualBalloon' )._rotatorView.content.on( 'add', ( evt, view ) => {
rajab natshah’s picture

Facing the same issue with Drupal 10.1.0-alpha1

editor5.js?rtzgxi:472 TypeError: Cannot read properties of null (reading 'extendTemplate')
    at s._changeFormToVertical (editorAdvancedLink.js?v=10.1.0-alpha1:1:3968)
    at s.init (editorAdvancedLink.js?v=10.1.0-alpha1:1:3734)

Thanks for your time and hints and following up on this issue

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

bbombachini’s picture

Got this started but it needs work and I don't have a lot of experience with ckeditor 5.
It does not prevent wysiwyg from loading as it was happening before, but the extra fields are not being added. I get errors about a deprecation on the console linking to this https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#erro...

bbombachini’s picture

Status: Active » Needs work
Issue tags: +ckeditor5
anybody’s picture

We're facing the same issue with Drupal 10.1.0-beta1.
Having a look at the MR I have to admit I'm also very unsure how to solve this correctly for this case.

a.dmitriiev’s picture

StatusFileSize
new28.83 KB

I have tried the code from MR on Drupal 10.1.0-beta1 and it indeed fixed fatal error. Unfortunately for extra fields only "Open in new window" is displayed and not others.

a.dmitriiev’s picture

Status: Needs work » Needs review

I think that the issue is now fixed in the MR. I moved everything inside the event listener for set:visibleView and it started working properly. Please review.

a.dmitriiev’s picture

Also uploading patch of the current MR state

breidert’s picture

I tested the patch #16 and it works for the properties Title, CSS classes, Open in new window, and in combination with Linkit module.

uber_denis’s picture

In my case when I add the link button to CKEditor then the editor is not displayed.
After adding #16 everything seems to work as expected.

mgstables’s picture

After applying patch #16 the ckeditor5 still won't load. The Console shows the following error message:

TypeError: this.editor.plugins.get(...).formView is null
    _changeFormToVertical http://localhost:8080/modules/contrib/editor_advanced_link/js/build/editorAdvancedLink.js?v=10.1.0-beta1:1
    init http://localhost:8080/modules/contrib/editor_advanced_link/js/build/editorAdvancedLink.js?v=10.1.0-beta1:1
ckeditor5.js:472:19
    attach http://localhost:8080/core/modules/ckeditor5/js/ckeditor5.js?rvm49a:472

Drupal 10.1.0-beta1
Advanced Link 2.1.1
PHP 8.1.6

robcarr’s picture

The patch at #16 worked for me: D10.1-beta1; PHP 8.1.6; Adv link 2.1.1; Chrome 113.0.5672.126

Note: I cleared Drupal cache and the browser cache

mgstables’s picture

Yes, clearing the browser cache made it work. Thanks @robcarr.
Now patch #16 works for me too.

robcarr’s picture

Status: Needs review » Reviewed & tested by the community
dwisnousky’s picture

adding as physical patch to keep our codebase as safe as possible. Thank you for the fix, fam!

a.dmitriiev’s picture

How is patch from #23 different from patch in #16?

anybody’s picture

Pinged the maintainer. @Maintainer: Please note the RTBC was for Ptch #16

@a.dmitriiev or anyone else, would you like to update the MR with the patch contents from #16 to make it easier for the maintainer to merge?

zenimagine’s picture

Hi, impossible to apply the patch on drupal 10.1 would you have a solution? THANKS

  - Installing drupal/core (10.1.0): Extracting archive
  - Applying patches for drupal/core
    https://www.drupal.org/files/issues/2023-05-24/3350254-ckeditor-5-36-compatibility-16.patch (CKEditor 5 ^36 compatibility — necessary for Drupal 10.1.x)
   Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2023-05-24/3350254-ckeditor-5-36-compatibility-16.patch
zenimagine’s picture

Status: Reviewed & tested by the community » Needs work
zenimagine’s picture

Sorry, error on my part, because I applied the patch to the kernel. I have now correctly applied the patch to the module, but it does not work. I have errors in the console and ckeditor does not load.

        "patches": {
            "drupal/editor_advanced_link": {
                "CKEditor 5 ^36 compatibility — necessary for Drupal 10.1.x": "https://www.drupal.org/files/issues/2023-05-24/3350254-ckeditor-5-36-compatibility-16.patch"
            }
        },
anybody’s picture

Status: Needs work » Reviewed & tested by the community

Patch works, the mistake is on your side. You have to patch drupal/editor_advanced_link not core. Like in #28.

zenimagine’s picture

I have applied the patch to the module and cleaned the cacahe but I have this error in the console and ckeditor does not load:

TypeError: this.editor.plugins.get(...).formView is null
    _changeFormToVertical https://www.example.fr/modules/contrib/editor_advanced_link/js/build/editorAdvancedLink.js?v=10.1.0:1
    init https://www.example.fr/modules/contrib/editor_advanced_link/js/build/editorAdvancedLink.js?v=10.1.0:1
    promise callback*./packages/ckeditor5-core/src/index.ts/init/p/< https://www.example.fr/core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js?v=38.0.1:5
    p https://www.example.fr/core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js?v=38.0.1:5
    init https://www.example.fr/core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js?v=38.0.1:5
    initPlugins https://www.example.fr/core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js?v=38.0.1:5
catapipper’s picture

Patch works for me. Thanks for this, thought I was in real trouble when I tested the Drupal update today.

a.dmitriiev’s picture

@Anybody the patch in #16 was created from MR, so they should be in sync.

a.dmitriiev’s picture

@zenimagine it might be also the cache in the browser. Try to clear browser cache.

agoradesign’s picture

patch #16 works for me on 10.1.0

bkline’s picture

Confirming patch #16 works on D10.1.0 with linkit module.

zenimagine’s picture

Thanks, it works. I had cleared cache in drupal but not in browser

ant1’s picture

Status: Reviewed & tested by the community » Needs work

Not compatible with 2.1.2

  • a.dmitriiev authored 9e7b116c on 2.x
    Issue #3350254 by bbombachini, a.dmitriiev, dwisnousky, FiNeX,...
duaelfr’s picture

Status: Needs work » Fixed

Thank you all!
I reworked the patch on top of the 2.x branch and fixed the last issue.

jkamizato’s picture

Status: Fixed » Needs work

I've moved to "need to work" because MR and patches can't be applied.

jkamizato’s picture

StatusFileSize
new159.03 KB

Guys, I've created a new branch 3350254-ckeditor-5-36-2 and I've applied manually the patch #23. I'm uploading the new patch and I've updated the code.

(Update, I'll hide the patch because still not applicable )

jkamizato’s picture

a.dmitriiev’s picture

Status: Needs work » Fixed

jkamizato you can't apply the patch, because it is already merged to the module and the new version was released.

carolpettirossi’s picture

Status: Fixed » Closed (fixed)

Moving to Closed Fixed as it's been already merged and available in the release

agoradesign’s picture

fyi, "Fixed" status gets moved to "Closed (fixed)" automatically after 14(?) days :)