Problem/Motivation
Discovered while working on #3245320: Automatic upgrade path always disables image uploads — in the UI.
Root cause:
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().
Steps to reproduce
Switch the default Basic HTML text format to use CKEditor 5 and observe the image uploads setting getting turned off.
Proposed resolution
Carry over image upload settings when switching text editor.
Remaining tasks
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 3245351-12.patch | 677 bytes | wim leers |
| #12 | interdiff.txt | 667 bytes | wim leers |
| #10 | 3245351-10.patch | 679 bytes | wim leers |
| #10 | interdiff.txt | 685 bytes | wim leers |
| #3 | 3245351-3.patch | 681 bytes | wim leers |
Comments
Comment #2
wim leersComment #3
wim leersComment #4
wim leersNote: when CKEditor 5 is in Drupal core, we can rely on the test coverage that #3245320: Automatic upgrade path always disables image uploads — in the UI is adding: we can then first remove the work-around that was added there, observe the test failing, and then add this more generic fix instead.
So, postponing on #3231364: Add CKEditor 5 module to Drupal core.
Comment #6
wim leersRealized this wasn't quite right yet after digging into this with @lauriii 😅
Comment #8
wim leersThis came up again, unexpectedly, in #3270734-6: Update Editor + CKEditor 5 module to not use CKEditor 4 in tests.
Comment #10
wim leersComment #12
wim leersComment #14
wim leersOne legitimate failure remains:
Will investigate.
Comment #17
wim leersNot important enough.