Explorar el Código

Simplify CKFinderCommand.refresh method as Image and Link are required plugins.

Maciej Gołaszewski hace 6 años
padre
commit
9662cb3699

+ 1 - 4
packages/ckeditor5-ckfinder/src/ckfindercommand.js

@@ -47,11 +47,8 @@ export default class CKFinderCommand extends Command {
 		const imageCommand = this.editor.commands.get( 'imageInsert' );
 		const linkCommand = this.editor.commands.get( 'link' );
 
-		const canUseImageCommand = !!( imageCommand && imageCommand.isEnabled );
-		const canUseLinkCommand = !!( linkCommand && linkCommand.isEnabled );
-
 		// The CKFinder command is enabled when one of image or link command is enabled.
-		this.isEnabled = canUseImageCommand || canUseLinkCommand;
+		this.isEnabled = imageCommand.isEnabled || linkCommand.isEnabled;
 	}
 
 	/**

+ 0 - 16
packages/ckeditor5-ckfinder/tests/ckfindercommand.js

@@ -128,22 +128,6 @@ describe( 'CKFinderCommand', () => {
 			command.refresh();
 			expect( command.isEnabled ).to.be.true;
 		} );
-
-		it( 'should be true when imageInsert command is not available', () => {
-			setModelData( model, '<paragraph>[]</paragraph>' );
-			const insertImage = editor.commands.get( 'imageInsert' );
-			editor.commands._commands.delete( 'link' );
-
-			insertImage.isEnabled = false;
-
-			command.refresh();
-			expect( command.isEnabled ).to.be.false;
-
-			insertImage.isEnabled = true;
-
-			command.refresh();
-			expect( command.isEnabled ).to.be.true;
-		} );
 	} );
 
 	describe( 'execute()', () => {