Problem/Motivation
This module does not work with Ckeditor 5. It depends on LinkIt which itself doesn't have a stable version for Ckeditor 5
Steps to reproduce
1. Install this module (should also install latest version of LinkIt)
2. Enable CKeditor 5
3. Enable LinkIt in Text Format Configuration for Ckeditor 5
4. Try creating a link via the edit page in a node
What was expected
The media library button that opens up the media library
Proposed resolution
Create branch that begins working on a solution for Ckeditor 5 using the dev version of LinkIt 6.0. Patch 113 currently supports Ckeditor 5
| Comment | File | Size | Author |
|---|---|---|---|
| #55 | Screenshot 2024-10-09 at 1.39.41 PM.png | 371.7 KB | bhogue |
| #45 | without-fix.png | 42.27 KB | shalini_jha |
| #45 | with-fix.png | 48.96 KB | shalini_jha |
| #24 | Screenshot from 2023-12-12 16-12-51.png | 26.01 KB | rodrigoaguilera |
Issue fork linkit_media_library-3329877
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
mfv commentedIs there any movement on this? This seems like a critical change. I see that there is a drupal 10 version. is that compatible with ckeditor 5?
Comment #3
jvogt commentedThe latest patch to make Linkit compatible with CKEditor 5 is testing well: https://www.drupal.org/project/linkit/issues/3232190. Can work on this issue be started against that patch?
My experience building CKEditor 5 modules is limited (assuming that's needed for this fix), but I'm happy to help collaborate and test. This functionality is critical to my sites as well.
Comment #4
dadderley commentedI have installed the newest version of Linkit 6.0.0-beta4 released 5 March 2023.
It seems to work well with CKEditor 5.
Unfortunately, Linkit Media Library does not work as yet.
Comment #5
bloomt commentedAny news? Would love to be able to use with ckeditor 5.
Comment #6
sclsweb commentedComment #7
sclsweb commentedComment #8
sclsweb commentedLinkit now has stable 6.0 and 6.1 releases supporting CKEditor 5, and there is a plan to bring some Linkit functionality to Drupal core.
I would love to see this module continue to work with Linkit and CKEditor 5. If someone can write the patch, I'll help test.
The ideal would be to switch to just core linking functionality (one day, when it becomes available) and stop using Linkit, but still be able to use this module. The sites I support don't typically use the full range of Linkit features, so it's likely that core will cover it -- the missing feature will be the Media Library button to allow uploads.
Comment #9
pyrello commentedGoing to take a look at this.
Comment #10
dadderley commentedIt would be really sweet if this worked.
Comment #11
pyrello commentedI think this should actually be targeting the dev version.
Comment #13
jvogt commentedThe patch in #12 applies to 1.0.3 but isn't working in Drupal 10.1.6 (php 8.2). It also appears to conflict with editor_advanced_link.
Scenario A: without editor_advanced_link installed:
The Media library button shows up, but clicking it does nothing. No javascript errors are thrown. FWIW, the console does log "_addMediaLibraryButton()" from line 28 of index.js.
The linkit matcher becomes non-functional. All of the javascript events are removed except blur, change, focus and input from ckeditor5-dll.js.
The rest are various additional issues when editor_advanced_link is installed and configured (no change if just installed and not configured).
Scenario B: only one advanced link attribute enabled (and it's not the Open in new window attribute): the same issues as Scenario A except this js error is thrown when clicking the Link button to bring up the link dialog: "Uncaught CKEditorError: collection-add-item-invalid-index" in ckeditor5-dll.js.
Scenario C: only the Open in new window attribute enabled: same issues as Scenario A except the Media library button does not show up.
Scenario D: multiple advanced attributes enabled, including Open in new window: Media library button doesn't show up. Matcher is non-functional like Scenario A. JS error thrown when expanding the "Advanced" accordion: "Uncaught CKEditorError: collection-add-item-already-exists" in ckeditor5-dll.js.
Scenario E: multiple advanced attributes enable, but not Open in new window: same as Scenario A except with a JS error thrown when expanding the "Advanced" accordion: "Uncaught CKEditorError: collection-add-item-invalid-index" in ckeditor5-dll.js.
Comment #14
pyrello commented@jvogt The MR is still in progress and not functional yet. It's my first CKEditor 5 plugin so I'm figuring it out as I go.
The errors you reported may be helpful later! Thanks.
Comment #15
jvogt commentedOh, that makes sense! Thanks for all your work on this!
Comment #16
bradley-b commented@pyrello Thanks for looking into this. Happy to do some testing as needed
Comment #17
pyrello commentedAfter a few days of having no idea what I was doing, it started to make sense to me today. Still hoping some CKEditor 5 expert will swoop in and finish it for me ;)
The main things that are left:
- Figure out how to put the button in the correct place.
- Figure out how to take the data from the dialog and insert it into the link field.
Comment #18
megan_m commentedThank you for working on this pyrello! My client is waiting for this. Unfortunately I don't know anything about writing ckeditor plugins either :)
Comment #19
laura.gatesI'm not sure if this needs to be it's own issue or not, but even with CKeditor 4, this module does not work with linkit 6.1.x. Linkit 6.1.x is what's needed for using Drupal Core 10.1.x+
Comment #20
pyrello commented@laura.gates, I think that should be its own bug report issue.
Comment #22
pyrello commentedI suspect that this still needs work. There are some issues where we worked around how Editor Advanced Link works that would be nice to find a better way to resolve in both modules. However, I think this is ready for some testing from anyone who is able to do so.
Comment #23
jvogt commentedLooking good! I'm seriously so excited to see this moving along.
First take: it works! Linking text to newly uploaded or existing media is now a reality. Woohoo!
Good stuff:
Notes:
Comment #24
rodrigoaguileraI tested this MR without having previous experience with the module.
The first thing I noticed is that it throws a js error on the console on any ckeditor5 textarea previous to configuring linkit for any text format:
CKEditorError: plugincollection-plugin-not-loaded {"plugin":"Linkit"}
Seems like it is always loaded when the link plugin of ckeaditor5 from the drupal core module is loaded.
The popup for the media library opens fine but when I click "insert selected" after selecting one existing media item the link is not updated.
Attached there is a screenshot of how the accept and cancel buttons are displaced by the media library button.
Drupal 10.1.7.
Linkit 6.1.2 and the latest version of the MR5 applied as a patch
Comment #25
rodrigoaguileraI just uploaded a little commit that fixes the first case by only loading the new plugin when the "linkit_extension" is loaded.
Comment #26
bhogue commentedUsing MR from #21, this solved the problem for us.
Comment #27
bradley-b commentedJust given the MR a try on our site and the editors are happy with the functionality. I did have to do a small amount of styling as the tick and cross button were escaping the container, could be specific to our site though. Shoutout to @pyrello for his work, much appreciated!
Comment #28
ejseguinte commentedThank you for all the work on getting this updated.
I had the same issue with the tick and cross not staying in the container. I found if you added the Editor Advance Link module that would move back into the container. I'm currently having an issue that when selecting the media item from the library nothing is getting linked.
Comment #29
dadderley commentedIs there a dev release of this module available?
Comment #30
alan ridgway commentedThis most recent update I have pushed removes the code that was fighting back against how editor advanced link was arranging buttons, as they seem to be fixing that with this patch here. I recommend using that patch for now while we wait for everything to get ironed out
Comment #31
nicross-com commentedMy team has been watching MR!5 and testing it as a patch. The changes made this morning in 6496453 no longer work for us because our Content Security Policy disallows unsafe
eval()statements. Is this intended?Comment #32
pyrello commented@nicross-com Looks like the build step was omitted so the plugin got built in non-production mode.
Comment #33
nicross-com commentedThanks for the swift fix! It's working great for us now. Cheers!
Comment #34
jmoreira commentedI had to do 2 tweaks to the current MR:
Comment #35
alan ridgway commented@jmoreira could you either add that to the MR or provide a diff for the changes? I'm sure it's small, but it's hard to see what changed.
Comment #36
jvogt commentedThe latest is working great for us! Thank you all for your hard work!
I still think the button styling could use some work to look like a button. I wrote this patch, but it depends on the Gin theme css variables so I don't know if it's appropriate to commit it to this project.
Comment #38
joewhitsittWe haven't had a chance to look into this yet, but we noticed when placing a link around a media item using the new media balloon toolbar, that it doesn't insert the media entity link properly with all of the necessary attributes.
data-entity-type, data-entity-uuid, data-entity-substitution
Comment #39
joewhitsittI found that this is not necessarily an issue with this patch for linkit_media_library, but that there is a upstream linkit issue here
https://www.drupal.org/project/linkit/issues/3396049
editor_advanced_link appears to be having the same issue: https://www.drupal.org/project/editor_advanced_link/issues/3349389
Comment #40
capysara commentedHiding the patch file since its changes were added to the MR.
Comment #41
matthodgson commentedI was able to cleanly apply the patch a few weeks ago but I am now running into issues "Could not apply patch! Skipping. The error was: The process "patch '-p1' --no-backup-if-mismatch -d 'web/modules/contrib/linkit_media_library' < '/var/folders/mn/4jv39pcj68j_d1ylyt_6pst40000gp/T/65dd0a4eafae8.patch'" exceeded the timeout of 300 seconds.". Has it been committed to the dev release?
Comment #42
cilefen commentedRegarding the 300 seconds issue: https://github.com/cweagans/composer-patches/issues/423#issuecomment-130...
Comment #43
joewhitsittThe z-index issues might be related to https://www.drupal.org/project/drupal/issues/3328425
Comment #45
shalini_jha commentedHI i have tested this MR 5 with drupal 9.5.11 and its working , one issues i found whenever click on media library button for link , media library dialog is not showing title of this dilog,i have fixed this issues.
Comment #46
jimmynash commentedTested MR5 against Core 9.5.11 with Linkit Media Library 1.0.3
Patch applied cleanly and the resulting functionality was as desired.
The button does show up in the Linkit dialog in CKEditor5 and works to insert the media link.
Seems to play nice with editor_advanced_link module as well.
Thanks!
Comment #47
sanderjp commentedLooks good, seems to work for me as well.
But should we add the full
yarn.lockfile of nearly 3k lines?Comment #48
sseto commentedWill this ever be released to 1.0.4 or should I use the MR? It's been 2 years since the last release.
Comment #50
andyf commentedI'm using this patch and found it stopped working for me after upgrading to 10.3 (even after using the patch from #3461637: linkit_media_library.opener.editor must be an instance of Drupal\media_library\MediaLibraryOpenerInterface). I was seeing the symptoms described in #3468979: Inserting selected isn't seen by Linkit field as not empty: after selecting an item from the library, I couldn't submit from the link modal (the button's disabled), and if I clicked on the URL in the textfield it would just use a normal link with an href of
/media/xxx(and no data attributes).It seems to be resolved by changing
to
which matches what linkit does afaict.
It would be great to get the tests running and passing on GitLab CI...
Comment #51
gfbarbosa commentedthanks andyf! same issue here and your update worked for me.
Comment #52
gfbarbosa commentedComment #53
4kant commentedThanks for comment #50.
That worked for me too (as mentioned, together with patch from
linkit_media_library.opener.editor must be an instance of Drupal\media_library\MediaLibraryOpenerInterface
)
Drupal 10.3.5 ;-)
Comment #54
glenshewchuck commentedWorked for me also (same as #53)
Drupal 10.3.1
Linkit 6.1.4
Comment #55
bhogue commentedThe combination of patches that others have mentioned does not work for me. I'm able to open the Media Library, but the linkit modal stays open and over the media library when I do so. I can still pick a media entity and click Insert, but no link is created. At most, the link field in the modal gets populated with something like /media/123456, but clicking the green check to apply it to the text that I had previously selected instead inserts a link that looks like /media/123456 and places it at the very beginning of the WYSIWYG.
Comment #56
dbgilbert commented#34 patch no longer works after I've updated Linkit to 6.1.5 (from 6.1.4). I get the following error on pages with a text editor using it:
Fatal error: Declaration of Drupal\media_link_enhancements\Plugin\Linkit\Matcher\MediaLinkEnhancementsMediaEntityMatcher::buildPath(Drupal\Core\Entity\EntityInterface $entity) must be compatible with Drupal\linkit\Plugin\Linkit\Matcher\EntityMatcher::buildPath(Drupal\Core\Entity\EntityInterface $entity, array $options = []) in /var/www/html/docroot/modules/contrib/media_link_enhancements/src/Plugin/Linkit/Matcher/MediaLinkEnhancementsMediaEntityMatcher.php on line 29I also get this error when trying to configure a linkit profile's matchers .../admin/config/content/linkit/manage/seic_linkit_profile/matchers
Comment #60
j. ayen green commentedDoes anyone know where we are on this?
I have Ckeditor5, D10.3.10, Linkit 6.1.4 (tried 7 as well) installed with the Linkit Media Library.
#50 doesn't seem to apply anymore as the line in question has been fixed in the CKEditor plugin, albeit with 'item.path' instead of 'attributes.href'.
I still see no difference when clicking the link button in CKEditor5. It's simply an autocomplete. No media library button.
Comment #61
jonraedeke commentedUsing the change in this MR and one additional patch mentioned in https://www.drupal.org/project/linkit_media_library/issues/3329877#comme... works really well for me.
Setup
Drupal 10.3.10
Linkit 6.1.6
Linkit Media 1.0.3
Patches
RTBC
Comment #63
smustgrave commentedThis doesn't appear to be working on linkit 7.0.x
Comment #65
smustgrave commentedHad to tweak a few things but think this is a good spot to least do a quick deploy for D11 + ck5
Comment #67
alphex commentedAny chance we can get a stable release for this?