Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ckeditor/ckeditor5-upload

Package Overview
Dependencies
Maintainers
1
Versions
702
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-upload - npm Package Compare versions

Comparing version 10.0.4 to 11.0.0

lang/translations/az.po

17

CHANGELOG.md
Changelog
=========
## [11.0.0](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.4...v11.0.0) (2019-02-28)
### Bug fixes
* `FileLoader` now accepts `Promise` instead of a `File` instance. Closes [#87](https://github.com/ckeditor/ckeditor5-upload/issues/87). ([62a8c69](https://github.com/ckeditor/ckeditor5-upload/commit/62a8c69))
### Other changes
* Add catch block for failed file promise in `FileRepository`. ([a2de5d5](https://github.com/ckeditor/ckeditor5-upload/commit/a2de5d5))
* Updated translations. ([6aaad73](https://github.com/ckeditor/ckeditor5-upload/commit/6aaad73)) ([b0469a8](https://github.com/ckeditor/ckeditor5-upload/commit/b0469a8)) ([f6e27cb](https://github.com/ckeditor/ckeditor5-upload/commit/f6e27cb))
### BREAKING CHANGES
* Upgraded minimal versions of Node to `8.0.0` and npm to `5.7.1`. See: [ckeditor/ckeditor5#1507](https://github.com/ckeditor/ckeditor5/issues/1507). ([612ea3c](https://github.com/ckeditor/ckeditor5-cloud-services/commit/612ea3c))
* The `FileLoader.file` property was changed to a getter which returns a native `Promise` instance instead of a `File` instance. The returned promise resolves to a `File` instance.
## [10.0.4](https://github.com/ckeditor/ckeditor5-upload/compare/v10.0.3...v10.0.4) (2018-12-05)

@@ -5,0 +22,0 @@

2

LICENSE.md

@@ -5,3 +5,3 @@ Software License Agreement

**CKEditor 5 Upload Feature** – https://github.com/ckeditor/ckeditor5-upload <br>
Copyright (c) 2003-2018, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved.
Copyright (c) 2003-2019, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved.

@@ -8,0 +8,0 @@ Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).

{
"name": "@ckeditor/ckeditor5-upload",
"version": "10.0.4",
"version": "11.0.0",
"description": "Upload Feature for CKEditor 5.",

@@ -12,30 +12,30 @@ "keywords": [

"dependencies": {
"@ckeditor/ckeditor5-core": "^11.1.0",
"@ckeditor/ckeditor5-engine": "^12.0.0",
"@ckeditor/ckeditor5-ui": "^11.2.0",
"@ckeditor/ckeditor5-utils": "^11.1.0"
"@ckeditor/ckeditor5-core": "^12.0.0",
"@ckeditor/ckeditor5-engine": "^13.0.0",
"@ckeditor/ckeditor5-ui": "^12.0.0",
"@ckeditor/ckeditor5-utils": "^12.0.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "^10.1.0",
"@ckeditor/ckeditor5-clipboard": "^10.0.4",
"@ckeditor/ckeditor5-editor-classic": "^11.0.2",
"@ckeditor/ckeditor5-enter": "^10.1.3",
"@ckeditor/ckeditor5-heading": "^10.1.1",
"@ckeditor/ckeditor5-image": "^12.0.0",
"@ckeditor/ckeditor5-list": "^11.0.3",
"@ckeditor/ckeditor5-paragraph": "^10.0.4",
"@ckeditor/ckeditor5-typing": "^11.0.2",
"@ckeditor/ckeditor5-undo": "^10.0.4",
"@ckeditor/ckeditor5-basic-styles": "^11.0.0",
"@ckeditor/ckeditor5-clipboard": "^11.0.0",
"@ckeditor/ckeditor5-editor-classic": "^12.0.0",
"@ckeditor/ckeditor5-enter": "^11.0.0",
"@ckeditor/ckeditor5-heading": "^11.0.0",
"@ckeditor/ckeditor5-image": "^13.0.0",
"@ckeditor/ckeditor5-list": "^12.0.0",
"@ckeditor/ckeditor5-paragraph": "^11.0.0",
"@ckeditor/ckeditor5-typing": "^12.0.0",
"@ckeditor/ckeditor5-undo": "^11.0.0",
"eslint": "^5.5.0",
"eslint-config-ckeditor5": "^1.0.7",
"husky": "^0.14.3",
"eslint-config-ckeditor5": "^1.0.11",
"husky": "^1.3.1",
"lint-staged": "^7.0.0"
},
"engines": {
"node": ">=6.9.0",
"npm": ">=3.0.0"
"node": ">=8.0.0",
"npm": ">=5.7.1"
},
"author": "CKSource (http://cksource.com/)",
"license": "GPL-2.0-or-later",
"homepage": "https://ckeditor.com",
"homepage": "https://ckeditor.com/ckeditor-5",
"bugs": "https://github.com/ckeditor/ckeditor5-upload/issues",

@@ -52,4 +52,3 @@ "repository": {

"scripts": {
"lint": "eslint --quiet '**/*.js'",
"precommit": "lint-staged"
"lint": "eslint --quiet '**/*.js'"
},

@@ -64,3 +63,8 @@ "lint-staged": {

"packages/**"
]
],
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}
/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -60,3 +60,3 @@ */

* @param {File} file Native File object.
* @returns {Promise} Returns a promise that will be resolved with file's content.
* @returns {Promise.<String>} Returns a promise that will be resolved with file's content.
* The promise will be rejected in case of an error or when the reading process is aborted.

@@ -63,0 +63,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -30,3 +30,3 @@ */

* {@link module:adapter-ckfinder/uploadadapter~CKFinderUploadAdapter}) or write your own one – see
* the {@glink framework/guides/deep-dive/upload-adapter "Custom image upload adpter" deep dive guide}.
* the {@glink framework/guides/deep-dive/upload-adapter "Custom image upload adapter" deep dive guide}.
*

@@ -69,2 +69,10 @@ * Then, you can use {@link module:upload/filerepository~FileRepository#createLoader `createLoader()`} and the returned

/**
* Loaders mappings used to retrieve loaders references.
*
* @private
* @member {Map<File|Promise, FileLoader>} #_loadersMap
*/
this._loadersMap = new Map();
/**
* Reference to a pending action registered in a {@link module:core/pendingactions~PendingActions} plugin

@@ -125,17 +133,11 @@ * while upload is in progress. When there is no upload then value is `null`.

/**
* Returns the loader associated with specified file.
* Returns the loader associated with specified file or promise.
*
* To get loader by id use `fileRepository.loaders.get( id )`.
*
* @param {File} file Native file handle.
* @param {File|Promise.<File>} fileOrPromise Native file or promise handle.
* @returns {module:upload/filerepository~FileLoader|null}
*/
getLoader( file ) {
for ( const loader of this.loaders ) {
if ( loader.file == file ) {
return loader;
}
}
return null;
getLoader( fileOrPromise ) {
return this._loadersMap.get( fileOrPromise ) || null;
}

@@ -148,6 +150,6 @@

*
* @param {File} file Native File object.
* @param {File|Promise.<File>} fileOrPromise Native File object or native Promise object which resolves to a File.
* @returns {module:upload/filerepository~FileLoader|null}
*/
createLoader( file ) {
createLoader( fileOrPromise ) {
if ( !this.createUploadAdapter ) {

@@ -163,3 +165,3 @@ /**

*
* See the {@glink features/image-upload comprehensive "Image upload" guide} to learn which upload
* See the {@glink features/image-upload/image-upload comprehensive "Image upload overview"} to learn which upload
* adapters are available in the builds and how to configure them.

@@ -171,5 +173,5 @@ *

* You can choose one of the existing upload adapters listed in the
* {@glink features/image-upload "Image upload" guide}.
* {@glink features/image-upload/image-upload "Image upload overview"}.
*
* You can also implement your {@glink framework/guides/deep-dive/upload-adapter own upload adapter}.
* You can also implement your {@glink framework/guides/deep-dive/upload-adapter own image upload adapter}.
*

@@ -183,7 +185,20 @@ * @error filerepository-no-upload-adapter

const loader = new FileLoader( file );
loader._adapter = this.createUploadAdapter( loader );
const loader = new FileLoader( Promise.resolve( fileOrPromise ), this.createUploadAdapter );
this.loaders.add( loader );
this._loadersMap.set( fileOrPromise, loader );
// Store also file => loader mapping so loader can be retrieved by file instance returned upon Promise resolution.
if ( fileOrPromise instanceof Promise ) {
loader.file.then( file => {
this._loadersMap.set( file, loader );
} );
}
// Catch the file promise rejection. If there are no `catch` clause, the browser
// will throw an error (see https://github.com/ckeditor/ckeditor5-upload/pull/90).
loader.file.catch( () => {
// The error will be handled by `FileLoader` so no action is required here.
} );
loader.on( 'change:uploaded', () => {

@@ -217,7 +232,7 @@ let aggregatedUploaded = 0;

*
* @param {File|module:upload/filerepository~FileLoader} fileOrLoader File associated with that loader or loader
* itself.
* @param {File|Promise|module:upload/filerepository~FileLoader} fileOrPromiseOrLoader File or Promise associated
* with that loader or loader itself.
*/
destroyLoader( fileOrLoader ) {
const loader = fileOrLoader instanceof FileLoader ? fileOrLoader : this.getLoader( fileOrLoader );
destroyLoader( fileOrPromiseOrLoader ) {
const loader = fileOrPromiseOrLoader instanceof FileLoader ? fileOrPromiseOrLoader : this.getLoader( fileOrPromiseOrLoader );

@@ -227,2 +242,8 @@ loader._destroy();

this.loaders.remove( loader );
this._loadersMap.forEach( ( value, key ) => {
if ( value === loader ) {
this._loadersMap.delete( key );
}
} );
}

@@ -264,6 +285,6 @@

*
* @param {File} file A native file instance.
* @param {module:upload/filerepository~UploadAdapter} adapter
* @param {Promise.<File>} filePromise A promise which resolves to a file instance.
* @param {Function} uploadAdapterCreator The function which returns {@link module:upload/filerepository~UploadAdapter} instance.
*/
constructor( file, adapter ) {
constructor( filePromise, uploadAdapterCreator ) {
/**

@@ -278,8 +299,8 @@ * Unique id of FileLoader instance.

/**
* A `File` instance associated with this file loader.
* Additional wrapper over the initial file promise passed to this loader.
*
* @readonly
* @member {File}
* @private
* @member {module:upload/filerepository~FilePromiseWrapper}
*/
this.file = file;
this._filePromiseWrapper = this._createFilePromiseWrapper( filePromise );

@@ -292,3 +313,3 @@ /**

*/
this._adapter = adapter;
this._adapter = uploadAdapterCreator( this );

@@ -370,2 +391,24 @@ /**

/**
* A `Promise` which resolves to a `File` instance associated with this file loader.
*
* @type {Promise.<File|null>}
*/
get file() {
if ( !this._filePromiseWrapper ) {
// Loader was destroyed, return promise which resolves to null.
return Promise.resolve( null );
} else {
// The `this._filePromiseWrapper.promise` is chained and not simply returned to handle a case when:
//
// * The `loader.file.then( ... )` is called by external code (returned promise is pending).
// * Then `loader._destroy()` is called (call is synchronous) which destroys the `loader`.
// * Promise returned by the first `loader.file.then( ... )` call is resolved.
//
// Returning `this._filePromiseWrapper.promise` will still resolve to a `File` instance so there
// is an additional check needed in the chain to see if `loader` was destroyed in the meantime.
return this._filePromiseWrapper.promise.then( file => this._filePromiseWrapper ? file : null );
}
}
/**
* Reads file using {@link module:upload/filereader~FileReader}.

@@ -388,3 +431,3 @@ *

*
* @returns {Promise} Returns promise that will be resolved with read data. Promise will be rejected if error
* @returns {Promise.<String>} Returns promise that will be resolved with read data. Promise will be rejected if error
* occurs or if read process is aborted.

@@ -399,3 +442,4 @@ */

return this._reader.read( this.file )
return this._filePromiseWrapper.promise
.then( file => this._reader.read( file ) )
.then( data => {

@@ -413,3 +457,3 @@ this.status = 'idle';

this.status = 'error';
throw this._reader.error;
throw this._reader.error ? this._reader.error : err;
} );

@@ -435,3 +479,3 @@ }

*
* @returns {Promise} Returns promise that will be resolved with response data. Promise will be rejected if error
* @returns {Promise.<Object>} Returns promise that will be resolved with response data. Promise will be rejected if error
* occurs or if read process is aborted.

@@ -446,3 +490,4 @@ */

return this._adapter.upload()
return this._filePromiseWrapper.promise
.then( () => this._adapter.upload() )
.then( data => {

@@ -471,7 +516,7 @@ this.uploadResponse = data;

if ( status == 'reading' ) {
if ( !this._filePromiseWrapper.isFulfilled ) {
this._filePromiseWrapper.rejecter( 'aborted' );
} else if ( status == 'reading' ) {
this._reader.abort();
}
if ( status == 'uploading' && this._adapter.abort ) {
} else if ( status == 'uploading' && this._adapter.abort ) {
this._adapter.abort();

@@ -489,2 +534,3 @@ }

_destroy() {
this._filePromiseWrapper = undefined;
this._reader = undefined;

@@ -494,4 +540,33 @@ this._adapter = undefined;

this.uploadResponse = undefined;
this.file = undefined;
}
/**
* Wraps a given file promise into another promise giving additional
* control (resolving, rejecting, checking if fulfilled) over it.
*
* @private
* @param filePromise The initial file promise to be wrapped.
* @returns {module:upload/filerepository~FilePromiseWrapper}
*/
_createFilePromiseWrapper( filePromise ) {
const wrapper = {};
wrapper.promise = new Promise( ( resolve, reject ) => {
wrapper.resolver = resolve;
wrapper.rejecter = reject;
wrapper.isFulfilled = false;
filePromise
.then( file => {
wrapper.isFulfilled = true;
resolve( file );
} )
.catch( err => {
wrapper.isFulfilled = true;
reject( err );
} );
} );
return wrapper;
}
}

@@ -539,3 +614,3 @@

* @method module:upload/filerepository~UploadAdapter#upload
* @returns {Promise} Promise that should be resolved when data is uploaded.
* @returns {Promise.<Object>} Promise that should be resolved when data is uploaded.
*/

@@ -552,1 +627,12 @@

*/
/**
* Object returned by {@link module:upload/filerepository~FileLoader#_createFilePromiseWrapper} method
* to add more control over the initial file promise passed to {@link module:upload/filerepository~FileLoader}.
*
* @typedef {Object} module:upload/filerepository~FilePromiseWrapper
* @property {Promise.<File>} promise Wrapper promise which can be chained for further processing.
* @property {Function} resolver Resolves the promise when called.
* @property {Function} rejecter Rejects the promise when called.
* @property {Boolean} isFulfilled Whether original promise is already fulfilled.
*/
/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc