imageParams.js 721 B

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