| 52 | } |
| 53 | @singleton() |
| 54 | export class MonacoService implements IMonacoService { |
| 55 | private _services: ServiceCollection; |
| 56 | private simpleEditorModelResolverService: SimpleEditorModelResolverService | null = |
| 57 | null; |
| 58 | private _container!: HTMLElement | null; |
| 59 | |
| 60 | constructor() {} |
| 61 | |
| 62 | public initWorkspace(container: HTMLElement) { |
| 63 | this._container = container; |
| 64 | this._services = this.createStandaloneServices(); |
| 65 | } |
| 66 | |
| 67 | get container() { |
| 68 | return this._container; |
| 69 | } |
| 70 | |
| 71 | get services() { |
| 72 | return this._services; |
| 73 | } |
| 74 | |
| 75 | get commandService() { |
| 76 | return this.services.get(ICommandService); |
| 77 | } |
| 78 | |
| 79 | private mergeEditorServices(overrides?: IEditorOverrideServices) { |
| 80 | if (overrides) { |
| 81 | const services = this.services; |
| 82 | for (const serviceId in overrides) { |
| 83 | if (serviceId) { |
| 84 | const service = services.get(serviceId); |
| 85 | if (service && overrides[serviceId]) { |
| 86 | services.set(serviceId, overrides[serviceId]); |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | public create( |
| 94 | domElement: HTMLElement, |
| 95 | options?: IStandaloneEditorConstructionOptions, |
| 96 | overrides?: IEditorOverrideServices |
| 97 | ): MonacoEditor.IStandaloneCodeEditor { |
| 98 | const services = this.services; |
| 99 | |
| 100 | this.mergeEditorServices(overrides); |
| 101 | if (!services.has(ITextModelService)) { |
| 102 | this.simpleEditorModelResolverService = |
| 103 | new SimpleEditorModelResolverService( |
| 104 | StaticServices.modelService.get() |
| 105 | ); |
| 106 | services.set( |
| 107 | ITextModelService, |
| 108 | this.simpleEditorModelResolverService |
| 109 | ); |
| 110 | } |
| 111 |
nothing calls this directly
no outgoing calls
no test coverage detected