@@ -41,20 +41,9 @@ class MonacoEditor extends React.PureComponent {
4141 afterViewInit = ( ) => {
4242 const context = this . props . context || window ;
4343
44- if ( context . monaco !== undefined ) {
45- this . initMonaco ( ) ;
46- return ;
47- }
48-
49- context . require . config ( {
50- url : '/public/13/vs/loader.js' ,
51- paths : {
52- vs : '/public/13/vs' ,
53- } ,
54- } ) ;
55-
56- // Load monaco
57- context . require ( [ 'vs/editor/editor.main' ] , ( ) => {
44+ require ( 'app/vscode/dev-bootstrap' ) . default (
45+ 'vs/editor/codesandbox.editor.main'
46+ ) ( ( ) => {
5847 this . initMonaco ( ) ;
5948 } ) ;
6049 } ;
@@ -98,189 +87,50 @@ class MonacoEditor extends React.PureComponent {
9887 const r = context . require ;
9988
10089 const [
101- { CodeSandboxCommandService } ,
102- { CodeSandboxHashService } ,
103- { CodeSandboxKeybindingService } ,
104- { CodeSandboxWindowsService } ,
105- { QuickOpenController } ,
106- { EditorPart } ,
107- { CodeSandboxWorkbench } ,
108- { CodeSandboxEnvironmentService } ,
109- { UntitledEditorService } ,
110- { CodeSandboxFileService } ,
111- { StorageService } ,
112- { HistoryService } ,
113- { NullLifecycleService } ,
114- { TextFileService } ,
115- { WindowService } ,
116- { CodeSandboxBackupService } ,
117- { CodeSandboxExtensionService } ,
118- { ExtensionEnablementService } ,
119- { CodeSandboxExtensionManagementService } ,
120- { CodeSandboxExtensionGalleryService } ,
121- { FileDecorationsService } ,
122- { PreferencesService } ,
123- { JSONEditingService } ,
124- { CodeSandboxWorkspacesService } ,
125- { CodeSandboxSearchService } ,
126- { ViewletService } ,
127- { TextModelResolverService } ,
12890 { CodeSandboxService } ,
129- { CodeSandboxBroadcastService } ,
130- { CodeSandboxCrashReporterService } ,
131- { BreadcrumbsService } ,
132- { ProgressService2 } ,
133- { CodeSandboxActivityService } ,
134- { CodeSandboxOutputService } ,
135- { CodeSandboxPanelService } ,
136- { QuickInputService } ,
137- { HeapService } ,
138- { CodeSandboxFileDialogService } ,
139- { CodeEditorService } ,
140- { CodeSandboxEditorConnectorService } ,
14191 { IEditorService } ,
14292 { ICodeEditorService } ,
14393 { ITextFileService } ,
144- { CodeSandboxRequestService } ,
14594 { ILifecycleService, LifecyclePhase } ,
95+ { IEditorGroupsService } ,
14696 ] = [
147- r ( 'vs/codesandbox/commandService' ) ,
148- r ( 'vs/codesandbox/hashService' ) ,
149- r ( 'vs/codesandbox/keybindingService' ) ,
150- r ( 'vs/codesandbox/windowsService' ) ,
151- r ( 'vs/workbench/browser/parts/quickopen/quickOpenController' ) ,
152- r ( 'vs/codesandbox/editorGroupsService' ) ,
153- r ( 'vs/codesandbox/workbench' ) ,
154- r ( 'vs/codesandbox/environmentService' ) ,
155- r ( 'vs/workbench/services/untitled/common/untitledEditorService' ) ,
156- r ( 'vs/codesandbox/fileService' ) ,
157- r ( 'vs/platform/storage/common/storageService' ) ,
158- r ( 'vs/workbench/services/history/electron-browser/history' ) ,
159- r ( 'vs/platform/lifecycle/common/lifecycle' ) ,
160- r ( 'vs/workbench/services/textfile/electron-browser/textFileService' ) ,
161- r ( 'vs/platform/windows/electron-browser/windowService' ) ,
162- r ( 'vs/codesandbox/backupFileService' ) ,
163- r ( 'vs/codesandbox/extensionService' ) ,
164- r ( 'vs/platform/extensionManagement/common/extensionEnablementService' ) ,
165- r ( 'vs/codesandbox/extensionManagementService' ) ,
166- r ( 'vs/codesandbox/extensionGalleryService' ) ,
167- r ( 'vs/workbench/services/decorations/browser/decorationsService' ) ,
168- r ( 'vs/workbench/services/preferences/browser/preferencesService' ) ,
169- r ( 'vs/workbench/services/configuration/node/jsonEditingService' ) ,
170- r ( 'vs/codesandbox/workspacesService' ) ,
171- r ( 'vs/codesandbox/searchService' ) ,
172- r ( 'vs/workbench/services/viewlet/browser/viewletService' ) ,
173- r (
174- 'vs/workbench/services/textmodelResolver/common/textModelResolverService'
175- ) ,
17697 r ( 'vs/codesandbox/services/codesandbox/browser/codesandboxService' ) ,
177- r ( 'vs/codesandbox/broadcastService' ) ,
178- r ( 'vs/codesandbox/crashReporterService' ) ,
179- r ( 'vs/workbench/browser/parts/editor/breadcrumbs' ) ,
180- r ( 'vs/workbench/services/progress/browser/progressService2' ) ,
181- r ( 'vs/codesandbox/activityService' ) ,
182- r ( 'vs/codesandbox/outputService' ) ,
183- r ( 'vs/codesandbox/panelService' ) ,
184- r ( 'vs/workbench/browser/parts/quickinput/quickInput' ) ,
185- r ( 'vs/workbench/api/electron-browser/mainThreadHeapService' ) ,
186- r ( 'vs/codesandbox/fileDialogService' ) ,
187- r ( 'vs/workbench/services/codeEditor/browser/codeEditorService' ) ,
188- r (
189- 'vs/codesandbox/services/codesandbox/browser/codesandboxEditorConnectorService'
190- ) ,
19198 r ( 'vs/workbench/services/editor/common/editorService' ) ,
19299 r ( 'vs/editor/browser/services/codeEditorService' ) ,
193100 r ( 'vs/workbench/services/textfile/common/textfiles' ) ,
194- r ( 'vs/codesandbox/requestService' ) ,
195101 r ( 'vs/platform/lifecycle/common/lifecycle' ) ,
102+ r ( 'vs/workbench/services/group/common/editorGroupsService' ) ,
196103 ] ;
197104
198- document . body . className += ' vs-dark' ;
105+ document . getElementById ( 'root' ) . className += ' monaco-shell vs-dark' ;
199106
200107 const container = document . createElement ( 'div' ) ;
201108 const part = document . createElement ( 'div' ) ;
202109
203- container . className = 'vs-dark monaco-workbench mac' ;
204- container . id = 'workbench.main.container' ;
205- part . className = 'part editor' ;
110+ const editorElement = document . getElementById ( 'workbench.main.container' ) ;
111+ container . className = 'monaco-workbench' ;
112+ editorElement . className += ' monaco-workbench mac nopanel' ;
113+ editorElement . id = 'workbench.main.container' ;
206114
207- container . appendChild ( part ) ;
115+ part . className = ' part editor has-watermark' ;
208116
209- const editor = document . getElementsByClassName (
210- 'react-monaco-editor-container'
211- ) [ 0 ] ;
212- editor . parentNode . removeChild ( editor ) ;
117+ container . appendChild ( part ) ;
213118
214- const rootEl = document . getElementsByClassName ( 'sc-dchYKM' ) [ 0 ] ;
119+ const rootEl = document . getElementById ( 'vscode-container' ) ;
215120 rootEl . appendChild ( container ) ;
216121
217122 context . monaco . editor [ diffEditor ? 'createDiffEditor' : 'create' ] (
218123 container ,
219124 appliedOptions ,
220125 {
221- backupFileService : i => i . createInstance ( CodeSandboxBackupService ) ,
222- hashService : i => i . createInstance ( CodeSandboxHashService ) ,
223- extensionService : i => i . createInstance ( CodeSandboxExtensionService ) ,
224- extensionEnablementService : i =>
225- i . createInstance ( ExtensionEnablementService ) ,
226- lifecycleService : NullLifecycleService ,
227- windowsService : i => i . createInstance ( CodeSandboxWindowsService ) ,
228- quickOpenService : i => i . createInstance ( QuickOpenController ) ,
229- commandService : i => i . createInstance ( CodeSandboxCommandService ) ,
230- IFileDecorationsService : i =>
231- i . createInstance ( FileDecorationsService ) ,
232- textFileService : i => i . createInstance ( TextFileService ) ,
233- fileService : i => i . createInstance ( CodeSandboxFileService ) ,
234- keybindingService : i =>
235- i . createInstance ( CodeSandboxKeybindingService , window ) ,
236- editorGroupsService : i =>
237- i . createInstance ( EditorPart , 'codesandbox' , false ) ,
238- untitledEditorService : i => i . createInstance ( UntitledEditorService ) ,
239- partService : i => i . createInstance ( CodeSandboxWorkbench ) ,
240- environmentService : i =>
241- i . createInstance ( CodeSandboxEnvironmentService ) ,
242- storageService : new StorageService ( localStorage , localStorage ) ,
243- historyService : i => i . createInstance ( HistoryService ) ,
244- // editorService: i => i.createInstance(EditorService),
245- windowService : i => i . createInstance ( WindowService ) ,
246- preferencesService : i => i . createInstance ( PreferencesService ) ,
247- jsonEditingService : i => i . createInstance ( JSONEditingService ) ,
248- workspacesService : i =>
249- i . createInstance ( CodeSandboxWorkspacesService ) ,
250- searchService : i => i . createInstance ( CodeSandboxSearchService ) ,
251- viewletService : i =>
252- i . createInstance ( ViewletService , {
253- onDidViewletOpen : ( ) => true ,
254- onDidViewletClose : ( ) => true ,
255- } ) ,
256- textModelService : i => i . createInstance ( TextModelResolverService ) ,
257126 codesandboxService : i =>
258127 i . createInstance ( CodeSandboxService , controller ) ,
259- extensionGalleryService : i =>
260- i . createInstance ( CodeSandboxExtensionGalleryService ) ,
261- extensionManagementService : i =>
262- i . createInstance ( CodeSandboxExtensionManagementService ) ,
263- broadcastService : new CodeSandboxBroadcastService ( 1 ) ,
264- crashReporterService : i =>
265- i . createInstance ( CodeSandboxCrashReporterService ) ,
266- IEditorBreadcrumbsService : i => i . createInstance ( BreadcrumbsService ) ,
267- progressService2 : i => i . createInstance ( ProgressService2 ) ,
268- activityService : i => i . createInstance ( CodeSandboxActivityService ) ,
269- outputService : i => i . createInstance ( CodeSandboxOutputService ) ,
270- panelService : i => i . createInstance ( CodeSandboxPanelService ) ,
271- quickInputService : i => i . createInstance ( QuickInputService ) ,
272- heapService : i => i . createInstance ( HeapService ) ,
273- fileDialogService : i =>
274- i . createInstance ( CodeSandboxFileDialogService ) ,
275- codeEditorService : i => i . createInstance ( CodeEditorService ) ,
276- codesandboxEditorConnectorService : i =>
277- i . createInstance ( CodeSandboxEditorConnectorService , controller ) ,
278- requestService2 : i => i . createInstance ( CodeSandboxRequestService ) ,
279128 } ,
280129 services => {
281- window . EditorPart . create ( part ) ;
130+ const EditorPart = services . get ( IEditorGroupsService ) ;
131+ EditorPart . create ( part ) ;
282132 setTimeout ( ( ) => {
283- window . EditorPart . layout ( {
133+ EditorPart . layout ( {
284134 width : this . props . width ,
285135 height : this . props . height ,
286136 } ) ;
@@ -294,39 +144,23 @@ class MonacoEditor extends React.PureComponent {
294144
295145 lifecycleService . phase = LifecyclePhase . Running ;
296146
297- console . log ( LifecyclePhase . Running ) ;
298-
299147 const editorApi = {
300148 openFile ( path : string ) {
301149 return codeEditorService . openCodeEditor ( {
302- resource : context . monaco . Uri . file ( path ) ,
150+ resource : context . monaco . Uri . file ( '/sandbox' + path ) ,
303151 } ) ;
304152 } ,
305153 getActiveCodeEditor ( ) {
306154 return codeEditorService . getActiveCodeEditor ( ) ;
307155 } ,
308156 textFileService,
309- editorPart : window . EditorPart ,
157+ editorPart : EditorPart ,
310158 editorService,
311159 } ;
312160 console . log ( services ) ;
313- console . log ( codeEditorService ) ;
314161
315162 // After initializing monaco editor
316163 this . editorDidMount ( editorApi , context . monaco ) ;
317-
318- // r(
319- // [
320- // 'vs/workbench/parts/snippets/electron-browser/snippets.contribution',
321- // 'vs/workbench/parts/snippets/electron-browser/snippetsService',
322- // 'vs/workbench/parts/snippets/electron-browser/insertSnippet',
323- // 'vs/workbench/parts/snippets/electron-browser/configureSnippets',
324- // 'vs/workbench/parts/snippets/electron-browser/tabCompletion',
325- // ],
326- // () => {
327- // console.log('Loaded snippets');
328- // }
329- // );
330164 }
331165 ) ;
332166
0 commit comments