mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-04-05 06:39:02 +02:00
Fix a bug where images could no longer be dragged and dropped onto the initial image box
This commit is contained in:
parent
57c3acd9d8
commit
fa080e380c
@ -280,7 +280,7 @@
|
|||||||
<script src="media/js/auto-save.js?v=4"></script>
|
<script src="media/js/auto-save.js?v=4"></script>
|
||||||
<script src="media/js/main.js?v=8"></script>
|
<script src="media/js/main.js?v=8"></script>
|
||||||
<script src="media/js/themes.js?v=3"></script>
|
<script src="media/js/themes.js?v=3"></script>
|
||||||
<script src="media/js/dnd.js?v=4"></script>
|
<script src="media/js/dnd.js?v=5"></script>
|
||||||
<script>
|
<script>
|
||||||
async function init() {
|
async function init() {
|
||||||
await initSettings()
|
await initSettings()
|
||||||
|
@ -359,18 +359,21 @@ async function readFile(file, i) {
|
|||||||
|
|
||||||
function dropHandler(ev) {
|
function dropHandler(ev) {
|
||||||
console.log('Content dropped...')
|
console.log('Content dropped...')
|
||||||
// Prevent default behavior (Prevent file/content from being opened)
|
let items = []
|
||||||
ev.preventDefault()
|
|
||||||
|
|
||||||
if (ev?.dataTransfer?.items) { // Use DataTransferItemList interface
|
if (ev?.dataTransfer?.items) { // Use DataTransferItemList interface
|
||||||
Array.from(ev.dataTransfer.items).forEach(function(item, i) {
|
items = Array.from(ev.dataTransfer.items)
|
||||||
if (item.kind === 'file') {
|
items = items.filter(item => item.kind === 'file')
|
||||||
const file = item.getAsFile()
|
items = items.map(item => item.getAsFile())
|
||||||
readFile(file, i)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else if (ev?.dataTransfer?.files) { // Use DataTransfer interface
|
} else if (ev?.dataTransfer?.files) { // Use DataTransfer interface
|
||||||
Array.from(ev.dataTransfer.files).forEach(readFile)
|
items = Array.from(ev.dataTransfer.files)
|
||||||
|
}
|
||||||
|
|
||||||
|
items = items.filter(item => item.name.toLowerCase().endsWith('.txt') || item.name.toLowerCase().endsWith('.json'))
|
||||||
|
|
||||||
|
if (items.length > 0) {
|
||||||
|
ev.preventDefault() // Prevent default behavior (Prevent file/content from being opened)
|
||||||
|
items.forEach(readFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function dragOverHandler(ev) {
|
function dragOverHandler(ev) {
|
||||||
|
Loading…
Reference in New Issue
Block a user