提交 f0c511b3 编写于 作者: B Benjamin Pasero

support in-app DND to editor area

上级 425305ae
......@@ -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);
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册