Browse Source

> Internal: Added `RemoveFormatEditing` plugin.

Marek Lewandowski 6 years ago
parent
commit
df33592b83

+ 4 - 10
packages/ckeditor5-remove-format/src/removeformat.js

@@ -10,13 +10,13 @@
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 
 import RemoveFormatUI from './removeformatui';
-import RemoveFormatCommand from './removeformatcommand';
+import RemoveFormatEditing from './removeformatediting';
 
 /**
  * The remove format plugin.
  *
- * This is a "glue" plugin which loads the {@link module:remove-format/removeformatcommand~RemoveFormatCommand command}
- * and the {@link module:remove-format/removeformatui~RemoveFormatUI UI}.
+ * This is a "glue" plugin which loads the {@link module:remove-format/removeformatediting~RemoveFormatEditing}
+ * and {@link module:remove-format/removeformatui~RemoveFormatUI} plugins.
  *
  * For a detailed overview, check out the {@glink features/remove-format remove format} feature documentation.
  *
@@ -27,13 +27,7 @@ export default class RemoveFormat extends Plugin {
 	 * @inheritDoc
 	 */
 	static get requires() {
-		return [ RemoveFormatCommand, RemoveFormatUI ];
-	}
-
-	init() {
-		const editor = this.editor;
-
-		editor.commands.add( 'removeFormat', new RemoveFormatCommand( editor ) );
+		return [ RemoveFormatEditing, RemoveFormatUI ];
 	}
 
 	/**

+ 37 - 0
packages/ckeditor5-remove-format/src/removeformatediting.js

@@ -0,0 +1,37 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/**
+ * @module remove-format/removeformatediting
+ */
+
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+
+import RemoveFormatCommand from './removeformatcommand';
+
+/**
+ * The remove format editing plugin.
+ *
+ * It registers the {@link module:remove-format/removeformatcommand~RemoveFormatCommand removeFormat} command.
+ *
+ * @extends module:core/plugin~Plugin
+ */
+export default class RemoveFormatEditing extends Plugin {
+	/**
+	 * @inheritDoc
+	 */
+	static get pluginName() {
+		return 'RemoveFormatEditing';
+	}
+
+	/**
+	 * @inheritDoc
+	 */
+	init() {
+		const editor = this.editor;
+
+		editor.commands.add( 'removeFormat', new RemoveFormatCommand( editor ) );
+	}
+}

+ 22 - 0
packages/ckeditor5-remove-format/tests/removeformat.js

@@ -0,0 +1,22 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+import RemoveFormat from '../src/removeformat';
+import RemoveFormatEditing from '../src/removeformatediting';
+import RemoveFormatUI from '../src/removeformatui';
+
+describe( 'RemoveFormat', () => {
+	it( 'should require RemoveFormatEditing', () => {
+		expect( RemoveFormat.requires ).to.include( RemoveFormatEditing );
+	} );
+
+	it( 'should require RemoveFormatUI', () => {
+		expect( RemoveFormat.requires ).to.include( RemoveFormatUI );
+	} );
+
+	it( 'should have pluginName property', () => {
+		expect( RemoveFormat.pluginName ).to.equal( 'RemoveFormat' );
+	} );
+} );

+ 28 - 0
packages/ckeditor5-remove-format/tests/removeformatediting.js

@@ -0,0 +1,28 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
+import RemoveFormatCommand from '../src/removeformatcommand';
+import RemoveFormatEditing from '../src/removeformatediting';
+
+describe( 'RemoveFormat', () => {
+	let editor;
+
+	beforeEach( () => {
+		return ModelTestEditor.create( {
+			plugins: [ RemoveFormatEditing ]
+		} ).then( newEditor => {
+			editor = newEditor;
+		} );
+	} );
+
+	afterEach( () => {
+		return editor.destroy();
+	} );
+
+	it( 'should register removeFormat command', () => {
+		expect( editor.commands.get( 'removeFormat' ) ).to.instanceof( RemoveFormatCommand );
+	} );
+} );