@@ -83,16 +83,137 @@ class MonacoEditor extends React.PureComponent {
8383 ) ;
8484
8585 appliedOptions . fontFamily = fonts . slice ( 1 ) . join ( ', ' ) ;
86+ const r = context . require ;
87+
88+ const [
89+ { CodeSandboxCommandService } ,
90+ { CodeSandboxHashService } ,
91+ { CodeSandboxKeybindingService } ,
92+ { CodeSandboxWindowsService } ,
93+ { QuickOpenController } ,
94+ { EditorPart } ,
95+ { CodeSandboxWorkbench } ,
96+ { CodeSandboxEnvironmentService } ,
97+ { EditorService } ,
98+ { UntitledEditorService } ,
99+ { CodeSandboxFileService } ,
100+ { StorageService } ,
101+ { HistoryService } ,
102+ { NullLifecycleService } ,
103+ { TextFileService } ,
104+ { WindowService } ,
105+ { CodeSandboxBackupService } ,
106+ { CodeSandboxExtensionService } ,
107+ { FileDecorationsService } ,
108+ { PreferencesService } ,
109+ { JSONEditingService } ,
110+ { CodeSandboxWorkspacesService } ,
111+ { CodeSandboxSearchService } ,
112+ { ViewletService } ,
113+ { TextModelResolverService } ,
114+ ] = [
115+ r ( 'vs/codesandbox/commandService' ) ,
116+ r ( 'vs/codesandbox/hashService' ) ,
117+ r ( 'vs/codesandbox/keybindingService' ) ,
118+ r ( 'vs/codesandbox/windowsService' ) ,
119+ r ( 'vs/workbench/browser/parts/quickopen/quickOpenController' ) ,
120+ r ( 'vs/codesandbox/editorGroupsService' ) ,
121+ r ( 'vs/codesandbox/workbench' ) ,
122+ r ( 'vs/codesandbox/environmentService' ) ,
123+ // r('vs/codesandbox/editorService'),
124+ r ( 'vs/workbench/services/editor/browser/editorService' ) ,
125+ r ( 'vs/workbench/services/untitled/common/untitledEditorService' ) ,
126+ r ( 'vs/codesandbox/fileService' ) ,
127+ r ( 'vs/platform/storage/common/storageService' ) ,
128+ r ( 'vs/workbench/services/history/electron-browser/history' ) ,
129+ r ( 'vs/platform/lifecycle/common/lifecycle' ) ,
130+ r ( 'vs/workbench/services/textfile/electron-browser/textFileService' ) ,
131+ r ( 'vs/platform/windows/electron-browser/windowService' ) ,
132+ r ( 'vs/codesandbox/backupFileService' ) ,
133+ r ( 'vs/codesandbox/extensionService' ) ,
134+ r ( 'vs/workbench/services/decorations/browser/decorationsService' ) ,
135+ r ( 'vs/workbench/services/preferences/browser/preferencesService' ) ,
136+ r ( 'vs/workbench/services/configuration/node/jsonEditingService' ) ,
137+ r ( 'vs/codesandbox/workspacesService' ) ,
138+ r ( 'vs/codesandbox/searchService' ) ,
139+ r ( 'vs/workbench/services/viewlet/browser/viewletService' ) ,
140+ r (
141+ 'vs/workbench/services/textmodelResolver/common/textModelResolverService'
142+ ) ,
143+ ] ;
86144
87145 this . editor = context . monaco . editor [
88146 diffEditor ? 'createDiffEditor' : 'create'
89- ] ( this . containerElement , appliedOptions ) ;
147+ ] ( this . containerElement , appliedOptions , {
148+ backupFileService : i => i . createInstance ( CodeSandboxBackupService ) ,
149+ hashService : i => i . createInstance ( CodeSandboxHashService ) ,
150+ extensionService : i => i . createInstance ( CodeSandboxExtensionService ) ,
151+ lifecycleService : NullLifecycleService ,
152+ windowsService : i => i . createInstance ( CodeSandboxWindowsService ) ,
153+ quickOpenService : i => i . createInstance ( QuickOpenController ) ,
154+ commandService : i => i . createInstance ( CodeSandboxCommandService ) ,
155+ IFileDecorationsService : i => i . createInstance ( FileDecorationsService ) ,
156+ textFileService : i => i . createInstance ( TextFileService ) ,
157+ fileService : i => i . createInstance ( CodeSandboxFileService ) ,
158+ keybindingService : i =>
159+ i . createInstance ( CodeSandboxKeybindingService , window ) ,
160+ editorGroupsService : i =>
161+ i . createInstance ( EditorPart , 'codesandbox' , false ) ,
162+ untitledEditorService : i => i . createInstance ( UntitledEditorService ) ,
163+ partService : i => i . createInstance ( CodeSandboxWorkbench ) ,
164+ environmentService : i =>
165+ i . createInstance ( CodeSandboxEnvironmentService ) ,
166+ storageService : new StorageService ( localStorage , localStorage ) ,
167+ historyService : i => i . createInstance ( HistoryService ) ,
168+ editorService : i => i . createInstance ( EditorService ) ,
169+ windowService : i => i . createInstance ( WindowService ) ,
170+ preferencesService : i => i . createInstance ( PreferencesService ) ,
171+ jsonEditingService : i => i . createInstance ( JSONEditingService ) ,
172+ workspacesService : i => i . createInstance ( CodeSandboxWorkspacesService ) ,
173+ searchService : i => i . createInstance ( CodeSandboxSearchService ) ,
174+ viewletService : i =>
175+ i . createInstance ( ViewletService , {
176+ onDidViewletOpen : ( ) => true ,
177+ onDidViewletClose : ( ) => true ,
178+ } ) ,
179+ textModelService : i => i . createInstance ( TextModelResolverService ) ,
180+ } ) ;
181+
90182 if ( theme ) {
91183 context . monaco . editor . setTheme ( theme ) ;
92184 }
93185
94186 // After initializing monaco editor
95187 this . editorDidMount ( this . editor , context . monaco ) ;
188+
189+ setTimeout ( ( ) => {
190+ const container = document . createElement ( 'div' ) ;
191+ const part = document . createElement ( 'div' ) ;
192+
193+ container . className = 'vs-dark monaco-workbench' ;
194+ container . id = 'workbench.main.container' ;
195+ part . className = 'part editor' ;
196+
197+ container . appendChild ( part ) ;
198+
199+ const editor = document . getElementsByClassName (
200+ 'react-monaco-editor-container'
201+ ) [ 0 ] ;
202+ editor . parentNode . removeChild ( editor ) ;
203+
204+ const rootEl = document . getElementsByClassName (
205+ 'elements__CodeContainer-ghvvch'
206+ ) [ 0 ] ;
207+ rootEl . appendChild ( container ) ;
208+ window . EditorPart . create ( part ) ;
209+
210+ setTimeout ( ( ) => {
211+ window . EditorPart . layout ( {
212+ width : this . props . width ,
213+ height : this . props . height ,
214+ } ) ;
215+ } , 500 ) ;
216+ } , 3000 ) ;
96217 }
97218 } ;
98219
@@ -109,9 +230,9 @@ class MonacoEditor extends React.PureComponent {
109230 render ( ) {
110231 const { width, height } = this . props ;
111232 const fixedWidth =
112- width . toString ( ) . indexOf ( '%' ) !== - 1 ? width : `${ width } px` ;
233+ width && width . toString ( ) . indexOf ( '%' ) !== - 1 ? width : `${ width } px` ;
113234 const fixedHeight =
114- height . toString ( ) . indexOf ( '%' ) !== - 1 ? height : `${ height } px` ;
235+ height && height . toString ( ) . indexOf ( '%' ) !== - 1 ? height : `${ height } px` ;
115236 const style = {
116237 width : fixedWidth ,
117238 height : fixedHeight ,
0 commit comments