diff options
author | MMaker <mmaker@mmaker.moe> | 2023-01-03 17:46:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-03 17:46:48 +0000 |
commit | 7c89f3718f9f078113833a88a86f02d3205855b4 (patch) | |
tree | 9f20643fce1a10822914f03b27ce634ce1636e10 /javascript | |
parent | 82cfc227d735c140447d5b8dca29a71ee9bde127 (diff) | |
download | stable-diffusion-webui-gfx803-7c89f3718f9f078113833a88a86f02d3205855b4.tar.gz stable-diffusion-webui-gfx803-7c89f3718f9f078113833a88a86f02d3205855b4.tar.bz2 stable-diffusion-webui-gfx803-7c89f3718f9f078113833a88a86f02d3205855b4.zip |
Add image paste fallback
Fixes Firefox pasting support
(and possibly other browsers)
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/dragdrop.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/javascript/dragdrop.js b/javascript/dragdrop.js index 3ed1cb3c..fe008924 100644 --- a/javascript/dragdrop.js +++ b/javascript/dragdrop.js @@ -9,11 +9,19 @@ function dropReplaceImage( imgWrap, files ) { return; } + const tmpFile = files[0]; + imgWrap.querySelector('.modify-upload button + button, .touch-none + div button + button')?.click(); const callback = () => { const fileInput = imgWrap.querySelector('input[type="file"]'); if ( fileInput ) { - fileInput.files = files; + if ( files.length === 0 ) { + files = new DataTransfer(); + files.items.add(tmpFile); + fileInput.files = files.files; + } else { + fileInput.files = files; + } fileInput.dispatchEvent(new Event('change')); } }; |