X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fcore%2Fcommand.js;h=c0868f0f922ae219f6e548705ee3139a2e942988;hb=refs%2Ftags%2Fv3.5.3;hp=bf5341cfeeb97ea0b1fad29161e96d7cbc94b7e3;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/core/command.js b/_source/core/command.js index bf5341c..c0868f0 100644 --- a/_source/core/command.js +++ b/_source/core/command.js @@ -1,18 +1,52 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ +/** + * Creates a command class instance. + * @class Represents a command that can be executed on an editor instance. + * @param {CKEDITOR.editor} editor The editor instance this command will be + * related to. + * @param {CKEDITOR.commandDefinition} commandDefinition The command + * definition. + * @augments CKEDITOR.event + * @example + * var command = new CKEDITOR.command( editor, + * { + * exec : function( editor ) + * { + * alert( editor.document.getBody().getHtml() ); + * } + * }); + */ CKEDITOR.command = function( editor, commandDefinition ) { + /** + * Lists UI items that are associated to this command. This list can be + * used to interact with the UI on command execution (by the execution code + * itself, for example). + * @type Array + * @example + * alert( 'Number of UI items associated to this command: ' + command.uiItems.length ); + */ this.uiItems = []; + /** + * Executes the command. + * @param {Object} [data] Any data to pass to the command. Depends on the + * command implementation and requirements. + * @returns {Boolean} A boolean indicating that the command has been + * successfully executed. + * @example + * command.exec(); // The command gets executed. + */ this.exec = function( data ) { if ( this.state == CKEDITOR.TRISTATE_DISABLED ) return false; - if( this.editorFocus ) // Give editor focus if necessary (#4355). + if ( this.editorFocus ) // Give editor focus if necessary (#4355). editor.focus(); return ( commandDefinition.exec.call( this, editor, data ) !== false ); @@ -20,9 +54,56 @@ CKEDITOR.command = function( editor, commandDefinition ) CKEDITOR.tools.extend( this, commandDefinition, // Defaults + /** @lends CKEDITOR.command.prototype */ { + /** + * The editor modes within which the command can be executed. The + * execution will have no action if the current mode is not listed + * in this property. + * @type Object + * @default { wysiwyg : 1 } + * @see CKEDITOR.editor.prototype.mode + * @example + * // Enable the command in both WYSIWYG and Source modes. + * command.modes = { wysiwyg : 1, source : 1 }; + * @example + * // Enable the command in Source mode only. + * command.modes = { source : 1 }; + */ modes : { wysiwyg : 1 }, - editorFocus : true, + + /** + * Indicates that the editor will get the focus before executing + * the command. + * @type Boolean + * @default true + * @example + * // Do not force the editor to have focus when executing the command. + * command.editorFocus = false; + */ + editorFocus : 1, + + /** + * Indicates the editor state. Possible values are: + *