Problem/Motivation

#1894644: Unidirectional editor configuration -> filter settings syncing ensured that changing the Text Editor's configuration caused filter settings to update also.

#2039163: Update CKEditor library to 4.4 broke that for CKEditor's image plugin.

Proposed resolution

The root cause is the assumption that Drupal (well, I) made: that button names are always identical to command names. This used to be the case at the time, but doesn't hold up, as this regression proves.

Therefore the solution is simple: track which buttons map to which features ("features" ~= "commands").

Remaining tasks

Review.

User interface changes

None, except that things start working again :)

API changes

None.

Data model changes

None.

Original report

I did a fresh install of Drupal 8.0.0-beta11. I enabled the Restricted HTML for both the administrator (unlike basic and full it was disabled by default) and for a new "Writer" role. In the CKEditor confguration the media button is in the toolbar for the Restricted HTML format as well as for the Basic HTML format.

Upon creating a new Article (both as Writer user or as Administrator) the format is set to basic and the media button is displayed in the CKEditor toolbar (the little image icon). However, upon switching to the Restricted HTML format the toolbar changes to reflect the set-up of the Restricted HTML format but the image icon goes missing.

Is there something I overlooked? I can't find any permissions that would affect this and I would expect this issue not to show up for the administrator user.

There are no javascript errors displayed in the console. Nor are there any drupal errors in the recent log messages.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

Which is this "Media" button? Is that a contrib module?

Kingdutch’s picture

Title: Restricted HTML missing Media button » Restricted HTML missing Image button
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active
FileSize
7.29 KB
8.87 KB

It's the button that has href="javascript:void("Image")". Renamed the title to match this.
The only contrib module I have installed is Google Analytics. However, I installed this module well after creating this issue.

I attached two screenshots. One displaying the toolbar with button (Text format Full HTML) and one with the button missing (Text format Restricted HTML). It's to the right of the Blockquote button (it should be anyway).

Wim Leers’s picture

Category: Support request » Bug report
Priority: Normal » Major
Issue summary: View changes
Issue tags: +JavaScript

Please see https://vimeo.com/62160137 — note how the list of allowed HTML tags is being updated when you add new buttons. That should've happened for you as well.

Reproduced. This is what should happen: https://vimeo.com/67687240 … but it does not. The image button is enabled for the Restricted HTML format if you enable CKEditor, but it should remain disabled.

So this broke somehow somewhere along the way :( I'm betting it's one of the Backbone updates.


@Kingdutch: Thanks for your great bug report :) You can fix it by adding <img> to the list of allowed HTML tags, which you can find at the bottom of what you called the CKEditor configuration page.

droplet’s picture

Version: 8.0.0-beta11 » 8.0.x-dev
Issue tags: +CKEditor in core, +ckeditor
FileSize
680 bytes

3 problems

- both drop & drag do not sync.
- drupalimage doesn't match correct command ?

editor.addCommand('editdrupalimage', {

- bad split tag function ( fixed in my patch )

Wim Leers’s picture

Title: Restricted HTML missing Image button » Unidirectional editor configuration -> filter settings syncing breaks when button name does not equal the command name
Issue summary: View changes
Status: Active » Needs review
Issue tags: -ckeditor
Related issues: +#1894644: Unidirectional editor configuration -> filter settings syncing, +#2039163: Update CKEditor library to 4.4
FileSize
4.61 KB

@reinmarpl — CKEditor developer — broke Drupal's automatic updating of text filter configuration in #2039163-32: Update CKEditor library to 4.4 — by changing the command from drupalimage to image. Drupal's JS that is able to do this automatic updating assumed that feature names == button names. But that's no longer true as of that moment. And apparently it was a wrong assumption all along.

This again shows why we very much need automated JS tests! :(

Wim Leers’s picture

  1. +++ b/core/modules/ckeditor/ckeditor.libraries.yml
    @@ -73,3 +73,5 @@ drupal.ckeditor.stylescombo.admin:
    +    # Ensure to run after ckeditor/drupal.ckeditor.admin.
    +    - ckeditor/drupal.ckeditor.admin
    

    This change fixes another bug: the fact that stylescombo's settings changes do not cause the allowed HTML tags to update as expected, because its event listener is created too early. This ensures it runs at the right time.

  2. +++ b/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js
    @@ -52,7 +52,7 @@
    -        widgetDefinition.allowedContent.img.attributes += ',data-align,data-caption';
    +        widgetDefinition.allowedContent.img.attributes += ',!data-align,!data-caption';
    

    This is also strictly speaking not fixing a bug here, but helps fix another issue: [LINK WILL FOLLOW].

    This really is just making things consistent with the drupalimage plugin, which does correctly specify the exclamation points for these required attributes.

    i.e. this ensures that CKEditor knows these attributes are required.

All other changes are directly there to fix the reported bug. The other changes are so small and are also in the area of "make setting syncing work again", so I figured I'd include them here.

Wim Leers’s picture

nod_’s picture

buttonsToFeatures[e.editor.getCommand(featureName).uiItems[0].name] = featureName;

Following doesn't work?

var command = e.editor.getCommand(featureName);
if (command) {
  buttonsToFeatures[command.uiItems[0].name] = featureName;
}

Otherwise, no problem with it.

Wim Leers’s picture

Oops, yes, of course. Manually tested, this also works, as one would expect since the code is equivalent :)

nod_’s picture

Status: Needs review » Reviewed & tested by the community

All good

Dave Reid’s picture

I'm assuming this will affect Entity Embed and URL Embed? I tried testing this and it's not adding drupal-entity to the list of allowed HTML tags for us.

Wim Leers’s picture

#11: It'd only affect it:

  • in the sense that'd it'd fix it again if it was previously working
  • if Entity Embed/URL Embed's CKEditor *button* names are different from the CKEditor *command* names

This cannot ever adversely affect those modules.

If it's not yet working for Entity Embed/URL Embed, then it probably means their CKEditor plugins don't have the necessary metadata set yet. I'm happy to help you fix that.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed f1a0e7c and pushed to 8.0.x. Thanks!

  • alexpott committed f1a0e7c on 8.0.x
    Issue #2510138 by Wim Leers, droplet, Kingdutch, nod_: Unidirectional...

Status: Fixed » Closed (fixed)

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