Problem/Motivation

With CKEditor 4, Drupal core did not provide a code button, even if the HTML tag was accepted by default. T«

Steps to reproduce

  1. Install and enable the Codetag module.
  2. Add the codetag button to a CKEditor-enabled text format.
    Codetag button
  3. Attempt to upgrade from CKeditor (4) to CKEditor 5.Also, notice the error that the button is not added.
    No upgrade
  4. With proosed fix, switching from CK4 to CK5 does not trigger warning, and the button is present in the same location in the toolbar.
    Good upgrade

Proposed resolution

Replace code with core's CK5 code button.

Remaining tasks

Add the upgrade path.

User interface changes

None.

API changes

New Contrib upgrade class for CK4 -> CK5 plugins

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcnventura created an issue. See original summary.

jcnventura’s picture

Issue summary: View changes
FileSize
68.65 KB
jcnventura’s picture

Issue summary: View changes
FileSize
45.97 KB
jcnventura’s picture

Providing a class that upgrades the Codetag module to the one provided by core's CK5, and that can be used as base for other contrib modules to provide their own upgrade path.

yogeshmpawar’s picture

Resolved CSpell errors

Status: Needs review » Needs work

The last submitted patch, 5: 3274278-5.patch, failed testing. View results

andregp’s picture

Status: Needs work » Needs review

Seems to be an unrelated feature, requeuing tests.

Status: Needs review » Needs work

The last submitted patch, 5: 3274278-5.patch, failed testing. View results

Wim Leers’s picture

Title: Upgrade contrib CK4 Codetag button to core's CK5 » Migrate "codetag" contrib CKEditor 4 plugin to built-in equivalent in core's CKEditor 5
Assigned: Unassigned » Wim Leers
Category: Feature request » Task
Priority: Normal » Major
Issue tags: +Needs tests, +ddd2022, +D8 upgrade path, +stable blocker
Parent issue: #3207845: [META] Port some initial CKEditor 4 plugin integration modules to CKEditor 5 » #3238333: Roadmap to CKEditor 5 stable in Drupal 9
Related issues: +#3207845: [META] Port some initial CKEditor 4 plugin integration modules to CKEditor 5

Thanks for this great contribution and wonderful news, @jcnventura! Thanks for investigating! 😊🙏 Because this is de facto now upgrading the core upgrade path, because it must be Drupal core providing this upgrade path (since the equivalent CKE5 plugin of the CKE4 plugin is part of Drupal core now), bumping this to a stable blocker.

Indeed unrelated failure. Re-queueing.

Note that this will need tests. I'll work on those.

Wim Leers’s picture

Assigned: Wim Leers » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
4.09 KB
6.14 KB

Tests. :) Test-only patch is also the interdiff.

(And limiting test runs for both to only CKE5 tests.)

The last submitted patch, 10: 3274278-10-test-only.patch, failed testing. View results

Wim Leers’s picture

That worked :)

Testing Drupal\Tests\ckeditor5\Kernel\CKEditor4to5UpgradeCompletenessTest
E..........                                                       11 / 11 (100%)

Time: 00:07.343, Memory: 4.00 MB

There was 1 error:

1) Drupal\Tests\ckeditor5\Kernel\CKEditor4to5UpgradeCompletenessTest::testButtons
OutOfBoundsException: No upgrade path found for the "Code" button. 

Let's run all tests again, not just CKE5's.

Wim Leers’s picture

  1. +++ b/core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Contrib.php
    @@ -0,0 +1,73 @@
    +      case NULL:
    +        // Do Nothing.
    +        break;
    

    I think we should delete this. phpcs dictates there must be at least one case. Well, that just means we can remove the switch statement.

  2. +++ b/core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Contrib.php
    @@ -0,0 +1,73 @@
    +      case NULL:
    +        // Do Nothing.
    +        break;
    

    Same thing here.

andregp’s picture

Manually tested patch #13

Steps I took:

  1. On a updated 9.4.x Drupal environment I installed codetag via composer ten enabled codetag
  2. Went to /admin/config/content/formats chose to configure one of the text formats (on my case I chose Full HTML)
  3. Added the codetag button to the active toolbar (first image)
  4. Saved the configuration
  5. Entered on the configuration again
  6. Attempted tho upgrade the editor to CKEditor 5 though the drop down
  7. Got the message "The CKEditor 4 button Code does not have a known upgrade path....." and the button was moved back to Available Buttons (second image)
  8. Applied patch and cleared the cache.
  9. Entered on the configuration again
  10. Attempted tho upgrade the editor to CKEditor 5 though the drop down
  11. Didn't get the previous message and the button was on the right place (third image)

I also checked the patch for spelling errors and coding standards. Everything was correct, only the method names on Contrib.php were not in lowerCamel format, but I see it was on purpose because of this module's name so it's RTBC for me.

+1 RTBC

Edit.: Please ignore the fourth file. I sent it by mistake.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

Given:

  1. the manual testing in #14
  2. the fact that it's @jcnventura who wrote the logic additions, not I, I only provided live reviews for him :)
  3. the fact that the test coverage was basically 2 lines of code

I think it's reasonable to RTBC this, despite my having contributed those 2 lines of code for the test coverage.

bnjmnm’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
361.38 KB

This looks great!

I notice that even when the code plugin is enabled to support the switch from codetag, it's not included in the "The following plugins were enabled" message. It would be good to have that, or at the very least an explanation as to why it isn't included (much better to have though 🙂)

Wim Leers’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
1.89 KB
5.14 KB

I notice that even when the code plugin is enabled to support the switch from codetag, it's not included in the "The following plugins were enabled" message. It would be good to have that, or at the very least an explanation as to why it isn't included (much better to have though 🙂)

That is intentional. We only generate such messages when there are additional plugins enabled compared to the CKEditor 4 configuration. In this case, the same exact functionality/button has an exact equivalent, so providing a message is not helpful.

If we'd change this then #3245967: Messages upon switching to CKEditor 5 are overwhelming would be even worse, and hence the expected_messages expectations in \Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest::provider() would increase by a lot.

To prove this, I'm adding an explicit test case to SmartDefaultSettingsTest too, that is just like the others. Observe how in this case, the expected messages are indeed empty, but many test cases have the The following plugins were enabled to support … style message you were hoping for. Since this is again so trivial, I am comfortable self-RTBC'ing.

alexpott’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 46903e6c3c to 10.0.x and 12e8b703f8 to 9.4.x and c94dc2dcc6 to 9.3.x. Thanks!

  • alexpott committed 46903e6 on 10.0.x
    Issue #3274278 by Wim Leers, jcnventura, yogeshmpawar, andregp, bnjmnm:...

  • alexpott committed 12e8b70 on 9.4.x
    Issue #3274278 by Wim Leers, jcnventura, yogeshmpawar, andregp, bnjmnm:...

  • alexpott committed c94dc2d on 9.3.x
    Issue #3274278 by Wim Leers, jcnventura, yogeshmpawar, andregp, bnjmnm:...

Status: Fixed » Closed (fixed)

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