drop.chapril.org-firefoxsend/app/pasteManager.js

16 lines
397 B
JavaScript
Raw Normal View History

2018-06-06 06:39:26 +02:00
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
2018-08-03 21:24:41 +02:00
emitter.emit('addFiles', { files: [file] });
2018-06-06 06:39:26 +02:00
}
});
}