Преглед изворни кода

Docs: Added ConfigOptions interface so we can list configuration options. [skip ci]

Piotrek Koszuliński пре 8 година
родитељ
комит
a845205f68

+ 101 - 0
packages/ckeditor5-core/src/editor/configoptions.jsdoc

@@ -0,0 +1,101 @@
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/**
+ * @module core/editor/configoptions
+ */
+
+/**
+ * The {@link module:core/editor/editor~Editor editor}'s configuration options.
+ *
+ * The object defining editor configuration can be passed when initializing the editor:
+ *
+ *		EditorClass
+ *			.create( {
+ * 				toolbar: [ 'bold', 'italic' ],
+ *				image: {
+ *					styles: [
+ *						...
+ *					]
+ *				}
+ * 			} )
+ *			.then( ... )
+ *			.catch( ... );
+ *
+ * @interface ConfigOptions
+ */
+
+/**
+ * The list of plugins to load.
+ *
+ * If you use an {@link builds/guides/overview editor build} you can define the list of plugins to load
+ * using names of plugins which are available:
+ *
+ *		const config = {
+ *			plugins: [ 'Bold', 'Italic', 'Typing', 'Enter', ... ]
+ *		};
+ *
+ * You can check the list of plugins available in a build using this snippet:
+ *
+ *		ClassicEditor.build.plugins.map( plugin => plugin.pluginName );
+ *
+ * If you use an editor creator directly (imported from a package like `@ckeditor/ckeditor5-editor-classic`) or you
+ * want to load additional plugins which were not included in a build you use, then you need to specify
+ * the plugins using their constructors:
+ *
+ *		// A preset of plugins is a plugin as well.
+ *		import EssentialsPreset from '@ckeditor/ckeditor5-presets/src/essentials';
+ *		// The bold plugin.
+ *		import Bold from '@ckeditor/ckeditor5-editor-basic-styles/src/bold';
+ *
+ *		const config = {
+ *			plugins: [ EssentialsPreset, Bold ]
+ *		};
+ *
+ * @member {Array.<String|Function>} module:core/editor/configoptions~ConfigOptions#plugins
+ */
+
+/**
+ * The list of plugins which should not be loaded despite being available in an {@link builds/guides/overview editor build}.
+ *
+ *		const config = {
+ *			removePlugins: [ 'Bold', 'Italic' ]
+ *		};
+ *
+ * @member {Array.<String>} module:core/editor/configoptions~ConfigOptions#removePlugins
+ */
+
+/**
+ * Editor toolbar configuration.
+ *
+ * Simple format (specifies only toolbar items):
+ *
+ *		const config = {
+ *			toolbar: [ 'bold', 'italic', 'undo', 'redo' ]
+ *		};
+ *
+ * Advanced format:
+ *
+ *		const config = {
+ *			toolbar: {
+ *				items: [ 'bold', 'italic', 'undo', 'redo' ],
+ *
+ *				viewportTopOffset: 30
+ *			}
+ *		};
+ *
+ * Options which can be set using the advanced format:
+ *
+ * * `items` – Array of toolbar items names. The components which can be used as toolbar items are defined in
+ * `editor.ui.componentFactory` and can be listed using the following snippet:
+ *
+ *		Array.from( editor.ui.componentFactory.names );
+ *
+ * * `viewportTopOffset` – The offset (in pixels) from the top of the viewport used when positioning a sticky toolbar.
+ * Useful when a page with which the editor is being integrated has some other sticky or fixed elements
+ * (e.g. the top menu). Thanks to setting the toolbar offset the toolbar won't be positioned underneath or above the page's UI.
+ *
+ * @member {Object} module:core/editor/configoptions~ConfigOptions#toolbar
+ */

+ 2 - 1
packages/ckeditor5-core/src/editor/editor.js

@@ -196,7 +196,8 @@ export default class Editor {
 	/**
 	 * Creates a basic editor instance.
 	 *
-	 * @param {Object} config See {@link module:core/editor/editor~Editor}'s param.
+	 * @param {Object} config The editor config. You can find the list of config options in
+	 * {@link module:core/editor/configoptions~ConfigOptions}.
 	 * @returns {Promise} Promise resolved once editor is ready.
 	 * @returns {module:core/editor/editor~Editor} return.editor The editor instance.
 	 */

+ 2 - 1
packages/ckeditor5-core/src/editor/standardeditor.js

@@ -107,7 +107,8 @@ export default class StandardEditor extends Editor {
 	 * Creates a standard editor instance.
 	 *
 	 * @param {HTMLElement} element See {@link module:core/editor/standardeditor~StandardEditor}'s param.
-	 * @param {Object} config See {@link module:core/editor/standardeditor~StandardEditor}'s param.
+	 * @param {Object} config The editor config. You can find the list of config options in
+	 * {@link module:core/editor/configoptions~ConfigOptions}.
 	 * @returns {Promise} Promise resolved once editor is ready.
 	 * @returns {module:core/editor/standardeditor~StandardEditor} return.editor The editor instance.
 	 */