Files
8d40a80726 Add drop/paste resource for css (#221612)
* New drop and paste providers that create a url function snippet

* added url pasting feature

* added url pasting feature

* added url pasting feature

* Target just dropping/pasting resources for now

* Move files

* Remove unused strings

* Removing more unused logic for now

* Remove tsconfig change

* Remove doc file

* Capitalize

* Remove old proposal names

---------

Co-authored-by: Meghan Kulkarni <kulkarni.meg@gmail.com>
Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>
2024-07-16 09:56:23 +02:00

43 lines
1.2 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { Utils } from 'vscode-uri';
export const Schemes = Object.freeze({
file: 'file',
notebookCell: 'vscode-notebook-cell',
untitled: 'untitled',
});
export const Mimes = Object.freeze({
plain: 'text/plain',
uriList: 'text/uri-list',
});
export function getDocumentDir(uri: vscode.Uri): vscode.Uri | undefined {
const docUri = getParentDocumentUri(uri);
if (docUri.scheme === Schemes.untitled) {
return vscode.workspace.workspaceFolders?.[0]?.uri;
}
return Utils.dirname(docUri);
}
function getParentDocumentUri(uri: vscode.Uri): vscode.Uri {
if (uri.scheme === Schemes.notebookCell) {
// is notebook documents necessary?
for (const notebook of vscode.workspace.notebookDocuments) {
for (const cell of notebook.getCells()) {
if (cell.document.uri.toString() === uri.toString()) {
return notebook.uri;
}
}
}
}
return uri;
}