فهرست منبع

enable dragging multiple selected files within & out of filebrowser (#3729)

* enable dragging multiple selected files within filebrowser

* add ability to drag and drop multiple files if they are selected

Right now this does not handle moving open widgets properly.
M Pacer 7 سال پیش
والد
کامیت
7c095b01ce
1فایلهای تغییر یافته به همراه18 افزوده شده و 2 حذف شده
  1. 18 2
      packages/filebrowser/src/listing.ts

+ 18 - 2
packages/filebrowser/src/listing.ts

@@ -26,7 +26,7 @@ import {
 } from '@phosphor/algorithm';
 
 import {
-  MimeData
+  MimeData, PromiseDelegate
 } from '@phosphor/coreutils';
 
 import {
@@ -1127,7 +1127,7 @@ class DirListing extends Widget {
     if (!source.classList.contains(SELECTED_CLASS)) {
       item = items[index];
       selectedNames = [item.name];
-    } else if (selectedNames.length === 1) {
+    } else {
       let name = selectedNames[0];
       item = find(items, value => value.name === name);
     }
@@ -1153,6 +1153,7 @@ class DirListing extends Widget {
     }));
     this._drag.mimeData.setData(CONTENTS_MIME, paths);
     if (item && item.type !== 'directory') {
+      const otherPaths = paths.slice(1).reverse();
       this._drag.mimeData.setData(FACTORY_MIME, () => {
         if (!item) {
           return;
@@ -1162,6 +1163,21 @@ class DirListing extends Widget {
         if (!widget) {
           widget = this._manager.open(item.path);
         }
+        if (otherPaths.length) {
+          const firstWidgetPlaced = new PromiseDelegate<void>();
+          firstWidgetPlaced.promise.then(() => {
+            let prevWidget = widget;
+            otherPaths.forEach(path => {
+              const options: DocumentRegistry.IOpenOptions = {
+                ref: prevWidget.id,
+                mode: 'tab-after'
+              };
+              prevWidget = this._manager.openOrReveal(path, void 0, void 0, options);
+              this._manager.openOrReveal(item.path);
+            });
+          });
+          firstWidgetPlaced.resolve(void 0);
+        }
         return widget;
       });
     }