mirror of
https://github.com/Microsoft/vscode
synced 2024-07-05 01:08:57 +00:00
more copy SVG fixes (#203937)
* re-add check for image for context menu, add selector for jupyter rendered SVGs * consisent command name
This commit is contained in:
parent
5e6ec068b2
commit
472af59e08
|
@ -113,7 +113,7 @@
|
|||
"webview/context": [
|
||||
{
|
||||
"command": "notebook.cellOutput.copy",
|
||||
"when": "webviewId == 'notebook.output'"
|
||||
"when": "webviewId == 'notebook.output' && webviewSection == 'image'"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ registerAction2(class CopyCellOutputAction extends Action2 {
|
|||
constructor() {
|
||||
super({
|
||||
id: COPY_OUTPUT_COMMAND_ID,
|
||||
title: localize('notebookActions.copyOutput', "Copy Output"),
|
||||
title: localize('notebookActions.copyOutput', "Copy Cell Output"),
|
||||
menu: {
|
||||
id: MenuId.NotebookOutputToolbar,
|
||||
when: NOTEBOOK_CELL_HAS_OUTPUTS
|
||||
|
@ -42,7 +42,14 @@ registerAction2(class CopyCellOutputAction extends Action2 {
|
|||
}
|
||||
|
||||
let outputViewModel: ICellOutputViewModel | undefined;
|
||||
if (!outputContext) {
|
||||
if (outputContext && 'outputId' in outputContext && typeof outputContext.outputId === 'string') {
|
||||
outputViewModel = getOutputViewModelFromId(outputContext.outputId, notebookEditor);
|
||||
} else if (outputContext && 'outputViewModel' in outputContext) {
|
||||
outputViewModel = outputContext.outputViewModel;
|
||||
}
|
||||
|
||||
if (!outputViewModel) {
|
||||
// not able to find the output from the provided context, use the active cell
|
||||
const activeCell = notebookEditor.getActiveCell();
|
||||
if (!activeCell) {
|
||||
return;
|
||||
|
@ -55,10 +62,6 @@ registerAction2(class CopyCellOutputAction extends Action2 {
|
|||
} else {
|
||||
outputViewModel = activeCell.outputsViewModels.find(output => output.pickedMimeType?.isTrusted);
|
||||
}
|
||||
} else if ('outputId' in outputContext && typeof outputContext.outputId === 'string') {
|
||||
outputViewModel = getOutputViewModelFromId(outputContext.outputId, notebookEditor);
|
||||
} else {
|
||||
outputViewModel = outputContext.outputViewModel;
|
||||
}
|
||||
|
||||
if (!outputViewModel) {
|
||||
|
|
|
@ -1400,7 +1400,9 @@ async function webviewPreloads(ctx: PreloadContext) {
|
|||
let image = outputElement?.querySelector('img');
|
||||
|
||||
if (!image) {
|
||||
const svgImage = outputElement?.querySelector('svg.output-image');
|
||||
const svgImage = outputElement?.querySelector('svg.output-image') ??
|
||||
outputElement?.querySelector('div.svgContainerStyle > svg');
|
||||
|
||||
if (svgImage) {
|
||||
image = new Image();
|
||||
image.src = 'data:image/svg+xml,' + encodeURIComponent(svgImage.outerHTML);
|
||||
|
|
Loading…
Reference in New Issue
Block a user