send/app/pasteManager.js
2018-08-03 16:11:13 -07:00

15 lines
397 B
JavaScript

export default function(state, emitter) {
window.addEventListener('paste', event => {
if (state.route !== '/' || state.uploading) return;
for (const item of event.clipboardData.items) {
if (!item.type.includes('image')) continue;
const file = item.getAsFile();
if (!file) continue; // Sometimes null
emitter.emit('addFiles', { files: [file] });
}
});
}