浏览代码

Improved docs.

Oskar Wróbel 6 年之前
父节点
当前提交
89251b6827
共有 2 个文件被更改,包括 20 次插入10 次删除
  1. 11 1
      packages/ckeditor5-core/src/context.js
  2. 9 9
      packages/ckeditor5-core/src/plugincollection.js

+ 11 - 1
packages/ckeditor5-core/src/context.js

@@ -126,6 +126,11 @@ export default class Context {
 
 		for ( const Plugin of plugins ) {
 			if ( typeof Plugin != 'function' ) {
+				/**
+				 * Only constructor is allowed as a Context plugin.
+				 *
+				 * @error context-initplugins-constructor-only
+				 */
 				throw new CKEditorError(
 					'context-initplugins-constructor-only: Only constructor is allowed as a Context plugin.',
 					null,
@@ -134,6 +139,11 @@ export default class Context {
 			}
 
 			if ( Plugin.isContextPlugin !== true ) {
+				/**
+				 * Only plugin marked as a ContextPlugin is allowed to be used with a context.
+				 *
+				 * @error context-initplugins-invalid-plugin
+				 */
 				throw new CKEditorError(
 					'context-initplugins-invalid-plugin: Only plugin marked as a ContextPlugin is allowed.',
 					null,
@@ -149,7 +159,7 @@ export default class Context {
 	 * Returns context configuration which will be copied to editors created using this context.
 	 *
 	 * The configuration returned by this method has removed plugins configuration - plugins are shared with all editors
-	 * in a special way.
+	 * through another mechanism.
 	 *
 	 * @returns {Object} Configuration as a plain object.
 	 */

+ 9 - 9
packages/ckeditor5-core/src/plugincollection.js

@@ -25,7 +25,7 @@ export default class PluginCollection {
 	 * Allows loading and initializing plugins and their dependencies.
 	 * Allows to provide a list of already loaded plugins, these plugins won't be destroyed along with this collection.
 	 *
-	 * @param {module:core/editor/editor~Editor} editor
+	 * @param {module:core/editor/editor~Editor|module:core/context~Context} context
 	 * @param {Array.<Function>} [availablePlugins] Plugins (constructors) which the collection will be able to use
 	 * when {@link module:core/plugincollection~PluginCollection#init} is used with plugin names (strings, instead of constructors).
 	 * Usually, the editor will pass its built-in plugins to the collection so they can later be
@@ -33,12 +33,12 @@ export default class PluginCollection {
 	 * @param {Iterable.<Array>} externalPlugins List of already initialized plugins represented by a
 	 * `[ PluginConstructor, pluginInstance ]` pair.
 	 */
-	constructor( editor, availablePlugins = [], externalPlugins = [] ) {
+	constructor( context, availablePlugins = [], externalPlugins = [] ) {
 		/**
 		 * @protected
-		 * @type {module:core/editor/editor~Editor}
+		 * @type {module:core/editor/editor~Editor|module:core/context~Context}
 		 */
-		this._editor = editor;
+		this._context = context;
 
 		/**
 		 * @protected
@@ -139,7 +139,7 @@ export default class PluginCollection {
 				pluginName = key.pluginName || key.name;
 			}
 
-			throw new CKEditorError( errorMsg, this._editor, { plugin: pluginName } );
+			throw new CKEditorError( errorMsg, this._context, { plugin: pluginName } );
 		}
 
 		return plugin;
@@ -176,7 +176,7 @@ export default class PluginCollection {
 	 */
 	init( plugins, removePlugins = [] ) {
 		const that = this;
-		const editor = this._editor;
+		const context = this._context;
 		const loading = new Set();
 		const loaded = [];
 
@@ -211,7 +211,7 @@ export default class PluginCollection {
 			// Log the error so it's more visible on the console. Hopefully, for better DX.
 			console.error( attachLinkToDocumentation( errorMsg ), { plugins: missingPlugins } );
 
-			return Promise.reject( new CKEditorError( errorMsg, this._editor, { plugins: missingPlugins } ) );
+			return Promise.reject( new CKEditorError( errorMsg, context, { plugins: missingPlugins } ) );
 		}
 
 		return Promise.all( pluginConstructors.map( loadPlugin ) )
@@ -312,7 +312,7 @@ export default class PluginCollection {
 							throw new CKEditorError(
 								'plugincollection-required: Cannot load a plugin because one of its dependencies is listed in' +
 								'the `removePlugins` option.',
-								editor,
+								context,
 								{ plugin: RequiredPluginConstructor.name, requiredBy: PluginConstructor.name }
 							);
 						}
@@ -321,7 +321,7 @@ export default class PluginCollection {
 					} );
 				}
 
-				const plugin = that._externalPlugins.get( PluginConstructor ) || new PluginConstructor( editor );
+				const plugin = that._externalPlugins.get( PluginConstructor ) || new PluginConstructor( context );
 				that._add( PluginConstructor, plugin );
 				loaded.push( plugin );