feat: support drop images #398 (#402)

pr675
baseWalker 2 years ago committed by GitHub
parent eadf7f6e49
commit a96d239036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,9 +1,19 @@
import { CanvasEvent } from '../CanvasEvent'
import { pasteImage } from './paste'
export function drop(evt: DragEvent, host: CanvasEvent) {
evt.preventDefault()
const data = evt.dataTransfer?.getData('text')
if (data) {
host.input(data)
} else {
const files = evt.dataTransfer?.files
if (!files) return
for (let i = 0; i < files.length; i++) {
const file = files[i]
if (file.type.startsWith('image')) {
pasteImage(host, file)
}
}
}
}

Loading…
Cancel
Save