Problem/Motivation

With the focus on all the complex/tricky parts, we lost sight of the simplest possible thing: the image upload settings!

Steps to reproduce

  1. Go to Basic HTML text format. Observe that Image Uploads are enabled.
  2. Switch to CKEditor 5
  3. Observe that Image Uploads are disabled

Note that this works fine in \Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest (i.e. when not using the UI), this is only a problem because \Drupal\ckeditor5\Plugin\CKEditor5Plugin\ImageUpload is interacting with global form state; it's unlike all other CKEditor 5 plugins, because its settings are stored "globally" in the Editor config entity.

Therefore this would not affect the automated Drupal 9 → 10 upgrade path, but it would affect anybody trying to use CKEditor 5 in Drupal 9.3/9.4.

Proposed resolution

  • Add failing test
  • Fix

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Issue fork ckeditor5-3245320

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

Wim Leers created an issue. See original summary.

wim leers’s picture

Issue summary: View changes
wim leers’s picture

Assigned: Unassigned » wim leers
Status: Active » Needs work

Yay, that failing test worked! :D

Now onto fixing this…

wim leers’s picture

Stepped through this with a debugger.

editor_form_filter_admin_format_editor_configure() does

    elseif (empty($editor) || $editor_value !== $editor->getEditor()) {
      $format = $form_state->getFormObject()->getEntity();
      $editor = Editor::create([
          'format' => $format->isNew() ? NULL : $format->id(),
        'editor' => $editor_value,
      ]);
      $form_state->set('editor', $editor);
    }

It's that second condition that allows entering this branch that is true when switching the text editor. While text-editor specific settings cannot be carried over, image upload settings can be, because they're embedded in the Editor config entity at the top-level, and they even have an API interface: \Drupal\editor\EditorInterface::getImageUploadSettings() + \Drupal\editor\EditorInterface::setImageUploadSettings().

Created core editor.module bug report: #3245351: Should switching text editors retain image upload settings?.

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs work » Needs review

Wim Leers credited lauriii.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Walked @lauriii through this on a call, he says it totally makes sense 🚢

  • Wim Leers committed bc5ca00 on 1.0.x
    Issue #3245320 by Wim Leers, lauriii: Automatic upgrade path always...
wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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