提交 7086bb87 编写于 作者: I isidor

multiple selection drag and drop inside workbench

上级 fca6ee5d
......@@ -49,6 +49,11 @@ export const DataTransfers = {
*/
URL: 'URL',
/**
* Application specific resource transfer type when multiple resources are being dragged.
*/
URLS: 'URLS',
/**
* Browser specific transfer type to download.
*/
......@@ -58,4 +63,4 @@ export const DataTransfers = {
* Typicaly transfer type for copy/paste transfers.
*/
TEXT: 'text/plain'
};
\ No newline at end of file
};
......@@ -241,13 +241,19 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): (IDragge
// Data Transfer: URL
else {
const rawURLData = e.dataTransfer.getData(DataTransfers.URL);
if (rawURLData) {
try {
resources.push({ resource: URI.parse(rawURLData), isExternal: false });
} catch (error) {
// Invalid URI
try {
const rawURLsData = e.dataTransfer.getData(DataTransfers.URLS);
if (rawURLsData) {
const uriStrArray: string[] = JSON.parse(rawURLsData);
resources.push(...uriStrArray.map(uriStr => ({ resource: URI.parse(uriStr), isExternal: false })));
} else {
const rawURLData = e.dataTransfer.getData(DataTransfers.URL);
if (rawURLData) {
resources.push({ resource: URI.parse(rawURLData), isExternal: false });
}
}
} catch (error) {
// Invalid URI
}
}
}
......@@ -268,4 +274,4 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): (IDragge
}
return resources;
}
\ No newline at end of file
}
......@@ -726,13 +726,14 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop {
});
// Apply some datatransfer types to allow for dragging the element outside of the application
// TODO@Isidor check this
if (sources.length === 1) {
if (!sources[0].isDirectory) {
originalEvent.dataTransfer.setData(DataTransfers.DOWNLOAD_URL, [MIME_BINARY, sources[0].name, sources[0].resource.toString()].join(':'));
}
originalEvent.dataTransfer.setData(DataTransfers.TEXT, getPathLabel(sources[0].resource));
} else {
originalEvent.dataTransfer.setData(DataTransfers.URLS, JSON.stringify(sources.map(s => s.resource.toString())));
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册