Commit f1a0e7c0 authored by alexpott's avatar alexpott

Issue #2510138 by Wim Leers, droplet, Kingdutch, nod_: Unidirectional editor...

Issue #2510138 by Wim Leers, droplet, Kingdutch, nod_: Unidirectional editor configuration -> filter settings syncing breaks when button name does not equal the command name
parent 2ecd3534
......@@ -73,3 +73,5 @@ drupal.ckeditor.stylescombo.admin:
- core/jquery.once
- core/drupal.vertical-tabs
- core/drupalSettings
# Ensure to run after ckeditor/drupal.ckeditor.admin.
- ckeditor/drupal.ckeditor.admin
......@@ -47,6 +47,11 @@
*/
hiddenEditorConfig: null,
/**
* A hash that maps buttons to features.
*/
buttonsToFeatures: null,
/**
* A hash, keyed by a feature name, that details CKEditor plugin features.
*/
......
......@@ -52,7 +52,7 @@
// Override requiredContent & allowedContent.
widgetDefinition.requiredContent = 'img[alt,src,width,height,data-entity-type,data-entity-uuid,data-align,data-caption]';
widgetDefinition.allowedContent.img.attributes += ',data-align,data-caption';
widgetDefinition.allowedContent.img.attributes += ',!data-align,!data-caption';
// Override allowedContent setting for the 'caption' nested editable.
// This must match what caption_filter enforces.
......
......@@ -179,17 +179,24 @@
CKEFeatureRulesMap[name].push(rule);
}
// Now convert these to Drupal.EditorFeature objects.
// Now convert these to Drupal.EditorFeature objects. And track which
// buttons are mapped to which features.
// @see getFeatureForButton()
var features = {};
var buttonsToFeatures = {};
for (var featureName in CKEFeatureRulesMap) {
if (CKEFeatureRulesMap.hasOwnProperty(featureName)) {
var feature = new Drupal.EditorFeature(featureName);
convertCKERulesToEditorFeature(feature, CKEFeatureRulesMap[featureName]);
features[featureName] = feature;
var command = e.editor.getCommand(featureName);
if (command) {
buttonsToFeatures[command.uiItems[0].name] = featureName;
}
}
}
callback(features);
callback(features, buttonsToFeatures);
}
});
},
......@@ -213,7 +220,7 @@
// Get a Drupal.editorFeature object that contains all metadata for
// the feature that was just added or removed. Not every feature has
// such metadata.
var featureName = button.toLowerCase();
var featureName = this.model.get('buttonsToFeatures')[button.toLowerCase()];
var featuresMetadata = this.model.get('featuresMetadata');
if (!featuresMetadata[featureName]) {
featuresMetadata[featureName] = new Drupal.EditorFeature(featureName);
......@@ -228,8 +235,13 @@
* @param {object} features
* A map of {@link Drupal.EditorFeature} objects.
*/
disableFeaturesDisallowedByFilters: function (features) {
disableFeaturesDisallowedByFilters: function (features, buttonsToFeatures) {
this.model.set('featuresMetadata', features);
// Store the button-to-feature mapping. Needs to happen only once, because
// the same buttons continue to have the same features; only the rules for
// specific features may change.
// @see getFeatureForButton()
this.model.set('buttonsToFeatures', buttonsToFeatures);
// Ensure that toolbar configuration changes are broadcast.
this.broadcastConfigurationChanges(this.$el);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment