Skip to content

Commit

Permalink
Update the drop example to use finalized api
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Jul 14, 2022
1 parent d7c486e commit 60b6a7e
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 86 deletions.
2 changes: 1 addition & 1 deletion drop-on-document/README.md
@@ -1,6 +1,6 @@
# Document on Drop Sample

This sample shows usage of the [document on drop API proposal](https://github.com/microsoft/vscode/issues/142990). It requires VS Code 1.69.
This sample shows usage of the [document on drop API](https://github.com/microsoft/vscode/issues/142990). It requires VS Code 1.70+.

This sample adds two sample drop providers for plain text files:

Expand Down
106 changes: 91 additions & 15 deletions drop-on-document/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions drop-on-document/package.json
Expand Up @@ -10,11 +10,8 @@
"type": "git",
"url": "https://github.com/Microsoft/vscode-extension-samples"
},
"enabledApiProposals": [
"textEditorDrop"
],
"engines": {
"vscode": "^1.69.0"
"vscode": "^1.70.0"
},
"categories": [
"Other"
Expand All @@ -28,14 +25,16 @@
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"lint": "eslint . --ext .ts,.tsx",
"watch": "tsc -watch -p ./"
"watch": "tsc -watch -p ./",
"download-api": "vscode-dts main",
"postinstall": "npm run download-api"
},
"devDependencies": {
"@types/node": "^16.11.7",
"@types/vscode": "^1.32.0",
"@typescript-eslint/eslint-plugin": "^5.30.0",
"@typescript-eslint/parser": "^5.30.0",
"eslint": "^8.13.0",
"typescript": "^4.7.2"
"typescript": "^4.7.2",
"vscode-dts": "^0.3.3"
}
}
14 changes: 7 additions & 7 deletions drop-on-document/src/extension.ts
Expand Up @@ -7,10 +7,10 @@ const uriListMime = 'text/uri-list';
* Provider that reverses dropped text.
*
* Note this does not apply to text that is drag and dropped with-in the current editor,
* only for text dropped from external apps.
* only for text dropped from external apps.
*/
class ReverseTextOnDropProvider implements vscode.DocumentOnDropEditProvider {
async provideDocumentOnDropEdits(
class ReverseTextOnDropProvider implements vscode.DocumentDropEditProvider {
async provideDocumentDropEdits(
_document: vscode.TextDocument,
position: vscode.Position,
dataTransfer: vscode.DataTransfer,
Expand Down Expand Up @@ -45,8 +45,8 @@ class ReverseTextOnDropProvider implements vscode.DocumentOnDropEditProvider {
* - The operating system
* - The open editors view
*/
class FileNameListOnDropProvider implements vscode.DocumentOnDropEditProvider {
async provideDocumentOnDropEdits(
class FileNameListOnDropProvider implements vscode.DocumentDropEditProvider {
async provideDocumentDropEdits(
_document: vscode.TextDocument,
position: vscode.Position,
dataTransfer: vscode.DataTransfer,
Expand Down Expand Up @@ -100,6 +100,6 @@ export function activate(context: vscode.ExtensionContext) {
const selector: vscode.DocumentSelector = { language: 'plaintext' };

// Register our providers
context.subscriptions.push(vscode.languages.registerDocumentOnDropEditProvider(selector, new ReverseTextOnDropProvider()));
context.subscriptions.push(vscode.languages.registerDocumentOnDropEditProvider(selector, new FileNameListOnDropProvider()));
context.subscriptions.push(vscode.languages.registerDocumentDropEditProvider(selector, new ReverseTextOnDropProvider()));
context.subscriptions.push(vscode.languages.registerDocumentDropEditProvider(selector, new FileNameListOnDropProvider()));
}
56 changes: 0 additions & 56 deletions drop-on-document/src/vscode.proposed.textEditorDrop.d.ts

This file was deleted.

0 comments on commit 60b6a7e

Please sign in to comment.