8
0
Quellcode durchsuchen

Internal: FileRepository should not log a warning when not configured. Closes #60.

Piotrek Koszuliński vor 8 Jahren
Ursprung
Commit
4b6162ff0e

+ 19 - 37
packages/ckeditor5-upload/src/filerepository.js

@@ -99,43 +99,6 @@ export default class FileRepository extends Plugin {
 		} );
 	}
 
-	afterInit() {
-		if ( !this.createAdapter ) {
-			/**
-			 * You need to enable an upload adapter in order to be able to upload files.
-			 *
-			 * This warning shows up when {@link module:upload/filerepository~FileRepository} is being used
-			 * without {@link #createAdapter definining an upload adapter}.
-			 *
-			 * If you see this warning when using one of the {@glink builds/index CKEditor 5 Builds}
-			 * it means that you did not configure any of the upload adapters available by default in those builds.
-			 * See:
-			 *
-			 * * {@link module:core/editor/editorconfig~EditorConfig#cloudServices `config.cloudServices`} for
-			 * Easy Image with Cloud Services integration,
-			 * * {@link module:core/editor/editorconfig~EditorConfig#ckfinder `config.ckfinder`} for CKFinder
-			 * file upload integration.
-			 *
-			 * If you do not need file upload functionality at all and you use one of the builds, you can disable the built-in
-			 * upload adapters to hide this warning:
-			 *
-			 *		ClassicEditor
-			 *			.create( document.querySelector( '#editor' ), {
-			 * 				removePlugins: [ 'EasyImage', 'CKFinderUploadAdapter', 'ImageUpload' ]
-			 *			} )
-			 *			.then( ... )
-			 *			.catch( ... );
-			 *
-			 * If you wish to implement your own upload adapter refer to the {@link ~Adapter `Adapter` interface} documentation.
-			 *
-			 * @error filerepository-no-adapter
-			 */
-			log.warn( 'filerepository-no-adapter: Upload adapter is not defined.' );
-
-			return null;
-		}
-	}
-
 	/**
 	 * Returns the loader associated with specified file.
 	 *
@@ -164,6 +127,25 @@ export default class FileRepository extends Plugin {
 	 */
 	createLoader( file ) {
 		if ( !this.createAdapter ) {
+			/**
+			 * You need to enable an upload adapter in order to be able to upload files.
+			 *
+			 * This warning shows up when {@link module:upload/filerepository~FileRepository} is being used
+			 * without {@link #createAdapter definining an upload adapter}.
+			 *
+			 * If you see this warning when using one of the {@glink builds/index CKEditor 5 Builds}
+			 * it means that you did not configure any of the upload adapters available by default in those builds.
+			 * See:
+			 *
+			 * * {@link module:core/editor/editorconfig~EditorConfig#cloudServices `config.cloudServices`} for
+			 * Easy Image with Cloud Services integration,
+			 * * {@link module:core/editor/editorconfig~EditorConfig#ckfinder `config.ckfinder`} for CKFinder
+			 * file upload integration.
+			 *
+			 * If you wish to implement your own upload adapter refer to the {@link ~Adapter `Adapter` interface} documentation.
+			 *
+			 * @error filerepository-no-adapter
+			 */
 			log.error( 'filerepository-no-adapter: Upload adapter is not defined.' );
 
 			return null;

+ 0 - 21
packages/ckeditor5-upload/tests/filerepository.js

@@ -91,27 +91,6 @@ describe( 'FileRepository', () => {
 		} );
 	} );
 
-	describe( 'afterInit()', () => {
-		it( 'logs a warning if no adapter was defined', () => {
-			const stub = testUtils.sinon.stub( log, 'warn' );
-
-			return VirtualTestEditor
-				.create()
-				.then( editor => {
-					const fileRepository = new FileRepository( editor );
-
-					fileRepository.init();
-					fileRepository.afterInit();
-
-					sinon.assert.calledOnce( stub );
-					sinon.assert.calledWithExactly(
-						stub,
-						'filerepository-no-adapter: Upload adapter is not defined.'
-					);
-				} );
-		} );
-	} );
-
 	describe( 'createLoader()', () => {
 		it( 'should return null if adapter is not present', () => {
 			const stub = testUtils.sinon.stub( log, 'error' );