Add setting to enable/disable markdown drop into editor

For #142990
This commit is contained in:
Matt Bierner
2022-04-05 15:37:15 -07:00
parent ddf70921cd
commit 032ee47056
3 changed files with 12 additions and 0 deletions

View File

@@ -407,6 +407,12 @@
"default": "off",
"description": "%markdown.trace.desc%",
"scope": "window"
},
"markdown.editor.drop.enabled": {
"type": "boolean",
"default": true,
"markdownDescription": "%configuration.markdown.editor.drop.enabled%",
"scope": "resource"
}
}
},

View File

@@ -28,5 +28,6 @@
"configuration.markdown.links.openLocation.currentGroup": "Open links in the active editor group.",
"configuration.markdown.links.openLocation.beside": "Open links beside the active editor.",
"configuration.markdown.suggest.paths.enabled.description": "Enable/disable path suggestions for markdown links",
"configuration.markdown.editor.drop.enabled": "Enable/disable dropping into the markdown editor to insert shift. Requires enabling `#workbench.editor.dropIntoEditor.enabled#`.",
"workspaceTrust": "Required for loading styles configured in the workspace."
}

View File

@@ -10,6 +10,11 @@ import * as URI from 'vscode-uri';
export function registerDropIntoEditor(selector: vscode.DocumentSelector) {
return vscode.languages.registerDocumentOnDropProvider(selector, new class implements vscode.DocumentOnDropProvider {
async provideDocumentOnDropEdits(document: vscode.TextDocument, position: vscode.Position, dataTransfer: vscode.DataTransfer, _token: vscode.CancellationToken): Promise<vscode.SnippetTextEdit | undefined> {
const enabled = vscode.workspace.getConfiguration('markdown', document).get('editor.drop.enabled', true);
if (!enabled) {
return;
}
const urlList = await dataTransfer.get('text/uri-list')?.asString();
if (!urlList) {
return undefined;