mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
support in-app DND to editor area
This commit is contained in:
parent
425305ae31
commit
f0c511b372
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue