Merge pull request #6 from avatao-content/modelist

Implement code highlighting
This commit is contained in:
therealkrispet 2018-02-15 13:31:49 +01:00 committed by GitHub
commit aceb544496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,22 @@
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import 'brace/mode/python';
import * as brace from 'brace';
import 'brace/ext/modelist';
import 'brace/mode/c_cpp';
import 'brace/mode/csharp';
import 'brace/mode/java';
import 'brace/mode/javascript';
import 'brace/mode/json';
import 'brace/mode/python';
import 'brace/mode/sql';
import 'brace/theme/monokai';
import { SourceCode } from './source-code';
import { WebSocketService } from '../websocket.service';
const modelist = brace.acequire('ace/ext/modelist');
const defaultSourceCode = `alert( 'Hello, world!' );`;
@Component({
@ -29,7 +40,7 @@ export class WebideComponent implements OnInit {
this.webSocketService.observeAnchor<SourceCode>(this.anchor_id).subscribe((event) => {
this.filename = event.data.filename;
this.code = event.data.content;
this.language = event.data.language;
this.language = modelist.getModeForPath(this.filename).name;
this.files = event.data.files;
if (event.data.command === 'write') { this.saveButtonState = 'SAVED'; }