2018-06-17 16:07:19 +00:00
|
|
|
/**
|
|
|
|
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
|
|
|
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
2014-04-11 20:05:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileOverview Defines the "virtual" {@link CKEDITOR.pluginDefinition} class which
|
2018-06-17 16:07:19 +00:00
|
|
|
* contains the defintion of a plugin. This file serves documentation
|
2014-04-11 20:05:45 +00:00
|
|
|
* purposes only.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-06-17 16:07:19 +00:00
|
|
|
* A virtual class that just illustrates the features of plugin objects which are
|
2014-04-11 20:05:45 +00:00
|
|
|
* passed to the {@link CKEDITOR.plugins#add} method.
|
|
|
|
*
|
2018-06-17 16:07:19 +00:00
|
|
|
* This class is not really a part of the API, so its constructor should not be called.
|
|
|
|
*
|
|
|
|
* See also:
|
|
|
|
*
|
|
|
|
* * [The Plugin SDK](#!/guide/plugin_sdk_intro)
|
|
|
|
* * [Creating a CKEditor plugin in 20 Lines of Code](#!/guide/plugin_sdk_sample)
|
|
|
|
* * [Creating a Simple Plugin Tutorial](#!/guide/plugin_sdk_sample_1)
|
2014-04-11 20:05:45 +00:00
|
|
|
*
|
|
|
|
* @class CKEDITOR.pluginDefinition
|
|
|
|
* @abstract
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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', {
|
2018-06-17 16:07:19 +00:00
|
|
|
* requires: 'button,selection'
|
|
|
|
* } );
|
|
|
|
*
|
|
|
|
* Or:
|
|
|
|
*
|
|
|
|
* CKEDITOR.plugins.add( 'sample', {
|
2014-04-11 20:05:45 +00:00
|
|
|
* requires: [ 'button', 'selection' ]
|
|
|
|
* } );
|
|
|
|
*
|
2018-06-17 16:07:19 +00:00
|
|
|
* @property {String/String[]} requires
|
2014-04-11 20:05:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-06-17 16:07:19 +00:00
|
|
|
* The list of language files available for this plugin. These files are stored inside
|
|
|
|
* the `lang` directory in the plugin directory, follow the name
|
2014-04-11 20:05:45 +00:00
|
|
|
* pattern of `langCode.js`, and contain the language definition created with
|
|
|
|
* {@link CKEDITOR.plugins#setLang}.
|
|
|
|
*
|
|
|
|
* When the plugin is being loaded, the editor checks this list to see if
|
2018-06-17 16:07:19 +00:00
|
|
|
* a language file in the current editor language ({@link CKEDITOR.editor#langCode})
|
2014-04-11 20:05:45 +00:00
|
|
|
* is available, and if so, loads it. Otherwise, the file represented by the first item
|
|
|
|
* in the list is loaded.
|
|
|
|
*
|
|
|
|
* CKEDITOR.plugins.add( 'sample', {
|
2018-06-17 16:07:19 +00:00
|
|
|
* lang: 'en,fr'
|
|
|
|
* } );
|
|
|
|
*
|
|
|
|
* Or:
|
|
|
|
*
|
|
|
|
* CKEDITOR.plugins.add( 'sample', {
|
2014-04-11 20:05:45 +00:00
|
|
|
* lang: [ 'en', 'fr' ]
|
|
|
|
* } );
|
|
|
|
*
|
2018-06-17 16:07:19 +00:00
|
|
|
* @property {String/String[]} lang
|
2014-04-11 20:05:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-06-17 16:07:19 +00:00
|
|
|
* 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 {@link CKEDITOR}'s methods such as the {@link CKEDITOR#addCss} method.
|
2014-04-11 20:05:45 +00:00
|
|
|
*
|
|
|
|
* CKEDITOR.plugins.add( 'sample', {
|
2018-06-17 16:07:19 +00:00
|
|
|
* onLoad: function() {
|
|
|
|
* CKEDITOR.addCss( '.cke_some_class { ... }' );
|
|
|
|
* }
|
|
|
|
* } );
|
|
|
|
*
|
|
|
|
* Read more about the initialization order in the {@link #init} method documentation.
|
|
|
|
*
|
|
|
|
* @method onLoad
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A function called on initialization of every editor instance created on the
|
|
|
|
* page before the {@link #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', {
|
2014-04-11 20:05:45 +00:00
|
|
|
* beforeInit: function( editor ) {
|
2018-06-17 16:07:19 +00:00
|
|
|
* 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'
|
2014-04-11 20:05:45 +00:00
|
|
|
* }
|
|
|
|
* } );
|
|
|
|
*
|
2018-06-17 16:07:19 +00:00
|
|
|
* Read more about the initialization order in the {@link #init} method documentation.
|
|
|
|
*
|
2014-04-11 20:05:45 +00:00
|
|
|
* @method beforeInit
|
|
|
|
* @param {CKEDITOR.editor} editor The editor instance being initialized.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-06-17 16:07:19 +00:00
|
|
|
* A function called on initialization of every editor instance created on the page.
|
2014-04-11 20:05:45 +00:00
|
|
|
*
|
|
|
|
* CKEDITOR.plugins.add( 'sample', {
|
|
|
|
* init: function( editor ) {
|
2018-06-17 16:07:19 +00:00
|
|
|
* console.log( 'Editor "' + editor.name + '" is being initialized!' );
|
2014-04-11 20:05:45 +00:00
|
|
|
* }
|
|
|
|
* } );
|
|
|
|
*
|
2018-06-17 16:07:19 +00:00
|
|
|
* Initialization order:
|
|
|
|
*
|
|
|
|
* 1. The {@link #beforeInit} methods of all enabled plugins are executed.
|
|
|
|
* 2. The {@link #init} methods of all enabled plugins are executed.
|
|
|
|
* 3. The {@link #afterInit} methods of all enabled plugins are executed.
|
|
|
|
* 4. The {@link CKEDITOR.editor#pluginsLoaded} event is fired.
|
|
|
|
*
|
|
|
|
* **Note:** The order in which the `init` methods are called does not depend on the plugins' {@link #requires requirements}
|
|
|
|
* or the order set in the {@link CKEDITOR.config#plugins} option. It may be random and therefore it is
|
|
|
|
* recommended to use the {@link #beforeInit} and {@link #afterInit} methods in order to ensure
|
|
|
|
* the right execution sequence.
|
|
|
|
*
|
|
|
|
* See also the {@link #onLoad} method.
|
|
|
|
*
|
2014-04-11 20:05:45 +00:00
|
|
|
* @method init
|
|
|
|
* @param {CKEDITOR.editor} editor The editor instance being initialized.
|
|
|
|
*/
|
|
|
|
|
2018-06-17 16:07:19 +00:00
|
|
|
/**
|
|
|
|
* A function called on initialization of every editor instance created on the
|
|
|
|
* page after the {@link #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 {@link #init} method documentation.
|
|
|
|
*
|
|
|
|
* @method afterInit
|
|
|
|
* @param {CKEDITOR.editor} editor The editor instance being initialized.
|
|
|
|
*/
|
|
|
|
|
2014-04-11 20:05:45 +00:00
|
|
|
/**
|
|
|
|
* 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**)
|
2018-06-17 16:07:19 +00:00
|
|
|
* is the `plugin_name/images/hidpi/` directory.
|
2014-04-11 20:05:45 +00:00
|
|
|
*
|
|
|
|
* This property is optional and only makes sense if `32px x 32px` icons
|
2018-06-17 16:07:19 +00:00
|
|
|
* and high-resolution images actually exist. If this flag is set to `true`, the editor
|
2014-04-11 20:05:45 +00:00
|
|
|
* will automatically detect the HiDPI environment and attempt to load the
|
|
|
|
* high-resolution resources.
|
|
|
|
*
|
|
|
|
* @since 4.2
|
|
|
|
* @property {Boolean} hidpi
|
2018-06-17 16:07:19 +00:00
|
|
|
*/
|