@ckeditor/ckeditor5-upload
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2
Changelog | ||
========= | ||
## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-upload/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2017-11-14) | ||
### Bug fixes | ||
* Destroying `FileDialogButtonView` should not throw an error. Closes [#66](https://github.com/ckeditor/ckeditor5-upload/issues/66). ([2d4ba62](https://github.com/ckeditor/ckeditor5-upload/commit/2d4ba62)) | ||
* Images pasted with additional HTML content will not be handled by the upload plugin which prevents data pasted from MS Word to be treated as an image. Closes [#68](https://github.com/ckeditor/ckeditor5-upload/issues/68). ([8d0644a](https://github.com/ckeditor/ckeditor5-upload/commit/8d0644a)) | ||
### Other changes | ||
* Updated translations. ([93e9643](https://github.com/ckeditor/ckeditor5-upload/commit/93e9643)) | ||
* Aligned UI library usage to the [changes in the UI framework](https://github.com/ckeditor/ckeditor5-ui/pull/332). | ||
### BREAKING CHANGES | ||
* The `FileDialogButtonView` is not a `ButtonView` instance anymore but a wrapper instead. The button of the component is available under the `#buttonView` property. | ||
## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-upload/compare/v0.2.0...v1.0.0-alpha.1) (2017-10-03) | ||
@@ -5,0 +22,0 @@ |
{ | ||
"name": "@ckeditor/ckeditor5-upload", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0-alpha.2", | ||
"description": "Upload Feature for CKEditor 5.", | ||
@@ -10,22 +10,22 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-engine": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-ui": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-utils": "^1.0.0-alpha.1" | ||
"@ckeditor/ckeditor5-core": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-engine": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-ui": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-utils": "^1.0.0-alpha.2" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-basic-styles": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-clipboard": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-dev-lint": "^3.1.4", | ||
"@ckeditor/ckeditor5-editor-classic": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-enter": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-heading": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-image": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-list": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-paragraph": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-typing": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-undo": "^1.0.0-alpha.1", | ||
"@ckeditor/ckeditor5-basic-styles": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-clipboard": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-editor-classic": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-enter": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-heading": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-image": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-list": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-paragraph": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-typing": "^1.0.0-alpha.2", | ||
"@ckeditor/ckeditor5-undo": "^1.0.0-alpha.2", | ||
"eslint": "^4.8.0", | ||
"eslint-config-ckeditor5": "^1.0.6", | ||
"gulp": "^3.9.1", | ||
"guppy-pre-commit": "^0.4.0" | ||
"husky": "^0.14.3", | ||
"lint-staged": "^4.2.3" | ||
}, | ||
@@ -48,3 +48,16 @@ "engines": { | ||
"theme" | ||
], | ||
"scripts": { | ||
"lint": "eslint --quiet '**/*.js'", | ||
"precommit": "lint-staged" | ||
}, | ||
"lint-staged": { | ||
"**/*.js": [ | ||
"eslint --quiet" | ||
] | ||
}, | ||
"eslintIgnore": [ | ||
"src/lib/**", | ||
"packages/**" | ||
] | ||
} |
@@ -30,6 +30,6 @@ /** | ||
* (which boils down to setting the {@link ~FileRepository#createAdapter} factory function – see | ||
* {@link ~Adapter `Adapter` interface} documentation). | ||
* {@link module:upload/filerepository~Adapter `Adapter` interface} documentation). | ||
* | ||
* Then, you can use {@link ~FileRepository#createLoader `createLoader()`} and the returned {@link ~FileLoader} instance to | ||
* load and upload files. | ||
* 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. | ||
* | ||
@@ -36,0 +36,0 @@ * @extends module:core/plugin~Plugin |
@@ -43,5 +43,2 @@ /** | ||
view.set( { | ||
label: t( 'Insert image' ), | ||
icon: imageIcon, | ||
tooltip: true, | ||
acceptedType: 'image/*', | ||
@@ -51,2 +48,8 @@ allowMultipleFiles: true | ||
view.buttonView.set( { | ||
label: t( 'Insert image' ), | ||
icon: imageIcon, | ||
tooltip: true | ||
} ); | ||
view.bind( 'isEnabled' ).to( command ); | ||
@@ -53,0 +56,0 @@ |
@@ -49,2 +49,8 @@ /** | ||
editor.editing.view.on( 'clipboardInput', ( evt, data ) => { | ||
// Skip if non empty HTML data is included. | ||
// https://github.com/ckeditor/ckeditor5-upload/issues/68 | ||
if ( isHtmlIncluded( data.dataTransfer ) ) { | ||
return; | ||
} | ||
let targetModelSelection = new ModelSelection( | ||
@@ -198,1 +204,9 @@ data.targetRanges.map( viewRange => editor.editing.mapper.toModelRange( viewRange ) ) | ||
} | ||
// Returns true if non-empty `text/html` is included in data transfer. | ||
// | ||
// @param {module:clipboard/datatransfer~DataTransfer} dataTransfer | ||
// @returns {Boolean} | ||
export function isHtmlIncluded( dataTransfer ) { | ||
return Array.from( dataTransfer.types ).includes( 'text/html' ) && dataTransfer.getData( 'text/html' ) !== ''; | ||
} |
@@ -6,4 +6,2 @@ /** | ||
/* globals document */ | ||
/** | ||
@@ -15,10 +13,31 @@ * @module upload/ui/filedialogbuttonview | ||
import View from '@ckeditor/ckeditor5-ui/src/view'; | ||
import Template from '@ckeditor/ckeditor5-ui/src/template'; | ||
/** | ||
* File Dialog button view. | ||
* The file dialog button view. | ||
* | ||
* @extends module:ui/button/buttonview~ButtonView | ||
* This component provides a button that opens the native file selection dialog. | ||
* It can be used to implement the UI of a file upload feature. | ||
* | ||
* const view = new FileDialogButtonView( locale ); | ||
* | ||
* view.set( { | ||
* acceptedType: 'image/*', | ||
* allowMultipleFiles: true | ||
* } ); | ||
* | ||
* view.buttonView.set( { | ||
* label: t( 'Insert image' ), | ||
* icon: imageIcon, | ||
* tooltip: true | ||
* } ); | ||
* | ||
* view.on( 'done', ( evt, files ) => { | ||
* for ( const file of Array.from( files ) ) { | ||
* console.log( 'Selected file', file ); | ||
* } | ||
* } ); | ||
* | ||
* @extends module:ui/view~View | ||
*/ | ||
export default class FileDialogButtonView extends ButtonView { | ||
export default class FileDialogButtonView extends View { | ||
/** | ||
@@ -31,8 +50,15 @@ * @inheritDoc | ||
/** | ||
* Hidden input view used to execute file dialog. It will be hidden and added to the end of `document.body`. | ||
* The button view of the component. | ||
* | ||
* @member {module:ui/button/buttonview~ButtonView} | ||
*/ | ||
this.buttonView = new ButtonView( locale ); | ||
/** | ||
* A hidden `<input>` view used to execute file dialog. | ||
* | ||
* @protected | ||
* @member {module:upload/ui/filedialogbuttonview~FileInputView} | ||
*/ | ||
this.fileInputView = new FileInputView( locale ); | ||
this._fileInputView = new FileInputView( locale ); | ||
@@ -48,3 +74,3 @@ /** | ||
*/ | ||
this.fileInputView.bind( 'acceptedType' ).to( this, 'acceptedType' ); | ||
this._fileInputView.bind( 'acceptedType' ).to( this ); | ||
@@ -57,4 +83,3 @@ /** | ||
*/ | ||
this.set( 'allowMultipleFiles', false ); | ||
this.fileInputView.bind( 'allowMultipleFiles' ).to( this, 'allowMultipleFiles' ); | ||
this._fileInputView.bind( 'allowMultipleFiles' ).to( this ); | ||
@@ -64,7 +89,7 @@ /** | ||
* | ||
* fileDialogButtonView.on( 'done', ( evt, files ) => { | ||
* for ( const file of files ) { | ||
* processFile( file ); | ||
* view.on( 'done', ( evt, files ) => { | ||
* for ( const file of files ) { | ||
* console.log( 'Selected file', file ); | ||
* } | ||
* } | ||
* } | ||
* | ||
@@ -74,18 +99,25 @@ * @event done | ||
*/ | ||
this.fileInputView.delegate( 'done' ).to( this ); | ||
this._fileInputView.delegate( 'done' ).to( this ); | ||
this.on( 'execute', () => { | ||
this.fileInputView.open(); | ||
this.setTemplate( { | ||
tag: 'span', | ||
attributes: { | ||
class: 'ck-file-dialog-button', | ||
}, | ||
children: [ | ||
this.buttonView, | ||
this._fileInputView | ||
] | ||
} ); | ||
document.body.appendChild( this.fileInputView.element ); | ||
this.buttonView.on( 'execute', () => { | ||
this._fileInputView.open(); | ||
} ); | ||
} | ||
/** | ||
* @inheritDoc | ||
* Focuses the {@link #buttonView}. | ||
*/ | ||
destroy() { | ||
document.body.removeChild( this.fileInputView.element ); | ||
super.destroy(); | ||
focus() { | ||
this.buttonView.focus(); | ||
} | ||
@@ -95,3 +127,3 @@ } | ||
/** | ||
* Hidden file input view class. | ||
* The hidden file input view class. | ||
* | ||
@@ -129,3 +161,3 @@ * @private | ||
this.template = new Template( { | ||
this.setTemplate( { | ||
tag: 'input', | ||
@@ -132,0 +164,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63126
42
1215