This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/app/utils/getDataTransferFiles.js
Tom Moor d024d31f66
refactor: flow typing (#1012)
* fix: padding

* fix: Minor button alignment issues

* feat: Add icon to invite people button

* WIP
2019-08-08 23:09:09 -07:00

23 lines
769 B
JavaScript

// @flow
export default function getDataTransferFiles(event: SyntheticEvent<>): File[] {
let dataTransferItemsList = [];
// $FlowFixMe
if (event.dataTransfer) {
const dt = event.dataTransfer;
if (dt.files && dt.files.length) {
dataTransferItemsList = dt.files;
} else if (dt.items && dt.items.length) {
// During the drag even the dataTransfer.files is null
// but Chrome implements some drag store, which is accesible via dataTransfer.items
dataTransferItemsList = dt.items;
}
// $FlowFixMe
} else if (event.target && event.target.files) {
dataTransferItemsList = event.target.files;
}
// Convert from DataTransferItemsList to the native Array
return Array.prototype.slice.call(dataTransferItemsList);
}