angular-plugin-architecture icon indicating copy to clipboard operation
angular-plugin-architecture copied to clipboard

Monaco Editor is not working

Open SANTOSHKVNSP opened this issue 6 years ago • 0 comments

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();
    }

SANTOSHKVNSP avatar Jun 10 '19 09:06 SANTOSHKVNSP