Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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.js42
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();
});
}
}