977bf97e7e8e4b86e3c593e2b8ebd4d2a09b778c
[ccsdk/cds.git] /
1 import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
2 import { AceEditorComponent } from 'ng2-ace-editor';
3 // import 'brace/ext/searchbox';
4 // import 'ace-builds/webpack-resolver';
5 // import 'brace';
6 // import 'brace/ext/language_tools';
7 // import 'ace-builds/src-min-noconflict/snippets/html';
8
9 @Component({
10     selector: 'app-source-editor',
11     templateUrl: './source-editor.component.html',
12     styleUrls: ['./source-editor.component.css']
13 })
14 export class SourceEditorComponent implements OnInit, AfterViewInit {
15
16
17     @Input() text: string;
18     @Output() textChange = new EventEmitter();
19     @Input() lang: string;
20     @ViewChild('editor', { static: false }) editor: AceEditorComponent;
21
22     ngOnInit(): void {
23         //  throw new Error("Method not implemented.");
24     }
25
26
27     ngAfterViewInit() {
28
29         console.log(this.lang);
30         this.editor.setTheme('eclipse');
31         this.editor.getEditor().setOptions({
32             enableBasicAutocompletion: true,
33             highlightSelectedWord: true,
34             maxLines: Infinity,
35             enableSnippets: true,
36             enableLiveAutocompletion: true,
37             showFoldWidgets: true,
38         });
39
40         this.editor.getEditor().commands.addCommand({
41             name: 'showOtherCompletions',
42             bindKey: 'Ctrl-.',
43             exec(editor) {
44
45             }
46         });
47     }
48
49     onChange(editor) {
50         this.textChange.emit(this.text);
51     }
52 }