fox-send/app/pasteManager.js

16 lines
397 B
JavaScript
Raw Normal View History

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