Move markdown preview files to own folder

This commit is contained in:
Matt Bierner
2022-03-29 11:34:05 -07:00
parent ffd8aea1a7
commit 7736c87cb0
25 changed files with 27 additions and 27 deletions

View File

@@ -0,0 +1,47 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import * as vscode from 'vscode';
import * as URI from 'vscode-uri';
export function registerDropIntoEditor() {
return vscode.workspace.onWillDropOnTextEditor(e => {
e.waitUntil((async () => {
const urlList = await e.dataTransfer.get('text/uri-list')?.asString();
if (!urlList) {
return;
}
const uris: vscode.Uri[] = [];
for (const resource of urlList.split('\n')) {
try {
uris.push(vscode.Uri.parse(resource));
} catch {
// noop
}
}
if (!uris.length) {
return;
}
const snippet = new vscode.SnippetString();
uris.forEach((uri, i) => {
const rel = path.relative(URI.Utils.dirname(e.editor.document.uri).fsPath, uri.fsPath);
snippet.appendText('[');
snippet.appendTabstop();
snippet.appendText(`](${rel})`);
if (i <= uris.length - 1 && uris.length > 1) {
snippet.appendText(' ');
}
});
return e.editor.insertSnippet(snippet, e.position);
})());
});
}