Problem/Motivation

Postponed on #3271057: Move Media Library CKEditor 4 integrations from Media into CKEditor.

The Media module integrates with both CKEditor 4 and CKEditor 5. CKEditor 4 will be deprecated and removed from core in Drupal 10, so Media's integrations should be owned by the CKEditor module instead of the Media module.

Proposed resolution

  • Move Media CKEditor integrations into the CKEditor namespace, including:
  • Updating references in core/modules/media/tests/modules/media_test_embed/media_test_embed.module, core/modules/media/tests/src/Kernel/MediaEmbedFilterTest.php, and core/modules/media/media.module to refer to text editors generally, not CKEditor specifically.
  • core/modules/media/css/plugins/drupalmedia/ckeditor.drupalmedia.css
  • core/modules/media/js/plugins/drupalmedia/plugin.es6.js
  • core/modules/media/js/plugins/drupalmedia/plugin.js
  • core/modules/media/src/Plugin/CKEditorPlugin/DrupalMedia.php
  • core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
  • Move media_embed_ckeditor_theme asset library to CKEditor.
  • Update references to plugin CSS in core/.stylelintrc.json for new paths.

Relevant commits: f17478 and 1150087da (these only remove references, rather than moving them to new namespaces).

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

To prepare for the removal of the CKEditor 4 module from core, CKEditor's Media integrations have been moved out of the Media module, into the CKEditor module. This changes the locations of several asset libraries, so modules that integrate with CKEditor and Media may need to update their library definitions.

CommentFileSizeAuthor
#26 3271094-26-10x.patch15.61 KBlauriii

Issue fork drupal-3271094

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xjm created an issue. See original summary.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Wim Leers’s picture

Title: [P-1] Move Media CKEditor 4 integration into CKEditor » Move Media CKEditor 4 integration into CKEditor
Assigned: Unassigned » Wim Leers

Quoting Drupal\media\Plugin\CKEditorPlugin\DrupalMedia:

 * @internal
 *   This is an internal part of the media system in Drupal core and may be
 *   subject to change in minor releases. This class should not be
 *   instantiated or extended by external code.

👍

Also, AFAICT this actually is not blocked on #3271057: Move Media Library CKEditor 4 integrations from Media into CKEditor. Let's see if I'm right 🤓

Wim Leers credited lauriii.

Wim Leers’s picture

Issue summary: View changes
Status: Postponed » Needs work
Issue tags: +Needs release note, +Needs change record

Next step: the media/media_embed_ckeditor_theme asset library.

@lauriii provided guidance on how to approach that:

  1. Deprecate media/media_embed_ckeditor_theme and classy/media_embed_ckeditor_theme libraries
  2. Move classy/media_embed_ckeditor_theme to ckeditor and load instead of media/media_embed_ckeditor_theme
  3. Needs a release note and change record
  4. Move classy/css/components/media-embed-error.css to ckeditor and load by default with media integration
  5. Remove mentions of the library and CSS from all other core themes
Wim Leers’s picture

The commits that d.o/GitLab are displaying between #5 and #6 actually all happened after #6. This is very confusing 😬

Pinged the Drupal Association about this: https://drupal.slack.com/archives/CGKLP028K/p1655226648791499 — apparently #1374090: Editing a comment still changes creation date is related.

Wim Leers’s picture

  1x: Theme "media" is extending a deprecated library. The media/media_embed_ckeditor_theme asset library is deprecated in Drupal 9.5.0 and will be removed in Drupal 10.0.0.

This deprecation error is causing a number of test failures.

Clearly the deprecation message is wrong. I debugged it, and it's actually the classy theme that is causing this. 🙃

Looks like that is caused by the 5th step not having been done yet. So … trying that now!

Wim Leers’s picture

Assigned: Wim Leers » lauriii
Status: Needs work » Needs review

Now I definitely need guidance from @lauriii 🤓

lauriii’s picture

Assigned: lauriii » Unassigned
Status: Needs review » Needs work

I added few comment to the MR. On top of that, we need to add some overrides to rupal\KernelTests\Core\Theme\ConfirmClassyCopiesTest get rid of the failures caused by the deprecated library.

Wim Leers’s picture

Status: Needs work » Needs review
Wim Leers’s picture

Assigned: Unassigned » lauriii

Hopefully that was the last round of this game of whack-a-mole 😬

(Turns out there was a bug in StableLibraryOverrideTest 😅)

Wim Leers’s picture

Assigned: lauriii » Wim Leers
Status: Needs review » Needs work

@lauriii made the right call.

