Skip to content

Commit 71e5ff4

Browse files
committed
Update the dependencies
Signed-off-by: Célian Garcia <[email protected]>
1 parent c020990 commit 71e5ff4

21 files changed

+40922
-8612
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ cd examples/<example-folder>
4343
npm install
4444
npm link monaco-promql
4545
npm start
46+
# Then modify manually the monaco-promql import :/ "monaco-promql" -> "monaco-promql/lib"
4647
```
4748

4849
## Roadmap

docs/angular_integration.md

+42-56
Original file line numberDiff line numberDiff line change
@@ -4,80 +4,66 @@ Add the these dependencies to your ``package.json`` :
44
- [prometheus-community/monaco-promql](https://github.com/prometheus-community/monaco-promql)
55

66
```bash
7-
npm install ngx-monaco-editor --save
7+
npm install @monaco-editor/loader --save
88
npm install monaco-promql --save
99
```
1010

11-
Add the glob to assets in your ``angular.json`` configuration file.
11+
> **Disclaimer**
12+
> I didn't manage to make a good plug-and-play integration for Angular.
13+
> It is a bit a mess but so far it works, modify as you wish and propose enhancements !
1214
13-
```json
14-
{
15-
"projects": {
16-
"my-project": {
17-
"architect": {
18-
"build": {
19-
"options": {
20-
"assets": [
21-
{ "glob": "**/*", "input": "./node_modules/ngx-monaco-editor/assets/monaco", "output": "./assets/monaco/" }
22-
]
23-
}
24-
}
25-
}
26-
}
27-
}
28-
}
29-
```
30-
31-
Integrate the language into the configuration of the angular module.
15+
- Copy the homemade monaco module from the [angular example](./../examples/angular-promql/src/app/monaco).
16+
- Mind the version of monaco-editor in the [MonacoLoaderService](./../examples/angular-promql/src/app/monaco/monaco-loader.service.ts).
17+
It should be the same as the one in your [package.json](./../examples/angular-promql/package.json).
18+
- Initialize monaco from your main angular module.
3219

3320
```typescript
34-
import { NgModule } from '@angular/core';
35-
import { FormsModule } from '@angular/forms';
3621
import { BrowserModule } from '@angular/platform-browser';
37-
import { MonacoEditorModule } from 'ngx-monaco-editor';
22+
import { APP_INITIALIZER, NgModule } from '@angular/core';
3823

39-
import { promLanguageDefinition } from 'monaco-promql';
40-
import { NgxMonacoEditorConfig } from 'ngx-monaco-editor';
24+
import { AppRoutingModule } from './app-routing.module';
4125
import { AppComponent } from './app.component';
4226

43-
export function onMonacoLoad(): void {
44-
// Register the PromQL language from the library
45-
const languageId = promLanguageDefinition.id;
46-
monaco.languages.register(promLanguageDefinition);
47-
monaco.languages.onLanguage(languageId, () => {
48-
promLanguageDefinition.loader().then((mod) => {
49-
monaco.languages.setMonarchTokensProvider(languageId, mod.language);
50-
monaco.languages.setLanguageConfiguration(languageId, mod.languageConfiguration);
51-
monaco.languages.registerCompletionItemProvider(languageId, mod.completionItemProvider);
52-
});
53-
});
54-
}
27+
import { FormsModule } from '@angular/forms';
28+
import { MonacoStoreService } from './monaco/monaco-store.service';
29+
import { MonacoLoaderService } from './monaco/monaco-loader.service';
30+
import { MonacoModule } from './monaco/monaco.module';
5531

56-
const monacoConfig: NgxMonacoEditorConfig = {
57-
baseUrl: 'assets', // configure base path for monaco editor default: './assets'
58-
defaultOptions: {scrollBeyondLastLine: false}, // pass default options to be used
59-
onMonacoLoad
60-
};
32+
function initializeMonaco(loader: MonacoLoaderService, store: MonacoStoreService): () => Promise<void> {
33+
return () => {
34+
return loader.initialize().then(monaco => {
35+
loader.registerPromQLLanguage(monaco);
36+
store.monacoInstance = monaco;
37+
});
38+
};
39+
}
6140

6241
@NgModule({
63-
declarations: [
64-
AppComponent
65-
],
66-
imports: [
67-
BrowserModule,
68-
FormsModule,
69-
MonacoEditorModule.forRoot(monacoConfig)
70-
],
71-
providers: [],
72-
bootstrap: [AppComponent]
42+
declarations: [
43+
AppComponent
44+
],
45+
imports: [
46+
BrowserModule,
47+
FormsModule,
48+
AppRoutingModule,
49+
MonacoModule
50+
],
51+
providers: [
52+
{
53+
provide: APP_INITIALIZER,
54+
multi: true,
55+
deps: [MonacoLoaderService, MonacoStoreService],
56+
useFactory: initializeMonaco
57+
}
58+
],
59+
bootstrap: [AppComponent]
7360
})
7461
export class AppModule {
7562
}
7663
```
7764

78-
Implements now the editor as simply as using the ``ngx-monaco-editor`` component.
65+
- Implements now the editor as simply as using the ``app-monaco-editor`` component.
7966

8067
```html
81-
<ngx-monaco-editor [options]="{ theme: 'vs-dark', language: 'promql' }"
82-
[(ngModel)]="sum(http_request_total)"></ngx-monaco-editor>
68+
<app-monaco-editor [(ngModel)]="'sum(http_request_total)'"></app-monaco-editor>
8369
```

examples/angular-promql/angular.json

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"optimization": true,
4545
"outputHashing": "all",
4646
"sourceMap": false,
47-
"extractCss": true,
4847
"namedChunks": false,
4948
"aot": true,
5049
"extractLicenses": true,

0 commit comments

Comments
 (0)