Problem/Motivation

With an increasing usage of Drupal 8/9 composer installation, configuration, and updates, composer support for CKEditor 4 plugins have been mediocre at best. With the deprecation of #2912387: Stop using wikimedia/composer-merge-plugin, we need a composer installation solution that eases the library burden for new installations.

CKEditor 4.x is epected to be replaced by CKEditor 5.x in Drupal 10: #2966864: Add optional support for CKEditor 5 in D9 so we can remove CKE 4 from Drupal 10

Proposed resolution

Based on the work in #3104018: Support library auto install via composer in asset dir, we would like to request the Drupl CKEditor contrib module community collaborate and centralize composer repos under an auto-install method, rather than requiring additional root directory composer.json configurations or modules such as drupal_libraries.

We have begun a drupal-ckeditor-libraries-group packagist repo to house these packages, and would like to have other CKEditor module contrib join this collection and make composer installs as easy as possible.

Big kudos to @voleger for the original request and partnerships to get the initial work done on this.

Remaining tasks

1. Confirm whether this would be appropriate for composer installs of this module.
2. Create a module owned Github repo to house a local copy of the required ckeditor plugin.
3. Create a packagist account.
4. Contact either @voleger and @Webbeh on adding a GitHub repo to the packagist account, and setting your local Github and packagist account to the repo.
5. After the repo is in place, create a patch (a la 3104018-31.patch) to update composer.json to point to the new repo.
6. Success!

User interface changes

TBD.

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

Webbeh created an issue. See original summary.

Webbeh’s picture

Status: Active » Needs work
Related issues: +#3219009: 'youtube' plugin support

We're kickstarting this process with #3219009: 'youtube' plugin support.

Webbeh’s picture

Assigned: Unassigned » Webbeh

And this plugin now shows on Packagist: https://packagist.org/packages/drupal-ckeditor-libraries-group/youtube

This needs a patch for an updated composer.json. I can do that.

Webbeh’s picture

Assigned: Webbeh » Unassigned
Status: Needs work » Needs review
gnuget’s picture

2. Create a module owned Github repo to house a local copy of the required ckeditor plugin.

Does this mean that now we will need to keep updated our own version of the CKEditor plugin and whenever a new release is done I will need update my fork?

I was thinking in doing something similar to what Webform is doing for this: https://git.drupalcode.org/project/webform/-/blob/6.x/composer.libraries...

I wonder if I can support both methods or if one has more advantages than the other.

Webbeh’s picture

Does this mean that now we will need to keep updated our own version of the CKEditor plugin and whenever a new release is done I will need update my fork?

Nope and nope (unless you want to specify an explicit tag or release in the module composer.json to maximize control). We should probably rewrite that for module owners, because a lot of that is our duty from the library maintainers.

Our actions_runner ( https://github.com/drupal-ckeditor-libraries-group/actions_runner/blob/m... ) rewrites the git history and injects a composer.json that is compatible with Drupal (see `type`: https://github.com/drupal-ckeditor-libraries-group/youtube/blob/master/c... ). The runner runs on a pre-established cron so it should periodically grab and rewrite the commit/tags for the original source youtube plugin ( https://github.com/fonini/ckeditor-youtube-plugin ) to inject the Drupal goodness into our clone ( https://github.com/drupal-ckeditor-libraries-group/youtube ).

Packagist is then ingesting `drupal-ckeditor-libraries-group/youtube` and delivering it for Drupal modules.

The problem we saw with the Webform approach was the same as similar approaches of defining libraries in the root `composer.json`, which was that version bumps required non-automated code updates to point to the new release, including locating the URL of the new zip. This should automate that process and manage it more effectively within composer, as we're cloning directly from the git repo.

If you're curious about the technical process on how we deploy the cloned repo, see https://github.com/drupal-ckeditor-libraries-group/actions_runner/issues/16 .

mkolar’s picture

Hi! looks like I can just require drupal-ckeditor-libraries-group/youtube and keep using drupal/ckeditor_youtube (without usage of forked module) + i had to configure youtube folder since its libraries/youtube/youtube.. in order to make library being downloaded via composer.

if you tell me how to review it properly i can do that and we can mark as reviewed. of this is enough?

chrisck’s picture

@Webbeh thank you for taking the initiative for putting ckeditor youtube plugin in the drupal-ckeditor-libraries-group on packagist. I've tried deploying your MR #4 in a patch form to test and composer is not downloading the drupal-ckeditor-libraries-group/youtube package. Am I missing something? What other steps need to happen to move this forward?

@mkolar your method of requiring drupal-ckeditor-libraries-group/youtube may work, but then you lose the dependency and automatic download and removal of the plugin from ckeditor_youtube module.

Webbeh’s picture

I've tried deploying your MR #4 in a patch form to test and composer is not downloading the drupal-ckeditor-libraries-group/youtube package.

I believe this is because composer isn't directly interfacing with the package; e.g. it's not reading `composer.json` after the patch is applied? This would be automatically applied with a new release once this MR is confirmed.

chrisck’s picture

Status: Needs review » Reviewed & tested by the community

@gnuget Can we get MR #4 in to get YouTube plugin downloaded via composer?

cobenash’s picture

Hope this MR could be merged. +1

Thanks.

dinarcon’s picture

Status: Reviewed & tested by the community » Needs work

Looks good. Can we update the README file to clarify that you can install manually or via Composer? If I recall correctly, when installed via Composer the CKEditor plugin ends up in a different location. The Reference folder structure section can be updated to match what Composer does.

It looks like we should also update the value library_path in config/install/ckeditor_youtube.settings.yml and the default path reference in Drupal\ckeditor_youtube\Form\YouTubePluginForm::buildForm.

Can we test what happens when a site that used the manual installation method, installs/updates the module via Composer with the new dependency on drupal-ckeditor-libraries-group/youtube?

chrisck’s picture

Status: Needs work » Needs review

@dinarcon The MR submitted addresses your comments in #13:

  1. Updated the README to include both instructions for auto-install and manual install
  2. Updated the library_path in config/install/ckeditor_youtube.settings.yml
  3. Updated the default path reference in Drupal\ckeditor_youtube\Form\YouTubePluginForm::buildForm
  4. Wrote an update hook for the new plugin path at /libraries/youtube/youtube

I've completed a manual test where sites that have installed the Youtube plugin manually at libraries/youtube and then update ckeditor_youtube with the patch containing the drupal-ckeditor-libraries-group/youtube dependency, the plugin gets auto-installed at libraries/youtube/youtube and the library_path is subsequently updated to the new path after the update hook.

Can you please review the changes?

  • dinarcon committed 89aac1d7 on 8.x-1.x authored by Webbeh
    Issue #3219372 by chrisck, Webbeh, dinarcon, gnuget: drupal-ckeditor-...
dinarcon’s picture

Thanks @chrisck for addressing my comments. I have manually tested the changes. I pushed a commit to account for the (unlikely) event that the module is updated, but it was never installed via Composer.

Thanks everyone for pushing for this improvement.

dinarcon’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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