From 41ff141daaeed0cfcdf69cb39ec6f7e240f93166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Thu, 31 Jan 2013 17:17:19 +0100 Subject: [PATCH 1/3] Remember names of features in ACRs registered by them. --- core/editor.js | 4 +++- core/filter.js | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/core/editor.js b/core/editor.js index 59a77540481..567ba5aac32 100644 --- a/core/editor.js +++ b/core/editor.js @@ -557,7 +557,9 @@ * @param {CKEDITOR.commandDefinition} commandDefinition The command definition. */ addCommand: function( commandName, commandDefinition ) { - return this.commands[ commandName ] = new CKEDITOR.command( this, commandDefinition ); + var cmd = new CKEDITOR.command( this, commandDefinition ); + cmd.name = commandName.toLowerCase(); + return this.commands[ commandName ] = cmd; }, /** diff --git a/core/filter.js b/core/filter.js index 56db2271fee..b1065de3445 100644 --- a/core/filter.js +++ b/core/filter.js @@ -72,9 +72,9 @@ this.customConfig = false; // Add editor's default rules. - this.allow( 'p br', 1 ); - this.allow( allowedContent, 1 ); - this.allow( editor.config.extraAllowedContent, 1 ); + this.allow( 'p br', 'default', 1 ); + this.allow( allowedContent, 'config', 1 ); + this.allow( editor.config.extraAllowedContent, 'extra', 1 ); // // Add filter listeners to toHTML and toDataFormat events. @@ -97,7 +97,7 @@ // Rules object passed in editorOrRules argument - initialize standalone filter. else { this.customConfig = false; - this.allow( editorOrRules, 1 ); + this.allow( editorOrRules, 'default', 1 ); } }; @@ -106,12 +106,13 @@ * Adds specified rules to the filter. * * @param {Object/String/CKEDITOR.style/Object[]/String[]/CKEDITOR.style[]} newRules + * @param {String} [featureName] Name of a feature that allows this content. * @param {Boolean} [overrideCustom] By default this method will reject any rules * if default {@link CKEDITOR.config#allowedContent} is defined. Pass `true` * to force rules addition. * @returns {Boolean} Whether rules were accepted. */ - allow: function( newRules, overrideCustom ) { + allow: function( newRules, featureName, overrideCustom ) { if ( this.disabled ) return false; @@ -133,7 +134,7 @@ newRules = convertStyleToRules( newRules ); else if ( CKEDITOR.tools.isArray( newRules ) ) { for ( i = 0; i < newRules.length; ++i ) - ret = this.allow( newRules[ i ], overrideCustom ); + ret = this.allow( newRules[ i ], featureName, overrideCustom ); return ret; // Return last status. } @@ -156,6 +157,9 @@ if ( groupName.charAt( 0 ) != '$' ) rule.elements = groupName; + if ( featureName ) + rule.featureName = featureName.toLowerCase(); + // Save rule and remember to optimize it. this.allowedContent.push( rule ); rulesToOptimize.push( rule ); @@ -297,6 +301,7 @@ * @param feature.allowedContent HTML that can be generated by this feature. * @param feature.requiredContent Minimal HTML that this feature must be allowed to * generate for it to be able to function at all. + * @param {String} feature.name Name of this feature. * @returns {Boolean} Whether this feature can be enabled. */ addFeature: function( feature ) { @@ -313,7 +318,7 @@ // If default configuration (will be checked inside #allow()), // then add allowed content rules. - this.allow( feature.allowedContent ); + this.allow( feature.allowedContent, feature.name ); this.addTransformations( feature.contentTransformations ); this.addContentForms( feature.contentForms ); From ef15e5c1c0c85c1aed06c3dff47a7b091b416d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Fri, 1 Feb 2013 16:51:51 +0100 Subject: [PATCH 2/3] Set command name on definition - like for UI definitions. --- core/editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/editor.js b/core/editor.js index 567ba5aac32..58a8aa0aa72 100644 --- a/core/editor.js +++ b/core/editor.js @@ -557,8 +557,8 @@ * @param {CKEDITOR.commandDefinition} commandDefinition The command definition. */ addCommand: function( commandName, commandDefinition ) { + commandDefinition.name = commandName.toLowerCase(); var cmd = new CKEDITOR.command( this, commandDefinition ); - cmd.name = commandName.toLowerCase(); return this.commands[ commandName ] = cmd; }, From 50d3db01d9a70998904258d45a7df57dbda0b50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Reinmar=20Koszuli=C5=84ski?= Date: Fri, 1 Feb 2013 16:52:18 +0100 Subject: [PATCH 3/3] Pass command, not command definition to editor#addFeature(). --- plugins/liststyle/plugin.js | 10 ++++++---- plugins/tabletools/plugin.js | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/liststyle/plugin.js b/plugins/liststyle/plugin.js index e3f8aab83cb..4e27245684c 100644 --- a/plugins/liststyle/plugin.js +++ b/plugins/liststyle/plugin.js @@ -11,19 +11,21 @@ if ( editor.blockless ) return; - var cmd = new CKEDITOR.dialogCommand( 'numberedListStyle', { + var def, cmd; + + def = new CKEDITOR.dialogCommand( 'numberedListStyle', { requiredContent: 'ol', allowedContent: 'ol{list-style-type}[start]' } ); - editor.addCommand( 'numberedListStyle', cmd ); + cmd = editor.addCommand( 'numberedListStyle', def ); editor.addFeature( cmd ); CKEDITOR.dialog.add( 'numberedListStyle', this.path + 'dialogs/liststyle.js' ); - cmd = new CKEDITOR.dialogCommand( 'bulletedListStyle', { + def = new CKEDITOR.dialogCommand( 'bulletedListStyle', { requiredContent: 'ul', allowedContent: 'ul{list-style-type}' } ); - editor.addCommand( 'bulletedListStyle', cmd ); + cmd = editor.addCommand( 'bulletedListStyle', def ); editor.addFeature( cmd ); CKEDITOR.dialog.add( 'bulletedListStyle', this.path + 'dialogs/liststyle.js' ); diff --git a/plugins/tabletools/plugin.js b/plugins/tabletools/plugin.js index e0e06d0978d..6db205a04d2 100644 --- a/plugins/tabletools/plugin.js +++ b/plugins/tabletools/plugin.js @@ -679,8 +679,8 @@ } }); } - function addCmd( name, cmd ) { - editor.addCommand( name, cmd ); + function addCmd( name, def ) { + var cmd = editor.addCommand( name, def ); editor.addFeature( cmd ); }