Indentation in lists isn't working

Steps to reproduce

  1. Type some text in the editor.
  2. Select it and press on list button.
  3. Then press in identate button

Expected behavior
The list is moved to the right

Current behavior
The list doesn't move

Inspecting the list with the development tools I can see that the list's class changes, that means that there are missing styles. I fixed this adding these styles to ckeditor.indentblock.css

p.Indent1, ul.Indent1, ol.Indent1 {
  margin-left: 2em;
}
p.Indent2, ul.Indent2, ol.Indent2 {
  margin-left: 4em;
}
p.Indent3, ul.Indent3, ol.Indent3 {
  margin-left: 6em;
}
p.Indent4, ul.Indent4, ol.Indent4 {
  margin-left: 8em;
}
p.Indent5, ul.Indent5, ol.Indent5 {
  margin-left: 10em;
}
p.Indent6, ul.Indent6, ol.Indent6 {
  margin-left: 12em;
}
p.Indent7, ul.Indent7, ol.Indent7 {
  margin-left: 14em;
}
p.Indent8, ul.Indent8, ol.Indent8 {
  margin-left: 16em;
}
p.Indent9, ul.Indent9, ol.Indent9 {
  margin-left: 18em;
}
p.Indent10, ul.Indent10, ol.Indent10 {
  margin-left: 20em;
}
CommentFileSizeAuthor
#4 ckeditor-indent-lists-2986139-4.patch1.12 KBdsutter

Comments

fabianfiorotto created an issue. See original summary.

meichr’s picture

Hi fabanfiorotto,
thanks for reporting. Please give me several days to check this and return to you as I'm currently on the road.
Meichr.

meichr’s picture

Updated!

Hi fabanfiorotto,
finally, I found time to reproduce the behavior you suggested.

I'm using Drupal 8.5.6 and the bundled CKEditor 4.8.0 and ckeditor_indentblock-8.x-1.0-beta1 for checking.

To reproduce the behavior, you also need to add the tags <u class> and <ol class> to the field Allowed HTM tags. In the tested Drupal version and by using the Bartik standard theme the suggested css is overruled by the Drupal provided css which means, we need to add more specifity to the ul.Indent and ol.Indent selectors in the css. Please feel free to suggest a solution.

Thanks again for the find. This is definitly worth to be included with the next release.
Meichr.

dsutter’s picture

StatusFileSize
new1.12 KB

Just wanted to contribute this patch file containing same code as above. I'm not sure that it's the best fix, but at least it gets something into the CKEditor and we can override the indent values in our theme.

idebr’s picture

Indentation of lists works differently in CKEditor:

Before indent:

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
</ul>

After indent:

<ul>
  <li>Item 1</li>
  <ul>
    <li>Item 2</li>
  </ul>
</ul>

If the indented list has no margin, the <ul> element does not have the necessary margin in css.

thejimbirch’s picture

Title: Identate lists » Add support for Indenting lists
thejimbirch’s picture

Status: Active » Reviewed & tested by the community

The patch in #4 applies cleanly and adds support for indenting lists by adding the more CSS specificity.

@idebr Since the module takes over the indent buttons, the same class is applied to the UL/OL and the P, so the normal CKEditor behavior is overridden.

Users may need to add the tags <ul class> and <ol class> to the field Allowed HTML tags. in their Text Formats as specified in #3

Moving to RTBC.

Thanks for the patch @dsutter and the module @meichr!

yuseferi’s picture

#4 works for me on Drupal 9.3 and plugin 4.17.1

  • heddn committed c7799976 on 8.x-1.x authored by dsutter
    Issue #2986139 by dsutter, thejimbirch, heddn: Add support for Indenting...
heddn’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone for your contributions.

Status: Fixed » Closed (fixed)

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