Gathering detailed insights and metrics for @abc.xyz/angular-monaco-editor-loader
Gathering detailed insights and metrics for @abc.xyz/angular-monaco-editor-loader
Gathering detailed insights and metrics for @abc.xyz/angular-monaco-editor-loader
Gathering detailed insights and metrics for @abc.xyz/angular-monaco-editor-loader
An awesome less hacky way to load monaco editor with Angular
npm install @abc.xyz/angular-monaco-editor-loader
Typescript
Module System
Node Version
NPM Version
71.5
Supply Chain
99.3
Quality
76.2
Maintenance
100
Vulnerability
100
License
JavaScript (62.68%)
TypeScript (37.32%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
6 Stars
182 Commits
1 Forks
2 Watchers
209 Branches
3 Contributors
Updated on Apr 05, 2022
Latest Version
13.0.2
Package Id
@abc.xyz/angular-monaco-editor-loader@13.0.2
Unpacked Size
57.04 kB
Size
14.13 kB
File Count
19
NPM Version
8.3.1
Node Version
17.4.0
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
Easy to install with the following command:
npm i @abc.xyz/angular-monaco-editor-loader
An easy to use Monaco Editor Loader Service for Angular! Just add *loadMonacoEditor
in your HTML Element, and you don't have to worry about timing issues!
If you are looking for Angular 5-7 please see the following release https://github.com/leolorenzoluis/xyz.MonacoEditorLoader/releases/tag/v5.0.0
If you are looking for Angular < 4 please see the following branch https://github.com/leolorenzoluis/xyz.MonacoEditorLoader/tree/angular-4
<div *loadMonacoEditor id="container"></div>
With custom monaco-editor path
<div *loadMonacoEditor="'libs/monaco-editor/vs'" id="container"></div>
Monaco Editor
in /assets/monaco-editor/vs
app.component
then DO NOT USE the directive. Instead use the following code in app.component.ts
constructor(private monaco: MonacoEditorLoaderService) {
}
this.monaco.isMonacoLoaded.subscribe(value => {
if (value) {
// Initialize monaco...
}
})
*loadMonacoEditor
inside your component's HTMLWebpack
do the following:plugins: [
new CopyWebpackPlugin([
{
from: 'node_modules/monaco-editor/min/vs',
to: './src/assets/monaco',
}
]),
],
angular.json
to the following:"assets": [
{
"glob": "**/*",
"input": "../node_modules/monaco-editor/min/",
"output": "./assets/monaco-editor/"
},
{
"glob": "**/*",
"input": "../node_modules/monaco-editor/min-maps/",
"output": "./assets/min-maps/"
},
{
"glob": "favicon.ico",
"input": "./",
"output": "./"
}
]
In your component's module or app module. Import the following:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { MonacoEditorLoaderModule, MonacoEditorLoaderService } from '@abc.xyz/angular-monaco-editor-loader';
import { AppComponent } from './app.component';
import { MonacoEditorComponent } from './monaco-editor/monaco-editor.component';
@NgModule({
declarations: [
AppComponent,
MonacoEditorComponent
],
imports: [
BrowserModule,
MonacoEditorLoaderModule <-- Insert this>
],
bootstrap: [AppComponent]
})
export class AppModule { }
Just add *loadMonacoEditor
, so with your custom component where you plan to create your own monaco component. Just add the following:
<monaco-editor *loadMonacoEditor></monaco-editor>
And in my custom component where I want to host Monaco Editor
I just do the following like I expect the Monaco library to be loaded at this point:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'monaco-editor',
templateUrl: './monaco-editor.component.html',
styleUrls: ['./monaco-editor.component.css']
})
export class MonacoEditorComponent implements OnInit {
constructor() { }
ngOnInit() {
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
noSemanticValidation: true,
noSyntaxValidation: false
});
// compiler options
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ES2016,
allowNonTsExtensions: true
});
// extra libraries
monaco.languages.typescript.javascriptDefaults.addExtraLib([
'declare class Facts {',
' /**',
' * Returns the next fact',
' */',
' static next():string',
'}',
].join('\n'), 'filename/facts.d.ts');
var jsCode = [
'"use strict";',
'',
"class Chuck {",
" greet() {",
" return Facts.next();",
" }",
"}"
].join('\n');
monaco.editor.create(document.getElementById("container"), {
value: jsCode,
language: "javascript"
});
}
}
And that's it! No timeouts
! No then
! It just goes with the correct flow in Angular!
Make sure you have Angular CLI installed!
cd demo
ng serve
I did not want to clutter my component or code with timeouts
or then
to determine if Monaco has loaded! I also wanna utilize ReactiveJS
when dealing with these kind of stuff.
Most of the code that was found here just wasn't the right timing when to check if Monaco is already loaded.
Sometimes I see hacks from Covalent such as adding timeouts
. So many timeouts everywhere!
if (this._webview) {
if (this._webview.send !== undefined) {
// don't want to keep sending content if event came from IPC, infinite loop
if (!this._fromEditor) {
this._webview.send('setEditorContent', value);
}
this.onEditorValueChange.emit(undefined);
this.onChange.emit(undefined);
this.propagateChange(this._value);
this._fromEditor = false;
} else {
// Editor is not loaded yet, try again in half a second
setTimeout(() => {
this.value = value;
}, 500);
}
}
For Angular refer to samples/angular13 angular.json and custom-webpack.js monaco webpack plugin to enable web workers
See more https://www.digitalocean.com/community/tutorials/angular-custom-webpack-config
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/9 approved changesets -- score normalized to 0
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
project is not fuzzed
Details
Reason
security policy file not detected
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
82 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