Problem/Motivation
Attemping to install 3.0.0-alpha1 with Composer on a Drupal 10.1 site.
Steps to reproduce
- composer require wikimedia/composer-merge-plugin
- edited composer.json to include merge-plugin section
- composer require 'drupal/anchor_link:^3.0@alpha'
- enabled module
- added anchor button to the CKeditor5 profile
CKeditor5 fails to load when editing a page after adding the anchor button.
Removing the anchor button from the profile allows CKEditor 5 to load again.
I do not have any plugin libraries in my libraries folder.
Am I missing any steps to enable the plugin? I was expecting to simply add the module, enable it, add it to the profile, and then use it.
Comments
Comment #2
dylan donkersgoed commentedTry running
composer require 'drupal/anchor_link:^3.0@alpha'again? I've noticed that it does not always seem to pull in the library on the first go. I think it's because the composer.libraries.json doesn't exist until after the module is updated. If you don't have the library under [YOUR WEB ROOT]/libraries/ckeditor5-anchor-drupal the module will not work.Comment #3
mlecha commentedI tried issuing
composer require 'drupal/anchor_link:^3.0@alpha'again but no luck.I uploaded the library manually to libraries/ckeditor5-anchor-drupal and included the contents of the archive from below the 'package' folder. That works. And the module works as expected. Thank you!
I'll follow along on the development of the module. The install will be a bit tricky for some. For such simple (but much appreciated) functionality, I think that our non-devs will find this install a challenge.
Comment #4
mlecha commentedComment #5
hummeldon commentedI am testing this in our environment as well. I couldn't get the library pulled in through composer and had to resort to manually adding it as mlecha mentioned.Apologies, I just noticed the documentation.
Comment #6
vadym.tseiko commentedHaving issue on D10.1.6 updated from D9.5.11 when change ckeditor to ckeditor5. When adding anchor link button in text and formats, any of the editor fields with the format where this plugin used, had js error that plugin does not exists and breaks the toolbar of the editor.
Comment #7
mkimmet commentedI am having a similar problem where the library doesn't show up until I run the composer install twice. Same with deleting the library, I have to run composer remove twice before it will get deleted. Not sure why.
Comment #8
generalredneckThe way we are getting around this is not to use the wikimedia/composer-merge-plugin package. This is a known limitation if the merge plugin is being installed for the very first time and/or a package is asking to merge in a composer.json that is downloaded WITH the package. See https://github.com/wikimedia/composer-merge-plugin/issues/165 and https://github.com/wikimedia/composer-merge-plugin/issues/170
If you want to ensure it works consistently, you will need to add the repositories section to your project's composer.json by copying it from composer.libraries.json and then running
composer require northernco/ckeditor5-anchor-drupalAnother alternative could be using asset-packagist.org and pulling in npm-asset/northernco--ckeditor5-anchor-drupal, so that you can always get the latest version as it updates.
Comment #9
dianacastillo commentedI had this same problem until I found the library mentioned in #3 here https://registry.npmjs.org/@northernco/ckeditor5-anchor-drupal/-/ckedito... and put it into my libraries folder and that worked
Comment #10
dianacastillo commentedComment #11
mkimmet commentedWe don't have the libraries folder committed to source control, so I don't think the suggestion in #9 would work for us, however, the solution in comment #8 worked.
Should the description on the anchor_link module page be changed to have the instructions from comment #8?
Just to give additional details to what is recommended in comment #8, instead of using wikimedia/composer-merge-plugin, I added the following (at the time of this post) to the composer.json "repositories" section:
That is what was in the /modules/contrib/anchor_link/composer.libraries.json at the time of this post, but will change over time and would need to get changed on the module home page each time things changed with northernco/ckeditor5-anchor-drupal.
Then as mentioned in comment # 8, I ran: composer require northernco/ckeditor5-anchor-drupal
Comment #12
kurt.j commented#9 worked for me, thanks!
Comment #13
javitan commented#11 worked for me! Thanks mkimmet!
Comment #14
joegraduateWhen I try installing the needed library using Asset Packagist (which is generally my preferred way to install JS library dependencies for modules), composer installs the library to
/libraries/northernco--ckeditor5-anchor-drupalwhich does not match the path referenced inanchor_link.libraries.yml.It would be nice if a
hook_library_info_alter()implementation that changes the path of the library based on a configuration setting could be added to the module to accomodate the different ways that site owners might install the library.Comment #15
thomaswalther commented#11 worked for me, thanks @mkimmet:
Comment #16
vija commented#11 doesn't work for me. I tried reinstalling anchor_link module, clearing cache etc.
I have an error in console: Uncaught CKEditorError: ckeditor-duplicated-modules Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/erro...
The error dissapears when I'm not using anchor_link
Comment #17
bonrita commentedSame here #11 doesn't work anymore using 3.0.0-alpha2 Not using the anchor link fixes the issue. Though I need it for my project.
Comment #18
lmoeni#11 worked for me with 3.0.0-alpha2 and Drupal 10.2.5.
I'm not seeing the error that #16 mentions.
Comment #19
Bzr commentedHey all,
Just wanted to pop this in here in case it helps anyone in the future. I was having this same issue, and the manually addition of the library didn't help. I just managed to resolve this issue by re-adding ckeditor 4.
I'd removed ckeditor 4 without any issue. I changed the text editors on my site to ckeditor 5, uninstalled, and removed version 4. That's when the formatting break happened, as is probably the same for you all. I re-required version 4, installed it, made it the default text editor again, then started the whole uninstall process over again. Honestly, it did seem like the act of re-adding version 4 to the site alone solved the issue, but I figured it'd be safer to go through the whole thing over again.
Obviously, this isn't super related to the anchor links module, but this was where I was looking when I figured this out. Hope someone out there can use this info.
Comment #20
jcrump@tulane.edu commentedI'm unable to get 3.0 alpha or dev to work in Drupal 10.2.7 with "northernco/ckeditor5-anchor-drupal": "^0.5.0" library installed.
Adding Anchor Link icon to toolbar makes it disappear.
Comment #21
rajab natshahInstallation
OPTION #1
The wikimedia/composer-merge-plugin method
1. Require the composer merge plugin
2. Expand the extra section of your
composer.jsonlike so you may need to adjust the"include"directory, e.g. your web files may start withdocrootinstead ofwebin which case it would start withdocroot/modules:3. Require Anchor Link module, which will bring its libraries
In some cases, you may need to run the above command twice so that the merge plugin picks up the library after the library information from the module is added.
4. Enable the Anchor Link module with Drush
OPTION #2:
The Asset Packagist method.
Downloading third-party libraries using Composer
Define npm-asset repository in the
composer.jsonfile, to allow downloading the CKEditor Anchor Link JavaScript library to the correct folder:1. Configure with composer commands by following steps.
2. Require the composer installer extender
3. Require the CKEditor5 Anchor Drupal library
Check that you have the library in the libraries folder.
4. Require Anchor Link module
5. Enable the Anchor Link module with Drush
Comment #22
rajab natshahComment #23
jsimonis commentedI used Option #1. Even ran the command twice. No library was added. I manually added it. Cleared my cache and everything. Still breaks ckeditor. I used the link from #9 and I'm using the 3.0.0-beta1 version of the module.
Comment #24
shani maurya#11 worked for me! Thanks mkimmet!
Comment #25
rajab natshahJenni @jsimonis , For Option #2 - Watch the video for How to install and configure the CKEditor Anchor Link module in Drupal 10/11
OPTION #2:
The Asset Packagist method.
Downloading third-party libraries using Composer
Define npm-asset repository in the
composer.jsonfile, to allow downloading the CKEditor Anchor Link JavaScript library to the correct folder:1. Configure with composer commands by following steps.
2. Require the composer installer extender
3. Require the CKEditor5 Anchor Drupal library
Check that you have the library in the libraries folder.
4. Require Anchor Link module
5. Enable the Anchor Link module with Drush
Comment #26
masipila commented@Rajab Natshah Would it make sense to swap the installation options 1 and 2 on the module front page?
I just run into this same issue. I had followed the option 1 very carefully, run the commands twice as instructed but still the javascript library was not downloaded.
Then I found this thread, read the comments and learnt the background for the 2nd installation option is the discussion above. I then tried the 2nd option which worked perfectly.
So as a suggestion: Resolve this issue by removing the option 1 from the installation instructions altogether or at least swap the order of the options so that the more reliable approach is mentioned 1st.
Side note for fellow site builders:
The comment #9 by @dianacastillo suggests to manully download the javascript library from npmjs.com to the libraries directory. If you follow this method, your library will get outdated sooner than later. The comment #9 is only 6 months old but already now contains an outdated version 0.4.0. At the moment the most recent version is 0.5.0.
Cheers,
Markus
Comment #27
masipila commentedComment #28
penyaskitoHad a similar issue, my solution was:
1. Adding npm-assets to repositories (I already had it in my project):
2. Require
3. Change location via installer-paths
Remarkable: This needs to come before
or similar.
Comment #29
alphex commentedJust confirming that the steps in #28 worked for me.
Comment #30
webdrips commentedIt should be noted that use of the wikimedia/composer-merge-plugin is deprecated within Drupal: https://www.drupal.org/node/3069730
Also, because it runs composer update, it will not work on Pantheon.
I believe any instructions involving the Composer Merge Plugin should be removed.
Comment #31
ccarnnia commented++ #28
this worked for me:
Comment #32
jcrump@tulane.edu commentedNumber 11 worked for me.
With 125+ sites cloud hosted, running composer twice wasn't an option.
Comment #33
goz commentedSame issue for me.
#1 Option does not download library.
#2 Option load library but name folder is
northernco--ckeditor5-anchor-drupal.Adding in installer-paths the mapping solve the issue as explained in #31.
Warning, it has to be added before
web/libraries/{$name}Remove first the library before changes, then require it again.
Comment #34
brianbrarian commented#11 also worked for me.
Comment #35
jnicola commented#11 did not work for me. Specifically because there are other values in my repositories array already, so one without a key didn't fly. Adding different keys like "ckeditor5-anchor-drupal" or "northernco/ckeditor5-anchor-drupal" or "northernco" when run with `composer require northernco/ckeditor5-anchor-drupal` resulted in:
Could not find a matching version of package northernco/ckeditor5-anchor-drupal. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (dev).
Can confirm though that the given install directions for step 1 is busted.
Comment #36
stewestMight be helpful, depending on the version you're using:
I believe we're now meant to be using vardot/ckeditor5-anchor-drupal:~2.0
see https://www.drupal.org/project/anchor_link
This plugin uses an external CKEditor5 library: Anchor Link CKEditor plugin - It is required in the module. No need to require it anymore.
Comment #37
fengtanI also ran into this when upgrading the module to 3.0.3.
Adding the module's dependency (listed in composer.libraries.json) as a direct dependency in my project's root
composer.json/composer.lockfiles seems to fix it:Comment #38
handkerchiefSame as #37, thank you @fengtan.
Comment #39
rajab natshah