Browse Source

Other: Aligned the implementation to the new Command API (see https://github.com/ckeditor/ckeditor5-core/issues/88).

BREAKING CHANGES: The command API has been changed.
Szymon Kupś 8 years ago
parent
commit
3f27701f6a

+ 1 - 1
packages/ckeditor5-enter/src/enter.js

@@ -30,7 +30,7 @@ export default class Enter extends Plugin {
 
 		editingView.addObserver( EnterObserver );
 
-		editor.commands.set( 'enter', new EnterCommand( editor ) );
+		editor.commands.add( 'enter', new EnterCommand( editor ) );
 
 		// TODO We may use the keystroke handler for that.
 		this.listenTo( editingView, 'enter', ( evt, data ) => {

+ 3 - 3
packages/ckeditor5-enter/src/entercommand.js

@@ -7,19 +7,19 @@
  * @module enter/entercommand
  */
 
-import Command from '@ckeditor/ckeditor5-core/src/command/command';
+import Command from '@ckeditor/ckeditor5-core/src/command';
 import Position from '@ckeditor/ckeditor5-engine/src/model/position';
 
 /**
  * Enter command. It is used by the {@link module:enter/enter~Enter Enter feature} to handle the <kbd>Enter</kbd> key.
  *
- * @extends modue:core/command/command~Command
+ * @extends module:core/command~Command
  */
 export default class EnterCommand extends Command {
 	/**
 	 * @inheritDoc
 	 */
-	_doExecute() {
+	execute() {
 		const doc = this.editor.document;
 		const batch = doc.batch();
 

+ 5 - 5
packages/ckeditor5-enter/tests/entercommand.js

@@ -17,7 +17,7 @@ describe( 'EnterCommand', () => {
 				doc = editor.document;
 
 				command = new EnterCommand( editor );
-				editor.commands.set( 'enter', command );
+				editor.commands.add( 'enter', command );
 
 				schema = doc.schema;
 
@@ -53,7 +53,7 @@ describe( 'EnterCommand', () => {
 		} );
 	} );
 
-	describe( '_doExecute', () => {
+	describe( 'execute()', () => {
 		describe( 'collapsed selection', () => {
 			test(
 				'does nothing in the root',
@@ -146,7 +146,7 @@ describe( 'EnterCommand', () => {
 				// @TODO: Add option for setting selection direction to model utils.
 				doc.selection._lastRangeBackward = true;
 
-				command._doExecute();
+				command.execute();
 
 				expect( getData( doc ) ).to.equal( '<p>[]</p>' );
 			} );
@@ -158,7 +158,7 @@ describe( 'EnterCommand', () => {
 
 				setData( doc, '<p>[x]</p>' );
 
-				command._doExecute();
+				command.execute();
 
 				expect( spy.calledOnce ).to.be.true;
 			} );
@@ -168,7 +168,7 @@ describe( 'EnterCommand', () => {
 			it( title, () => {
 				setData( doc, input );
 
-				command._doExecute();
+				command.execute();
 
 				expect( getData( doc ) ).to.equal( output );
 			} );