We should not be changing the media_embed_error templates. Those should remain unchanged because they're used not by the CKEditor 4 module but by \Drupal\media\Plugin\Filter\MediaEmbed::renderMissingMediaIndicator().

Wim Leers’s picture

I dug in.

CKE4

The crucial bit is this in core/modules/ckeditor/js/plugins/drupalmedia/plugin.es6.js:

        _loadPreview(callback) {
          jQuery.get({
            url: Drupal.url(`media/${editor.config.drupal.format}/preview`),
…
            success: (previewHtml, textStatus, jqXhr) => {
…
            },
            error: () => {
              this.element.setHtml(Drupal.theme('mediaEmbedPreviewError'));
            },

Drupal.theme.mediaEmbedPreviewError() is only relevant for client-side preview errors. In other words: network connectivity issues.

CKE5

Same thing in CKEditor 5's equivalent at core/modules/ckeditor5/js/ckeditor5_plugins/drupalMedia/src/drupalmediaediting.js:

  async _fetchPreview(modelElement) {
…
    if (response.ok) {
…
      return { label, preview };
    }

    return { label: this.labelError, preview: this.themeError };
  }

with

media_media:
  ckeditor5:
…
    config:
      drupalMedia:
…
        themeError:
          func:
            name: Drupal.theme
            args: [mediaEmbedPreviewError]
            invoke: true

Conclusion

  1. mediaEmbedPreviewError would've been a lot clearer if it were named mediaEmbedPreviewClientError … the "preview" was thought to imply it probably, but clearly it was not adequate
  2. this means we arguably should keep it … especially because the CKEditor 5 Drupal media plugin was already designed to use the exact same template as the CKEditor 4 Drupal media plugin
Wim Leers’s picture

Assigned: Wim Leers » Unassigned
Status: Needs work » Needs review

Pushed 5 commits that undo many of the changes and picks for a much more targeted approach.

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

Wim Leers’s picture

@bnjmnm Thanks, I just pushed the same thing, only to see after the fact you did the same 😅 The difference in line endings was caused by git 😬

Wim Leers’s picture

Implemented solution for that last hurdle 🤞

lauriii’s picture

The code itself looks good. 👍 Thank you for your patience on this @Wim Leers. 🙏

I think the code itself would be RTBC, but a critical piece of this issue is still to write a CR + release note for the fact that Drupal.theme.mediaEmbedEditButton is now in CKEditor 4.

Wim Leers’s picture

Assigned: Unassigned » Wim Leers

Yay!

On it 😄

Wim Leers’s picture

Assigned: Wim Leers » Unassigned
Issue summary: View changes
Issue tags: -Needs release note, -Needs change record

Done. CR: https://www.drupal.org/node/3292250. Release note added to issue summary.

Wim Leers’s picture

Issue summary: View changes

Improved as requested in chat!

lauriii’s picture

Status: Needs review » Reviewed & tested by the community

Thank you!

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

A bit more involved than a straight move because media was mixing generic editor integration with ckeditor4-specific stuff, but it all looks OK to me. I opened #3293741: Rename media_embed_ckeditor_theme to something more generic for a follow-up.

However, this needs a 10.1.x MR/patch, doesn't apply there.

xjm’s picture

Issue tags: +Drupal 10 beta blocker
lauriii’s picture

Status: Needs work » Needs review
FileSize
15.61 KB
lauriii’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll

Moving back to RTBC since #26 is green and it was just a simple reroll.

  • catch committed e13e5ef on 9.5.x
    Issue #3271094 by Wim Leers, lauriii, xjm, catch: Move Media CKEditor 4...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed the respective patches to 10.1.x/10.0.x and 9.5.x, thanks!

  • catch committed 14c4131 on 10.0.x
    Issue #3271094 by Wim Leers, lauriii, xjm, catch: Move Media CKEditor 4...
  • catch committed 0becafa on 10.1.x
    Issue #3271094 by Wim Leers, lauriii, xjm, catch: Move Media CKEditor 4...
xjm’s picture

Issue summary: View changes

Simplifying the CR a bit -- module developers can read the details in the CR, and site owners don't need to understand which libraries have been moved where.

xjm’s picture

Issue tags: +9.4.4 release notes
xjm’s picture

Just noted this was not actually backported to 9.4.x. Should it be backported to 9.4.x?

catch’s picture

If we're only going to deprecate ckeditor module in 9.5.x, I'm not sure it's worth backporting. But, also not opposed if there's a good reason.

xjm’s picture

@bnjmnm also agreed on not backporting it, so retagging accordingly.

Status: Fixed » Closed (fixed)

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