.../ckeditor/js/plugins/drupalimage/plugin.js | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js index 05704d5..170585d 100644 --- a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js @@ -94,14 +94,29 @@ }; // Overrides default implementation. Used to populate the "classes" - // property of the widget's "data" property. Is applied to whatever the - // main element of the widget is (
or ). We don't need this - // because we only want those classes to be applied to
, not to - // . And the widget template already contains the necessary classes - // (image2_captionedClass). + // property of the widget's "data" property, which is used for the + // "widget styles" functionality + // (http://docs.ckeditor.com/#!/guide/dev_styles-section-widget-styles). + // Is applied to whatever the main element of the widget is (
or + // ). The classes in image2_captionedClass are always added due to + // a bug in CKEditor. In the case of drupalimage, we don't ever want to + // add that class, because the widget template already contains it. + // @see http://dev.ckeditor.com/ticket/13888 // @see https://www.drupal.org/node/2268941 + var originalGetClasses = widgetDefinition.getClasses; widgetDefinition.getClasses = function () { - return {}; + var classes = originalGetClasses.call(this); + var captionedClasses = (this.editor.config.image2_captionedClass || '').split(/\s+/); + + if (captionedClasses.length && classes) { + for (var i = 0; i < captionedClasses.length; i++) { + if (captionedClasses[i] in classes) { + delete classes[captionedClasses[i]]; + } + } + } + + return classes; }; // Protected; keys of the widget data to be sent to the Drupal dialog.