diff options
Diffstat (limited to 'app/assets/javascripts/pages/projects/ci/lints/ci_lint_editor.js')
-rw-r--r-- | app/assets/javascripts/pages/projects/ci/lints/ci_lint_editor.js | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/app/assets/javascripts/pages/projects/ci/lints/ci_lint_editor.js b/app/assets/javascripts/pages/projects/ci/lints/ci_lint_editor.js index d270bee25c7..df635522e94 100644 --- a/app/assets/javascripts/pages/projects/ci/lints/ci_lint_editor.js +++ b/app/assets/javascripts/pages/projects/ci/lints/ci_lint_editor.js @@ -1,13 +1,11 @@ -import createFlash from '~/flash'; -import { BLOB_EDITOR_ERROR } from '~/blob_edit/constants'; +import EditorLite from '~/editor/editor_lite'; export default class CILintEditor { constructor() { - const monacoEnabled = window?.gon?.features?.monacoCi; this.clearYml = document.querySelector('.clear-yml'); this.clearYml.addEventListener('click', this.clear.bind(this)); - return monacoEnabled ? this.initEditorLite() : this.initAce(); + return this.initEditorLite(); } clear() { @@ -15,34 +13,20 @@ export default class CILintEditor { } initEditorLite() { - import(/* webpackChunkName: 'monaco_editor_lite' */ '~/editor/editor_lite') - .then(({ default: EditorLite }) => { - const editorEl = document.getElementById('editor'); - const fileContentEl = document.getElementById('content'); - const form = document.querySelector('.js-ci-lint-form'); + const editorEl = document.getElementById('editor'); + const fileContentEl = document.getElementById('content'); + const form = document.querySelector('.js-ci-lint-form'); - const rootEditor = new EditorLite(); + const rootEditor = new EditorLite(); - this.editor = rootEditor.createInstance({ - el: editorEl, - blobPath: '.gitlab-ci.yml', - blobContent: editorEl.innerText, - }); - - form.addEventListener('submit', () => { - fileContentEl.value = this.editor.getValue(); - }); - }) - .catch(() => createFlash({ message: BLOB_EDITOR_ERROR })); - } - - initAce() { - this.editor = window.ace.edit('ci-editor'); - this.textarea = document.getElementById('content'); + this.editor = rootEditor.createInstance({ + el: editorEl, + blobPath: '.gitlab-ci.yml', + blobContent: editorEl.innerText, + }); - this.editor.getSession().setMode('ace/mode/yaml'); - this.editor.on('input', () => { - this.textarea.value = this.editor.getSession().getValue(); + form.addEventListener('submit', () => { + fileContentEl.value = this.editor.getValue(); }); } } |