Skip to content
Permalink
Browse files

Merge branch 't/10072' into major

  • Loading branch information...
Reinmar committed Feb 20, 2013
2 parents 493f477 + 866b50f commit 013be3c08b04fad69feead3d9b775769a7ecac29
Showing with 22 additions and 9 deletions.
  1. +22 −9 core/command.js
@@ -40,11 +40,7 @@ CKEDITOR.command = function( editor, commandDefinition ) {
* @returns {Boolean} A boolean indicating that the command has been successfully executed.
*/
this.exec = function( data ) {
if ( this.state == CKEDITOR.TRISTATE_DISABLED )
return false;

// Test if this command is allowed.
if ( !editor.filter.checkFeature( this ) )
if ( this.state == CKEDITOR.TRISTATE_DISABLED || !this.checkAllowed() )
return false;

if ( this.editorFocus ) // Give editor focus if necessary (#4355).
@@ -85,6 +81,23 @@ CKEDITOR.command = function( editor, commandDefinition ) {
return ( commandDefinition.refresh && commandDefinition.refresh.apply( this, arguments ) !== false );
};

var allowed;

/**
* Checks whether this command is allowed by the allowed
* content filter ({@link CKEDITOR.filter}). This means
* that if command implements Feature interface it will be tested
* by {@link CKEDITOR.filter.checkFeature}.
*
* @returns {Boolean} Whether command is allowed.
*/
this.checkAllowed = function() {
if ( typeof allowed == 'boolean' )
return allowed;

return allowed = editor.filter.checkFeature( this );
};

CKEDITOR.tools.extend( this, commandDefinition, {
/**
* The editor modes within which the command can be executed. The
@@ -136,9 +149,9 @@ CKEDITOR.command = function( editor, commandDefinition ) {
* if ( command.state == CKEDITOR.TRISTATE_DISABLED )
* alert( 'This command is disabled' );
*
* @property {Number} [=CKEDITOR.TRISTATE_OFF]
* @property {Number} [=CKEDITOR.TRISTATE_DISABLED]
*/
state: CKEDITOR.TRISTATE_OFF
state: CKEDITOR.TRISTATE_DISABLED
});

// Call the CKEDITOR.event constructor to initialize this instance.
@@ -154,7 +167,7 @@ CKEDITOR.command.prototype = {
* command.exec(); // Execute the command.
*/
enable: function() {
if ( this.state == CKEDITOR.TRISTATE_DISABLED )
if ( this.state == CKEDITOR.TRISTATE_DISABLED && this.checkAllowed() )
this.setState( ( !this.preserveState || ( typeof this.previousState == 'undefined' ) ) ? CKEDITOR.TRISTATE_OFF : this.previousState );
},

@@ -184,7 +197,7 @@ CKEDITOR.command.prototype = {
*/
setState: function( newState ) {
// Do nothing if there is no state change.
if ( this.state == newState )
if ( this.state == newState || !this.checkAllowed() )
return false;

this.previousState = this.state;

0 comments on commit 013be3c

Please sign in to comment.
You can’t perform that action at this time.