mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-16 05:41:56 +00:00
Use modelist to automagically select correct code highlight
This commit is contained in:
parent
c88fd8c3b8
commit
ae58ee906f
@ -1,11 +1,15 @@
|
|||||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
import * as brace from 'brace';
|
||||||
|
import 'brace/ext/modelist';
|
||||||
import 'brace/mode/python';
|
import 'brace/mode/python';
|
||||||
import 'brace/mode/javascript';
|
import 'brace/mode/javascript';
|
||||||
import 'brace/theme/monokai';
|
import 'brace/theme/monokai';
|
||||||
import { SourceCode } from './source-code';
|
import { SourceCode } from './source-code';
|
||||||
import { WebSocketService } from '../websocket.service';
|
import { WebSocketService } from '../websocket.service';
|
||||||
|
|
||||||
|
const modelist = brace.acequire('ace/ext/modelist');
|
||||||
|
|
||||||
const defaultSourceCode = `alert( 'Hello, world!' );`;
|
const defaultSourceCode = `alert( 'Hello, world!' );`;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -29,7 +33,7 @@ export class WebideComponent implements OnInit {
|
|||||||
this.webSocketService.observeAnchor<SourceCode>(this.anchor_id).subscribe((event) => {
|
this.webSocketService.observeAnchor<SourceCode>(this.anchor_id).subscribe((event) => {
|
||||||
this.filename = event.data.filename;
|
this.filename = event.data.filename;
|
||||||
this.code = event.data.content;
|
this.code = event.data.content;
|
||||||
this.language = event.data.language;
|
this.language = modelist.getModeForPath(this.filename).name;
|
||||||
this.files = event.data.files;
|
this.files = event.data.files;
|
||||||
|
|
||||||
if (event.data.command === 'write') { this.saveButtonState = 'SAVED'; }
|
if (event.data.command === 'write') { this.saveButtonState = 'SAVED'; }
|
||||||
|
Loading…
Reference in New Issue
Block a user