mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
Merge pull request #123 from fuzzytent/paste-images
Allow copy-pasting images into file inputs
This commit is contained in:
commit
782b819a55
16
script.js
16
script.js
@ -172,3 +172,19 @@ function submit(){
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener('paste', e => {
|
||||||
|
const files = e.clipboardData.files;
|
||||||
|
if (!files || files.length !== 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!['image/png', 'image/gif', 'image/jpeg'].includes(files[0].type)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[...gradioApp().querySelectorAll('input[type=file][accept="image/x-png,image/gif,image/jpeg"]')]
|
||||||
|
.filter(input => !input.matches('.\\!hidden input[type=file]'))
|
||||||
|
.forEach(input => {
|
||||||
|
input.files = files;
|
||||||
|
input.dispatchEvent(new Event('change'))
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user