Gathering detailed insights and metrics for @materia-ui/ngx-monaco-editor
Gathering detailed insights and metrics for @materia-ui/ngx-monaco-editor
Gathering detailed insights and metrics for @materia-ui/ngx-monaco-editor
Gathering detailed insights and metrics for @materia-ui/ngx-monaco-editor
npm install @materia-ui/ngx-monaco-editor
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
159 Stars
157 Commits
35 Forks
3 Watching
30 Branches
4 Contributors
Updated on 19 Aug 2024
TypeScript (96.46%)
HTML (1.83%)
JavaScript (0.98%)
SCSS (0.73%)
Cumulative downloads
Total Downloads
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
1
2
🚀 Try it out on Stackblitz
👉 See it in action with our live demo
📖 Api reference available here
The library is currently supported by Angular v13.
Check older versions support:
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}
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:
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}
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}
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 }
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:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
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
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
84 existing vulnerabilities detected
Details
Score
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