mirror of
https://github.com/Microsoft/vscode
synced 2024-10-12 06:17:18 +00:00
Enable pasting of image attachments by default for ipynb (#166058)
Fixes https://github.com/microsoft/vscode-jupyter/issues/11987
This commit is contained in:
parent
8294940ac6
commit
1ccc8d438b
|
@ -32,14 +32,11 @@
|
|||
"configuration": [
|
||||
{
|
||||
"properties": {
|
||||
"ipynb.experimental.pasteImages.enabled": {
|
||||
"ipynb.pasteImagesAsAttachments.enabled": {
|
||||
"type": "boolean",
|
||||
"scope": "resource",
|
||||
"markdownDescription": "%ipynb.experimental.pasteImages.enabled%",
|
||||
"default": false,
|
||||
"tags": [
|
||||
"experimental"
|
||||
]
|
||||
"markdownDescription": "%ipynb.pasteImagesAsAttachments.enabled%",
|
||||
"default": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"displayName": ".ipynb Support",
|
||||
"description": "Provides basic support for opening and reading Jupyter's .ipynb notebook files",
|
||||
"ipynb.experimental.pasteImages.enabled":"Enable/Disable pasting images into markdown cells within ipynb files. Requires enabling `#editor.experimental.pasteActions.enabled#`."
|
||||
"ipynb.pasteImagesAsAttachments.enabled": "Enable/disable pasting of images into Markdown cells in ipynb notebook files. Pasted images are inserted as attachments to the cell."
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
|
||||
context.subscriptions.push(notebookImagePasteSetup());
|
||||
|
||||
const enabled = vscode.workspace.getConfiguration('ipynb').get('experimental.pasteImages.enabled', false);
|
||||
const enabled = vscode.workspace.getConfiguration('ipynb').get('pasteImagesAsAttachments.enabled', false);
|
||||
if (enabled) {
|
||||
const cleaner = new AttachmentCleaner();
|
||||
context.subscriptions.push(cleaner);
|
||||
|
|
|
@ -15,7 +15,7 @@ class CopyPasteEditProvider implements vscode.DocumentPasteEditProvider {
|
|||
_token: vscode.CancellationToken
|
||||
): Promise<vscode.DocumentPasteEdit | undefined> {
|
||||
|
||||
const enabled = vscode.workspace.getConfiguration('ipynb', document).get('experimental.pasteImages.enabled', false);
|
||||
const enabled = vscode.workspace.getConfiguration('ipynb', document).get('pasteImagesAsAttachments.enabled', false);
|
||||
if (!enabled) {
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
|
|||
import { createStringDataTransferItem, UriList, VSDataTransfer } from 'vs/base/common/dataTransfer';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Mimes } from 'vs/base/common/mime';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { toVSDataTransfer } from 'vs/editor/browser/dnd';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
@ -69,9 +70,12 @@ export class CopyPasteController extends Disposable implements IEditorContributi
|
|||
}
|
||||
|
||||
private arePasteActionsEnabled(model: ITextModel): boolean {
|
||||
return this._configurationService.getValue('editor.experimental.pasteActions.enabled', {
|
||||
resource: model.uri
|
||||
});
|
||||
if (this._configurationService.getValue('editor.experimental.pasteActions.enabled', { resource: model.uri })) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: This check is only here to support enabling `ipynb.pasteImagesAsAttachments.enabled` by default
|
||||
return model.uri.scheme === Schemas.vscodeNotebookCell;
|
||||
}
|
||||
|
||||
private handleCopy(e: ClipboardEvent) {
|
||||
|
|
Loading…
Reference in a new issue