The default rich text configuration is unable to be overrided.

Steps to reproduce it at https://rgadp.ply.st/:

Since you are overriding the configuration you expect to see it, I've tried exported the configuration to a new feature and it is not possible to add single extra formats. the same happens with the Underline.

I believe the priority is Major since lot of editors would like to add single tools like this to the wysiwyg.

Comments

acidaniel created an issue. See original summary.

acidaniel’s picture

Issue summary: View changes
balsama’s picture

I was able to reproduce this and added it to our 2.1.4 sprint.

phenaproxima’s picture

Confirmed, and I agree that this is major. Will work on it.

phenaproxima’s picture

I talked about this extensively with @Wim Leers, who knows the Editor, CKEditor, and Filter modules inside and out.

The problem here basically boils down to the Allowed HTML filter, which is enabled with the Rich Text format in Lightning, and which exerts a strong influence on which buttons actually show up in any given editor instance, and which can under certain circumstances disregard the way the editor has been configured by the site builder. Therefore, the quick workaround here is to totally disable the Allowed HTML filter -- but that is a dangerous idea because it's a potential security hazard, and emphatically not recommended.

The point here is that some buttons will work, and some will not. The alignment buttons, in particular, are known to be broken: #2649546: [upstream] Alignment/justify buttons not appearing for CKEditor, <p class="text-align-left text-align-center text-align-right text-align-justify"> not being allowed automatically.

A major part of the problem, as Wim explained, is that these parts of core have next to zero JavaScript test coverage, which would likely have caught such problems early on...but JavaScript testing did not come to core until Drupal 8.1.0. So this stuff is way older than any JavaScript tests. Another aspect of it is that the problem may be due to a bug or as-yet unknown regression in CKEditor. Or, it might be due to a bug in Drupal itself. Without JavaScript test coverage, we simply can't be certain.

Wim sent me to the related issues I am attaching to this comment. He also said that three things would be incredibly valuable towards fixing this:

  1. Write a JavaScript test to prove that adding the Underline button to the editor toolbar will automatically update the Allowed HTML filter configuration so that it allows the <u> tag.
  2. Write another JavaScript test to prove that adding any (or all) of the alignment buttons does NOT update the Allowed HTML filter configuration appropriately, even though it should. This would be our regression test for when we...
  3. ...actually fix the bug, either in core or CKEditor itself, depending on where it originates.

In any event, it seems pretty clear that the problem here is core, not Lightning itself. Therefore, I'm closing it. Even though it doesn't work as intended, this is not a problem that Lightning itself is introducing. It would be helpful to follow the related issues, and hopefully write tests and work towards fixing them all. I'm not sure that Lightning will be able to devote time to this -- there is just too much on our plate and never enough resources. But it is at least worth documenting all of this here.

balsama’s picture

To be clear, the simple workaround here is to whitelist the HTML tags in your Allowed HTML tags filter settings. For example, if you want to include the justify left, center, and right buttons, you will also need to add the classes used by those buttons to the p tag like this:

<p class="text-align-left text-align-center text-align-right">

The core issues referenced above are about automatically whitelisting tags when buttons are added.

acidaniel’s picture

@balsama's Workaround works I tested.