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

Do not show notification on required commands: link & imageInsert.

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

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

@@ -89,18 +89,8 @@ export default class CKFinderCommand extends Command {
 				const links = files.filter( file => !file.isImage() );
 				const links = files.filter( file => !file.isImage() );
 				const images = files.filter( file => file.isImage() );
 				const images = files.filter( file => file.isImage() );
 
 
-				if ( !editor.commands.get( 'link' ) ) {
-					const notification = editor.plugins.get( 'Notification' );
-					const t = editor.locale.t;
-
-					notification.showWarning( t( 'The "link" command must be available to insert links.' ), {
-						title: t( 'Inserting link failed' ),
-						namespace: 'ckfinder'
-					} );
-				} else {
-					for ( const linkFile of links ) {
-						editor.execute( 'link', linkFile.getUrl() );
-					}
+				for ( const linkFile of links ) {
+					editor.execute( 'link', linkFile.getUrl() );
 				}
 				}
 
 
 				const imagesUrls = [];
 				const imagesUrls = [];
@@ -142,18 +132,6 @@ export default class CKFinderCommand extends Command {
 function insertImages( editor, urls ) {
 function insertImages( editor, urls ) {
 	const imageCommand = editor.commands.get( 'imageInsert' );
 	const imageCommand = editor.commands.get( 'imageInsert' );
 
 
-	if ( !imageCommand ) {
-		const notification = editor.plugins.get( 'Notification' );
-		const t = editor.locale.t;
-
-		notification.showWarning( t( 'The "imageInsert" command must be available to insert images.' ), {
-			title: t( 'Inserting image failed' ),
-			namespace: 'ckfinder'
-		} );
-
-		return;
-	}
-
 	// Check if inserting an image is actually possible - it might be possible to only insert a link.
 	// Check if inserting an image is actually possible - it might be possible to only insert a link.
 	if ( !imageCommand.isEnabled ) {
 	if ( !imageCommand.isEnabled ) {
 		const notification = editor.plugins.get( 'Notification' );
 		const notification = editor.plugins.get( 'Notification' );

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

@@ -400,42 +400,6 @@ describe( 'CKFinderCommand', () => {
 				.to.equal( '<paragraph>f[o]o</paragraph>' );
 				.to.equal( '<paragraph>f[o]o</paragraph>' );
 		} );
 		} );
 
 
-		it( 'should show warning notification if link command is not available', done => {
-			// Remove link command.
-			editor.commands._commands.delete( 'link' );
-			const notification = editor.plugins.get( Notification );
-
-			notification.on( 'show:warning', ( evt, data ) => {
-				expect( data.message ).to.equal( 'The "link" command must be available to insert links.' );
-				expect( data.title ).to.equal( 'Inserting link failed' );
-				evt.stop();
-
-				done();
-			}, { priority: 'high' } );
-
-			command.execute();
-
-			mockFilesChooseEvent( [ mockFinderFile( 'foo/bar.pdf', false ) ] );
-		} );
-
-		it( 'should show warning notification if link command is not available', done => {
-			// Remove link command.
-			editor.commands._commands.delete( 'imageInsert' );
-			const notification = editor.plugins.get( Notification );
-
-			notification.on( 'show:warning', ( evt, data ) => {
-				expect( data.message ).to.equal( 'The "imageInsert" command must be available to insert images.' );
-				expect( data.title ).to.equal( 'Inserting image failed' );
-				evt.stop();
-
-				done();
-			}, { priority: 'high' } );
-
-			command.execute();
-
-			mockFilesChooseEvent( [ mockFinderFile( 'foo/bar.png', true ) ] );
-		} );
-
 		it( 'should not insert image nor crash when image could not be inserted', () => {
 		it( 'should not insert image nor crash when image could not be inserted', () => {
 			model.schema.register( 'other', {
 			model.schema.register( 'other', {
 				allowIn: '$root',
 				allowIn: '$root',