Skip to content

Instantly share code, notes, and snippets.

@wimleers
Created March 22, 2013 12:59
Show Gist options
  • Save wimleers/5221057 to your computer and use it in GitHub Desktop.
Save wimleers/5221057 to your computer and use it in GitHub Desktop.
core/modules/ckeditor/js/ckeditor.admin.js | 35 ++++++++--------------------
1 file changed, 10 insertions(+), 25 deletions(-)
diff --git a/core/modules/ckeditor/js/ckeditor.admin.js b/core/modules/ckeditor/js/ckeditor.admin.js
index a483296..7d0d755 100644
--- a/core/modules/ckeditor/js/ckeditor.admin.js
+++ b/core/modules/ckeditor/js/ckeditor.admin.js
@@ -206,43 +206,28 @@ Drupal.behaviors.ckeditorAdmin = {
* Asynchronously retrieve the metadata for all available CKEditor features.
*/
function getCKEditorFeatures(CKEditorConfig, callback) {
- // @todo D8 get rid of this once CKEditor introduces requiredStyles,
- // requiredAttributes and requiredClasses.
- // See http://dev.ckeditor.com/ticket/10191.
- var parseCKEPropertiesList = function(CKEPropertiesList, required, allowed) {
- if (typeof CKEPropertiesList !== 'string') {
- return;
- }
-
- var properties = CKEPropertiesList.split(',');
- for (var i = 0; i < properties.length; i++) {
- var property = properties[i];
- if (property[0] === '!') {
- var actual = property.substring(1);
- allowed.push(actual);
- required.push(actual);
- }
- else {
- allowed.push(property);
- }
- }
+ var getProperties = function(CKEPropertiesList) {
+ return (_.isObject(CKEPropertiesList)) ? _.keys(CKEPropertiesList) : [];
};
-
var convertCKERulesToEditorFeature = function (feature, CKEFeatureRules) {
for (var i = 0; i < CKEFeatureRules.length; i++) {
var CKERule = CKEFeatureRules[i];
var rule = new Drupal.EditorFeatureHTMLRule();
// Tags.
- var tags = CKERule.elements.split(/\W+/);
+ var tags = getProperties(CKERule.elements);
rule.required.tags = (CKERule.propertiesOnly) ? [] : tags;
rule.allowed.tags = tags;
// Attributes.
- parseCKEPropertiesList(CKERule.attributes, rule.required.attributes, rule.allowed.attributes);
+ rule.required.attributes = getProperties(CKERule.requiredAttributes);
+ rule.allowed.attributes = getProperties(CKERule.attributes);
// Styles.
- parseCKEPropertiesList(CKERule.styles, rule.required.styles, rule.allowed.styles);
+ rule.required.styles = getProperties(CKERule.requiredStyles);
+ rule.allowed.styles = getProperties(CKERule.styles);
// Classes.
- parseCKEPropertiesList(CKERule.classes, rule.required.classes, rule.allowed.classes);
+ rule.required.classes = getProperties(CKERule.requiredClasses);
+ rule.allowed.classes = getProperties(CKERule.classes);
+
// Raw.
rule.raw = CKERule;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment