Overview

There are requests to make the redux field widgets work with widgets such as the formatted text one used by TextLongItem, but there is currently no way to add a prop that uses such a widget, so we need to get that working before reduxing it can be explored

This will be supported once #3467959: SDC and code component props should be able to receive HTML, editable in formatted text fields+widgets is taken care of.

Proposed resolution

Make the block HTML prop shapes in the wysiwyg-ptops component from the sdc_test_all_props module load CKEditor 5, rather than just <textarea>:

Do that by:

  1. ✅ updating
    /**
     * No-op transform for rich text fields with CKEditor 5 integration.
     * Simply passes through the value without transformation.
     *
     * @todo Add actual logic in https://www.drupal.org/i/3512867
     */
    const richText: Transformer<void, any> = (value) => {
      return value;
    };
    

    ui/src/utils/transforms.ts — added by #3467959: SDC and code component props should be able to receive HTML, editable in formatted text fields+widgets

    (or deleting it if it's obsolete)

  2. ✅ Adding end-to-end test coverage to ui/tests/e2e/prop-types.cy.js — with AI-generated tests already present, but no idea how good they are. See
        // @todo Uncomment this test in https://www.drupal.org/i/3512867 and refactor as needed.
        /*
        it('HTML inline formatting field uses CKEditor with appropriate configuration', () => {
    

User interface changes

CKEditor 5 is available in the right sidebar for some component props!

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

bnjmnm created an issue. See original summary.

wim leers’s picture

Component: Code » Redux-integrated field widgets
wim leers’s picture

bnjmnm’s picture

Issue summary: View changes
Status: Active » Postponed

Not much point working on this until we can get CKEditor 5 loading on textareas #3512867: CKEditor 5 not loading on formatted text Field Widgets in the content entity form so postponing on that

The current MR is outdated to the point that it's probably not worth continuing, and will likely be less relevant after #3512867 so I'm going to hide that one and recommend a new MR starts once we have CKEditor 5 working in the fields that are configured to use it. #3512867 already has it the editor properly loading with formatted text fields in the Page Data form

bnjmnm changed the visibility of the branch 3484395-wysiwyg-ckeditor5-widget to hidden.

bnjmnm changed the visibility of the branch 3484395-support-props-that to hidden.

wim leers’s picture

Title: Support props that can use wysiwyg widgets » [PP-2] CKEditor 5 not loading on formatted text Field Widgets in the component instance form
Assigned: bnjmnm » Unassigned
Priority: Normal » Critical
Issue summary: View changes
Issue tags: +stable blocker
Related issues: +#3512867: CKEditor 5 not loading on formatted text Field Widgets in the content entity form

#5++ — thanks so much for assessing and summarizing this issue's status, @bnjmnm! 🙏😊

Per #3512867-11: CKEditor 5 not loading on formatted text Field Widgets in the content entity form, retitling this to more precisely reflect this issue's scope.

wim leers’s picture

Title: [PP-2] CKEditor 5 not loading on formatted text Field Widgets in the component instance form » [PP-1] CKEditor 5 not loading on formatted text Field Widgets in the component instance form
wim leers’s picture

Issue summary: View changes

This issue/MR will update bits and pieces #3467959 introduced; making that clear in the issue summary.

wim leers’s picture

Title: [PP-1] CKEditor 5 not loading on formatted text Field Widgets in the component instance form » CKEditor 5 not loading on formatted text Field Widgets in the component instance form
Assigned: Unassigned » bnjmnm
Status: Postponed » Active
wim leers’s picture

bnjmnm’s picture

StatusFileSize
new164.77 KB

MR has it working, still need to add tests.

wim leers’s picture

Status: Active » Needs work

#13: exciting! 😄🤩

wim leers’s picture

Note: the "inline" ones don't need to work, as described in #3517735: [later phase] [needs upstream feature] Make `x-formatting-context: inline` work. Sorry for making that not more clear, @bnjmnm :(

(It was kind of mentioned in #3519910, but I just made that more explicit: #3519910-3: [META] WYSIWYG in Experience Builder.)

bnjmnm’s picture

Status: Needs work » Needs review

There are PHP tests failing due to there being commented-out props in the all-props sdc. These are props unrelated to the work happening here, but their presence results an error occurring any time a value changes on any prop in all-props. It is being worked on in this issue: #3467959: SDC and code component props should be able to receive HTML, editable in formatted text fields+widgets

They're commented for now so the work being done here can be reviewed manually and the CK5 e2e tests pass. That should be enough to get this reviewed, but we shouldn't commit until #3467959 lands and we un-comment those props.

wim leers’s picture

Status: Needs review » Needs work

🏓 Review posted!

It is being worked on in this issue: […]

That issue is closed, so did you perhaps intend to link to another issue?

bnjmnm’s picture

Assigned: bnjmnm » anjali rathod

I did some manual testing of this and noticed after the first update of the preview (in response to an edit in a CKE field) there is a flicker as the form is rebuilt and then CKE is reattached. And from that point editing the field value doesn't trigger an update anymore. Here's an example showing I've put 'Hi dog what's up more edits' in the field but it doesn't trigger an update in the preview.

\

This turned out to be a pretty big thing to address, but it's good this came up and I have the underlying issue fixed. Instead of relying on Drupal behaviors, this is now using the Ckeditor5 React Integration.

Now the editors work without flickering and the preview updates as you'd expect. However, I've been at this for far too long and the code is a bit scary looking so it's switched to draft. There's some cleanup + the format switching will need to be refactored a bit to work with the React-rendered CKEditor5 components. I think this is for the best as CKEditor5 is probably too complex to graft the Vanilla JS version onto our React forms if there's an official React solution available.

I'm unassigned myself in case someone wants to jump into the chaos, but I'll be back at it tomorrow.

bnjmnm’s picture

Assigned: anjali rathod » Unassigned

Sorry @ anjali your name is right next to "Unassigned"

bnjmnm’s picture

Status: Needs work » Needs review

The flickering reported earlier wound up being a pretty big deal and I switched out the drupalBehaviors grafting to instead use the React solution from CKEditor themselves.

The only failing e2e test is the recently addedfield_xbt_entity_ref_tags which was added to day and should(?) be unrelated to anything here.

The MR should probably have gotten another once over from me before switching to NR, but I gotta leave the computer + this is high priority and probably good to get some eyes on it

bnjmnm’s picture

Issue summary: View changes
Status: Needs review » Needs work

Pausing the NR - spotted something locally that could be improved

bnjmnm’s picture

Status: Needs work » Needs review
wim leers’s picture

Assigned: Unassigned » bnjmnm
Issue tags: +Needs documentation

@larowlan already did a detailed review, so I won't :)

I want to zoom out and look at what our intent/hope is with Redux-integrated field widgets ("keep existing widgets working without significant changes") versus the reality here:

I switched out the drupalBehaviors grafting to instead use the React solution from CKEditor themselves

  • On the one hand: 👏 for pragmatism!
  • On the other hand: 🤔 for this sounding like we'll have to do one-off things like this for more widgets.

Then again, CKEditor 5 is a massively complex application on its own, which Drupal's been embedding, and now we're embedding it into XB, another complex app on its own!

So: can we be confident that this deep special-casing will be only necessary for very complex widgets like this one? Is it extra complex because we're only going to allow these 2 specific locked text formats/editors in component instances? IOW: can we document why this is so complex and special? 🙏 A new section in docs/redux-integrated-field-widgets.md perhaps?

bnjmnm’s picture

I want to zoom out and look at what our intent/hope is with "Redux-integrated field widgets" ("keep existing widgets working without significant changes") versus the reality here

Maybe this should be a separate issue? This is higher level than just CKEditor5 , and our decision to use Radix has necessitated far more complexity than anything in this issue.

I also think this is based on an assumption that this introduces unprecedented special-casing which I don't really think it does.

So: can we be confident that this deep special-casing will be only necessary for very complex widgets like this one?

  • It's not particularly deep special casing IMO. The majority of what might be seen as complex is code copied from core's ckeditor5.js. If the code wasn't encapsulated we could have called it directly and reduced the MR size significantly
  • What is largely happening in the MR is I opted to use an already-available React component recommended by the CKEditor5 team. It's an existing React solution for exactly what we need. The CK5 implementation has required less bending-to-our-will than the decision to use Radix has required.

Is it extra complex because we're only going to allow these 2 specific locked text formats/editors in component instances?

No, nothing in the React or semi coupled code was any more/less complex because of the that. It just works with whatever is made available to it.

There was additional complexity due to the design decision to hide the format select element behind a popup and render that element with Radix instead of making it a standard select.

OW: can we document why this is so complex and special? 🙏 A new section in docs/redux-integrated-field-widgets.md perhaps?

I still don't think this stands out as novel in its complexity

If documenting additional complexity in the Render Array -> React layer seems beneficial, justifying the complexity introduced by Radix should probably get the emphasis, which would be out of scope here. I think this could be worthwhile to do in a separate issue.

wim leers’s picture

Assigned: bnjmnm » wim leers

This is higher level than just CKEditor5

It is a higher-level question, indeed, but it is prompted by this MR adding a lot of extra JS code to make the "formatted text" Field Widget work within XB. That's why I'm asking for documentation in docs/redux-integrated-field-widgets.md so that somebody who joins the Experience Builder project might be able to learn/understand how all this fits together, and why for certain field widgets extra work/complexity is justified.

I was hoping this would be a first case where a complex widget can be shown to be made to work without significant JS work, similar to what we've been saying how we want contrib/custom field widgets to work in XB. That's where this concern/question is coming from — it's not that this isn't great work (it is! 😄), but that this gives me pause for how we can expect our approach to scale to the entire field widget ecosystem.

I understand that that feels like a distraction/is technically out of scope. But isn't expanding docs/redux-integrated-field-widgets.md with one concrete advanced example, on the MR that is introducing said example … reasonable? 😅 Moving it to a follow-up makes no sense to me, because writing docs later will cause loss of insight, and the act of writing the docs might result in improvements? 😊

and our decision to use Radix has necessitated far more complexity than anything in this issue.

😞 I did not know that. I don't see anything about that in either docs/redux-integrated-field-widgets.md nor docs/shape-matching-into-field-types.md.

due to the design decision to hide the format select element behind a popup and render that element with Radix instead of making it a standard select.

IIRC this was not really a design decision, but just a choice @balintbrews made many months ago because we didn't have designs!


I'll review the back-end pieces of this MR. But my concerns above WRT FE pieces still exist. I do fully acknowledge most of this is a black box to me already, but I've been able to conceptually reason about it. This MR makes
If @larowlan, @effulgentsia and @balintbrews are comfortable with this landing without docs, then great!

wim leers’s picture

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

Per #26. Back-end review completed.

Manual testing: this works beautifully! 🤩

Self-addressed all my remarks, except for two: 1, 2.

wim leers’s picture

Does this need review from me, @bnjmnm? 😇 Would like to land this one! :D

bnjmnm’s picture

Does this need review from me, @bnjmnm? 😇 Would like to land this one! :D

Not yet. #24 & #26 opened a can of worms and this will be another few days at least, potentially longer depending on how many rounds of revisions are requested on the docs.

bnjmnm’s picture

Upon discovering that much of the implementation I was fighting against was done due to lack of designs vs something intentional, I gutted it and replaced it with something that required fewer hacks & workarounds. It's not suddenly simple, but all the steps are very clearly geared towards the implementation the CK team's CKEditor 5 React component, instead of wiring disparate parts together.

Functionally this is basically ready to go (I'm sure there will be some changes requested in review) but the following need to be considered

Current Limitations

  • The dialog that appears when the text format changes is not currently implemented. For the component instance form this isn't an issue since there's only one format. It could be taken care of in a followup
  • The text format info below the field does not change based on the format changing. This is nothing new, just more noticeable with a fully working editor. This could be done in a followup

Documentation Needs
This could take a while for a few reasons

  • Documentation that properly addresses the concerns expressed in #24 and #26 needs to provide context beyond CKEditor5 implementation. For example, there's arguably more complexity due to using Radix instead of fully authoring our own templates. Highlighting one example without sufficient context can lead to overattribution and misunderstanding. This is information worth documenting, but it's a big topic that needs to be addressed thoughtfully. So this could take some time especially because....
  • It's likely it will require several rounds of feedback much like this documentation issue did: #3446434: Document "Semi-Coupled Theme Engine" and "Redux-integrated field widgets" components
bnjmnm’s picture

Assigned: bnjmnm » Unassigned
Status: Needs work » Needs review

Added two followups

wim leers’s picture

Aiming for RTBC since it was so very close in #27 already!

Removing Needs documentation tag, that's now going to be handled in #3522999: Document use cases where XB's field widgets don't 1:1 match how they would work in a twig theme.

daterange_default detour

@bnjmnm must've been testing with the (optional) daterange module installed and hence ran into a one-line logic bug introduced by #3515629: FieldWidget's XB transforms must be bubbled by the Field Widget rendering to inform the client. To get past that, he defined an empty client-side transform for the daterange_default widget, which then resulted in it being claimed to be working in \Drupal\Tests\experience_builder\Kernel\EcosystemSupport\FieldWidgetSupportTest, which then undermined the value/meaningfulness of that test … because it doesn't actually work (and I spent ~30 minutes debugging and trying to get it to work, which is why there's now a detailed analysis of where it goes wrong) 😅
To avoid that information to go to waste: #3523379: [later phase] Support `daterange_default` field widget in component instance form.

Manual testing

Works great! 🤩

wim leers’s picture

Assigned: Unassigned » bnjmnm

Argh, can't merge because package-lock.json was just updated in #3516390: Compile Tailwind CSS globally for code components. Can you do that, @bnjmnm? 🙏

  • wim leers committed d68d08a4 on 0.x authored by bnjmnm
    Issue #3484395 by bnjmnm, wim leers, larowlan: CKEditor 5 not loading on...
wim leers’s picture

Assigned: bnjmnm » Unassigned
Status: Reviewed & tested by the community » Fixed

🥳

Status: Fixed » Closed (fixed)

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