Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
788 additions
and
224 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { extensions } from "shared/extensions/extensions"; | ||
|
||
export function handleDragAndDrop() { | ||
function removeDragData(ev: DragEvent) { | ||
if (ev.dataTransfer.items) { | ||
// Use DataTransferItemList interface to remove the drag data | ||
ev.dataTransfer.items.clear(); | ||
} else { | ||
// Use DataTransfer interface to remove the drag data | ||
ev.dataTransfer.clearData(); | ||
} | ||
} | ||
|
||
$(document).on("dragover", $ev => { | ||
$ev.preventDefault(); | ||
const ev = $ev.originalEvent as DragEvent; | ||
ev.dataTransfer.dropEffect = "copy"; | ||
}); | ||
|
||
$(document).on("drop", async $ev => { | ||
$ev.preventDefault(); | ||
const ev = $ev.originalEvent as DragEvent; | ||
|
||
var dt = ev.dataTransfer; | ||
var files = dt.files; | ||
|
||
for (let file of files) { | ||
for (let extension of extensions) { | ||
const handleDragAndDropFile = extension[1].handleDragAndDropFile; | ||
if (handleDragAndDropFile && (await handleDragAndDropFile(file.path))) { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
removeDragData(ev); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.