Explorar el Código

Improve ckfinder command refresh() method code style.

Maciej Gołaszewski hace 7 años
padre
commit
49dcb631a8
Se han modificado 1 ficheros con 3 adiciones y 4 borrados
  1. 3 4
      packages/ckeditor5-ckfinder/src/ckfindercommand.js

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

@@ -34,9 +34,7 @@ export default class CKFinderCommand extends Command {
 		this.stopListening( this.editor.model.document, 'change' );
 
 		// Lower this command listener priority to be sure that refresh() will be called after link & image refresh.
-		this.listenTo( this.editor.model.document, 'change', () => {
-			this.refresh();
-		}, { priority: 'low' } );
+		this.listenTo( this.editor.model.document, 'change', () => this.refresh(), { priority: 'low' } );
 	}
 
 	/**
@@ -46,7 +44,8 @@ export default class CKFinderCommand extends Command {
 		const imageCommand = this.editor.commands.get( 'imageUpload' );
 		const linkCommand = this.editor.commands.get( 'link' );
 
-		this.isEnabled = ( !imageCommand || !linkCommand ) ? false : ( imageCommand.isEnabled || linkCommand.isEnabled );
+		// The CKFinder command is enabled when one of image or link command is enabled.
+		this.isEnabled = imageCommand && linkCommand && ( imageCommand.isEnabled || linkCommand.isEnabled );
 	}
 
 	/**