diff --git a/packages/block-library/CHANGELOG.md b/packages/block-library/CHANGELOG.md index 8df197bb991957..39fbb90aa0c65f 100644 --- a/packages/block-library/CHANGELOG.md +++ b/packages/block-library/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.1.8 (Unreleased) + +### Polish + +- File Block: Create file blocks when dropping multiple files at once. + ## 2.1.7 (2018-10-30) ## 2.1.6 (2018-10-30) diff --git a/packages/block-library/src/file/index.js b/packages/block-library/src/file/index.js index 7f26a4abc025e4..43471765187c8a 100644 --- a/packages/block-library/src/file/index.js +++ b/packages/block-library/src/file/index.js @@ -77,20 +77,27 @@ export const settings = { from: [ { type: 'files', - isMatch: ( files ) => files.length === 1, + isMatch( files ) { + return files.length > 0; + }, // We define a lower priorty (higher number) than the default of 10. This // ensures that the File block is only created as a fallback. priority: 15, transform: ( files ) => { - const file = files[ 0 ]; - const blobURL = createBlobURL( file ); + const blocks = []; - // File will be uploaded in componentDidMount() - return createBlock( 'core/file', { - href: blobURL, - fileName: file.name, - textLinkHref: blobURL, + files.map( ( file ) => { + const blobURL = createBlobURL( file ); + + // File will be uploaded in componentDidMount() + blocks.push( createBlock( 'core/file', { + href: blobURL, + fileName: file.name, + textLinkHref: blobURL, + } ) ); } ); + + return blocks; }, }, {