@@ -14,8 +14,7 @@ import { URI } from 'vs/base/common/uri';
1414import { generateUuid } from 'vs/base/common/uuid' ;
1515import { FileSystemProviderErrorCode , markAsFileSystemProviderError } from 'vs/platform/files/common/files' ;
1616import { RemoteAuthorityResolverErrorCode } from 'vs/platform/remote/common/remoteAuthorityResolver' ;
17- import * as extHostTypeConverters from 'vs/workbench/api/common/extHostTypeConverters' ;
18- import { addIdToOutput , CellEditType , ICellEditOperation } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
17+ import { addIdToOutput , CellEditType , ICellEditOperation , IDisplayOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
1918import type * as vscode from 'vscode' ;
2019
2120function es5ClassCompat ( target : Function ) : any {
@@ -647,7 +646,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
647646 _type : FileEditType . Cell , metadata, uri, edit : {
648647 editType : CellEditType . Output , index, outputs : outputs . map ( output => {
649648 if ( NotebookCellOutput . isNotebookCellOutput ( output ) ) {
650- return addIdToOutput ( extHostTypeConverters . NotebookCellOutput . from ( output ) ) ;
649+ return addIdToOutput ( output . toJSON ( ) ) ;
651650 } else {
652651 return addIdToOutput ( output ) ;
653652 }
@@ -2806,6 +2805,25 @@ export class NotebookCellOutput {
28062805 readonly outputs : NotebookCellOutputItem [ ] ,
28072806 readonly metadata ?: Record < string , string | number | boolean >
28082807 ) { }
2808+
2809+ toJSON ( ) : IDisplayOutput {
2810+ let data : { [ key : string ] : unknown ; } = { } ;
2811+ let custom : { [ key : string ] : unknown ; } = { } ;
2812+ let hasMetadata = false ;
2813+
2814+ for ( let item of this . outputs ) {
2815+ data [ item . mime ] = item . value ;
2816+ if ( item . metadata ) {
2817+ custom [ item . mime ] = item . metadata ;
2818+ hasMetadata = true ;
2819+ }
2820+ }
2821+ return {
2822+ outputKind : CellOutputKind . Rich ,
2823+ data,
2824+ metadata : hasMetadata ? { custom } : undefined
2825+ } ;
2826+ }
28092827}
28102828
28112829export enum CellKind {
0 commit comments