Problem/Motivation

Drupal 10 will be delivered with CKEditor 5 (since Drupal 9.3.x, we can enable CKEditor 5 module and set it as a text editor).
In order to make your plugin available for Drupal 10, we should have a new branch and rewrite the plugin as it is actually not compatible with CKEditor 5.

Issue fork nbsp-3277174

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

MacSim created an issue. See original summary.

mmiramont’s picture

Hello!

I was looking for this module for a project I am currently working on. At first I would have just replaced the deprecated code to make it Drupal 10 compatible, but seeing this issue made me start some modifications to also make it compatible with CKEditor 5.

Things I currently did:

  • Use a custom tag <nbsp></nbsp> on the CKEditor 4 and 5 versions, as explained on Issue 3066349. The filter is changed to replace this custom tag with a str_replace.
  • Replaced deprecated code (drupal_gret_path) to their latest version, Drupal 10 compatible (and dependancy injection)
  • Pass the icon location through the plugin configuration
  • Start of a CKEditor 5 compatibility : library, definition and CKEditor4To5Upgrade class. As part of it, I recreated the icon on a SVG file.

Things currently not working or done:

  • The created plugin does not load, yet the button is correctly visible on the 'Text and format editors' admin menu. I have no CKEditor experience but I'll make it load and work. Failed to load nbsp - Nbsp | CKEditorError: plugincollection-plugin-not-found {"plugin":null}
  • CKEditor 5 tests.

I'll create an issue fork and publish the modifications I did.

EDIT: code has been pushed to the branch associated to this issue

mmiramont’s picture

Status: Active » Needs work

I am still working on it. I finally managed to make the plugin work on CKEditor 5, but it actually creates a <nbsp>&nbsp;</nbsp> tag and moves the rest of the line visually on a new line. The SVG icon is also not displayed.

I pushed the 'open merge request' to see if it show me a window, but didn't asked for a confirmation. The work is not finished, I am moving this on a 'needs work' status.

mmiramont’s picture

FileSize
37.39 KB

I decided to go back on the modifications I did on the CKEditor 4 version of the plugin, and reuse the previous code while setting the template to <nbsp>&nbsp;</nbsp>

For the CKEditor 5 version, the icon did not show up because it needed path to be correctly displayed. It is better now.
I splitted the JS files to get a similar behaviour and naming of the 'ckeditor5_plugin_starter_template' of the CKEditor5 Dev plugin

For the <nbsp>&nbsp;</nbsp> insertion, I followed the FAQ to insert the same template as the CKEditor 4 version.

I also wrote the Test file, based on existing uses of the CKEditor5TestTrait. Currently the 'testButton' is failing. I'll move the status to 'Ready for Review' when I will pass it.

NBSP Plugin on CKEditor5

mmiramont’s picture

Status: Needs work » Needs review

The test failed because having the <nbsp>&nbsp;</nbsp> alone is prevented by the allowWhere: '$text' definition on the plugin. It needs text alongside to be correctly inserted and displayed. I do not see this as an issue, as non-breaking spaces are used alongside punctuation characters.

I added some text before clicking the button, the test is now ok. I think I thought of everything.

VladimirAus’s picture

It does not allow me to push to existing fork so I'll upload the patch to match that applied to the latest version.

mmiramont’s picture

Sorry I didn't closely follow the latest changes on the module, and didn't see there was a new version. I rebased the branch onto, and following the latest changes on the Drupal 10 Beta 2 version where ckeditor4 is removed as well as older themes, I had to make some changes on the theme used during the tests and the dependencies.

From what I can see, it seems hard to provide the same module version for CKeditor4 and CKeditor5. Would it be better to provide an exclusive version of this module for Drupal 10 and another version for Drupal 9 (the current one published for example). Ckeditor4 code would be removed then in this branch.

VladimirAus’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
38.52 KB

Thank you. Works.

nbsp

wengerk credited Artusamak.

wengerk credited PhilY.

wengerk’s picture

Update-related issues (https://www.drupal.org/project/nbsp/issues/3066349) and credit people from that issue.

Working and reviewing the suggested code. Seems pretty solid at first sight.

I agree with you @mmiramont abour having another branch for the Drupal 10 + CKeditor 5 exclusive code.

Still if the current suggestion works for both I will merge in the current branch, create a release for Drupal 9, CKeditor 4|5 and then create a new dev branch where we will remove the Ckeditor 4 code to only support Ckeditor 5 for Drupal 10.

  • wengerk committed 043779f on 8.x-2.x
    Issue #3277174 by mmiramont, VladimirAus, MacSim, Artusamak, John...
wengerk’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @mmiramont for your hard works on this issue !! This has now been merged into the current dev branch (8.x-2.x).

Fow now we have to do the following things in this order:

  • Make the project working on Drupal 10 without deprecation notice
  • Release a version 8.x-2.2 that works on Drupal 9/10 and CKeditor 4/5
  • Once done, create a new branch 3.0.x for future D10 + CKeditor 5 only
  • Update the code base of 3.0.x by removing support of D9/CKeditor 4
  • Release a version 3.0.0 supporting Drupal 10 & CKeditor 5 only
wengerk’s picture

Released 8.x-2.2 (CKEditor 4 & CKEditor 5) and 3.0.0 (CKEditor 5) done.

The new default branch is now 3.0.x.

Wim Leers’s picture

Wow! CKEditor 4 support, CKEditor 5 support, upgrade path, and test coverage for the upgrade path — and updated https://www.drupal.org/docs/core-modules-and-themes/core-modules/ckedito...! 🤩 👏

Superb work, @mmiramont! 😊

Status: Fixed » Closed (fixed)

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