support in-app DND to editor area

This commit is contained in:
Benjamin Pasero 2016-06-15 15:11:18 +02:00
parent 425305ae31
commit f0c511b372

View file

@ -762,20 +762,32 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
node.addEventListener(DOM.EventType.DROP, (e: DragEvent) => {
DOM.EventHelper.stop(e);
// Check for native file transfer
if (e.dataTransfer && e.dataTransfer.files) {
let thepaths: string[] = [];
for (let i = 0; i < e.dataTransfer.files.length; i++) {
if (e.dataTransfer.files[i] && e.dataTransfer.files[i].path) {
thepaths.push(e.dataTransfer.files[i].path);
const droppedResources: URI[] = [];
if (e.dataTransfer.types.length > 0) {
// Check for in-app DND
const rawData = e.dataTransfer.getData(e.dataTransfer.types[0]);
if (rawData) {
const resource = URI.parse(rawData);
if (resource.scheme === 'file' || resource.scheme === 'untitled') {
droppedResources.push(resource);
}
}
if (thepaths.length) {
window.focus(); // make sure this window has focus so that the open call reaches the right window!
this.openFromDrop(thepaths.map(p => URI.file(p)), <HTMLElement>e.toElement).done(null, errors.onUnexpectedError);
// Check for native file transfer
if (e.dataTransfer && e.dataTransfer.files) {
for (let i = 0; i < e.dataTransfer.files.length; i++) {
if (e.dataTransfer.files[i] && e.dataTransfer.files[i].path) {
droppedResources.push(URI.file(e.dataTransfer.files[i].path));
}
}
}
}
if (droppedResources.length) {
window.focus(); // make sure this window has focus so that the open call reaches the right window!
this.openFromDrop(droppedResources, <HTMLElement>e.toElement).done(null, errors.onUnexpectedError);
}
});
}