CKEDITOR.plugins.indent.specificDefinition
A base class for specific indentation command definitions responsible for handling a pre-defined set of elements i.e. indentlist for lists or indentblock for text block elements.
Commands of this class perform indentation operations and modify the DOM structure. They listen for events fired by CKEDITOR.plugins.indent.genericDefinition and execute defined actions.
NOTE: This is not an editor command. Context-specific commands are internal, for indentation system only.
Filtering
Properties
-
database : ObjectCKEDITOR.plugins.indent.specificDefinition#databaseStores created markers for the command so they can eventually be purged after the
execfunction is run.Defaults to
{} -
Determines whether the editor that the command belongs to has config.enterMode set to CKEDITOR.ENTER_BR.
Defaults to
false -
A keystroke associated with this command (Tab or Shift+Tab).
-
Determines whether the command belongs to the indentation family. Otherwise it is assumed to be an outdenting command.
Defaults to
false -
An object of jobs handled by the command. Each job consists of two functions:
refreshandexecas well as the execution priority.The
refreshfunction determines whether a job is doable for a particular context. These functions are executed in the order of priorities, one by one, for all plugins that registered jobs. As jobs are related to generic commands, refreshing occurs when the global command is firing therefreshevent.Note: This function must return either CKEDITOR.TRISTATE_DISABLED or CKEDITOR.TRISTATE_OFF.
The
execfunction modifies the DOM if possible. Just likerefresh,execfunctions are executed in the order of priorities while the generic command is executed. This function is not executed ifrefreshfor this job returned CKEDITOR.TRISTATE_DISABLED.Note: This function must return a Boolean value, indicating whether it was successful. If a job was successful, then no other jobs are being executed.
Sample definition:
command.jobs = { // Priority = 20. '20': { refresh( editor, path ) { if ( condition ) return CKEDITOR.TRISTATE_OFF; else return CKEDITOR.TRISTATE_DISABLED; }, exec( editor ) { // DOM modified! This was OK. return true; } }, // Priority = 60. This job is done later. '60': { // Another job. } };For additional information, please check comments for the
setupGenericListenersfunction.Defaults to
{} -
The name of the global command related to this one.
Methods
-
execJob( editor, priority ) → BooleanCKEDITOR.plugins.indent.specificDefinition#execJobExecutes the content-specific procedure if the context is correct. It calls the
execfunction of a job of the givenprioritythat modifies the DOM.Parameters
editor : editorThe editor instance this command will be applied to.
priority : NumberThe priority of the job to be executed.
Returns
BooleanIndicates whether the job was successful.
-
getContext( node ) → elementCKEDITOR.plugins.indent.specificDefinition#getContextChecks if the element path contains the element handled by this indentation command.
Parameters
node : elementPathA path to be checked.
Returns
element
-
refreshJob( editor, priority ) → NumberCKEDITOR.plugins.indent.specificDefinition#refreshJobCalls the
refreshfunction of a job of the givenpriority. The function returns the state of the job which can be either CKEDITOR.TRISTATE_DISABLED or CKEDITOR.TRISTATE_OFF.Parameters
editor : editorThe editor instance this command will be applied to.
priority : NumberThe priority of the job to be executed.
Returns
NumberThe state of the job.
-
private
setupGenericListeners( command )CKEDITOR.plugins.indent.specificDefinition#setupGenericListenersAttaches event listeners for this generic command. Since the indentation system is event-oriented, generic commands communicate with content-specific commands using the
execandrefreshevents.Listener priorities are crucial. Different indentation phases are executed with different priorities.
For the
execevent:- 0: Selection and bookmarks are saved by the generic command.
- 1-99: Content-specific commands try to indent the code by executing their own jobs (jobs).
- 100: Bookmarks are re-selected by the generic command.
The visual interpretation looks as follows:
+------------------+ | Exec event fired | +------ + ---------+ | 0 -<----------+ Selection and bookmarks saved. | | 25 -<---+ Exec 1st job of plugin#1 (return false, continuing...). | | 50 -<---+ Exec 1st job of plugin#2 (return false, continuing...). | | 75 -<---+ Exec 2nd job of plugin#1 (only if plugin#2 failed). | | 100 -<-----------+ Re-select bookmarks, clean-up. | +-------- v ----------+ | Exec event finished | +---------------------+For the
refreshevent:- <100: Content-specific commands refresh their job states according
to the given path. Jobs save their states in the
evt.data.statesobject passed along with the event. This can be either CKEDITOR.TRISTATE_DISABLED or CKEDITOR.TRISTATE_OFF. 100: Command state is determined according to what states have been returned by content-specific jobs (
evt.data.states). UI elements are updated at this stage.Note: If there is at least one job with the CKEDITOR.TRISTATE_OFF state, then the generic command state is also CKEDITOR.TRISTATE_OFF. Otherwise, the command state is CKEDITOR.TRISTATE_DISABLED.
Parameters
command : commandThe command to be set up.