diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/assets/javascripts/merge_conflicts | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/assets/javascripts/merge_conflicts')
-rw-r--r-- | app/assets/javascripts/merge_conflicts/components/diff_file_editor.js | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/app/assets/javascripts/merge_conflicts/components/diff_file_editor.js b/app/assets/javascripts/merge_conflicts/components/diff_file_editor.js index 3a67d0ad64a..356d8619fed 100644 --- a/app/assets/javascripts/merge_conflicts/components/diff_file_editor.js +++ b/app/assets/javascripts/merge_conflicts/components/diff_file_editor.js @@ -1,11 +1,10 @@ /* eslint-disable no-param-reassign */ -/* global ace */ import Vue from 'vue'; +import { debounce } from 'lodash'; import axios from '~/lib/utils/axios_utils'; import { deprecatedCreateFlash as flash } from '~/flash'; import { __ } from '~/locale'; -import getModeByFileExtension from '~/lib/utils/ace_utils'; (global => { global.mergeConflicts = global.mergeConflicts || {}; @@ -28,7 +27,6 @@ import getModeByFileExtension from '~/lib/utils/ace_utils'; data() { return { saved: false, - loading: false, fileLoaded: false, originalContent: '', }; @@ -37,7 +35,6 @@ import getModeByFileExtension from '~/lib/utils/ace_utils'; classObject() { return { saved: this.saved, - 'is-loading': this.loading, }; }, }, @@ -45,7 +42,7 @@ import getModeByFileExtension from '~/lib/utils/ace_utils'; 'file.showEditor': function showEditorWatcher(val) { this.resetEditorContent(); - if (!val || this.fileLoaded || this.loading) { + if (!val || this.fileLoaded) { return; } @@ -59,30 +56,25 @@ import getModeByFileExtension from '~/lib/utils/ace_utils'; }, methods: { loadEditor() { - this.loading = true; + const EditorPromise = import(/* webpackChunkName: 'EditorLite' */ '~/editor/editor_lite'); + const DataPromise = axios.get(this.file.content_path); - axios - .get(this.file.content_path) - .then(({ data }) => { - const content = this.$el.querySelector('pre'); - const fileContent = document.createTextNode(data.content); + Promise.all([EditorPromise, DataPromise]) + .then(([{ default: EditorLite }, { data: { content, new_path: path } }]) => { + const contentEl = this.$el.querySelector('.editor'); - content.textContent = fileContent.textContent; - - this.originalContent = data.content; + this.originalContent = content; this.fileLoaded = true; - this.editor = ace.edit(content); - this.editor.$blockScrolling = Infinity; // Turn off annoying warning - this.editor.getSession().setMode(getModeByFileExtension(data.new_path)); - this.editor.on('change', () => { - this.saveDiffResolution(); + + this.editor = new EditorLite().createInstance({ + el: contentEl, + blobPath: path, + blobContent: content, }); - this.saveDiffResolution(); - this.loading = false; + this.editor.onDidChangeModelContent(debounce(this.saveDiffResolution.bind(this), 250)); }) .catch(() => { flash(__('An error occurred while loading the file')); - this.loading = false; }); }, saveDiffResolution() { @@ -95,7 +87,7 @@ import getModeByFileExtension from '~/lib/utils/ace_utils'; }, resetEditorContent() { if (this.fileLoaded) { - this.editor.setValue(this.originalContent, -1); + this.editor.setValue(this.originalContent); } }, cancelDiscardConfirmation(file) { |