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

Commit 55697a9

Browse files
committed
Merge branch 't/22'
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`.
2 parents 9cd8053 + bd77c74 commit 55697a9

25 files changed

+42
-1917
lines changed

src/filereader.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import mix from '@ckeditor/ckeditor5-utils/src/mix';
1616
* FileReader class - wrapper over native FileReader.
1717
*/
1818
export default class FileReader {
19+
/**
20+
* Creates an instance of the FileReader.
21+
*/
1922
constructor() {
2023
const reader = new window.FileReader();
2124

src/filerepository.js

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

6868
/**
@@ -120,18 +120,18 @@ export default class FileRepository extends Plugin {
120120
/**
121121
* Creates a loader instance for the given file.
122122
*
123-
* Requires {@link #createAdapter} factory to be defined.
123+
* Requires {@link #createUploadAdapter} factory to be defined.
124124
*
125125
* @param {File} file Native File object.
126126
* @returns {module:upload/filerepository~FileLoader|null}
127127
*/
128128
createLoader( file ) {
129-
if ( !this.createAdapter ) {
129+
if ( !this.createUploadAdapter ) {
130130
/**
131131
* You need to enable an upload adapter in order to be able to upload files.
132132
*
133133
* This warning shows up when {@link module:upload/filerepository~FileRepository} is being used
134-
* without {@link #createAdapter definining an upload adapter}.
134+
* without {@link #createUploadAdapter definining an upload adapter}.
135135
*
136136
* **If you see this warning when using one of the {@glink builds/index CKEditor 5 Builds}**
137137
* it means that you did not configure any of the upload adapters available by default in those builds.
@@ -143,8 +143,8 @@ export default class FileRepository extends Plugin {
143143
* file upload integration.
144144
*
145145
* **If you see this warning when using a custom build** there is a chance that you enabled
146-
* a feature like {@link module:upload/imageupload~ImageUpload},
147-
* or {@link module:upload/imageuploadbutton~ImageUploadButton} but you did not enable any upload adapter.
146+
* a feature like {@link module:image/imageupload~ImageUpload},
147+
* or {@link module:image/imageupload/imageuploadui~ImageUploadUI} but you did not enable any upload adapter.
148148
* You can choose one of the existing upload adapters:
149149
*
150150
* * {@link module:easy-image/cloudservicesuploadadapter~CloudServicesUploadAdapter}
@@ -153,17 +153,17 @@ export default class FileRepository extends Plugin {
153153
* (remember to {@link module:core/editor/editorconfig~EditorConfig#ckfinder configure it})
154154
*
155155
* You can also implement your own upload adapter (in which case, please refer
156-
* to the {@link ~Adapter `Adapter` interface} documentation).
156+
* to the {@link ~UploadAdapter `UploadAdapter` interface} documentation).
157157
*
158-
* @error filerepository-no-adapter
158+
* @error filerepository-no-upload-adapter
159159
*/
160-
log.error( 'filerepository-no-adapter: Upload adapter is not defined.' );
160+
log.error( 'filerepository-no-upload-adapter: Upload adapter is not defined.' );
161161

162162
return null;
163163
}
164164

165165
const loader = new FileLoader( file );
166-
loader._adapter = this.createAdapter( loader );
166+
loader._adapter = this.createUploadAdapter( loader );
167167

168168
this.loaders.add( loader );
169169

@@ -218,7 +218,7 @@ class FileLoader {
218218
* Creates a new instance of `FileLoader`.
219219
*
220220
* @param {File} file A native file instance.
221-
* @param {module:upload/filerepository~Adapter} adapter
221+
* @param {module:upload/filerepository~UploadAdapter} adapter
222222
*/
223223
constructor( file, adapter ) {
224224
/**
@@ -241,7 +241,7 @@ class FileLoader {
241241
* Adapter instance associated with this file loader.
242242
*
243243
* @private
244-
* @member {module:upload/filerepository~Adapter}
244+
* @member {module:upload/filerepository~UploadAdapter}
245245
*/
246246
this._adapter = adapter;
247247

@@ -365,7 +365,7 @@ class FileLoader {
365365
}
366366

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

445445
/**
446-
* Adapter interface used by FileRepository to handle file upload. Adapter is a bridge between the editor and server that
446+
* Upload adapter interface used by FileRepository to handle file upload. Upload adapter is a bridge between the editor and server that
447447
* handles file uploads. It should contain logic necessary to initiate upload process and monitor its progress.
448448
*
449449
* It should implement two methods:
450450
*
451-
* * {@link module:upload/filerepository~Adapter#upload `upload()`},
452-
* * {@link module:upload/filerepository~Adapter#abort `abort()`}.
451+
* * {@link module:upload/filerepository~UploadAdapter#upload `upload()`},
452+
* * {@link module:upload/filerepository~UploadAdapter#abort `abort()`}.
453453
*
454-
* Example adapter implementation:
454+
* Example upload adapter implementation:
455455
*
456-
* class Adapter {
456+
* class UploadAdapter {
457457
* constructor( loader ) {
458458
* // Save Loader instance to update upload progress.
459459
* this.loader = loader;
@@ -476,13 +476,13 @@ mix( FileLoader, ObservableMixin );
476476
* }
477477
* }
478478
*
479-
* Then adapter can be set to be used by {@link module:upload/filerepository~FileRepository FileRepository}:
479+
* Then upload adapter can be set to be used by {@link module:upload/filerepository~FileRepository FileRepository}:
480480
*
481-
* editor.plugins.get( 'FileRepository' ).createAdapter = function( loader ) {
482-
* return new Adapter( loader );
481+
* editor.plugins.get( 'FileRepository' ).createUploadAdapter = function( loader ) {
482+
* return new UploadAdapter( loader );
483483
* };
484484
*
485-
* @interface Adapter
485+
* @interface UploadAdapter
486486
*/
487487

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

518518
/**
519519
* Aborts the upload process.
520520
* After aborting it should reject promise returned from {@link #upload upload()}.
521521
*
522-
* Take a look at {@link module:upload/filerepository~Adapter example Adapter implementation} and
523-
* {@link module:upload/filerepository~FileRepository#createAdapter createAdapter method}.
522+
* Take a look at {@link module:upload/filerepository~UploadAdapter example Adapter implementation} and
523+
* {@link module:upload/filerepository~FileRepository#createUploadAdapter createUploadAdapter method}.
524524
*
525-
* @method module:upload/filerepository~Adapter#abort
525+
* @method module:upload/filerepository~UploadAdapter#abort
526526
*/

src/imageupload.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/imageuploadbutton.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/imageuploadcommand.js

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)