Gathering detailed insights and metrics for @ng-util/monaco-editor
Gathering detailed insights and metrics for @ng-util/monaco-editor
Gathering detailed insights and metrics for @ng-util/monaco-editor
Gathering detailed insights and metrics for @ng-util/monaco-editor
npm install @ng-util/monaco-editor
Typescript
Module System
Node Version
NPM Version
TypeScript (76.2%)
Shell (10.98%)
JavaScript (10.58%)
HTML (2.23%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
34 Stars
75 Commits
11 Forks
3 Watchers
22 Branches
4 Contributors
Updated on Jul 08, 2025
Latest Version
20.0.3
Package Id
@ng-util/monaco-editor@20.0.3
Unpacked Size
393.47 kB
Size
77.62 kB
File Count
7
NPM Version
10.9.2
Node Version
22.16.0
Published on
Jul 08, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Monaco Code Editor for Angular.
Inspired by ngx-monaco-editor.
Install from npm repository:
1npm install @ng-util/monaco-editor --save
Configure monaco-editor library
Currently this library only supports load monaco-editor with AMD mode. The default is to use cdn (https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min
) lazy loading。
If you are using local monaco editor library, you could add the following:
"assets": [
{
"glob": "**/*",
"input": "node_modules/monaco-editor/min/vs",
"output": "/lib/vs"
}
],
And configure baseUrl
via NuMonacoEditorModule.forRoot
.
1NuMonacoEditorModule.forRoot({
2 baseUrl: `lib`,
3}),
Include NuMonacoEditorModule
in Main Module and Feature Modules where you want to use the editor component.(eg: app.module.ts):
1import { NgModule } from '@angular/core'; 2import { NuMonacoEditorModule } from '@ng-util/monaco-editor'; 3 4@NgModule({ 5 imports: [ 6 NuMonacoEditorModule // And use `provideNuMonacoEditorConfig` to modify the global configuration 7 ], 8}) 9export class AppModule { }
Create Editor options in component.
1import { Component } from '@angular/core'; 2 3@Component({ 4 selector: 'app-root', 5 template: `<nu-monaco-editor [(ngModel)]="value" [options]="editorOptions"></nu-monaco-editor>`, 6}) 7export class DemoComponent { 8 value: string = 'const a = 1;'; 9 editorOptions = { theme: 'vs-dark', language: 'typescript' }; 10}
Or monaco diff editor:
1import { Component } from '@angular/core'; 2import { NuMonacoEditorDiffModel } from '@ng-util/monaco-editor'; 3 4@Component({ 5 selector: 'app-root', 6 template: `<nu-monaco-diff-editor [options]="editorOptions" [old]="old" [new]="new"></nu-monaco-diff-editor>`, 7}) 8export class DemoComponent { 9 editorOptions = { theme: 'vs-dark', language: 'javascript' }; 10 old: NuMonacoEditorDiffModel = { code: `<p>1</p>` }; 11 new: NuMonacoEditorDiffModel = { code: `<p>2</p>` }; 12}
Output event
can be divided into different stages of feedback according to the type
attribute. When you need to initialize init
, you can program the editor in one step.
1import { Component } from '@angular/core'; 2import { NuMonacoEditorEvent } from '@ng-util/monaco-editor'; 3 4@Component({ 5 selector: 'app-root', 6 template: `<nu-monaco-editor [(ngModel)]="value" [options]="editorOptions" (event)="showEvent($event)"></nu-monaco-editor>`, 7}) 8export class DemoComponent { 9 value: string = 'const a = 1;'; 10 editorOptions = { theme: 'vs-dark', language: 'javascript' }; 11 12 showEvent(e: NuMonacoEditorEvent): void { 13 if (e.type === 'init') { 14 // doing 15 } 16 } 17}
forRoot()
method of NuMonacoEditorModule
accepts config of type NuMonacoEditorConfig
.
1NuMonacoEditorModule.forRoot({
2 baseUrl: ``, // The base URL to monaco editor library assets via AMD (RequireJS), Default: `https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.20.0/min`
3 defaultOptions: {}, // Default options when creating editors
4 monacoLoad: (m) => {} // The event after the first loading of the monaco editor library is completed, use this function to extend monaco editor functionalities.
5}),
monacoLoad
property of NuMonacoEditorConfig
can be used to configure JSON default.
1NuMonacoEditorModule.forRoot({ 2 defaultOptions: { scrollBeyondLastLine: false }, 3 monacoLoad: () => { 4 const uri = monaco.Uri.parse('a://b/foo.json'); 5 monaco.languages.json.jsonDefaults.setDiagnosticsOptions({ 6 validate: true, 7 schemas: [ 8 { 9 uri: 'http://myserver/foo-schema.json', 10 fileMatch: [uri.toString()], 11 schema: { 12 type: 'object', 13 properties: { 14 p1: { 15 enum: ['v1', 'v2'], 16 }, 17 p2: { 18 $ref: 'http://myserver/bar-schema.json', 19 }, 20 }, 21 }, 22 }, 23 { 24 uri: 'http://myserver/bar-schema.json', 25 fileMatch: [uri.toString()], 26 schema: { 27 type: 'object', 28 properties: { 29 q1: { 30 enum: ['x1', 'x2'], 31 }, 32 }, 33 }, 34 }, 35 ], 36 }); 37 }, 38}),
Now pass model
config of type NuMonacoEditorModule
to Editor Component.
1import { Component } from '@angular/core'; 2import { NuMonacoEditorEvent, NuMonacoEditorModel } from '@ng-util/monaco-editor'; 3 4@Component({ 5 selector: 'app-demo', 6 template: ` 7 <nu-monaco-editor #a [(ngModel)]="value" [model]="model" (event)="showEvent($event)"></nu-monaco-editor> 8 <button (click)="a.editor.getAction('editor.action.formatDocument').run()">Format document</button> 9 `, 10}) 11export class DemoComponent { 12 value = '{"p1":"a"}'; 13 model: NuMonacoEditorModel; 14 15 showEvent(e: NuMonacoEditorEvent) { 16 if (e.type === 'init') { 17 this.model = { 18 language: 'json', 19 uri: monaco.Uri.parse('a://b/foo.json'), 20 }; 21 } 22 } 23}
Property | Description | Type | Default |
---|---|---|---|
[placeholder] | Placeholder of monaco editor, Can change the style via defining the .monaco-editor-placeholder CSS. | string | - |
[height] | Height of monaco editor | string | 200px |
[disabled] | Disabled of monaco editor | boolean | false |
[autoFormat] | Whether to automatically format the document | boolean | true |
[options] | Default options when creating editors | monaco.editor.IStandaloneEditorConstructionOptions | - |
[model] | Model of monaco editor | NuMonacoEditorModel | - |
[delay] | Delay init monaco editor, unit: ms | number | 0 |
(event) | Event callback | EventEmitter<NuMonacoEditorEvent> | - |
Property | Description | Type | Default |
---|---|---|---|
[height] | Height of monaco editor | string | 200px |
[disabled] | Disabled of monaco editor | boolean | false |
[options] | Default options when creating editors | monaco.editor.IStandaloneEditorConstructionOptions | - |
[old] | Old model of monaco editor | NuMonacoEditorDiffModel | - |
[new] | New model of monaco editor | NuMonacoEditorDiffModel | - |
[delay] | Delay init monaco editor, unit: ms | number | 0 |
(event) | Event callback | EventEmitter<NuMonacoEditorEvent> | - |
The MIT License (see the LICENSE file for the full text)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
8 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 6
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
16 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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