редактор monaco + angular, редактор не распознает языки должным образом - PullRequest
0 голосов
/ 25 июня 2018

Использование angular и monaco-editor, а редактор, созданный из этого углового компонента, не окрашивает и не завершает «ключевые» слова в java, такие как int, double и т. Д. Я пробовал так много вещей на данный момент иМне интересно, если проблема в том, как Монако взаимодействует с угловой или что.Стиль не меняется по какой-то причине.

declare var require: any;
import { NgModule, DoCheck } from '@angular/core';
import { Component, ViewChild, Input, ElementRef, ViewEncapsulation } from '@angular/core';
import * as monaco from 'monaco-editor';
import { CommonModule } from '@angular/common';
import 'script-loader!../../../../node_modules/monaco-editor/dev/vs/editor/editor.main';
import  {registerLanguage} from 'script-loader!../../../../node_modules/monaco-editor/dev/vs/basic-languages/_.contribution';
import {conf} from 'script-loader!../../../../node_modules/monaco-editor/dev/vs/basic-languages/java/java.js';


export class ZoeComponent implements IComponent {
  capabilities: Array<Capability>;
  element: HTMLElement;
  constructor(inputCapabilities: Array<Capability>, inputEl: HTMLElement) {
    this.element = inputEl;
    this.capabilities = inputCapabilities.slice(0);
  }
  getDOMElement(): HTMLElement {
    return this.element;
  }
  getCapabilities(): Capability[] {
    return this.capabilities;
  }
}

@Component({
  selector: 'zlux-editor-window',
  templateUrl: 'zlux-editor-window.component.html',
  encapsulation: ViewEncapsulation.None,
  styleUrls: ['zlux-editor-window.component.css',
    '../../../../node_modules/monaco-editor/dev/vs/editor/editor.main.css']
})
export class ZluxEditorWindowComponent implements ComponentFactory {
  @ViewChild('editor') editorContent: ElementRef;
  editorEle: HTMLElement;
  componentClass: ComponentClass;
  capabilities: Array<Capability>;
  inputContents: fileContents = { filePath: '/u/ts6223/', fileName: 'hello.txt', fileContents: ['hi', "i'm", "right here!"] };

  constructor() {
    this.componentClass = ComponentClass.CodeEditor;
  }
  ngAfterViewInit() {

    var onGotAmdLoader = () => {

        this.initMonaco(this.inputContents.fileContents);

    };
    onGotAmdLoader();



  }
  initMonaco(inputContents: Array<string>) {
    this.editorEle = this.editorContent.nativeElement;
    let x =monaco.editor.create(this.editorEle, {
      value: inputContents
        .join('\n'),
      language: 'java',
      quickSuggestions: { other: true, comments: true, strings: true }


    }).layout({ width: 500, height: 800 });
  }
}

@NgModule({
  declarations: [ZluxEditorWindowComponent],
  imports: [CommonModule],
  exports: [ZluxEditorWindowComponent],
  entryComponents: [ZluxEditorWindowComponent]
})
export class ZluxEditorWindowModule { }

Есть ли что-то внутри секций Монако, которые, кажется, отключены?

-

...