This commit is contained in:
Johannes Rieken 2020-09-25 18:04:10 +02:00
parent 2fc01432c1
commit 1e7454f72a
6 changed files with 20 additions and 22 deletions

View file

@ -423,9 +423,9 @@ suite('Notebook API tests', () => {
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
await vscode.notebook.activeNotebookEditor!.edit(editBuilder => {
editBuilder.replaceCellOutput(0, [new vscode.NotebookCellOutputList([
new vscode.NotebookCellOutput('application/foo', 'bar'),
new vscode.NotebookCellOutput('application/json', { data: true }, { metadata: true }),
editBuilder.replaceCellOutput(0, [new vscode.NotebookCellOutput([
new vscode.NotebookCellOutputItem('application/foo', 'bar'),
new vscode.NotebookCellOutputItem('application/json', { data: true }, { metadata: true }),
])]);
});

View file

@ -1226,8 +1226,7 @@ declare module 'vscode' {
export type CellOutput = CellStreamOutput | CellErrorOutput | CellDisplayOutput;
//TODO@jrieken rename to NotebookCellOutputItem
export class NotebookCellOutput {
export class NotebookCellOutputItem {
readonly mime: string;
readonly value: unknown;
@ -1236,14 +1235,13 @@ declare module 'vscode' {
constructor(mime: string, value: unknown, metadata?: Record<string, string | number | boolean>);
}
//TODO@jrieken rename to NotebookCellOutput
//TODO@jrieken add id?
export class NotebookCellOutputList {
export class NotebookCellOutput {
readonly outputs: NotebookCellOutput[];
readonly outputs: NotebookCellOutputItem[];
readonly metadata?: Record<string, string | number | boolean>;
constructor(outputs: NotebookCellOutput[], metadata?: Record<string, string | number | boolean>);
constructor(outputs: NotebookCellOutputItem[], metadata?: Record<string, string | number | boolean>);
}
export enum NotebookCellRunState {
@ -1434,7 +1432,7 @@ declare module 'vscode' {
export interface NotebookEditorEdit {
replaceMetadata(value: NotebookDocumentMetadata): void;
replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
replaceCellOutput(index: number, outputs: (NotebookCellOutputList | CellOutput)[]): void;
replaceCellOutput(index: number, outputs: (NotebookCellOutput | CellOutput)[]): void;
replaceCellMetadata(index: number, metadata: NotebookCellMetadata): void;
}

View file

@ -1148,8 +1148,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
NotebookRunState: extHostTypes.NotebookRunState,
NotebookCellStatusBarAlignment: extHostTypes.NotebookCellStatusBarAlignment,
NotebookEditorRevealType: extHostTypes.NotebookEditorRevealType,
NotebookCellOutputList: extHostTypes.NotebookCellOutputList,
NotebookCellOutput: extHostTypes.NotebookCellOutput,
NotebookCellOutputItem: extHostTypes.NotebookCellOutputItem,
};
};
}

View file

@ -55,13 +55,13 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
});
}
replaceCellOutput(index: number, outputs: (vscode.NotebookCellOutputList | vscode.CellOutput)[]): void {
replaceCellOutput(index: number, outputs: (vscode.NotebookCellOutput | vscode.CellOutput)[]): void {
this._throwIfFinalized();
this._collectedEdits.push({
editType: CellEditType.Output,
index,
outputs: outputs.map(output => {
if (extHostTypes.NotebookCellOutputList.isNotebookCellOutputList(output)) {
if (extHostTypes.NotebookCellOutput.isNotebookCellOutputList(output)) {
return addIdToOutput(NotebookCellOutputList.from(output));
} else {
return addIdToOutput(output);

View file

@ -1296,7 +1296,7 @@ export namespace LogLevel {
}
export namespace NotebookCellOutputList {
export function from(output: types.NotebookCellOutputList): IDisplayOutput {
export function from(output: types.NotebookCellOutput): IDisplayOutput {
let data: { [key: string]: unknown; } = {};
let custom: { [key: string]: unknown; } = {};
@ -1318,7 +1318,7 @@ export namespace NotebookCellOutputList {
}
export namespace NotebookCellOutput {
export function from(output: types.NotebookCellOutput): IDisplayOutput {
export function from(output: types.NotebookCellOutputItem): IDisplayOutput {
return {
outputKind: CellOutputKind.Rich,
data: { [output.mime]: output.value },

View file

@ -2772,10 +2772,10 @@ export enum ColorThemeKind {
//#region Notebook
export class NotebookCellOutput {
export class NotebookCellOutputItem {
static isNotebookCellOutput(obj: unknown): obj is vscode.NotebookCellOutput {
return obj instanceof NotebookCellOutput;
static isNotebookCellOutput(obj: unknown): obj is vscode.NotebookCellOutputItem {
return obj instanceof NotebookCellOutputItem;
}
constructor(
@ -2785,14 +2785,14 @@ export class NotebookCellOutput {
) { }
}
export class NotebookCellOutputList {
export class NotebookCellOutput {
static isNotebookCellOutputList(obj: unknown): obj is vscode.NotebookCellOutputList {
return obj instanceof NotebookCellOutputList;
static isNotebookCellOutputList(obj: unknown): obj is vscode.NotebookCellOutput {
return obj instanceof NotebookCellOutput;
}
constructor(
readonly outputs: NotebookCellOutput[],
readonly outputs: NotebookCellOutputItem[],
readonly metadata?: Record<string, string | number | boolean>
) { }
}