diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-09-08 04:49:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-08 04:49:12 +0000 |
commit | 782b819a553404f43b67fe1ca19afd5678af4834 (patch) | |
tree | a841e071c6a204632cbdeec7f80dad8023ac25dc /script.js | |
parent | 02fecac1c7c3ee5451b7c67ce62c138be63c5cf2 (diff) | |
parent | 4d5a366f00de906b8ff5b124f7f7b6e771fee155 (diff) | |
download | stable-diffusion-webui-gfx803-782b819a553404f43b67fe1ca19afd5678af4834.tar.gz stable-diffusion-webui-gfx803-782b819a553404f43b67fe1ca19afd5678af4834.tar.bz2 stable-diffusion-webui-gfx803-782b819a553404f43b67fe1ca19afd5678af4834.zip |
Merge pull request #123 from fuzzytent/paste-images
Allow copy-pasting images into file inputs
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -172,3 +172,19 @@ function submit(){ } 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')) + }); +}); |