Code Index | File Index

Namespaces

Classes


Class CKEDITOR.command

Represents a command that can be executed on an editor instance.
Extends CKEDITOR.event.
Defined in: core/command.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
CKEDITOR.command(editor, commandDefinition)
Creates a command class instance.
Field Summary
Field Attributes Field Name and Description
 
Indicates that the editor will get the focus before executing the command.
 
The editor modes within which the command can be executed.
 
Indicates the previous command state.
 
Indicates the editor state.
 
Lists UI items that are associated to this command.
Method Summary
Method Attributes Method Name and Description
 
Disables the command for execution.
 
Enables the command for execution.
 
exec(data)
Executes the command.
 
Explicitly update the status of the command, by firing the CKEDITOR.command#event:refresh event, as well as invoke the CKEDITOR.commandDefinition.prototype.refresh method if defined, this method is to allow different parts of the editor code to contribute in command status resolution.
 
setState(newState)
Sets the command state.
 
Toggles the on/off (active/inactive) state of the command.
Methods borrowed from class CKEDITOR.event:
fire, fireOnce, hasListeners, on, removeListener
Event Summary
Event Attributes Event Name and Description
 
Fired when the command state changes.
Class Detail
CKEDITOR.command(editor, commandDefinition)
Since: 3.0
Creates a command class instance.
var command = new CKEDITOR.command( editor,
    {
        exec : function( editor )
        {
            alert( editor.document.getBody().getHtml() );
        }
    });
Parameters:
{CKEDITOR.editor} editor
The editor instance this command will be related to.
{CKEDITOR.commandDefinition} commandDefinition
The command definition.
Field Detail
{Boolean} editorFocus
Since: 3.0
Indicates that the editor will get the focus before executing the command.
// Do not force the editor to have focus when executing the command.
command.editorFocus = false;
Default Value:
true

{Object} modes
Since: 3.0
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.
// Enable the command in both WYSIWYG and Source modes.
command.modes = { wysiwyg : 1, source : 1 };
// Enable the command in Source mode only.
command.modes = { source : 1 };
See:
CKEDITOR.editor.prototype.mode

{Number} previousState
Since: 3.0
Indicates the previous command state.
alert( command.previousState );
See:
#state

{Number} state
Since: 3.0
Indicates the editor state. Possible values are: Do not set this property directly, using the #setState method instead.
if ( command.state == CKEDITOR.TRISTATE_DISABLED )
    alert( 'This command is disabled' );

{Array} uiItems
Since: 3.0
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).
alert( 'Number of UI items associated to this command: ' + command.uiItems.length );
Method Detail
{Undefined} disable()
Since: 3.0
Disables the command for execution. The command state (see CKEDITOR.command.prototype.state) will be set to CKEDITOR.TRISTATE_DISABLED.
command.disable();
command.exec();    // "false" - Nothing happens.

{Undefined} enable()
Since: 3.0
Enables the command for execution. The command state (see CKEDITOR.command.prototype.state) available before disabling it is restored.
command.enable();
command.exec();    // Execute the command.

{Boolean} exec(data)
Since: 3.0
Executes the command.
command.exec();  // The command gets executed.
Parameters:
{Object} data Optional
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.

{Undefined} refresh()
Since: 3.0
Explicitly update the status of the command, by firing the CKEDITOR.command#event:refresh event, as well as invoke the CKEDITOR.commandDefinition.prototype.refresh method if defined, this method is to allow different parts of the editor code to contribute in command status resolution.
NO EXAMPLE AVAILABLE

{Boolean} setState(newState)
Since: 3.0
Sets the command state.
command.setState( CKEDITOR.TRISTATE_ON );
command.exec();    // Execute the command.
command.setState( CKEDITOR.TRISTATE_DISABLED );
command.exec();    // "false" - Nothing happens.
command.setState( CKEDITOR.TRISTATE_OFF );
command.exec();    // Execute the command.
Parameters:
{Number} newState
The new state. See #state.
Returns:
{Boolean} Returns "true" if the command state changed.

{Undefined} toggleState()
Since: 3.0
Toggles the on/off (active/inactive) state of the command. This is mainly used internally by context sensitive commands.
command.toggleState();
Event Detail
state : <object>.on( 'state', function( e ){ ... } )
Since: 3.0
Fired when the command state changes.
command.on( 'state' , function( e )
    {
        // Alerts the new state.
        alert( this.state );
    });
Parameters:
{CKEDITOR.eventInfo} e
The standard event object passed to event listeners.

Copyright © 2003-2010, CKSource - Frederico Knabben. All rights reserved.