Problem/Motivation
Drupal core has switched from CKEditor 4 to CKEditor 5 — see #3270438: Remove CKEditor 4 from core and https://www.drupal.org/node/3308802.
In CKEditor 5, the linking experience no longer uses EditorLinkDialog (related: #3231341: Deprecate EditorLinkDialog, EditorImageDialog and EditorMediaDialog in Drupal 10.1 for removal in Drupal 11), to ensure a smoother linking UX. This means that the editor_advanced_link module no longer can use form alterations to make additional link attributes editable.
Remaining tasks
- ✅
Assess the changes in the base features of CKEditor 5 to see what would need to be changed to maintain backward compatibility - ✅
Understand the new structure of CKEditor 5 plugins and how to alter them if possible - ✅
Working CKEditor 5 plugin - ✅
Upgrade path - ✅
Upgrade path test coverage Probably open a new major version to hold the changesAdd to the current major version OR create a new major version that supports both CKE 4 and 5; it's important to support both CKEditor 4 and 5 simultaneously, to allow for an easy transition where both tect editors are supported simultaneously. CKEditor 4 support should be dropped in a new major version.
| Comment | File | Size | Author |
|---|---|---|---|
| #50 | 3232052-50.patch | 173.65 KB | wim leers |
| #48 | 3232052-48.patch | 172.89 KB | wim leers |
| #46 | 3232052-46.patch | 172.63 KB | wim leers |
| #40 | 3232052-40.patch | 172.32 KB | wim leers |
| #37 | 3232052-37.patch | 171.84 KB | wim leers |
Issue fork editor_advanced_link-3232052
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
wim leersmanual. But it's probably better to wait forWe'll get more information about this in ~2 weeks.
Comment #3
wim leersComment #5
wim leershas now been implemented:

So that's #2.1 taken care of.
More news about #2.2 tomorrow, hopefully 😊🤞
Comment #6
wim leersLatest news: #3231364-57: Add CKEditor 5 module to Drupal core.
Comment #7
lauriiiI've been doing some experimentation on this with Oleq from CKSource. We have a PoC that allows adding new form elements to the existing link bubble. Here's how it looks:

The solution works surprisingly well, but requires tinkering with some internal CKEditor properties. I'm assigning this to myself to take the PoC to a MR on this issue.
Comment #8
wim leers🥳
Comment #10
wim leers@lauriii: Thanks for pushing a working MR! 🥳 Just one more request: can you record a short screencast to show how it works in CKEditor 5, both for this issue and the core issue? 🙏
I'll add the automatic upgrade path if you like, unless you want to do that too?
Comment #11
wim leersTo test the automatic upgrade path, I modified
basic_htmlto have this allowed HTML:(Note the addition of
relto<a>.)Did that in
1eb593bbac9b7dffb2e3512ebd69d49a7053b2de.Comment #12
wim leersWhile working on this, found #3244911: Automatic upgrade path failing when CKEditor 4 has the StylesCombo plugin configured.
Comment #13
wim leersA problem with the current merge request is that it's all or nothing. (Well, for all attributes that are currently supported:
title class aria-label.)That means it currently always looks like this:
But in Drupal 8|9 with CKEditor 4, Editor Advanced Link module just respects the configured HTML restrictions: it only shows "class" if
<a class>is allowed. So we should match that! 💪 Right now that works byeditor_advanced_link_form_editor_link_dialog_alter()inspecting the HTML restrictions of the text format. That works great. But now we're shifting to a model where this form is rendered client-side, so we can't actually do those checks easily. So we need a different strategy: we need to have the server pass on configuration to the client. IOW: theeditorAdvancedLink.EditorAdvancedLinkplugin needs to accept configuration.We could automatically generate that configuration using
\Drupal\ckeditor5\Plugin\CKEditor5PluginInterface::getDynamicPluginConfig(), but there's another (related!) catch. See next comment.Comment #14
wim leersThe other catch is that in Drupal + CKEditor 5, we're switching things around: rather than requiring the user to manually modify the 's setting (which is very brittle, and requires a certain level of expertise that we should not require), and requiring the user to keep that manually in sync with the CKEditor 5 toolbar/plugin configuration, we're generating that setting automatically.
That also means that the old "configuration" model of the Editor Advanced Link module does not work anymore. It currently instructs users like so:
It's that last step that won't work: the user cannot do that.
The solution is simple:
<a>Step 1 is introducing that configuration UI. I just pushed that. It looks like this:
Comment #15
wim leersStep 2: upgrade path. Just pushed that:
a81afaa0277790cec14eea4711b99a577c85f6b6.Wanna see it in action? Yes, I would too:
Comment #16
wim leersThe only things that remain at this point are:
But the key things have been proven:
So marking only for the latter.
Comment #17
daniel.haggman commentedWhich of the points listed in #16 would be considered needed for this to be mergable into the dev-branch? Are there ideas on how to work on the remaining items?
Comment #18
kristen polBot patch (just info file): #3287149: Automated Drupal 10 compatibility fixes
Comment #19
catapipperI'm very excited for this to be merged. Thank you everyone for your hard work on this. I am running into a small issue with running the MR/patch found here. When I try to edit any of the Text Filters I'm getting:
LogicException: The "ckeditor5_link" CKEditor 5 plugin implements ::getElementsSubset() and did not return a subset, the following tags are absent from the plugin definition: "<a href>". in Drupal\ckeditor5\Plugin\CKEditor5PluginManager->getProvidedElements() (line 336 of /var/www/html/web/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php).I'm not sure if I missed a patch I needed or if CKEditor5 has updated since this MR was created. If someone could advise me on how to proceed, I would be most appreciated.
Comment #20
wim leersConfirmed on Drupal 9.4.5. This is because CKEditor 5 in Drupal core has evolved and improved while it was experimental in the past year 🤓
Note that this merge request was last updated on October 27, 2021, almost a year ago!
Did some digging. This is caused a bug in the
filtermodule that was fixed in #3278636: HTMLRestrictions::fromString() bug: multiple occurrences of same tag results in only last one being respected. ⚠️ That's why you need to update to at least Drupal 9.4.6, to get the required bugfix.But after that's fixed, we must also update
\Drupal\editor_advanced_link\Plugin\CKEditor5Plugin\EditorAdvancedLink::getElementsSubset()because of #3273983: Do not assume that plugin supporting <tag attr> also supports <tag> in SourceEditingRedundantTags and upgrade path.Pushed fix.
But then there's still the need to update the built JS plugin. I know that that's been improved drastically since October last year, but I am not the person most proficient at that. I'll ask @bnjmnm or @lauriii to update that part of the MR!
Comment #22
bnjmnmI just pushed an updated JS build of the plugin and updated build scripts to the current approach.
The editor will not load
link.Linkdue to what I believe is something ineditor_advanced_link_ckeditor5_plugin_info_alterI temporarily set the plugin up as its own plugin instead of extending
ckeditor5_linkto confirm the built plugin worked, and it worked fine, so with confirmation that the JS itself is good, either theckeditor5_plugin_info_altercan be changed or the approach can be adjusted to load this as an additional plugin that is only enabled iflink.Linkalso is.Comment #23
wim leersThanks, @bnjmnm! But even with that, I get:
😢
Comment #24
wim leersI posted #23 while #22 was being written! 🙈
+1 to that, that's a new capability that didn't exist a year ago! Declarative code FTW.
Implemented your proposal!
Just one bug left?
Looks like we still need to make sure that the JS respects the attributes that actually have been enabled; right now it always shows all of them. 🐛
Comment #25
wim leers#3287149: Automated Drupal 10 compatibility fixes just landed, rebasing…
Comment #26
wim leersfor
Comment #27
wim leersI'll tackle upgrade path tests.
Comment #28
wim leersThe upgrade path completeness test passes just fine. But the upgrade path test itself is uncovering a whole range of problems 😬 Have been investigating, and will have to continue for a while…
Comment #29
wim leersWriting complete upgrade path tests is pretty much impossible until #3314770: Enforce order of CKEditor 5 plugin settings in config export (as well as other sequences) is solved.
Comment #30
wim leers330a29fb gets us down from 17 failures to 3. For those 3 to pass tests, we need #3314770: Enforce order of CKEditor 5 plugin settings in config export (as well as other sequences).
Comment #31
wim leersThis now has complete upgrade path test coverage and complete functional JS test coverage.
target="_blank"looks like this:And all others look like this:

