summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pages/projects/ci/lints/ci_lint_editor.js
blob: 9ab73be80a0d0d699e471d49bff9d2b6b773d881 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
export default class CILintEditor {
  constructor() {
    this.editor = window.ace.edit('ci-editor');
    this.textarea = document.querySelector('#content');
    this.clearYml = document.querySelector('.clear-yml');

    this.editor.getSession().setMode('ace/mode/yaml');
    this.editor.on('input', () => {
      const content = this.editor.getSession().getValue();
      this.textarea.value = content;
    });

    this.clearYml.addEventListener('click', this.clear.bind(this));
  }

  clear() {
    this.editor.setValue('');
  }
}