[CKE5] Div Manager removing the selected tag instead of wrapping them in the Div

Created on 4 August 2023, over 1 year ago
Updated 16 December 2023, 11 months ago

Problem/Motivation

Div Manager in CKEditor5 is removing the selected tag instead of wrapping them in the Div

Steps to reproduce

Please check the attached videos for Div Manager in CKEditor 4 vs CKEditor 5.

🐛 Bug report
Status

Needs work

Version

3.0

Component

Code

Created by

🇮🇳India HardikSolanki

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

Comments & Activities

  • Issue created by @HardikSolanki
  • 🇮🇳India vipul tulse

    Hey team
    Any update on this issue

  • 🇨🇦Canada smulvih2 Canada 🍁
  • 🇮🇳India vipul tulse

    Guys any plan to work on this?

  • 🇳🇱Netherlands Web-Beest

    The problem with this is that only the text is selected to be shown in the modal window. Perhaps it is a better idea to not use a popup, but to insert the div as-is. You can add classes through the styles dropdown.

    If you look at the demo block-widget plugin on the ckeditor page (https://ckeditor.com/docs/ckeditor5/latest/tutorials/widgets/implementin...) you can see a working example. The modal could still be used for simple or advanced editing of attributes, but without the content part.

    I'm currently working on version that does this and I'll fork a new branch when I'm done.

  • 🇮🇳India vipul tulse

    I have rewritten the whole plugin with dialog, will commit the change soon

  • 🇨🇦Canada smulvih2 Canada 🍁

    Thanks @vipul, I can test once you submit a MR.

  • @vipul-tulse opened merge request.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India vipul tulse

    Hello smulvih2, Please review the MR.

  • Status changed to Needs work about 1 year ago
  • 🇱🇻Latvia mansspams

    Patch introduces error on text format edit form - `Uncaught TypeError: [].find(...) is undefined`, something is wrong. Tested on D10.1.3.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India vipul tulse

    Hello smulvih2, Did you got any chance to review my MR

  • 🇨🇦Canada smulvih2 Canada 🍁

    @vipul thanks for the work done on this! I tested the MR and it works much better in CKE5. The one issue I notice is this change - https://git.drupalcode.org/project/ckeditor_div_manager/-/merge_requests/5/diffs#8666e23169ac0343f408a031c6a22373924ffc41_18_18

    With this change, since I already have this plugin enabled, it breaks CKE5. Even when I go to update my text format the admin UI is broken. I need to manually change "DivManager" to "DivWrapper" in the admin UI and save to get it working again. But with that said, after I fixed it the plugin works great! I also like the icon you included.

    Can you please change back to "DivManager" and push up a new commit? Thanks!

  • Status changed to Needs work about 1 year ago
  • 🇨🇦Canada smulvih2 Canada 🍁
  • 🇨🇦Canada smulvih2 Canada 🍁

    Also can you please explain what changes you have made and why? I see you deleted all files from the divManagerPlugin folder and added files to a new div_wrapper folder. Why are we changing div manager to div wrapper in different spots? Can we also please keep the README file and update it if required? Thanks!

  • 🇺🇸United States jrb Raleigh-Durham Area, NC, USA

    I tried this MR with Drupal 10.1.6 and ran into two issues with a text format where the "Limit allowed HTML tags and correct faulty HTML" filter is enabled.

    1. When I first add the new "Div" button, it throws this error:

    The following tag(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Div Manager (<div>).

    If I remove <div> from the "Manually editable HTML tags" field, the error goes away.

    2. When trying to save, I get this error:

    The current CKEditor 5 build requires the following elements and attributes:
    <br> <p class="iframe-responsive messages messages--status messages--warning messages--error messages--blue messages--purple messages--gray text-align-left text-align-center text-align-right text-align-justify"> <h2 id class="text-align-left text-align-center text-align-right text-align-justify"> <h3 id class="text-align-left text-align-center text-align-right text-align-justify"> <h4 id class="text-align-left text-align-center text-align-right text-align-justify"> <h5 id class="text-align-left text-align-center text-align-right text-align-justify"> <h6 id class="text-align-left text-align-center text-align-right text-align-justify"> <a class="button" hreflang href id target="_blank" data-entity-type data-entity-uuid data-entity-substitution> <* dir="ltr rtl" lang> <cite> <dl> <dt> <dd> <blockquote cite> <ul type> <ol start type> <strong> <em> <s> <sub> <sup> <li> <hr> <table> <tr> <td rowspan colspan> <th rowspan colspan> <thead> <tbody> <tfoot> <caption> <drupal-media data-entity-type data-entity-uuid alt data-caption data-align> <div class id style title>
    The following elements are missing:
    <div style>

    As you can see, <div style> is actually on the list as <div class id style title> (at the end). I can manually edit the config file and import to get it to work, but then I still can't save it via the UI.

    So, as it is now, we can't use this with the "Limit allowed HTML tags and correct faulty HTML" filter enabled.

  • I can confirm the problem of @jrb that there is a problem with activating "Limit allowed HTML tags and correct faulty HTML" filter.

Production build 0.71.5 2024