aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/source-editor/source-editor.component.ts
blob: 8f4c376a3fb4c9cf0a5e05bec0aa288c8f2ec159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
import { AceEditorComponent } from 'ng2-ace-editor';
// import 'brace/ext/searchbox';
// import 'ace-builds/webpack-resolver';
// import 'brace';
// import 'brace/ext/language_tools';
// import 'ace-builds/src-min-noconflict/snippets/html';

@Component({
    selector: 'app-source-editor',
    templateUrl: './source-editor.component.html',
    styleUrls: ['./source-editor.component.css']
})
export class SourceEditorComponent implements OnInit, AfterViewInit {


    @Input() text: string;
    @Output() textChange = new EventEmitter();
    @Input() lang: string;
    @ViewChild('editor', { static: false }) editor: AceEditorComponent;

    ngOnInit(): void {
        //  throw new Error("Method not implemented.");
    }


    ngAfterViewInit() {

        console.log(this.lang);
        this.editor.setTheme('eclipse');
        this.editor.getEditor().setOptions({
            enableBasicAutocompletion: true,
            // fontSize: '14pt',
            // maxLines: 4096,
            // behavioursEnabled: true,
            // wrapBehavioursEnabled: true,
            // showPrintMargin: true,
            // indentedSoftWrap: true,
            // wrap: true,
        });

        this.editor.getEditor().commands.addCommand({
            name: 'showOtherCompletions',
            bindKey: 'Ctrl-.',
            exec(editor) {

            }
        });
    }

    onChange(editor) {
        this.textChange.emit(this.text);
    }
}