plugindefinition.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or http://ckeditor.com/license
  4. */
  5. /**
  6. * @fileOverview Defines the "virtual" {@link CKEDITOR.pluginDefinition} class which
  7. * contains the defintion of a plugin. This file serves documentation
  8. * purposes only.
  9. */
  10. /**
  11. * A virtual class that just illustrates the features of plugin objects which are
  12. * passed to the {@link CKEDITOR.plugins#add} method.
  13. *
  14. * This class is not really a part of the API, so its constructor should not be called.
  15. *
  16. * See also:
  17. *
  18. * * [The Plugin SDK](#!/guide/plugin_sdk_intro)
  19. * * [Creating a CKEditor plugin in 20 Lines of Code](#!/guide/plugin_sdk_sample)
  20. * * [Creating a Simple Plugin Tutorial](#!/guide/plugin_sdk_sample_1)
  21. *
  22. * @class CKEDITOR.pluginDefinition
  23. * @abstract
  24. */
  25. /**
  26. * A list of plugins that are required by this plugin. Note that this property
  27. * does not determine the loading order of the plugins.
  28. *
  29. * CKEDITOR.plugins.add( 'sample', {
  30. * requires: 'button,selection'
  31. * } );
  32. *
  33. * Or:
  34. *
  35. * CKEDITOR.plugins.add( 'sample', {
  36. * requires: [ 'button', 'selection' ]
  37. * } );
  38. *
  39. * @property {String/String[]} requires
  40. */
  41. /**
  42. * The list of language files available for this plugin. These files are stored inside
  43. * the `lang` directory in the plugin directory, follow the name
  44. * pattern of `langCode.js`, and contain the language definition created with
  45. * {@link CKEDITOR.plugins#setLang}.
  46. *
  47. * When the plugin is being loaded, the editor checks this list to see if
  48. * a language file in the current editor language ({@link CKEDITOR.editor#langCode})
  49. * is available, and if so, loads it. Otherwise, the file represented by the first item
  50. * in the list is loaded.
  51. *
  52. * CKEDITOR.plugins.add( 'sample', {
  53. * lang: 'en,fr'
  54. * } );
  55. *
  56. * Or:
  57. *
  58. * CKEDITOR.plugins.add( 'sample', {
  59. * lang: [ 'en', 'fr' ]
  60. * } );
  61. *
  62. * @property {String/String[]} lang
  63. */
  64. /**
  65. * A function called when the plugin definition is loaded for the first time.
  66. * It is usually used to execute some code once for the entire page,
  67. * for instance code that uses the {@link CKEDITOR}'s methods such as the {@link CKEDITOR#addCss} method.
  68. *
  69. * CKEDITOR.plugins.add( 'sample', {
  70. * onLoad: function() {
  71. * CKEDITOR.addCss( '.cke_some_class { ... }' );
  72. * }
  73. * } );
  74. *
  75. * Read more about the initialization order in the {@link #init} method documentation.
  76. *
  77. * @method onLoad
  78. */
  79. /**
  80. * A function called on initialization of every editor instance created on the
  81. * page before the {@link #init} call task. This feature makes it possible to
  82. * initialize things that could be used in the `init` function of other plugins.
  83. *
  84. * CKEDITOR.plugins.add( 'sample1', {
  85. * beforeInit: function( editor ) {
  86. * editor.foo = 'bar';
  87. * }
  88. * } );
  89. *
  90. * CKEDITOR.plugins.add( 'sample2', {
  91. * init: function( editor ) {
  92. * // This will work regardless of order in which
  93. * // plugins sample1 and sample2 where initialized.
  94. * console.log( editor.foo ); // 'bar'
  95. * }
  96. * } );
  97. *
  98. * Read more about the initialization order in the {@link #init} method documentation.
  99. *
  100. * @method beforeInit
  101. * @param {CKEDITOR.editor} editor The editor instance being initialized.
  102. */
  103. /**
  104. * A function called on initialization of every editor instance created on the page.
  105. *
  106. * CKEDITOR.plugins.add( 'sample', {
  107. * init: function( editor ) {
  108. * console.log( 'Editor "' + editor.name + '" is being initialized!' );
  109. * }
  110. * } );
  111. *
  112. * Initialization order:
  113. *
  114. * 1. The {@link #beforeInit} methods of all enabled plugins are executed.
  115. * 2. The {@link #init} methods of all enabled plugins are executed.
  116. * 3. The {@link #afterInit} methods of all enabled plugins are executed.
  117. * 4. The {@link CKEDITOR.editor#pluginsLoaded} event is fired.
  118. *
  119. * **Note:** The order in which the `init` methods are called does not depend on the plugins' {@link #requires requirements}
  120. * or the order set in the {@link CKEDITOR.config#plugins} option. It may be random and therefore it is
  121. * recommended to use the {@link #beforeInit} and {@link #afterInit} methods in order to ensure
  122. * the right execution sequence.
  123. *
  124. * See also the {@link #onLoad} method.
  125. *
  126. * @method init
  127. * @param {CKEDITOR.editor} editor The editor instance being initialized.
  128. */
  129. /**
  130. * A function called on initialization of every editor instance created on the
  131. * page after the {@link #init} call task. This feature makes it possible to use things
  132. * that were initialized in the `init` function of other plugins.
  133. *
  134. * CKEDITOR.plugins.add( 'sample1', {
  135. * afterInit: function( editor ) {
  136. * // This will work regardless of order in which
  137. * // plugins sample1 and sample2 where initialized.
  138. * console.log( editor.foo ); // 'bar'
  139. * }
  140. * } );
  141. *
  142. * CKEDITOR.plugins.add( 'sample2', {
  143. * init: function( editor ) {
  144. * editor.foo = 'bar';
  145. * }
  146. * } );
  147. *
  148. * Read more about the initialization order in the {@link #init} method documentation.
  149. *
  150. * @method afterInit
  151. * @param {CKEDITOR.editor} editor The editor instance being initialized.
  152. */
  153. /**
  154. * Announces the plugin as HiDPI-ready (optimized for high pixel density screens, e.g. *Retina*)
  155. * by providing high-resolution icons and images. HiDPI icons must be twice as big
  156. * (defaults are `16px x 16px`) and stored under `plugin_name/icons/hidpi/` directory.
  157. *
  158. * The common place for additional HiDPI images used by the plugin (**but not icons**)
  159. * is the `plugin_name/images/hidpi/` directory.
  160. *
  161. * This property is optional and only makes sense if `32px x 32px` icons
  162. * and high-resolution images actually exist. If this flag is set to `true`, the editor
  163. * will automatically detect the HiDPI environment and attempt to load the
  164. * high-resolution resources.
  165. *
  166. * @since 4.2
  167. * @property {Boolean} hidpi
  168. */