CKEditor 4 Documentation

CKEDITOR.pluginDefinition

Files

A virtual class that just illustrates the features of plugin objects which are passed to the CKEDITOR.plugins.add method.

This class is not really a part of the API, so its constructor should not be called.

See also:

Defined By

Properties

CKEDITOR.pluginDefinition
view source
: Boolean
Announces the plugin as HiDPI-ready (optimized for high pixel density screens, e.g. ...

Announces the plugin as HiDPI-ready (optimized for high pixel density screens, e.g. Retina) by providing high-resolution icons and images. HiDPI icons must be twice as big (defaults are 16px x 16px) and stored under plugin_name/icons/hidpi/ directory.

The common place for additional HiDPI images used by the plugin (but not icons) is the plugin_name/images/hidpi/ directory.

This property is optional and only makes sense if 32px x 32px icons and high-resolution images actually exist. If this flag is set to true, the editor will automatically detect the HiDPI environment and attempt to load the high-resolution resources.

Available since: 4.2

CKEDITOR.pluginDefinition
view source
: String/String[]
The list of language files available for this plugin. ...

The list of language files available for this plugin. These files are stored inside the lang directory in the plugin directory, follow the name pattern of langCode.js, and contain the language definition created with CKEDITOR.plugins.setLang.

When the plugin is being loaded, the editor checks this list to see if a language file in the current editor language (CKEDITOR.editor.langCode) is available, and if so, loads it. Otherwise, the file represented by the first item in the list is loaded.

CKEDITOR.plugins.add( 'sample', {
    lang: 'en,fr'
} );

Or:

CKEDITOR.plugins.add( 'sample', {
    lang: [ 'en', 'fr' ]
} );
CKEDITOR.pluginDefinition
view source
: String/String[]
A list of plugins that are required by this plugin. ...

A list of plugins that are required by this plugin. Note that this property does not determine the loading order of the plugins.

CKEDITOR.plugins.add( 'sample', {
    requires: 'button,selection'
} );

Or:

CKEDITOR.plugins.add( 'sample', {
    requires: [ 'button', 'selection' ]
} );
Defined By

Methods

CKEDITOR.pluginDefinition
view source
( editor )
A function called on initialization of every editor instance created on the page after the init call task. ...

A function called on initialization of every editor instance created on the page after the init call task. This feature makes it possible to use things that were initialized in the init function of other plugins.

CKEDITOR.plugins.add( 'sample1', {
    afterInit: function( editor ) {
        // This will work regardless of order in which
        // plugins sample1 and sample2 where initialized.
        console.log( editor.foo ); // 'bar'
    }
} );

CKEDITOR.plugins.add( 'sample2', {
    init: function( editor ) {
        editor.foo = 'bar';
    }
} );

Read more about the initialization order in the init method documentation.

Parameters

CKEDITOR.pluginDefinition
view source
( editor )
A function called on initialization of every editor instance created on the page before the init call task. ...

A function called on initialization of every editor instance created on the page before the init call task. This feature makes it possible to initialize things that could be used in the init function of other plugins.

CKEDITOR.plugins.add( 'sample1', {
    beforeInit: function( editor ) {
        editor.foo = 'bar';
    }
} );

CKEDITOR.plugins.add( 'sample2', {
    init: function( editor ) {
        // This will work regardless of order in which
        // plugins sample1 and sample2 where initialized.
        console.log( editor.foo ); // 'bar'
    }
} );

Read more about the initialization order in the init method documentation.

Parameters

CKEDITOR.pluginDefinition
view source
( editor )
A function called on initialization of every editor instance created on the page. ...

A function called on initialization of every editor instance created on the page.

CKEDITOR.plugins.add( 'sample', {
    init: function( editor ) {
        console.log( 'Editor "' + editor.name + '" is being initialized!' );
    }
} );

Initialization order:

  1. The beforeInit methods of all enabled plugins are executed.
  2. The init methods of all enabled plugins are executed.
  3. The afterInit methods of all enabled plugins are executed.
  4. The CKEDITOR.editor.pluginsLoaded event is fired.

Note: The order in which the init methods are called does not depend on the plugins' requirements or the order set in the CKEDITOR.config.plugins option. It may be random and therefore it is recommended to use the beforeInit and afterInit methods in order to ensure the right execution sequence.

See also the onLoad method.

Parameters

CKEDITOR.pluginDefinition
view source
( )
A function called when the plugin definition is loaded for the first time. ...

A function called when the plugin definition is loaded for the first time. It is usually used to execute some code once for the entire page, for instance code that uses the CKEDITOR's methods such as the CKEDITOR.addCss method.

CKEDITOR.plugins.add( 'sample', {
    onLoad: function() {
        CKEDITOR.addCss( '.cke_some_class { ... }' );
    }
} );

Read more about the initialization order in the init method documentation.