mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 16:49:06 +01:00
Add drop feedback UX (#179434)
For #179430 Adds two new UX components: - An inline progress icon shown when a drop operation takes over 500ms. This replaces the notification. You can click on it to cancel the drop - Post drop, a drop feedback icon that lets you drop the file in a different way. This lets you drop the file as plain text for instance instead of as a markdown link
This commit is contained in:
@@ -45,7 +45,7 @@ class PasteEditProvider implements vscode.DocumentPasteEditProvider {
|
||||
}
|
||||
|
||||
const snippet = await tryGetUriListSnippet(document, dataTransfer, token);
|
||||
return snippet ? new vscode.DocumentPasteEdit(snippet) : undefined;
|
||||
return snippet ? new vscode.DocumentPasteEdit(snippet.snippet) : undefined;
|
||||
}
|
||||
|
||||
private async _makeCreateImagePasteEdit(document: vscode.TextDocument, file: vscode.DataTransferFile, token: vscode.CancellationToken): Promise<vscode.DocumentPasteEdit | undefined> {
|
||||
|
||||
@@ -38,12 +38,23 @@ export function registerDropIntoEditorSupport(selector: vscode.DocumentSelector)
|
||||
}
|
||||
|
||||
const snippet = await tryGetUriListSnippet(document, dataTransfer, token);
|
||||
return snippet ? new vscode.DocumentDropEdit(snippet) : undefined;
|
||||
if (!snippet) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const edit = new vscode.DocumentDropEdit(snippet.snippet);
|
||||
edit.label = snippet.label;
|
||||
return edit;
|
||||
}
|
||||
}, {
|
||||
id: 'vscode.markdown.insertLink',
|
||||
dropMimeTypes: [
|
||||
'text/uri-list'
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
export async function tryGetUriListSnippet(document: vscode.TextDocument, dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken): Promise<vscode.SnippetString | undefined> {
|
||||
export async function tryGetUriListSnippet(document: vscode.TextDocument, dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken): Promise<{ snippet: vscode.SnippetString; label: string } | undefined> {
|
||||
const urlList = await dataTransfer.get('text/uri-list')?.asString();
|
||||
if (!urlList || token.isCancellationRequested) {
|
||||
return undefined;
|
||||
@@ -58,7 +69,17 @@ export async function tryGetUriListSnippet(document: vscode.TextDocument, dataTr
|
||||
}
|
||||
}
|
||||
|
||||
return createUriListSnippet(document, uris);
|
||||
const snippet = createUriListSnippet(document, uris);
|
||||
if (!snippet) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
snippet: snippet,
|
||||
label: uris.length > 1
|
||||
? vscode.l10n.t('Insert uri links')
|
||||
: vscode.l10n.t('Insert uri link')
|
||||
};
|
||||
}
|
||||
|
||||
interface UriListSnippetOptions {
|
||||
|
||||
Reference in New Issue
Block a user