imageParams.js 675 B

123456789101112131415161718
  1. window.onload = (function(){
  2. window.addEventListener('drop', e => {
  3. const target = e.composedPath()[0];
  4. if (target.placeholder.indexOf("Prompt") == -1) return;
  5. let prompt_target = get_tab_index('tabs') == 1 ? "img2img_prompt_image" : "txt2img_prompt_image";
  6. e.stopPropagation();
  7. e.preventDefault();
  8. const imgParent = gradioApp().getElementById(prompt_target);
  9. const files = e.dataTransfer.files;
  10. const fileInput = imgParent.querySelector('input[type="file"]');
  11. if ( fileInput ) {
  12. fileInput.files = files;
  13. fileInput.dispatchEvent(new Event('change'));
  14. }
  15. });
  16. });