Problem/Motivation

By working on #3216015: Generate CKEditor 5 configuration based on pre-existing text format configuration for CKEditor 5, we noticed a lot of hoops to jump through.

When switching from CKEditor 4 to CKEditor 5, or just when enabling CKEditor 5, we should give the user (the site builder) a sensible result when they see CKEditor 5:

  1. When switching from CKEditor 4 to CKEditor 5, they should have an identical toolbar layout if at all possible
  2. When enabling CKEditor 5 for a text format that did not yet have a text editor configured, it should not just enable a CKEditor 5 toolbar configuration of Heading Bold Italic — it should automatically place toolbar items that are relevant for the allowed HTML tags!

But the current \Drupal\editor\Plugin\EditorPluginInterface::getDefaultSettings() API makes that impossible, because it is not given any context. It is currently a poorly designed API (I can say those words because I created it ~7 years ago 🙈) because it could currently have been static.

Steps to reproduce

See above.

Proposed resolution

Take advantage of the fact that \Drupal\editor\Plugin\EditorPluginInterface::getDefaultSettings() is not static right now, and add optional parameters:

\Drupal\editor\Plugin\EditorPluginInterface::getDefaultSettings(FilterFormatInterface $text_format, EditorInterface $old_text_editor)

That would allow it to not return a hardcoded default, but a contextually relevant default.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3226673

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

Wim Leers created an issue. See original summary.

Wim Leers’s picture

Version: 10.0.x-dev » 9.3.x-dev

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

apaderno’s picture

Issue tags: -d10 +Drupal 10

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.

Libbna’s picture

Assigned: Unassigned » Libbna

I will give it a try on this.

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

apaderno’s picture

Assigned: Libbna » Unassigned
Status: Active » Needs work
Libbna’s picture

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

Status: Needs review » Needs work

Thanks for pushing this forward! 🥳

Posted a review that shows next steps on how to get the builds to pass :)

ravi.shankar made their first commit to this issue’s fork.

ravi.shankar’s picture

Status: Needs work » Needs review

Tried to address comment #11, please review.

Wim Leers’s picture

Status: Needs review » Needs work

Yeah … looks like that's still considered a BC break by PHP…

😬

We'll need to think of an alternative approach … the only thing I can think of: a new interface that is optional.

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

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.