mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Prevent error whilst drag/drop importing from leaving dropTarget visible
Fixes #2982
This commit is contained in:
parent
e641b0a965
commit
3e43597617
@ -1260,22 +1260,27 @@ RED.clipboard = (function() {
|
|||||||
hideDropTarget();
|
hideDropTarget();
|
||||||
})
|
})
|
||||||
.on("drop",function(event) {
|
.on("drop",function(event) {
|
||||||
if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
|
try {
|
||||||
var data = event.originalEvent.dataTransfer.getData("text/plain");
|
if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
|
||||||
data = data.substring(data.indexOf('['),data.lastIndexOf(']')+1);
|
var data = event.originalEvent.dataTransfer.getData("text/plain");
|
||||||
importNodes(data);
|
data = data.substring(data.indexOf('['),data.lastIndexOf(']')+1);
|
||||||
} else if ($.inArray("Files",event.originalEvent.dataTransfer.types) != -1) {
|
importNodes(data);
|
||||||
var files = event.originalEvent.dataTransfer.files;
|
} else if ($.inArray("Files",event.originalEvent.dataTransfer.types) != -1) {
|
||||||
if (files.length === 1) {
|
var files = event.originalEvent.dataTransfer.files;
|
||||||
var file = files[0];
|
if (files.length === 1) {
|
||||||
var reader = new FileReader();
|
var file = files[0];
|
||||||
reader.onload = (function(theFile) {
|
var reader = new FileReader();
|
||||||
return function(e) {
|
reader.onload = (function(theFile) {
|
||||||
importNodes(e.target.result);
|
return function(e) {
|
||||||
};
|
importNodes(e.target.result);
|
||||||
})(file);
|
};
|
||||||
reader.readAsText(file);
|
})(file);
|
||||||
|
reader.readAsText(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch(err) {
|
||||||
|
// Ensure any errors throw above doesn't stop the drop target from
|
||||||
|
// being hidden.
|
||||||
}
|
}
|
||||||
hideDropTarget();
|
hideDropTarget();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
Loading…
Reference in New Issue
Block a user