CKeditor not loading on formatted text fields in the content entity + component instance forms

Created on 13 March 2025, 20 days ago

Overview

Not categorizing as *bug* because this, like many other things XB, is functionality that hasn't been built yet. Nothing has been broken, etc.

I assume we want this? If the wysiwyg is provided in node/edit, we oughta provide it in the XB equivalent.

Proposed resolution

User interface changes

πŸ“Œ Task
Status

Active

Version

0.0

Component

Redux-integrated field widgets

Created by

πŸ‡ΊπŸ‡ΈUnited States bnjmnm Ann Arbor, MI

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

Merge Requests

Comments & Activities

  • Issue created by @bnjmnm
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    πŸ’― β€” and this was surfaced in #3512433-6: Provide visibility into which (core) field types (74%), field type props (63%) can be mapped into Content Type Templates vs not, and which field widgets (36%) are supported β†’ earlier today:

    πŸ€“

    Note that this is a special beast, see \Drupal\editor\Element::preRenderTextFormat():

        // \Drupal\filter\Element\TextFormat::processFormat() copies properties to
        // the expanded 'value' to the child element, including the #pre_render
        // property. Skip this text format widget, if it contains no 'format'.
        if (!isset($element['format'])) {
          return $element;
        }
    

    and

        foreach ($editors as $key => $editor) {
          $definition = $this->pluginManager->getDefinition($editor->getEditor());
          if (!in_array($element['#base_type'], $definition['supported_element_types'])) {
            unset($editors[$key]);
          }
        }
    

    β€” IOW the Text Editor (editor) module alters the text field type's widget's form render array representation πŸ˜…

  • Merge request !806Draft: #3512867 ckeditor ought to show up β†’ (Open) created by bnjmnm
  • πŸ‡ΊπŸ‡ΈUnited States bnjmnm Ann Arbor, MI

    MR I just opened has logic that gets CKEditor5 to appear. It's not ready for prime-time yet but the underlying issue has been identified and there is a solution.

  • Pipeline finished with Failed
    13 days ago
    Total: 1345s
    #453471
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Nice first step! Does CKEditor 5 itself also work?

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • πŸ‡ΊπŸ‡ΈUnited States bnjmnm Ann Arbor, MI

    Does CKEditor 5 itself also work?

    The CKEditor 5 editor works - you can format the text using the various buttons like one might expect.

    Do the contents of the edited-by-CKEdtor5 field get saved? That part does not appear to work. It that can be tackled in a separate issue once this lands.

  • πŸ‡ΊπŸ‡ΈUnited States bnjmnm Ann Arbor, MI

    My next step was to see if changing editors worked, and ran into a situation that will likely require nontrivial refactoring. The underlying cause may cause problems for more than just this use case.

    Radix <Select> does result in a <select> tag in the UI. It is instead a button that triggers the appearance of selectable options.

    Drupal.behaviors.editor very much expects a <select>, in some cases not adding the listeners unless that is the element type.

     if (editor.tagName === 'SELECT') {
              $this.on('change.editorAttach', { field }, onTextFormatChange);
            }
    

    The Radix select does have a hidden <select>, which is not exposed as a ref in @radix-ui/themes, but looks like it miiight be accessible if we access it more directly instead of the theme. I did some exploring and this doesn't look like something that can be done quickly, but there is a forwarded ref in the Select primitive, so it should be possible somehow. However, even if the <select> can be accessed via ref, we may still run into a limitation with some part of Drupal due to the select in the UI not being an actual <select>

  • πŸ‡ΊπŸ‡ΈUnited States bnjmnm Ann Arbor, MI

    Got this working by querying from the available ref

    const hiddenSelect =
          selectRef.current.parentElement?.querySelector<HTMLSelectElement>(
            'select[aria-hidden]',
          );

    Doesn't feel the most solid to me, but maybe it's OK. So far seems to work.

  • Pipeline finished with Success
    12 days ago
    Total: 2235s
    #454324
  • Pipeline finished with Failed
    8 days ago
    Total: 1974s
    #457194
  • Pipeline finished with Failed
    8 days ago
    Total: 1940s
    #457333
  • Pipeline finished with Failed
    2 days ago
    Total: 1360s
    #461922
  • Pipeline finished with Failed
    2 days ago
    Total: 1427s
    #461936
  • Pipeline finished with Failed
    2 days ago
    Total: 1512s
    #461973
Production build 0.71.5 2024