8
0
Просмотр исходного кода

Enable CKFinder command when either link or image insert commands is enabled.

Maciej Gołaszewski 6 лет назад
Родитель
Сommit
dae93f86cb

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

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

+ 8 - 2
packages/ckeditor5-ckfinder/tests/ckfindercommand.js

@@ -105,7 +105,7 @@ describe( 'CKFinderCommand', () => {
 			expect( command.isEnabled ).to.be.false;
 		} );
 
-		it( 'should be true when imageInsert and link command are enabled', () => {
+		it( 'should be true when imageInsert or link command is enabled', () => {
 			setModelData( model, '<paragraph>[]</paragraph>' );
 			const insertImage = editor.commands.get( 'imageInsert' );
 			const linkCommand = editor.commands.get( 'link' );
@@ -116,11 +116,17 @@ describe( 'CKFinderCommand', () => {
 			command.refresh();
 			expect( command.isEnabled ).to.be.false;
 
-			linkCommand.isEnabled = true;
+			linkCommand.isEnabled = false;
 			insertImage.isEnabled = true;
 
 			command.refresh();
 			expect( command.isEnabled ).to.be.true;
+
+			linkCommand.isEnabled = true;
+			insertImage.isEnabled = false;
+
+			command.refresh();
+			expect( command.isEnabled ).to.be.true;
 		} );
 	} );