Installations
npm install @materia-ui/ngx-monaco-editor
Developer
geoastronaute
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
No
Node Version
14.17.0
NPM Version
6.14.13
Statistics
159 Stars
157 Commits
35 Forks
3 Watching
30 Branches
4 Contributors
Updated on 19 Aug 2024
Languages
TypeScript (96.46%)
HTML (1.83%)
JavaScript (0.98%)
SCSS (0.73%)
Total Downloads
Cumulative downloads
Total Downloads
1,364,010
Last day
3%
1,796
Compared to previous day
Last week
6.2%
8,752
Compared to previous week
Last month
0.9%
34,716
Compared to previous month
Last year
-6.8%
435,518
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
2
Resources
-
🚀 Try it out on Stackblitz
-
👉 See it in action with our live demo
-
📖 Api reference available here
Angular versions
The library is currently supported by Angular v13.
Check older versions support:
Standard installation
Install from npm repository:
npm install monaco-editor @materia-ui/ngx-monaco-editor --save
Add the glob to assets in angular.json (to make monaco-editor lib available to the app):
1{ 2 ... 3 "projects": { 4 "YOUR_APP_NAME": { 5 ... 6 "architect": { 7 "build": { 8 ... 9 "options": { 10 ... 11 "assets": [ 12 { "glob": "**/*", "input": "node_modules/monaco-editor", "output": "assets/monaco-editor/" } 13 ], 14 ... 15 } 16 ... 17 } 18 } 19 ... 20 } 21 }, 22 ... 23}
Sample
Include MonacoEditorModule in Main Module and Feature Modules where you want to use the editor component.(eg: app.module.ts):
1import { BrowserModule } from '@angular/platform-browser'; 2import { NgModule } from '@angular/core'; 3import { FormsModule } from '@angular/forms'; 4 5import { AppComponent } from './app.component'; 6import { MonacoEditorModule } from '@materia-ui/ngx-monaco-editor'; 7 8@NgModule({ 9 declarations: [ 10 AppComponent 11 ], 12 imports: [ 13 BrowserModule, 14 FormsModule, 15 MonacoEditorModule 16 ], 17 providers: [], 18 bootstrap: [AppComponent] 19}) 20export class AppModule { 21}
Create Editor options in component.(eg: app.component.ts)
1import { Component } from '@angular/core'; 2 3@Component({ 4 selector: 'app-root', 5 templateUrl: './app.component.html' 6}) 7export class AppComponent { 8 editorOptions = {theme: 'vs-dark', language: 'javascript'}; 9 code: string = 'function x() {\nconsole.log("Hello world!");\n}'; 10 originalCode: string = 'function x() { // TODO }'; 11}
Include editor component in your html with options input and ngModel bindings (eg: app.component.html) or using ReactiveForm features.
1<ngx-monaco-editor [options]="editorOptions" [(ngModel)]="code"></ngx-monaco-editor>
Include diff-editor component in your html and use the following inputs: options, original and modified (eg: app.component.html).
1<ngx-monaco-diff-editor [options]="editorOptions" [original]="originalCode" [modified]="code"></ngx-monaco-diff-editor>
Both components support all available monaco-editor
options:
- EditorOptions: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.ieditorconstructionoptions.html,
- DiffEditorOptions: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.idiffeditorconstructionoptions.html.
Configure default monaco-editor library path
You can configure the default path used to load the monaco-editor library.
It allows you to either change the localization of your local installed library or load the library from a remote resource.
Example load monaco-editor from a CDN:
⚠️ Warning: in this case you don't need to install monaco-editor and neither modify angular.json.
1import { BrowserModule } from '@angular/platform-browser'; 2import { NgModule } from '@angular/core'; 3import { FormsModule } from '@angular/forms'; 4 5import { AppComponent } from './app.component'; 6import { MonacoEditorModule, MONACO_PATH } from '@materia-ui/ngx-monaco-editor'; 7 8@NgModule({ 9 declarations: [ 10 AppComponent 11 ], 12 imports: [ 13 BrowserModule, 14 FormsModule, 15 MonacoEditorModule 16 ], 17 providers: [{ 18 provide: MONACO_PATH, 19 useValue: 'https://unpkg.com/monaco-editor@0.24.0/min/vs' 20 }], 21 bootstrap: [AppComponent] 22}) 23export class AppModule { 24}
Access editor instance
If you need to retrieve an editor instance you can do so by using the init
output:
1<ngx-monaco-editor [options]="editorOptions" [(ngModel)]="code" (init)="editorInit($event)"></ngx-monaco-editor>
1import { Component } from '@angular/core'; 2... 3export class AppComponent { 4 editorOptions = {theme: 'vs-dark', language: 'javascript'}; 5 code: string= 'function x() {\nconsole.log("Hello world!");\n}'; 6 7 editorInit(editor) { 8 // Here you can access editor instance 9 this.editor = editor; 10 } 11}
Access Monaco instance
If you need to retrieve monaco-editor
instance for advance use cases (like defining a custom theme, add custom auto-complete support, etc...), you have to wait until monaco is loaded using our MonacoEditorLoaderService
:
1import { MonacoEditorLoaderService } from '@materia-ui/ngx-monaco-editor'; 2... 3constructor(private monacoLoaderService: MonacoEditorLoaderService) { 4 this.monacoLoaderService.isMonacoLoaded$.pipe( 5 filter(isLoaded => isLoaded), 6 take(1), 7 ).subscribe(() => { 8 // here, we retrieve monaco-editor instance 9 monaco.setTheme(...); 10 }); 11 }
Motivations
We wanted to use monaco-editor library with angular in our desktop application: Materia Designer.
The current angular libraries did not cover all of our needs, notably:
- Works on Browser and Electron application,
- Support flex-box container and correctly resize editor when container size changes.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
84 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-xwcq-pm8m-c4vf
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-3wcq-x3mq-6r9p
- Warn: Project is vulnerable to: GHSA-phwq-j96m-2c2q
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-273r-mgr4-v34f
- Warn: Project is vulnerable to: GHSA-r7qp-cfhv-p84w
- Warn: Project is vulnerable to: GHSA-q9mw-68c2-j6m5
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-jg8v-48h5-wgxg
- Warn: Project is vulnerable to: GHSA-36fh-84j7-cv5h
- Warn: Project is vulnerable to: GHSA-7x7c-qm48-pq9c
- Warn: Project is vulnerable to: GHSA-rc3x-jf5g-xvc5
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-82v2-mx6x-wq7q
- Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj
- Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2
- Warn: Project is vulnerable to: GHSA-5rrq-pxf6-6jx5
- Warn: Project is vulnerable to: GHSA-8fr3-hfg3-gpgp
- Warn: Project is vulnerable to: GHSA-gf8q-jrpm-jvxq
- Warn: Project is vulnerable to: GHSA-2r2c-g63r-vccr
- Warn: Project is vulnerable to: GHSA-cfm4-qjh2-4765
- Warn: Project is vulnerable to: GHSA-x4jg-mjrx-434g
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-25hc-qcg6-38wj
- Warn: Project is vulnerable to: GHSA-qm95-pgcg-qqfq
- Warn: Project is vulnerable to: GHSA-cqmj-92xf-r6r9
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
1.7
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More