mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 01:58:53 +01:00
workaround cyclic dependency issue
This commit is contained in:
@@ -7,7 +7,6 @@ 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 * 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';
|
||||
@@ -62,7 +61,7 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
|
||||
index,
|
||||
outputs: outputs.map(output => {
|
||||
if (extHostTypes.NotebookCellOutput.isNotebookCellOutput(output)) {
|
||||
return addIdToOutput(NotebookCellOutput.from(output));
|
||||
return addIdToOutput(output.toJSON());
|
||||
} else {
|
||||
return addIdToOutput(output);
|
||||
}
|
||||
|
||||
@@ -1299,23 +1299,7 @@ export namespace LogLevel {
|
||||
|
||||
export namespace NotebookCellOutput {
|
||||
export function from(output: types.NotebookCellOutput): 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
|
||||
};
|
||||
return output.toJSON();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { FileSystemProviderErrorCode, markAsFileSystemProviderError } from 'vs/platform/files/common/files';
|
||||
import { RemoteAuthorityResolverErrorCode } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
||||
import * as extHostTypeConverters from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import { addIdToOutput, CellEditType, ICellEditOperation } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { addIdToOutput, CellEditType, ICellEditOperation, IDisplayOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import type * as vscode from 'vscode';
|
||||
|
||||
function es5ClassCompat(target: Function): any {
|
||||
@@ -647,7 +646,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
||||
_type: FileEditType.Cell, metadata, uri, edit: {
|
||||
editType: CellEditType.Output, index, outputs: outputs.map(output => {
|
||||
if (NotebookCellOutput.isNotebookCellOutput(output)) {
|
||||
return addIdToOutput(extHostTypeConverters.NotebookCellOutput.from(output));
|
||||
return addIdToOutput(output.toJSON());
|
||||
} else {
|
||||
return addIdToOutput(output);
|
||||
}
|
||||
@@ -2806,6 +2805,25 @@ export class NotebookCellOutput {
|
||||
readonly outputs: NotebookCellOutputItem[],
|
||||
readonly metadata?: Record<string, string | number | boolean>
|
||||
) { }
|
||||
|
||||
toJSON(): IDisplayOutput {
|
||||
let data: { [key: string]: unknown; } = {};
|
||||
let custom: { [key: string]: unknown; } = {};
|
||||
let hasMetadata = false;
|
||||
|
||||
for (let item of this.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 enum CellKind {
|
||||
|
||||
Reference in New Issue
Block a user