Problem/Motivation
DrupalMedia plugin's plugin.js has this code:
this.element.setAttributes(this.data.attributes);
This unfortunately doesn't unset attributes such as 'data-align' as one would expect. If in the dialog, you set 'data-align' to 'none', one expects that it's removed from the embed. While it does remove it from the downcast embed, it doesn't remove it from the drupal-media element inside the widget. It doesn't unset previously set attributes.
This is a blocker for #3072279: Stop generating align-* classes for preview in DrupalMedia CKEditor plugin
this.element is a CKEDITOR.dom.element:
window.CKEDITOR.window.CKEDITOR.dom.CKEDITOR.dom.element {$: drupal-media.cke_widget_element}
$: drupal-media.cke_widget_element
...
attributes: NamedNodeMap
0: data-cke-widget-data
1: data-cke-widget-upcasted
2: data-cke-widget-keep-attr
3: data-widget
4: class
5: data-view-mode
6: data-caption
7: data-entity-type
8: data-entity-uuid
9: data-align
...
Proposed resolution
I think we need to iterate through the old data attributes and remove them (this.oldData.attributes
in drupalmedia plugin.js)
If you try this.element.removeAttributes()
and then set the attributes, CKEditor blows up, because some of the attributes are internal to CKEditor.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#2 | 3084340-2.patch | 4.87 KB | oknate |
#2 | 3084340-2--FAIL.patch | 1.21 KB | oknate |
Comments
Comment #2
oknateHere's a patch to fix it.
Comment #3
oknateComment #5
Wim LeersComment #6
larowlanCommitted b1f525d and pushed to 8.8.x. Thanks!
Comment #8
oknateThanks!
Comment #9
Wim LeersThis unblocked #3072279: Stop generating align-* classes for preview in DrupalMedia CKEditor plugin.