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

Make CKFinder command use imageInsert command instead of imageUpload.

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

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

@@ -38,7 +38,7 @@ export default class CKFinderCommand extends Command {
 	 * @inheritDoc
 	 */
 	refresh() {
-		const imageCommand = this.editor.commands.get( 'imageUpload' );
+		const imageCommand = this.editor.commands.get( 'imageInsert' );
 		const linkCommand = this.editor.commands.get( 'link' );
 
 		// The CKFinder command is enabled when one of image or link command is enabled.
@@ -124,7 +124,7 @@ export default class CKFinderCommand extends Command {
 }
 
 function insertImages( editor, urls ) {
-	const imageCommand = editor.commands.get( 'imageUpload' );
+	const imageCommand = editor.commands.get( 'imageInsert' );
 
 	// Check if inserting an image is actually possible - it might be possible to only insert a link.
 	if ( !imageCommand.isEnabled ) {

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

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