Sfoglia il codice sorgente

Docs: Improved error docs.

Piotrek Koszuliński 8 anni fa
parent
commit
6d30038dad
1 ha cambiato i file con 26 aggiunte e 1 eliminazioni
  1. 26 1
      packages/ckeditor5-core/src/plugincollection.js

+ 26 - 1
packages/ckeditor5-core/src/plugincollection.js

@@ -107,12 +107,23 @@ export default class PluginCollection {
 			 * This is usually done by the builder by setting the {@link module:core/editor/editor~Editor.build}
 			 * This is usually done by the builder by setting the {@link module:core/editor/editor~Editor.build}
 			 * property.
 			 * property.
 			 *
 			 *
+			 * **If you see this warning when using one of the {@glink builds/index CKEditor 5 Builds}** it means
+			 * that you try to enable a plugin which was not included into that build. This may a be due to a typo
+			 * in the plugin name or simply because that plugin is not part of this build. In the latter scenario,
+			 * read more about {@glink builds/guides/development/custom-builds custom builds}.
+			 *
+			 * **If you see this warning when using one of the editor creators directly** (not a build), then it means
+			 * that you tried loading plugins by name. However, unlike CKEditor 4, CKEditor 5 does not implement a "plugin loader".
+			 * This means that CKEditor 5 does not know where to load the plugin modules from. Therefore, you need to
+			 * provide each plugin through reference (as a constructor function). Check out the examples in
+			 * {@glink builds/guides/integration/advanced-setup#Scenario-2-Building-from-source "Building from source"}.
+			 *
 			 * @error plugincollection-plugin-not-found
 			 * @error plugincollection-plugin-not-found
 			 * @param {Array.<String>} plugins The name of the plugins which could not be loaded.
 			 * @param {Array.<String>} plugins The name of the plugins which could not be loaded.
 			 */
 			 */
 			const errorMsg = 'plugincollection-plugin-not-found: Some plugins are not available and could not be loaded.';
 			const errorMsg = 'plugincollection-plugin-not-found: Some plugins are not available and could not be loaded.';
 
 
-			// Log the error so it's more visible on the console. Hopefuly, for better DX.
+			// Log the error so it's more visible on the console. Hopefully, for better DX.
 			log.error( errorMsg, { plugins: missingPlugins } );
 			log.error( errorMsg, { plugins: missingPlugins } );
 
 
 			return Promise.reject( new CKEditorError( errorMsg, { plugins: missingPlugins } ) );
 			return Promise.reject( new CKEditorError( errorMsg, { plugins: missingPlugins } ) );
@@ -136,6 +147,20 @@ export default class PluginCollection {
 					/**
 					/**
 					 * It was not possible to load the plugin.
 					 * It was not possible to load the plugin.
 					 *
 					 *
+					 * This is a generic error logged to the console when a JavaSript error is thrown during one of
+					 * the plugins initialization.
+					 *
+					 * If you correctly handled a promise returned by the editor's `create()` method (like shown below)
+					 * you will find the original error logged on the console too:
+					 *
+					 *		ClassicEditor.create( document.getElementById( 'editor' ) )
+					 *			.then( editor => {
+					 *				// ...
+					 * 			} )
+					 *			.catch( error => {
+					 *				console.error( error );
+					 *			} );
+					 *
 					 * @error plugincollection-load
 					 * @error plugincollection-load
 					 * @param {String} plugin The name of the plugin that could not be loaded.
 					 * @param {String} plugin The name of the plugin that could not be loaded.
 					 */
 					 */