mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 17:48:56 +01:00
adopt changes after feedback round one
This commit is contained in:
@@ -1148,6 +1148,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
NotebookRunState: extHostTypes.NotebookRunState,
|
||||
NotebookCellStatusBarAlignment: extHostTypes.NotebookCellStatusBarAlignment,
|
||||
NotebookEditorRevealType: extHostTypes.NotebookEditorRevealType,
|
||||
NotebookCellOutputList: extHostTypes.NotebookCellOutputList,
|
||||
NotebookCellOutput: extHostTypes.NotebookCellOutput,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ import { readonly } from 'vs/base/common/errors';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { MainThreadNotebookShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { NotebookCellOutput } from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import { NotebookCellOutputList } from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
|
||||
import { addIdToOutput, CellEditType, ICellEditOperation, ICellReplaceEdit, INotebookEditData, notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import * as vscode from 'vscode';
|
||||
@@ -55,14 +55,14 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
|
||||
});
|
||||
}
|
||||
|
||||
replaceCellOutput(index: number, outputs: (vscode.NotebookCellOutput | vscode.CellOutput)[]): void {
|
||||
replaceCellOutput(index: number, outputs: (vscode.NotebookCellOutputList | vscode.CellOutput)[]): void {
|
||||
this._throwIfFinalized();
|
||||
this._collectedEdits.push({
|
||||
editType: CellEditType.Output,
|
||||
index,
|
||||
outputs: outputs.map(output => {
|
||||
if (extHostTypes.NotebookCellOutput.isNotebookCellOutput(output)) {
|
||||
return addIdToOutput(NotebookCellOutput.from(output));
|
||||
if (extHostTypes.NotebookCellOutputList.isNotebookCellOutputList(output)) {
|
||||
return addIdToOutput(NotebookCellOutputList.from(output));
|
||||
} else {
|
||||
return addIdToOutput(output);
|
||||
}
|
||||
|
||||
@@ -1295,6 +1295,28 @@ export namespace LogLevel {
|
||||
}
|
||||
}
|
||||
|
||||
export namespace NotebookCellOutputList {
|
||||
export function from(output: types.NotebookCellOutputList): IDisplayOutput {
|
||||
|
||||
let data: { [key: string]: unknown; } = {};
|
||||
let custom: { [key: string]: unknown; } = {};
|
||||
let hasMetadata = false;
|
||||
|
||||
for (let item of output.outputs) {
|
||||
data[item.mime] = item.value;
|
||||
if (item.metadata) {
|
||||
custom[item.mime] = item.metadata;
|
||||
hasMetadata = true;
|
||||
}
|
||||
}
|
||||
return {
|
||||
outputKind: CellOutputKind.Rich,
|
||||
data,
|
||||
metadata: hasMetadata ? { custom } : undefined
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export namespace NotebookCellOutput {
|
||||
export function from(output: types.NotebookCellOutput): IDisplayOutput {
|
||||
return {
|
||||
|
||||
@@ -2785,6 +2785,18 @@ export class NotebookCellOutput {
|
||||
) { }
|
||||
}
|
||||
|
||||
export class NotebookCellOutputList {
|
||||
|
||||
static isNotebookCellOutputList(obj: unknown): obj is vscode.NotebookCellOutputList {
|
||||
return obj instanceof NotebookCellOutputList;
|
||||
}
|
||||
|
||||
constructor(
|
||||
readonly outputs: NotebookCellOutput[],
|
||||
readonly metadata?: Record<string, string | number | boolean>
|
||||
) { }
|
||||
}
|
||||
|
||||
export enum CellKind {
|
||||
Markdown = 1,
|
||||
Code = 2
|
||||
|
||||
Reference in New Issue
Block a user