aboutsummaryrefslogtreecommitdiff
path: root/javascript
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-01-04 14:15:44 +0300
committerGitHub <noreply@github.com>2023-01-04 14:15:44 +0300
commitc6c56c807aa83b6e26b773c7bee8576b91fde9bc (patch)
tree755f417b62f0b6d559f0526bcec3b5acb0372412 /javascript
parentaa44f40cc1acc8c58a449feca938cfd15b99aca2 (diff)
parent7c89f3718f9f078113833a88a86f02d3205855b4 (diff)
Merge pull request #6272 from stysmmaker/feat/image-paste-fallback
Add image paste fallback
Diffstat (limited to 'javascript')
-rw-r--r--javascript/dragdrop.js10
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'));
}
};