Problem/Motivation

Following a comment in #3623375: Document textarea filter, better message when no profile exist:

TextareaWidget has been added in January as a temporary fix, and the filter.format.display_builder_html followed in July.

4 months later, with 1.0.0-rc1 around the corner, are we sure we still need this workaround?

The issue is already described in documentation:

Drupal's `#type => 'text_format'` only syncs its textarea on a native form submit, which HTMX never performs.

This is important to try this now because:

  • TextareaWidget is hardcoding the call to filter.format.display_builder_html which is not recommended.
  • TextareaWidget is targeting string and identifier prop types which must not accept markup

Proposed resolution

In 3 steps:

  1. Fix wysiwyg source. Let's try to keep it light, in a single, dedicated, javascript file.
  2. Drop textarea source
  3. Migrate stored source tree from textarea to wysiwyg

Disclaimers:

  • JavaScript being out of my comfort zone, I plan to be helped by a LLM #ai-accelerated
  • Because there is a data migration task, I am suggesting to do that before rc1, so I took the liberty to add #display_builder-1.0.0-beta. I will remove it if I fail.
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

pdureau created an issue. See original summary.

pdureau’s picture

Title: Fix wysiwyg source and drop » Wysiwyg source compatibility with HTMX

pdureau’s picture

Issue summary: View changes

MR created with first step done: https://git.drupalcode.org/project/display_builder/-/merge_requests/591

Checks:

Step Results
Drop a Wysiwyg source in a slot ✅ The source is a placeholder in the builder (because it is empty)
Write something in "Plain text" (the default format) and change the focus (the event expected by HTMX in all form elements) ✅ The placeholder is replaced by the test in Builder
Switch to "Full HTML", the "Change text format" modal appears, click "Continue" ✅ The modal is not reloading as it was doing after fix, one click is enough. (but ⚠️ the button labels are not clearly readable with admin theme)
Check the contextual panel ✅ The "Full HTML" format is selected, my text is still here, ckeditor5 is avaialable.
Put some markup in the text (bold, links, lists..), including markup not available in "Basic HTML" (like <sup>, <sub>) and change the focus ✅ The preview is updated in the Builder
Switch to "Basic HTML", the "Change text format" modal appears, click "Cancel" ✅ Nothing has changed in the contextual form and the builder preview
Switch to "Basic HTML", the "Change text format" modal appears, click "Continue" ✅ As before, the modal is not reloading as it was doing after fix, one click is enough.
Check the contextual panel ✅ The "Basic HTML" format is selected, ckeditor5 has changed, my markup is still here but without the parts not available with this format
Check the Builder panel ✅ The preview has been updated too.

Next step/commit: Drop textarea source (and the filter format entity).

pdureau’s picture

Issue summary: View changes
Status: Active » Needs review
  1. Drop textarea source (and the filter format entity) >> ✅ DONE
  2. Migration mechanism added >> ✅ DONE

I will check the migration mechanism manually before sending to review to someone else.

pdureau’s picture

Status: Needs review » Needs work

Migration tested:

  1. Fresh Drupal install on display_builder 1.0.x
  2. Add a textarea source in a slot, and add markup inside
  3. Add a textarea source in a string prop, and add markup inside
  4. Checkout to 3640354-fix-wysiwyg-source
  5. Run drush updb

You must see:

  Module            Update ID                        Type          Description                                                                                                                          
  display_builder   textarea_to_wysiwyg_in_config    post-update  ....
  display_builder   textarea_to_wysiwyg_in_content   post-update   ...       

Results:

  • For the slot, wysiwyg source with basic_html format if present: ❌ still the removed "Display Builder HTML"
  • For the prop, textfield source with the markup stripped: ❌ markup is still present
pdureau’s picture

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

Same test

  1. Fresh Drupal install on display_builder 1.0.x
  2. Add a textarea source in a slot, and add markup inside
  3. Add a textarea source in a string prop, and add markup inside
  4. Checkout to 3640354-fix-wysiwyg-source
  5. Run drush updb

You must see:

  Module            Update ID                        Type          Description                                                                                                                          
  display_builder   textarea_to_wysiwyg_in_config    post-update  ....
  display_builder   textarea_to_wysiwyg_in_content   post-update   ... 
  display_builder   textarea_to_wysiwyg_remove_format   post-update ...

Results:

  • For the slot, wysiwyg source with basic_html format if present: ✅
  • For the prop, textfield source with the markup stripped: ✅