3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import { VSBuffer } from 'vs/base/common/buffer' ;
7
6
import { Iterable } from 'vs/base/common/iterator' ;
8
7
import { KeyCode , KeyMod } from 'vs/base/common/keyCodes' ;
9
8
import { Disposable , IDisposable } from 'vs/base/common/lifecycle' ;
@@ -29,7 +28,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
29
28
import { IConfigurationRegistry , Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry' ;
30
29
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
31
30
import { EditorActivation , IResourceEditorInput } from 'vs/platform/editor/common/editor' ;
32
- import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions' ;
33
31
import { IFileService } from 'vs/platform/files/common/files' ;
34
32
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors' ;
35
33
import { InstantiationType , registerSingleton } from 'vs/platform/instantiation/common/extensions' ;
@@ -56,9 +54,9 @@ import { INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/no
56
54
import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget' ;
57
55
import * as icons from 'vs/workbench/contrib/notebook/browser/notebookIcons' ;
58
56
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService' ;
59
- import { CellEditType , CellKind , CellUri , ICellOutput , INTERACTIVE_WINDOW_EDITOR_ID , NotebookData } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
57
+ import { CellEditType , CellKind , CellUri , INTERACTIVE_WINDOW_EDITOR_ID } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
60
58
import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService' ;
61
- import { INotebookSerializer , INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService' ;
59
+ import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService' ;
62
60
import { columnToEditorGroup } from 'vs/workbench/services/editor/common/editorGroupColumn' ;
63
61
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService' ;
64
62
import { IEditorResolverService , RegisteredEditorPriority } from 'vs/workbench/services/editor/common/editorResolverService' ;
@@ -88,78 +86,6 @@ export class InteractiveDocumentContribution extends Disposable implements IWork
88
86
) {
89
87
super ( ) ;
90
88
91
- const contentOptions = {
92
- transientOutputs : true ,
93
- transientCellMetadata : { } ,
94
- transientDocumentMetadata : { } ,
95
- cellContentMetadata : { }
96
- } ;
97
-
98
- const serializer : INotebookSerializer = {
99
- options : contentOptions ,
100
- dataToNotebook : async ( data : VSBuffer ) : Promise < NotebookData > => {
101
- if ( data . byteLength > 0 ) {
102
- try {
103
- const document = JSON . parse ( data . toString ( ) ) as { cells : { kind : CellKind ; language : string ; metadata : any ; mime : string | undefined ; content : string ; outputs ?: ICellOutput [ ] } [ ] } ;
104
- return {
105
- cells : document . cells . map ( cell => ( {
106
- source : cell . content ,
107
- language : cell . language ,
108
- cellKind : cell . kind ,
109
- mime : cell . mime ,
110
- outputs : cell . outputs
111
- ? cell . outputs . map ( output => ( {
112
- outputId : output . outputId ,
113
- outputs : output . outputs . map ( ot => ( {
114
- mime : ot . mime ,
115
- data : ot . data
116
- } ) )
117
- } ) )
118
- : [ ] ,
119
- metadata : cell . metadata
120
- } ) ) ,
121
- metadata : { }
122
- } ;
123
- } catch ( e ) {
124
- logService . error ( `error when converting data to notebook data object: ${ e } ` ) ;
125
- }
126
- }
127
-
128
- return {
129
- metadata : { } ,
130
- cells : [ ]
131
- } ;
132
-
133
- } ,
134
- notebookToData : async ( data : NotebookData ) : Promise < VSBuffer > => {
135
- const cells = data . cells . map ( cell => ( {
136
- kind : cell . cellKind ,
137
- language : cell . language ,
138
- metadata : cell . metadata ,
139
- mine : cell . mime ,
140
- outputs : cell . outputs . map ( output => {
141
- return {
142
- outputId : output . outputId ,
143
- outputs : output . outputs . map ( ot => ( {
144
- mime : ot . mime ,
145
- data : ot . data
146
- } ) )
147
- } ;
148
- } ) ,
149
- content : cell . source
150
- } ) ) ;
151
-
152
- return VSBuffer . fromString ( JSON . stringify ( {
153
- cells : cells
154
- } ) ) ;
155
- }
156
- } ;
157
-
158
- this . _register ( notebookService . registerNotebookSerializer ( 'interactive' , {
159
- id : new ExtensionIdentifier ( 'interactive.builtin' ) ,
160
- location : undefined
161
- } , serializer ) ) ;
162
-
163
89
const info = notebookService . getContributedNotebookType ( 'interactive' ) ;
164
90
165
91
// We need to contribute a notebook type for the Interactive Window to provide notebook models.
0 commit comments