mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Fix tree view sample to run on older versions of VS Code
Fixes https://github.com/microsoft/vscode-extension-samples/issues/531
This commit is contained in:
@ -36,6 +36,9 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
// Test View
|
||||
new TestView(context);
|
||||
|
||||
// Drag and Drop sample
|
||||
new TestViewDragAndDrop(context);
|
||||
// Drag and Drop proposed API sample
|
||||
// This check is for older versions of VS Code that don't have the most up-to-date tree drag and drop API proposal.
|
||||
if (typeof vscode.TreeDataTransferItem === 'function') {
|
||||
new TestViewDragAndDrop(context);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,16 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
class TestViewObjectTransferItem extends vscode.TreeDataTransferItem {
|
||||
// TestTreeDataTransferItem is for older versions of VS Code that don't have the most up-to-date tree drag and drop API proposal.
|
||||
const TestTreeDataTransferItem = (typeof vscode.TreeDataTransferItem === 'function') ? vscode.TreeDataTransferItem : class MockItem {
|
||||
async asString(): Promise<string> {
|
||||
return 'mock';
|
||||
}
|
||||
|
||||
constructor(_value: any) { /* this is a mock constructor */ }
|
||||
};
|
||||
|
||||
|
||||
class TestViewObjectTransferItem extends TestTreeDataTransferItem {
|
||||
constructor(private _nodes: Node[]) {
|
||||
super(_nodes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user