CKEDITOR.pluginDefinition
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:
Filtering
Properties
-
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 underplugin_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 totrue
, the editor will automatically detect the HiDPI environment and attempt to load the high-resolution resources. -
icons : String
CKEDITOR.pluginDefinition#icons
The list of icon files registered by this plugin. These files are stored inside the
icons
directory in the plugin directory and follow the name pattern ofname.png
.CKEDITOR.plugins.add( 'sample', { icons: 'first,second' } );
-
lang : String | String[]
CKEDITOR.pluginDefinition#lang
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 oflangCode.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' ] } );
-
requires : String | String[]
CKEDITOR.pluginDefinition#requires
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' ] } );
Methods
-
afterInit( editor )
CKEDITOR.pluginDefinition#afterInit
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
editor : editor
The editor instance being initialized.
-
beforeInit( editor )
CKEDITOR.pluginDefinition#beforeInit
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
editor : editor
The editor instance being initialized.
-
init( editor )
CKEDITOR.pluginDefinition#init
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:
- The beforeInit methods of all enabled plugins are executed.
- The init methods of all enabled plugins are executed.
- The afterInit methods of all enabled plugins are executed.
- 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
editor : editor
The editor instance being initialized.
-
since 4.12.0
isSupportedEnvironment( editor ) → Boolean
CKEDITOR.pluginDefinition#isSupportedEnvironment
A function that should be implemented if a plugin is not supported in every available environment according to Browser Compatibility or a specific editor configuration.
This function will not be called by the plugin loader itself and it is not required for a proper plugin initialization. However, it is recommended to implement the function if a plugin has environment requirements. This information may be important for related features and the testing environment.
CKEDITOR.plugins.add( 'sample', { isSupportedEnvironment: function( editor ) { // A plugin supported only in modern browsers. return !CKEDITOR.env.ie || CKEDITOR.env.edge; } } );
Parameters
editor : editor
Returns
Boolean
Information whether the plugin is supported in the current environment.
-
onLoad()
CKEDITOR.pluginDefinition#onLoad
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.