Sfoglia il codice sorgente

Removed Feature class and concept. Hurray!

Piotrek Koszuliński 9 anni fa
parent
commit
022a98b68b

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

@@ -97,7 +97,7 @@ export default class Editor {
 	}
 
 	/**
-	 * Loads and initializes plugins specified in config features.
+	 * Loads and initializes plugins specified in the config.
 	 *
 	 * @returns {Promise} A promise which resolves once the initialization is completed.
 	 */
@@ -109,9 +109,7 @@ export default class Editor {
 			.then( initPlugins );
 
 		function loadPlugins() {
-			let plugins = config.get( 'features' ) || [];
-
-			return that.plugins.load( plugins );
+			return that.plugins.load( config.get( 'plugins' ) || [] );
 		}
 
 		function initPlugins( loadedPlugins ) {

+ 5 - 6
packages/ckeditor5-core/src/editor/editorui.jsdoc

@@ -17,17 +17,16 @@
  */
 
 /**
- * Instance of the {@link ui.ComponentFactory}, a registry used by features
- * to register and create instance of UI components.
+ * Instance of the {@link ui.ComponentFactory}, a registry used by plugins
+ * to register factories of specific UI components.
  *
  * @readonly
- * @member {ui.ComponentFactory} core.editor.EditorUI#featureComponents
+ * @member {ui.ComponentFactory} core.editor.EditorUI#componentFactory
  */
 
 /**
- * Keeps information about editor UI focus and propagates it among
- * various features and components, unifying them in a uniform
- * focus group.
+ * Keeps information about editor UI focus and propagates it among various plugins and components,
+ * unifying them in a uniform focus group.
  *
  * @readonly
  * @member {utils.FocusTracker} core.editor.EditorUI#focusTracker

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

@@ -50,8 +50,8 @@ export default class StandardEditor extends Editor {
 		 * Editor UI instance.
 		 *
 		 * This property is set by more specialized editor constructors. However, it's required
-		 * for features to work (their UI-related part will try to interact with editor UI),
-		 * so every editor class which is meant to work with default features should set this property.
+		 * for plugins to work (their UI-related part will try to interact with editor UI),
+		 * so every editor class which is meant to work with default plugins should set this property.
 		 *
 		 * @readonly
 		 * @member {core.editor.EditorUI} core.editor.StandardEditor#ui

+ 0 - 20
packages/ckeditor5-core/src/feature.js

@@ -1,20 +0,0 @@
-/**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-import Plugin from './plugin.js';
-
-/**
- * The base class for CKEditor feature classes. Features are main way to enhance CKEditor abilities with tools,
- * utilities, services and components.
- *
- * The main responsibilities for Feature are:
- * * setting required dependencies (see {@link core.Plugin#requires},
- * * configuring, instantiating and registering commands to editor,
- * * registering converters to editor (if the feature operates on Tree Model),
- * * setting and registering UI components (if the feature uses it).
- *
- * @memberOf core
- */
-export default class Feature extends Plugin {}

+ 2 - 2
packages/ckeditor5-core/src/keystrokehandler.js

@@ -7,10 +7,10 @@ import EmitterMixin from '../utils/emittermixin.js';
 import { getCode, parseKeystroke } from '../utils/keyboard.js';
 
 /**
- * Keystroke handler. Its instance is available in {@link core.editor.Editor#keystrokes} so features
+ * Keystroke handler. Its instance is available in {@link core.editor.Editor#keystrokes} so plugins
  * can register their keystrokes.
  *
- * E.g. an undo feature would do this:
+ * E.g. an undo plugin would do this:
  *
  *		editor.keystrokes.set( 'ctrl + Z', 'undo' );
  *		editor.keystrokes.set( 'ctrl + shift + Z', 'redo' );

+ 5 - 1
packages/ckeditor5-core/src/plugin.js

@@ -20,6 +20,8 @@ export default class Plugin {
 	 */
 	constructor( editor ) {
 		/**
+		 * The editor instance.
+		 *
 		 * @readonly
 		 * @member {core.editor.Editor} core.Plugin#editor
 		 */
@@ -33,7 +35,7 @@ export default class Plugin {
 	 *
 	 *		import Image from './image.js';
 	 *
-	 *		export default class ImageCaption extends Feature {
+	 *		export default class ImageCaption extends Plugin {
      *			static get requires() {
      *				return [ Image ];
      *			}
@@ -44,6 +46,8 @@ export default class Plugin {
 	 */
 
 	/**
+	 * Initializes the plugin.
+	 *
 	 * @returns {null|Promise}
 	 */
 	init() {}

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

@@ -107,7 +107,7 @@ export default class PluginCollection {
 		function assertIsPlugin( PluginConstructor ) {
 			if ( !( PluginConstructor.prototype instanceof Plugin ) ) {
 				/**
-				 * The loaded plugin module is not an instance of Plugin.
+				 * The loaded plugin module is not an instance of {@link core.Plugin}.
 				 *
 				 * @error plugincollection-instance
 				 * @param {*} plugin The constructor which is meant to be loaded as a plugin.

+ 3 - 3
packages/ckeditor5-core/tests/_utils-tests/classictesteditor.js

@@ -8,7 +8,7 @@
 import StandardEditor from 'ckeditor5/core/editor/standardeditor.js';
 import ClassicTestEditor from 'tests/core/_utils/classictesteditor.js';
 
-import Feature from 'ckeditor5/core/feature.js';
+import Plugin from 'ckeditor5/core/plugin.js';
 import HtmlDataProcessor from 'ckeditor5/engine/dataprocessor/htmldataprocessor.js';
 
 import ClassicTestEditorUI from 'tests/core/_utils/classictesteditorui.js';
@@ -69,13 +69,13 @@ describe( 'ClassicTestEditor', () => {
 		it( 'loads data from the editor element', () => {
 			editorElement.innerHTML = 'foo';
 
-			class FeatureTextInRoot extends Feature {
+			class PluginTextInRoot extends Plugin {
 				init() {
 					this.editor.document.schema.allow( { name: '$text', inside: '$root' } );
 				}
 			}
 
-			return ClassicTestEditor.create( editorElement, { features: [ FeatureTextInRoot ] } )
+			return ClassicTestEditor.create( editorElement, { plugins: [ PluginTextInRoot ] } )
 				.then( editor => {
 					expect( getData( editor.document, { withoutSelection: true } ) ).to.equal( 'foo' );
 				} );

+ 2 - 2
packages/ckeditor5-core/tests/_utils-tests/classictesteditorui.js

@@ -28,8 +28,8 @@ describe( 'ClassicTestEditorUI', () => {
 			expect( ui.view ).to.equal( view );
 		} );
 
-		it( 'creates #featureComponents factory', () => {
-			expect( ui.featureComponents ).to.be.instanceOf( ComponentFactory );
+		it( 'creates #componentFactory factory', () => {
+			expect( ui.componentFactory ).to.be.instanceOf( ComponentFactory );
 		} );
 
 		it( 'creates #focusTracker', () => {

+ 3 - 3
packages/ckeditor5-core/tests/_utils/classictesteditorui.js

@@ -7,7 +7,7 @@ import ComponentFactory from 'ckeditor5/ui/componentfactory.js';
 import FocusTracker from 'ckeditor5/utils/focustracker.js';
 
 /**
- * A simplified classic editor ui class. Useful for testing features.
+ * A simplified classic editor UI class. Useful for testing features.
  *
  * @memberOf tests.core._utils
  * @extends ui.View
@@ -40,9 +40,9 @@ export default class ClassicTestEditorUI {
 		 * Instance of the {@link ui.ComponentFactory}.
 		 *
 		 * @readonly
-		 * @member {ui.ComponentFactory} tests.core._utils.ClassicTestEditorUI#featureComponents
+		 * @member {ui.ComponentFactory} tests.core._utils.ClassicTestEditorUI#componentFactory
 		 */
-		this.featureComponents = new ComponentFactory( editor );
+		this.componentFactory = new ComponentFactory( editor );
 
 		/**
 		 * Keeps information about editor focus.

+ 5 - 5
packages/ckeditor5-core/tests/editor/editor.js

@@ -76,7 +76,7 @@ describe( 'Editor', () => {
 
 		it( 'loads plugins', () => {
 			return Editor.create( {
-					features: [ PluginA ]
+					plugins: [ PluginA ]
 				} )
 				.then( editor => {
 					expect( getPlugins( editor ).length ).to.equal( 1 );
@@ -87,9 +87,9 @@ describe( 'Editor', () => {
 	} );
 
 	describe( 'initPlugins', () => {
-		it( 'should load features', () => {
+		it( 'should load plugins', () => {
 			const editor = new Editor( {
-				features: [ PluginA, PluginB ]
+				plugins: [ PluginA, PluginB ]
 			} );
 
 			expect( getPlugins( editor ) ).to.be.empty;
@@ -104,7 +104,7 @@ describe( 'Editor', () => {
 
 		it( 'should initialize plugins in the right order', () => {
 			const editor = new Editor( {
-				features: [ PluginA, PluginD ]
+				plugins: [ PluginA, PluginD ]
 			} );
 
 			return editor.initPlugins().then( () => {
@@ -148,7 +148,7 @@ describe( 'Editor', () => {
 			}
 
 			const editor = new Editor( {
-				features: [ PluginA, PluginSync ]
+				plugins: [ PluginA, PluginSync ]
 			} );
 
 			return editor.initPlugins().then( () => {

+ 4 - 4
packages/ckeditor5-core/tests/editor/standardeditor.js

@@ -12,7 +12,7 @@ import { getData, setData } from 'ckeditor5/engine/dev-utils/model.js';
 
 import EditingController from 'ckeditor5/engine/controller/editingcontroller.js';
 import KeystrokeHandler from 'ckeditor5/core/keystrokehandler.js';
-import Feature from 'ckeditor5/core/feature.js';
+import Plugin from 'ckeditor5/core/plugin.js';
 
 describe( 'StandardEditor', () => {
 	let editorElement;
@@ -40,11 +40,11 @@ describe( 'StandardEditor', () => {
 
 	describe( 'create', () => {
 		it( 'initializes editor with plugins and config', () => {
-			class FeatureFoo extends Feature {}
+			class PluginFoo extends Plugin {}
 
 			return StandardEditor.create( editorElement, {
 					foo: 1,
-					features: [ FeatureFoo ]
+					plugins: [ PluginFoo ]
 				} )
 				.then( editor => {
 					expect( editor ).to.be.instanceof( StandardEditor );
@@ -52,7 +52,7 @@ describe( 'StandardEditor', () => {
 					expect( editor.config.get( 'foo' ) ).to.equal( 1 );
 					expect( editor ).to.have.property( 'element', editorElement );
 
-					expect( editor.plugins.get( FeatureFoo ) ).to.be.instanceof( FeatureFoo );
+					expect( editor.plugins.get( PluginFoo ) ).to.be.instanceof( PluginFoo );
 				} );
 		} );
 	} );

+ 2 - 2
packages/ckeditor5-core/tests/plugincollection.js

@@ -9,14 +9,14 @@ import testUtils from 'tests/core/_utils/utils.js';
 import Editor from 'ckeditor5/core/editor/editor.js';
 import PluginCollection from 'ckeditor5/core/plugincollection.js';
 import Plugin from 'ckeditor5/core/plugin.js';
-import Feature from 'ckeditor5/core/feature.js';
 import CKEditorError from 'ckeditor5/utils/ckeditorerror.js';
 import log from 'ckeditor5/utils/log.js';
 
 let editor;
 let PluginA, PluginB, PluginC, PluginD, PluginE, PluginF, PluginG, PluginH, PluginI, PluginX;
 class TestError extends Error {}
-class GrandPlugin extends Feature {}
+class ChildPlugin extends Plugin {}
+class GrandPlugin extends ChildPlugin {}
 
 testUtils.createSinonSandbox();