Both of those are a net improvement compared to the CKEditor 4 experience, because they do not require waiting for a modal dialog to be served from Drupal like was the case for CKEditor 4:

Right now, this is only waiting for #3314770: Enforce order of CKEditor 5 plugin settings in config export (as well as other sequences) to land, to allow predictable config export order, which in turn enables maintainable upgrade path tests. Other than that, this is ready for final review.
Comment #32
wim leers#3314770: Enforce order of CKEditor 5 plugin settings in config export (as well as other sequences) is in! Pushing a commit to trigger a new test…
Comment #33
wim leersD'oh, this is getting tested against
9.4, which doesn't have that fix yet.So uploading MR as a patch so I can choose to test this against other core versions.
Comment #34
duaelfrThe MR branch needed to be rebased.
Here is a new patch so we can trigger the testbot as needed :)
Comment #36
wim leersCKEditor4to5UpgradeCompletenessTestdoes not exist in D10. That just requires some PHP shenanigans to make it work on all versions.Comment #37
wim leersDone.
On
10.0.x:On
9.5.x:Comment #39
wim leersOn 10:
… but that's in
Drupal\Tests\editor_advanced_link\Functional\AdvancedLinkDialogTest, for CKEditor 4 — not for CKEditor 5. So it's out of scope for this issue.Still, if you want to fix that, @DuaelFr, it's really simple:
Comment #40
wim leersComment #42
wim leersUndefined array key "ckeditor"now … because the CKE4 test is relying on the Standard install profile, which has changed …Comment #43
duaelfrWouldn't it be easier and safer to drop D9 and CKE4 support on this branch? I wonder how much more energy it would need to have green tests on both versions. We could just push D10 with ckeditor 4 contrib module support on 1.x and keep only D10 with CKE5 on 2.x. What do you think about it?
Comment #44
wim leers@DuaelFr I already explained this in the issue summary:
Supporting CKEditor 4 on Drupal 10 is basically zero effort. I can make the test pass there too for you if that will be the decisive fact.
Comment #45
wim leersComment #46
wim leersComment #48
wim leersComment #50
wim leersArgh — #48 does not pass because
@requires module FOOonly works for kernel tests…Note that https://git.drupalcode.org/project/editor_advanced_link/-/merge_requests... will actually ensure that after this gets committed, the CKE4 test module will get installed. DrupalCI just refuses to respect dependency-related changes in a patch/MR…
Comment #52
wim leersThis is really ready … it's only not passing on 9.4 currently because #3314770: Enforce order of CKEditor 5 plugin settings in config export (as well as other sequences) has not been cherry-picked yet. But that only affects the upgrade path test, not the upgrade path itself, nor any of the functionality provided by this module!
This is still ready to go, and has been for a week now 👍
Comment #54
duaelfrThank you all for your great work on this issue! 👏
Sorry for the delay I've been in vacation for 10 days :)
I'll tag a new release now.
Comment #55
smustgrave commentedFYI the 2.1.0 release from today doesn't appear to have any of the changes here.
Comment #56
duaelfrThis is what happens when you try to do a lot of things at the same time...
I published 2.1.1, thanks!
Comment #57
zenimagine commented@DuaelFr Hello, I just updated to 2.1.1 and this module broke my whole website:
The website encountered an unexpected error. Please try again later.Comment #58
zenimagine commentedComment #59
zenimagine commentedComment #60
duaelfrI don't know what happened but I'm glad you seem to have found a solution.
Comment #61
wim leers🥳