CKEditor 5 buttons not visible on configuration page for full_html

Created on 26 September 2023, about 1 year ago
Updated 14 July 2024, 4 months ago

Problem/Motivation

Instead of the icons I see text references to the icons under "available buttons" and "active toolbar"
screenshot ckeditor

Steps to reproduce

launch config/content/formats/manage/full_html
save configuration
log message: "TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in in_array() (line 659 of /var/www/testes/web/core/modules/ckeditor5/ckeditor5.module)."
I found out that after removing "sourceEditing" and saving, the icons reappear and I can add any icon without having errors. When I add the source icon, it's screwed up again.
It seems similar to issue https://www.drupal.org/project/drupal/issues/3335155 💬 CKEditor 5 toolbar configuration: no admin UI visible, only JSON in a Closed: duplicate
but I don't understand the solution "bandwidth-optimailisation"

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

💬 Support request
Status

Postponed: needs info

Version

11.0 🔥

Component
CKEditor 5 

Last updated about 21 hours ago

Created by

🇧🇪Belgium jjgw

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue created by @jjgw
  • If there are steps to reproduce this is a bug report.

    That's a TypeError. Does Drupal crash when you save the configuration form?

  • Status changed to Postponed: needs info about 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    That is most likely caused by a Drupal contrib module. Can you please export your core.extension config and upload it here? Which of your installed modules provide CKEditor 5 plugins?

    Which version of Drupal core are you using?

    P.S.: the screenshot is not visible, I have to accept some weird terms of service (which I won't do). Please upload images here.

  • 🇧🇪Belgium jjgw

    There is no bug involved here, but my database is corrupted. In fact, I had a power failure and I am now experiencing similar problems in other modules, like blocks. To avoid further surprises I am forced to redo my work of the last 3 days. Sorry voor het storen.

  • 🇺🇸United States DamienMcKenna NH, USA

    Should we close this?

  • 🇧🇪Belgium jjgw

    my configuration:
    Drupal 10.1.4
    Apache 2.4.57 Ubuntu
    PHP 8.2.10
    Mysql 8.0.34.0 Ubuntu 22.04.1

    I did following tests on localhost:
    1° install drupal with spanish translation
    composer create-project drupal/recommended-project
    2° check all text formats for basic page
    goto /admin/structure/types/manage/page/fields/node.page.body
    check all text formats and save
    3° try to modify formats for Full HTML
    goto /admin/config/content/formats
    select full HTML
    click on configure
    4° result:
    No icons are visible. Instead there are the text references to the icons.

    This time I have no more the error message as mentioned above.

    What's weird:
    I did this test 3 times with the same result.
    I also did the same test with a non translated installation. (English)
    And here the icons for full HTML are visible as expected!!!

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    #6: when the config UI does not render correctly, can you please check your browser's JavaScript console? I bet there is a JavaScript error!

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • 🇧🇪Belgium jjgw

    On http://es.localhost/admin/config/content/formats/manage/basic_html?desti...
    that's the clean spanish site without any content and contrib modules
    I have no js errors but 2 (same) warnings:
    [Deprecation] The keyword 'push-button' specified to an 'appearance' property is not standardized. It will be removed in the future.
    I added all the available buttons, except the source button, to the active toolbar without getting js errors.
    When I added the source button and saved the configuration, the buttons dissapear and are replaced by text, and I get 6 js errors + the 2 warnings.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Please upload the screenshots here. That link will stop working at some point. And it already doesn't allow me to view the screenshots! 😅

    [Deprecation] The keyword 'push-button' specified to an 'appearance' property is not standardized. It will be removed in the future.

    This appears to be a warning from your browser about some CSS. It's not a JS error, fortunately 😊

  • 🇧🇪Belgium jjgw

    I thought uploading on this forum was not possible. It took me a while to find the right button.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Those errors imply drupal.js never loaded. 🤯

    That's definitely not related to CKEditor 5.

    Without steps to reproduce, there's absolutely nothing I can do to help you, @jjgw 😞

  • 🇪🇸Spain slajo

    Same error on a Drupal 10.1.6 default installation profile. Site default language Spanish.
    I couldn`t reproduce this problem on a english (en) or portugês (pt-pt) sites.
    When you try to change the format text editor to none you have this error stack:

    TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in in_array() (line 659 of core/modules/ckeditor5/ckeditor5.module).
    ckeditor5_editor_presave(Object)
    call_user_func_array(Object, Array) (Line: 409)
    Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'ckeditor5') (Line: 388)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith('editor_presave', Object) (Line: 416)
    Drupal\Core\Extension\ModuleHandler->invokeAll('editor_presave', Array) (Line: 341)
    Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook('presave', Object) (Line: 529)
    Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 483)
    Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 257)
    Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object) (Line: 339)
    Drupal\Core\Entity\EntityBase->save() (Line: 609)
    Drupal\Core\Config\Entity\ConfigEntityBase->save() (Line: 255)
    editor_form_filter_admin_format_submit(Array, Object)
    call_user_func_array('editor_form_filter_admin_format_submit', Array) (Line: 114)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
    Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
    Drupal\Core\Form\FormBuilder->processForm('filter_format_edit_form', Array, Object) (Line: 325)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    If you add other languaje to the site (e.g english) you can change to that new language and edit de ckeditor ckeditor5-toolbar-configuration fieldset with no error.

    The error only apear if de sourceEditing plugin is enabled.
    No errors or warnings on Xdebug when loading de format edit page.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
    TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in in_array() (line 659 of core/modules/ckeditor5/ckeditor5.module).
    ckeditor5_editor_presave(Object)
    

    is referring to this line in 10.1.6:

    if (in_array('codeBlock', $settings['toolbar']['items'], TRUE) && !isset($settings['plugins']['ckeditor5_codeBlock'])) {
    

    It should not be possible for $settings['toolbar']['items'] to be an array.

    Can you please provide a config export of your editor config entity, in all of the 3 languages you mentioned? 🙏

  • 🇪🇸Spain slajo

    Here are my basic_html editor config files in tree diferent cases

    • es: This is the config in a modified site. The editor works fine if you remove de sourceEditing value from de settings.toolbar.items list. If you add this value you have a JS error in de front (you see the tokens instead the buttons) and when try to change the editor to "none" you have the back error.
    • es default: The same case as above but I export the config from a clean default instalation
    • en default: No errors 🤯
  • 🇪🇸Spain slajo

    In comment#15 es default case when sourceEditing plugin is added a JS error trowed (before saving the config, only dragging the plugin to enable it):

    Uncaught TypeError: Cannot set properties of undefined (setting 'value')
    at Drupal.verticalTab.focus (vertical-tabs.js?v=10.1.6:199:65)
    at vertical-tabs.js?v=10.1.6:117:42
    at Array.forEach ()
    at Object.attach (vertical-tabs.js?v=10.1.6:64:68)
    at drupal.js?v=10.1.6:166:24
    at Array.forEach ()
    at Drupal.attachBehaviors (drupal.js?v=10.1.6:162:34)
    at HTMLDivElement. (ajax.js?v=10.1.6:1362:20)
    at Function.each (jquery.min.js?v=3.7.0:2:3129)
    at ce.fn.init.each (jquery.min.js?v=3.7.0:2:1594)

    Everything works well in the en default case.

  • 🇪🇸Spain jmohino

    After upgrading to Drupal 10.2.2 I have the same problem when using css/js aggregation

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Please provide exact steps to reproduce on a fresh Drupal site.

  • 🇪🇸Spain jmohino

    In my case, after installing Gin as an administration theme, the problem has been solved

  • 🇧🇪Belgium jjgw

    The problem stil persists on a new Drupal installation with Spanish as selected language.
    In the "Steps to reproduce" not even "source" is involved, just the choice of the Spanish language is sufficient for the deviant behavior.

    Steps to reproduce
    1° Install Drupal 10.3.1
    2° Go to /admin/config/content/formats
    3° Select HTML completo
    4° No icons are showed
    5° Change CKEditor 5 into Ninguno and Save
    6° The website encountered an unexpected error. Try again later
    7° Refresh
    8° Go to /admin/config/content/formats
    9° Select HTML completo
    10° Change Ningunu into CKEditor 5
    11° The Available buttons and Active toolbar are now OK
    12° Save
    13° Go to step 2° and 3° and you are back at the beginning: the icons are not shown.

Production build 0.71.5 2024