[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing sourceMap in PROD and relative default assets folder #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Change base Editor to use relative assets folder
  • Loading branch information
Arno Abraham committed Aug 7, 2019
commit ca683f9b3be9df6cc9714a1e9acab0e34804abf1
38 changes: 25 additions & 13 deletions projects/editor/src/lib/base-editor.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import { AfterViewInit, ElementRef, EventEmitter, Input, OnDestroy, Output, ViewChild } from '@angular/core';
import { Subscription } from 'rxjs';
import { NgxMonacoEditorConfig } from './config';
import {
AfterViewInit,
ElementRef,
EventEmitter,
Input,
OnDestroy,
Output,
ViewChild
} from "@angular/core";
import { Subscription } from "rxjs";
import { NgxMonacoEditorConfig } from "./config";

let loadedMonaco = false;
let loadPromise: Promise<void>;
declare const require: any;

export abstract class BaseEditor implements AfterViewInit, OnDestroy {
@ViewChild('editorContainer') _editorContainer: ElementRef;
@ViewChild("editorContainer") _editorContainer: ElementRef;
@Output() EventEmitter<any>();
protected _editor: any;
private _options: any;
protected _windowResizeSubscription: Subscription;

@Input('options')
@Input("options")
set options(options: any) {
this._options = Object.assign({}, this.config.defaultOptions, options);
if (this._editor) {
Expand All @@ -37,16 +45,18 @@ export abstract class BaseEditor implements AfterViewInit, OnDestroy {
} else {
loadedMonaco = true;
loadPromise = new Promise<void>((resolve: any) => {
const baseUrl = this.config.baseUrl || '/assets';
if (typeof ((<any>window).monaco) === 'object') {
const baseUrl = this.config.baseUrl || "./assets";
if (typeof (<any>window).monaco === "object") {
resolve();
return;
}
const onGotAmdLoader: any = () => {
// Load monaco
(<any>window).require.config({ paths: { 'vs': `${baseUrl}/monaco/vs` } });
(<any>window).require(['vs/editor/editor.main'], () => {
if (typeof this.config. 'function') {
(<any>window).require.config({
paths: { vs: `${baseUrl}/monaco/vs` }
});
(<any>window).require(["vs/editor/editor.main"], () => {
if (typeof this.config. "function") {
this.config.onMonacoLoad();
}
this.initMonaco(this.options);
Expand All @@ -56,10 +66,12 @@ export abstract class BaseEditor implements AfterViewInit, OnDestroy {

// Load AMD loader if necessary
if (!(<any>window).require) {
const loaderScript: HTMLScriptElement = document.createElement('script');
loaderScript.type = 'text/javascript';
const loaderScript: HTMLScriptElement = document.createElement(
"script"
);
loaderScript.type = "text/javascript";
loaderScript.src = `${baseUrl}/monaco/vs/loader.js`;
loaderScript.addEventListener('load', onGotAmdLoader);
loaderScript.addEventListener("load", onGotAmdLoader);
document.body.appendChild(loaderScript);
} else {
onGotAmdLoader();
Expand Down