@@ -26,42 +26,85 @@ declare module 'vscode' {
26
26
dragAndDropController ?: DragAndDropController < T > ;
27
27
}
28
28
29
+ /**
30
+ * A class for encapsulating data transferred during a tree drag and drop event.
31
+ *
32
+ * If your `DragAndDropController` implements `onWillDrop`, you can extend `TreeDataTransferItem` and return
33
+ * an instance of your new class for easy access to the source tree items.
34
+ *
35
+ * ```ts
36
+ * class TestViewObjectTransferItem extends vscode.TreeDataTransferItem {
37
+ * constructor(private _nodes: Node[]) {
38
+ * super(_nodes);
39
+ * }
40
+ *
41
+ * asObject(): Node[] {
42
+ * return this._nodes;
43
+ * }
44
+ * }
45
+ * ```
46
+ */
29
47
export class TreeDataTransferItem {
30
48
asString ( ) : Thenable < string > ;
31
49
32
50
constructor ( value : any ) ;
33
51
}
34
52
53
+ /**
54
+ * A map containing a mapping of the mime type of the corresponding transferred data.
55
+ * Trees that support drag and drop can implement `DragAndDropController.onWillDrop` to add additional mime types
56
+ * when the drop occurs on an item in the same tree.
57
+ */
35
58
export class TreeDataTransfer < T extends TreeDataTransferItem = TreeDataTransferItem > {
36
59
/**
37
- * A map containing a mapping of the mime type of the corresponding data.
38
- * Trees that support drag and drop can implement `DragAndDropController.onWillDrop` to add additional mime types
39
- * when the drop occurs on an item in the same tree.
60
+ * Retrieves the data transfer item for a given mime type.
61
+ * @param mimeType The mime type to get the data transfer item for.
40
62
*/
41
63
get ( mimeType : string ) : T | undefined ;
64
+
65
+ /**
66
+ * Sets a mime type to data transfer item mapping.
67
+ * @param mimeType The mime type to set the data for.
68
+ * @param value The data transfer item for the given mime type.
69
+ */
42
70
set ( mimeType : string , value : T ) : void ;
71
+
72
+ /**
73
+ * Allows iteration through the data transfer items.
74
+ * @param callbackfn Callback for iteration through the data transfer items.
75
+ */
43
76
forEach ( callbackfn : ( value : T , key : string ) => void ) : void ;
44
77
}
45
78
79
+ /**
80
+ * Provides support for drag and drop in `TreeView`.
81
+ */
46
82
export interface DragAndDropController < T > extends Disposable {
83
+
84
+ /**
85
+ * The mime types that this `DragAndDropController` supports. This could be well-defined, existing, mime types,
86
+ * and also mime types defined by the extension that are returned in the `TreeDataTransfer` from `onWillDrop`.
87
+ */
47
88
readonly supportedMimeTypes : string [ ] ;
48
89
49
90
/**
50
91
* When the user drops an item from this DragAndDropController on **another tree item** in **the same tree**,
51
- * `onWillDrop` will be called with the dropped tree item . This is the DragAndDropController's opportunity to
92
+ * `onWillDrop` will be called with the dropped tree items . This is the DragAndDropController's opportunity to
52
93
* package the data from the dropped tree item into whatever format they want the target tree item to receive.
53
94
*
54
95
* The returned `TreeDataTransfer` will be merged with the original`TreeDataTransfer` for the operation.
55
96
*
56
- * @param source
97
+ * @param source The source items for the drag and drop operation.
57
98
*/
58
99
onWillDrop ( source : T [ ] ) : Thenable < TreeDataTransfer > ;
59
100
60
101
/**
102
+ * Called when a drag and drop action results in a drop on the tree that this `DragAndDropController` belongs too.
103
+ *
61
104
* Extensions should fire `TreeDataProvider.onDidChangeTreeData` for any elements that need to be refreshed.
62
105
*
63
- * @param source
64
- * @param target
106
+ * @param source The data transfer items of the source of the drag.
107
+ * @param target The target tree element that the drop is occuring on.
65
108
*/
66
109
onDrop ( source : TreeDataTransfer , target : T ) : Thenable < void > ;
67
110
}
0 commit comments