Bullet lists will not indent as block

Created on 28 November 2023, 7 months ago
Updated 16 May 2024, about 1 month ago

Problem/Motivation

Running Drupal 10.1.6 with indentblock 1.0. The problem I am facing is that there is no way to place a bullet or number list within an indented block. The bullet list always starts at the left margin.
To be clear, if I start a bullet list, I can indent within it, but I cannot indent the entire list. I have attached a video to demonstrate exactly what I mean.

Steps to reproduce

If you create a bullet list, the bullets are aligned to the left margin. If you attempt to indent the entire bullet list (as a block), the bullets remain aligned to left margin and only the text is indented. See this image:

Video demonstrating issue:

https://www.drupal.org/files/issues/2023-11-28/ckeditor5_css_issues.mp4 β†’

Using any browser, other than Safari, bullets and lists do not align properly in CKEditor 5 or display properly in browser
Using Safari, bullets and lists align properly in CKEditor 5 and in browser

We are using W3CSS as our theme - https://www.drupal.org/project/d8w3css β†’
This did not occur until Drupal 10.x updates. It worked as expected in Drupal 9 and ckeditor.
We do not have Paste-from-Word module installed - https://www.drupal.org/project/ckeditor5_paste_filter β†’

Proposed resolution

I have also attached a video of how it should work and used to work in Drupal 7.

https://www.drupal.org/files/issues/2023-11-28/demonsration%20of%20how%2... β†’

Just need some guidance on how to get the bullet lists to indent correctly. Quite curious that the only browser where this issue does NOT happen is the Safari browser.

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States SomebodySysop

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.

  • πŸ‡ΊπŸ‡ΈUnited States justcaldwell

    Hi @SomebodySysop! Not sure if you're still looking for an answer on this, or that I have one, but I thought I'd throw out some things to consider:

    1) Safari seems to be the outlier here, in that it appears to be applying the margin of a child element (the <p class="Indent1">) to the containing <li>. Whereas the other browsers are (correctly?) applying the margin to the paragraph, so there is extra space between the list marker and the contents of the <p>. I don't know who's right, but you might be able to add some CSS to account for the disparity (if a list of indented paragraphs is really what you require).

    2) The only way I could produce code similar to your demo was to a) select several paragraphs, b) indent them, then c) turn them into a list. Obviously this is possible, but you're really creating a list of indented paragraph items, not an indented list, if that makes sense. This isn't the way the plugin was intended to work with lists (see below).

    3) The indent plugin (provided by CKEditor 5) is not intended to act on a "root-level" list as a block. If you select all items in a single level list, you'll see that the indent icon is disabled. It supports indentation in lists by nesting an additional ol/ul within a given list item. Then it's up to your theme to set the margin on lists nested within list items.

    4) To indent a list as a block, you could enable the Styles plugin, then add something like this to your Styles in the text format config:

    ul.Indent1|Unordered list indent 1
    ul.Indent2|Unordered list indent 2
    ul.Indent3|Unordered list indent 3
    ...
    ol.Indent1|Ordered list indent 1
    ol.Indent2|Ordered list indent 2
    ol.Indent3|Ordered list indent 3
    ...
    

    Obviously this gets messy, as Styles requires a unique entry for each element/class combination, as well as a unique "human friendly" name for each style.

    I hope some of that makes sense and/or helps.

  • πŸ‡ΊπŸ‡ΈUnited States SomebodySysop

    Thank you for the response. I better understand why it works the way it does. But, I still miss being able create the "list of indented paragraph items" like I could before.

    I'm going to try the new ckeditor5 plugin pack to see if it helps: https://ckeditor.com/blog/drupal-ckeditor-5-plugin-pack/?utm_source=The+...

    If not, I'll try your suggestions.

    Again, thanks!

  • πŸ‡ΊπŸ‡ΈUnited States justcaldwell

    Understood β€” good luck!

    I experimented with plugin-pack's indent feature, as I need indent support for headers. Unfortunately it turned out to be a no-go for me. As far as I could tell, it does not support indentation with classes. It uses inline styles, and the indent appears to be hard-coded to '40px' per level. Kinda kills the ability to style lists in the theme.

    If that's not a concern, it may be great for your needs.

  • πŸ‡ΊπŸ‡ΈUnited States justcaldwell

    Turns out there's content on our site that has the structure you described, so I ended up writing the CSS below to address this. Not something that can be added to the module, I don't think, as it likely needs to be tweaked for the specific needs of a given site.

    The CSS needs to be in your front-facing theme, as well as pulled into your CKEditor 5 styles β†’ . This is only works for current browsers with support for :has(), is:() etc.

    li:has(> p.Indent1)  { margin-left: 2rem; }
    li:has(> p.Indent2)  { margin-left: 4rem; }
    li:has(> p.Indent3)  { margin-left: 6rem; }
    li:has(> p.Indent4)  { margin-left: 8rem; }
    li:has(> p.Indent5)  { margin-left: 10rem; }
    li:has(> p.Indent6)  { margin-left: 12rem; }
    li:has(> p.Indent7)  { margin-left: 14rem; }
    li:has(> p.Indent8)  { margin-left: 16rem; }
    li:has(> p.Indent9)  { margin-left: 18rem; }
    li:has(> p.Indent10) { margin-left: 20rem; }
    
    li:has(> p[class*="Indent"]) > p {
      margin-left: 0;
      margin-bottom: 0;
    }
    
    li:has(> p[class*="Indent"]) :is(ul, ol) li {
      margin-left: 0;
    }
    

    This essentially moves indent/margin applied to a <p> in a list item to the containing <li> (as Safari seems to do natively).

    If your theme has other classnames that would match on the "Indent" substring in the last two rules, you could use :has() instead, e.g. replace:

    li:has(> p[class*="Indent"]) ...

    with

    li:has(> p:has(.Indent1, .Indent2, .Indent3, .Indent4, .Indent5, .Indent6, .Indent7, .Indent8, .Indent9, .Indent10) ...

  • πŸ‡ΊπŸ‡ΈUnited States SomebodySysop

    Thanks much! Will definitely give it a try!

Production build 0.69.0 2024