Block Indent by Class Instead of Style

Created on 26 June 2024, 5 months ago
Updated 29 August 2024, 3 months ago

Problem/Motivation

I've attempted to use the block indentation function. It doesn't save because it is adding a style attribute, but styles aren't allowed through the filter. If I try to add style to p in the "Manually editable HTML tags", it throws an error that it is a security risk. The end result is that I can show indented in the editor, but not in the published result.

Steps to reproduce

If it matters, Drupal 10.3.0 and PHP 8.2, although I think I had similar behaviour the first time I tried this on Drupal 10.2.

Enable the Block Indentation module.

Try to indent a paragraph in a node and save it.

Note that the style for the margin has been stripped out and no indent is shown.

Proposed resolution

Instead of adding style="margin", add a class. The ckeditor_indentblock module takes this approach. Along with solving the immediate base functionality problem, that has the added benefit that if a site developer wants to change the size of the indent margin, they can do so easily with a CSS override of the class.

You could even look at merging ckeditor_indentblock into the plugin pack instead of having duplicate functionality.

🐛 Bug report
Status

Fixed

Version

1.1

Component

Code

Created by

🇨🇦Canada ryanrobinson_wlu

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

Comments & Activities

  • Issue created by @ryanrobinson_wlu
  • Status changed to Fixed 3 months ago
  • 🇵🇱Poland dolszewski

    Hi @ryanrobinson_wlu
    We added Block Indent by class in the newest release (1.2.1). Please check if it works for you.

  • 🇩🇪Germany dbielke1986

    @dolszewski:

    Great work because now we can switch to this module, which is perfect.
    The only thing I may would prefer is to move from px to em:

    .cke5-custom-block-indent-1 {
      margin-left: 40px;
    }
    

    vs

    .cke5-custom-block-indent-1 {
      margin-left: 2em;
    }
    

    What do you think about this?

  • 🇨🇦Canada ryanrobinson_wlu

    I would support the use of em instead of px as the default for this. In the context of a CKE block, that will usually make more sense and be adaptable for tools like our accessibility toolbar that allows changing font sizes or spacing.

    I haven't tried the new release yet. We're about to do a new production release so we're frozen on new non-essential changes. But I will definitely try to switch out the existing indentblock module for this after that.

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

Production build 0.71.5 2024