angular-plugin-architecture
angular-plugin-architecture copied to clipboard
Monaco Editor is not working
I have tried to import monaco-editor as a shared component.
When I try to load the monaco using the below code , require is not loaded as a global function and gives the error saying config of undefined error
const onGotAmdLoader = (e?) => {
// Load monaco
(window).require.config({ paths: { 'vs': `assets/monaco-editor/min/vs` } });
(window).require(['vs/editor/editor.main'], () => {
setTimeout(() => {
(window).monaco = monaco;
this.monacoLoaded = true;
this.monacoLoadedSubject.next(true);
});
});
};
// Load AMD loader if necessary
if (!(window).require) {
const loaderScript = document.createElement('script');
loaderScript.type = 'text/javascript';
loaderScript.src = '/assets/monaco-editor/min/vs/loader.js';
loaderScript.addEventListener('load', onGotAmdLoader);
document.body.appendChild(loaderScript);
} else {
onGotAmdLoader();
}