浏览代码

Changed in Commands _execute to execute and doExecute to _doExecute.

Szymon Cofalik 9 年之前
父节点
当前提交
44b7baeebe

+ 1 - 1
packages/ckeditor5-engine/src/command/attributecommand.js

@@ -110,7 +110,7 @@ export default class AttributeCommand extends Command {
 	 * @param {Boolean} [forceValue] If set it will force command behavior. If `true`, command will apply attribute,
 	 * otherwise command will remove attribute. If not set, command will look for it's current value to decide what it should do.
 	 */
-	_execute( forceValue ) {
+	_doExecute( forceValue ) {
 		const document = this.editor.document;
 		const selection = document.selection;
 		const value = ( forceValue === undefined ) ? !this.value : forceValue;

+ 3 - 3
packages/ckeditor5-engine/src/command/command.js

@@ -79,9 +79,9 @@ export default class Command {
 	 * @protected
 	 * @param {*} param Parameter passed to {@link core.command.Command#execute execute} method of this command.
 	 */
-	doExecute( param ) {
+	execute( param ) {
 		if ( this.isEnabled ) {
-			this._execute( param );
+			this._doExecute( param );
 		}
 	}
 
@@ -114,7 +114,7 @@ export default class Command {
 	 *
 	 * @private
 	 */
-	_execute() {
+	_doExecute() {
 	}
 }
 

+ 1 - 1
packages/ckeditor5-engine/src/editor.js

@@ -206,7 +206,7 @@ export default class Editor {
 			throw new CKEditorError( 'editor-command-not-found: Specified command has not been added to the editor.' );
 		}
 
-		command.doExecute( commandParam );
+		command.execute( commandParam );
 	}
 }
 

+ 12 - 12
packages/ckeditor5-engine/tests/commands/attributecommand.js

@@ -51,7 +51,7 @@ describe( 'value', () => {
 	} );
 } );
 
-describe( '_execute', () => {
+describe( '_doExecute', () => {
 	let p;
 
 	beforeEach( () => {
@@ -67,7 +67,7 @@ describe( '_execute', () => {
 
 		expect( command.value ).to.be.false;
 
-		command._execute();
+		command._doExecute();
 
 		expect( command.value ).to.be.true;
 		expect( p.getChild( 1 ).hasAttribute( attrKey ) ).to.be.true;
@@ -79,7 +79,7 @@ describe( '_execute', () => {
 
 		expect( command.value ).to.be.true;
 
-		command._execute();
+		command._doExecute();
 
 		expect( command.value ).to.be.false;
 		expect( p.getChild( 3 ).hasAttribute( attrKey ) ).to.be.false;
@@ -92,7 +92,7 @@ describe( '_execute', () => {
 
 		expect( command.value ).to.be.true;
 
-		command._execute( true );
+		command._doExecute( true );
 
 		expect( command.value ).to.be.true;
 		expect( p.getChild( 9 ).hasAttribute( attrKey ) ).to.be.true;
@@ -103,7 +103,7 @@ describe( '_execute', () => {
 
 		expect( command.value ).to.be.false;
 
-		command._execute( false );
+		command._doExecute( false );
 
 		expect( command.value ).to.be.false;
 		expect( p.getChild( 3 ).hasAttribute( attrKey ) ).to.be.false;
@@ -115,12 +115,12 @@ describe( '_execute', () => {
 
 		expect( command.value ).to.be.false;
 
-		command._execute();
+		command._doExecute();
 
 		expect( command.value ).to.be.true;
 		expect( modelDoc.selection.hasAttribute( 'bold' ) ).to.be.true;
 
-		command._execute();
+		command._doExecute();
 
 		expect( command.value ).to.be.false;
 		expect( modelDoc.selection.hasAttribute( 'bold' ) ).to.be.false;
@@ -128,7 +128,7 @@ describe( '_execute', () => {
 
 	it( 'should not store attribute change on selection if selection is collapsed in non-empty parent', () => {
 		modelDoc.selection.addRange( new Range( new Position( root, [ 0, 1 ] ), new Position( root, [ 0, 1 ] ) ) );
-		command._execute();
+		command._doExecute();
 
 		// It should not save that bold was executed at position ( root, [ 0, 1 ] ).
 
@@ -146,7 +146,7 @@ describe( '_execute', () => {
 
 		expect( command.value ).to.be.false;
 
-		command._execute();
+		command._doExecute();
 
 		expect( command.value ).to.be.true;
 		expect( modelDoc.selection.hasAttribute( 'bold' ) ).to.be.true;
@@ -163,7 +163,7 @@ describe( '_execute', () => {
 		// Attribute should be restored.
 		expect( command.value ).to.be.true;
 
-		command._execute();
+		command._doExecute();
 
 		expect( command.value ).to.be.false;
 		expect( modelDoc.selection.hasAttribute( 'bold' ) ).to.be.false;
@@ -174,7 +174,7 @@ describe( '_execute', () => {
 		modelDoc.on( 'change', spy );
 
 		modelDoc.selection.removeAllRanges();
-		command._execute();
+		command._doExecute();
 
 		expect( spy.called ).to.be.false;
 		expect( Array.from( modelDoc.selection.getAttributes() ) ).to.deep.equal( [ ] );
@@ -187,7 +187,7 @@ describe( '_execute', () => {
 
 		expect( command.isEnabled ).to.be.true;
 
-		command._execute();
+		command._doExecute();
 
 		let expectedHas = [ 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 ];
 

+ 7 - 7
packages/ckeditor5-engine/tests/commands/command.js

@@ -142,22 +142,22 @@ describe( 'enable', () => {
 	} );
 } );
 
-describe( 'doExecute', () => {
+describe( 'execute', () => {
 	it( 'should not execute command if it is disabled', () => {
 		command._disable();
 
-		sinon.spy( command, '_execute' );
+		sinon.spy( command, '_doExecute' );
 
-		command.doExecute();
+		command.execute();
 
-		expect( command._execute.called ).to.be.false;
+		expect( command._doExecute.called ).to.be.false;
 	} );
 
 	it( 'should execute command if it is enabled', () => {
-		sinon.spy( command, '_execute' );
+		sinon.spy( command, '_doExecute' );
 
-		command.doExecute();
+		command.execute();
 
-		expect( command._execute.called ).to.be.true;
+		expect( command._doExecute.called ).to.be.true;
 	} );
 } );

+ 2 - 2
packages/ckeditor5-engine/tests/editor/editor.js

@@ -204,12 +204,12 @@ describe( 'execute', () => {
 		const editor = new Editor( element );
 
 		let command = new Command( editor );
-		sinon.spy( command, '_execute' );
+		sinon.spy( command, 'execute' );
 
 		editor.commands.set( 'command_name', command );
 		editor.execute( 'command_name' );
 
-		expect( command._execute.calledOnce ).to.be.true;
+		expect( command.execute.calledOnce ).to.be.true;
 	} );
 
 	it( 'should throw an error if specified command has not been added', () => {