Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge branch 't/22'
Browse files Browse the repository at this point in the history
Other: Moved the image upload plugins to the `@ckeditor/ckeditor5-image` package. Minor cleanup in the API. Closes #22.

BREAKING CHANGE: Renamed `Adapter` to `UploadAdapter`.
BREAKING CHANGE: Removed `ImageUpload` plugin. It can be no found in ckeditor5-image repository.
BREAKING CHANGE: Removed `ImageUploadEngine` plugin. It can be no found in ckeditor5-image repository.
BREAKING CHANGE: Removed `ImageUploadProgress` plugin. It can be no found in ckeditor5-image repository.
BREAKING CHANGE: Removed `ImageUploadButton` plugin. It can be no found in ckeditor5-image repository.
BREAKING CHANGE: Renamed `FileRepository#createAdapter()` to `FileRepository#createUploadAdapter()`.
BREAKING CHANGE: Renamed `filerepository-no-adapter` error to `filerepository-no-upload-adapter`.
  • Loading branch information
Reinmar committed Feb 2, 2018
2 parents 9cd8053 + bd77c74 commit 55697a9
Show file tree
Hide file tree
Showing 25 changed files with 42 additions and 1,917 deletions.
3 changes: 3 additions & 0 deletions src/filereader.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import mix from '@ckeditor/ckeditor5-utils/src/mix';
* FileReader class - wrapper over native FileReader.
*/
export default class FileReader {
/**
* Creates an instance of the FileReader.
*/
constructor() {
const reader = new window.FileReader();

Expand Down
64 changes: 32 additions & 32 deletions src/filerepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import uid from '@ckeditor/ckeditor5-utils/src/uid.js';
* (sending the file and handling server's response). You can use one of the existing plugins introducing upload adapters
* (e.g. {@link module:easy-image/cloudservicesuploadadapter~CloudServicesUploadAdapter} or
* {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter}) or write your own one
* (which boils down to setting the {@link ~FileRepository#createAdapter} factory function – see
* {@link module:upload/filerepository~Adapter `Adapter` interface} documentation).
* (which boils down to setting the {@link ~FileRepository#createUploadAdapter} factory function – see
* {@link module:upload/filerepository~UploadAdapter `UploadAdapter` interface} documentation).
*
* Then, you can use {@link module:upload/filerepository~FileRepository#createLoader `createLoader()`} and the returned
* {@link module:upload/filerepository~FileLoader} instance to load and upload files.
Expand Down Expand Up @@ -56,13 +56,13 @@ export default class FileRepository extends Plugin {
/**
* A factory function which should be defined before using `FileRepository`.
*
* It should return a new instance of {@link module:upload/filerepository~Adapter} that will be used to upload files.
* It should return a new instance of {@link module:upload/filerepository~UploadAdapter} that will be used to upload files.
* {@link module:upload/filerepository~FileLoader} instance associated with the adapter
* will be passed to that function.
*
* For more information and example see {@link module:upload/filerepository~Adapter}.
* For more information and example see {@link module:upload/filerepository~UploadAdapter}.
*
* @member {Function} #createAdapter
* @member {Function} #createUploadAdapter
*/

/**
Expand Down Expand Up @@ -120,18 +120,18 @@ export default class FileRepository extends Plugin {
/**
* Creates a loader instance for the given file.
*
* Requires {@link #createAdapter} factory to be defined.
* Requires {@link #createUploadAdapter} factory to be defined.
*
* @param {File} file Native File object.
* @returns {module:upload/filerepository~FileLoader|null}
*/
createLoader( file ) {
if ( !this.createAdapter ) {
if ( !this.createUploadAdapter ) {
/**
* 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}.
* without {@link #createUploadAdapter 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.
Expand All @@ -143,8 +143,8 @@ export default class FileRepository extends Plugin {
* file upload integration.
*
* **If you see this warning when using a custom build** there is a chance that you enabled
* a feature like {@link module:upload/imageupload~ImageUpload},
* or {@link module:upload/imageuploadbutton~ImageUploadButton} but you did not enable any upload adapter.
* a feature like {@link module:image/imageupload~ImageUpload},
* or {@link module:image/imageupload/imageuploadui~ImageUploadUI} but you did not enable any upload adapter.
* You can choose one of the existing upload adapters:
*
* * {@link module:easy-image/cloudservicesuploadadapter~CloudServicesUploadAdapter}
Expand All @@ -153,17 +153,17 @@ export default class FileRepository extends Plugin {
* (remember to {@link module:core/editor/editorconfig~EditorConfig#ckfinder configure it})
*
* You can also implement your own upload adapter (in which case, please refer
* to the {@link ~Adapter `Adapter` interface} documentation).
* to the {@link ~UploadAdapter `UploadAdapter` interface} documentation).
*
* @error filerepository-no-adapter
* @error filerepository-no-upload-adapter
*/
log.error( 'filerepository-no-adapter: Upload adapter is not defined.' );
log.error( 'filerepository-no-upload-adapter: Upload adapter is not defined.' );

return null;
}

const loader = new FileLoader( file );
loader._adapter = this.createAdapter( loader );
loader._adapter = this.createUploadAdapter( loader );

this.loaders.add( loader );

Expand Down Expand Up @@ -218,7 +218,7 @@ class FileLoader {
* Creates a new instance of `FileLoader`.
*
* @param {File} file A native file instance.
* @param {module:upload/filerepository~Adapter} adapter
* @param {module:upload/filerepository~UploadAdapter} adapter
*/
constructor( file, adapter ) {
/**
Expand All @@ -241,7 +241,7 @@ class FileLoader {
* Adapter instance associated with this file loader.
*
* @private
* @member {module:upload/filerepository~Adapter}
* @member {module:upload/filerepository~UploadAdapter}
*/
this._adapter = adapter;

Expand Down Expand Up @@ -365,7 +365,7 @@ class FileLoader {
}

/**
* Reads file using the provided {@link module:upload/filerepository~Adapter}.
* Reads file using the provided {@link module:upload/filerepository~UploadAdapter}.
*
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `filerepository-upload-wrong-status` when status
* is different than `idle`.
Expand Down Expand Up @@ -443,17 +443,17 @@ class FileLoader {
mix( FileLoader, ObservableMixin );

/**
* Adapter interface used by FileRepository to handle file upload. Adapter is a bridge between the editor and server that
* Upload adapter interface used by FileRepository to handle file upload. Upload adapter is a bridge between the editor and server that
* handles file uploads. It should contain logic necessary to initiate upload process and monitor its progress.
*
* It should implement two methods:
*
* * {@link module:upload/filerepository~Adapter#upload `upload()`},
* * {@link module:upload/filerepository~Adapter#abort `abort()`}.
* * {@link module:upload/filerepository~UploadAdapter#upload `upload()`},
* * {@link module:upload/filerepository~UploadAdapter#abort `abort()`}.
*
* Example adapter implementation:
* Example upload adapter implementation:
*
* class Adapter {
* class UploadAdapter {
* constructor( loader ) {
* // Save Loader instance to update upload progress.
* this.loader = loader;
Expand All @@ -476,13 +476,13 @@ mix( FileLoader, ObservableMixin );
* }
* }
*
* Then adapter can be set to be used by {@link module:upload/filerepository~FileRepository FileRepository}:
* Then upload adapter can be set to be used by {@link module:upload/filerepository~FileRepository FileRepository}:
*
* editor.plugins.get( 'FileRepository' ).createAdapter = function( loader ) {
* return new Adapter( loader );
* editor.plugins.get( 'FileRepository' ).createUploadAdapter = function( loader ) {
* return new UploadAdapter( loader );
* };
*
* @interface Adapter
* @interface UploadAdapter
*/

/**
Expand All @@ -508,19 +508,19 @@ mix( FileLoader, ObservableMixin );
* correctly set `width` attribute of the image. See this discussion:
* https://github.com/ckeditor/ckeditor5-easy-image/issues/4 for more information.
*
* Take a look at {@link module:upload/filerepository~Adapter example Adapter implementation} and
* {@link module:upload/filerepository~FileRepository#createAdapter createAdapter method}.
* Take a look at {@link module:upload/filerepository~UploadAdapter example Adapter implementation} and
* {@link module:upload/filerepository~FileRepository#createUploadAdapter createUploadAdapter method}.
*
* @method module:upload/filerepository~Adapter#upload
* @method module:upload/filerepository~UploadAdapter#upload
* @returns {Promise} Promise that should be resolved when data is uploaded.
*/

/**
* Aborts the upload process.
* After aborting it should reject promise returned from {@link #upload upload()}.
*
* Take a look at {@link module:upload/filerepository~Adapter example Adapter implementation} and
* {@link module:upload/filerepository~FileRepository#createAdapter createAdapter method}.
* Take a look at {@link module:upload/filerepository~UploadAdapter example Adapter implementation} and
* {@link module:upload/filerepository~FileRepository#createUploadAdapter createUploadAdapter method}.
*
* @method module:upload/filerepository~Adapter#abort
* @method module:upload/filerepository~UploadAdapter#abort
*/
36 changes: 0 additions & 36 deletions src/imageupload.js

This file was deleted.

68 changes: 0 additions & 68 deletions src/imageuploadbutton.js

This file was deleted.

67 changes: 0 additions & 67 deletions src/imageuploadcommand.js

This file was deleted.

Loading

0 comments on commit 55697a9

Please sign in to comment.