2018-03-20 14:12:48 +00:00
|
|
|
<script>
|
2018-03-25 12:02:09 +00:00
|
|
|
import { mapState, mapGetters, mapActions } from 'vuex';
|
2019-04-17 20:41:07 +00:00
|
|
|
import { viewerInformationForPath } from '~/vue_shared/components/content_viewer/lib/viewer_utils';
|
2020-08-20 09:09:55 +00:00
|
|
|
import { deprecatedCreateFlash as flash } from '~/flash';
|
2018-04-05 11:12:40 +00:00
|
|
|
import ContentViewer from '~/vue_shared/components/content_viewer/content_viewer.vue';
|
2018-06-13 09:35:52 +00:00
|
|
|
import DiffViewer from '~/vue_shared/components/diff_viewer/diff_viewer.vue';
|
2020-09-30 00:09:53 +00:00
|
|
|
import {
|
|
|
|
WEBIDE_MARK_FILE_CLICKED,
|
2020-11-18 18:09:08 +00:00
|
|
|
WEBIDE_MARK_REPO_EDITOR_START,
|
|
|
|
WEBIDE_MARK_REPO_EDITOR_FINISH,
|
|
|
|
WEBIDE_MEASURE_REPO_EDITOR,
|
2020-09-30 00:09:53 +00:00
|
|
|
WEBIDE_MEASURE_FILE_AFTER_INTERACTION,
|
2020-11-05 21:08:51 +00:00
|
|
|
} from '~/performance/constants';
|
|
|
|
import { performanceMarkAndMeasure } from '~/performance/utils';
|
2020-09-30 00:09:53 +00:00
|
|
|
import eventHub from '../eventhub';
|
2019-07-23 22:13:36 +00:00
|
|
|
import {
|
2020-02-18 06:09:06 +00:00
|
|
|
leftSidebarViews,
|
2019-07-23 22:13:36 +00:00
|
|
|
viewerTypes,
|
|
|
|
FILE_VIEW_MODE_EDITOR,
|
|
|
|
FILE_VIEW_MODE_PREVIEW,
|
|
|
|
} from '../constants';
|
2018-03-20 14:12:48 +00:00
|
|
|
import Editor from '../lib/editor';
|
2018-08-16 11:41:21 +00:00
|
|
|
import FileTemplatesBar from './file_templates/bar.vue';
|
2019-06-24 05:30:35 +00:00
|
|
|
import { __ } from '~/locale';
|
2020-05-15 00:08:06 +00:00
|
|
|
import { extractMarkdownImagesFromEntries } from '../stores/utils';
|
2020-11-02 18:09:03 +00:00
|
|
|
import { getFileEditorOrDefault } from '../stores/modules/editor/utils';
|
2020-09-17 09:09:32 +00:00
|
|
|
import { getPathParent, readFileAsDataURL, registerSchema, isTextFile } from '../utils';
|
2020-06-10 18:09:15 +00:00
|
|
|
import { getRulesWithTraversal } from '../lib/editorconfig/parser';
|
|
|
|
import mapRulesToMonaco from '../lib/editorconfig/rules_mapper';
|
2018-03-20 14:12:48 +00:00
|
|
|
|
|
|
|
export default {
|
2020-11-18 18:09:08 +00:00
|
|
|
name: 'RepoEditor',
|
2018-04-05 11:12:40 +00:00
|
|
|
components: {
|
|
|
|
ContentViewer,
|
2018-06-13 09:35:52 +00:00
|
|
|
DiffViewer,
|
2018-08-16 11:41:21 +00:00
|
|
|
FileTemplatesBar,
|
2018-04-05 11:12:40 +00:00
|
|
|
},
|
2018-03-20 14:12:48 +00:00
|
|
|
props: {
|
|
|
|
file: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2020-05-15 00:08:06 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
content: '',
|
|
|
|
images: {},
|
2020-06-10 18:09:15 +00:00
|
|
|
rules: {},
|
2020-05-15 00:08:06 +00:00
|
|
|
};
|
|
|
|
},
|
2018-03-20 14:12:48 +00:00
|
|
|
computed: {
|
2018-09-27 21:57:30 +00:00
|
|
|
...mapState('rightPane', {
|
|
|
|
rightPaneIsOpen: 'isOpen',
|
|
|
|
}),
|
2020-11-02 18:09:03 +00:00
|
|
|
...mapState('editor', ['fileEditors']),
|
2020-01-06 15:07:26 +00:00
|
|
|
...mapState([
|
|
|
|
'viewer',
|
|
|
|
'panelResizing',
|
|
|
|
'currentActivityView',
|
|
|
|
'renderWhitespaceInCode',
|
2020-02-15 21:08:49 +00:00
|
|
|
'editorTheme',
|
2020-05-15 00:08:06 +00:00
|
|
|
'entries',
|
2020-09-14 12:09:34 +00:00
|
|
|
'currentProjectId',
|
2020-01-06 15:07:26 +00:00
|
|
|
]),
|
2018-05-01 09:46:28 +00:00
|
|
|
...mapGetters([
|
|
|
|
'currentMergeRequest',
|
|
|
|
'getStagedFile',
|
2018-05-02 14:30:51 +00:00
|
|
|
'isEditModeActive',
|
2018-05-01 09:46:28 +00:00
|
|
|
'isCommitModeActive',
|
2020-05-13 21:08:55 +00:00
|
|
|
'currentBranch',
|
2020-09-16 12:10:15 +00:00
|
|
|
'getJsonSchemaForPath',
|
2018-05-01 09:46:28 +00:00
|
|
|
]),
|
2018-08-16 11:41:21 +00:00
|
|
|
...mapGetters('fileTemplates', ['showFileTemplatesBar']),
|
2020-11-02 18:09:03 +00:00
|
|
|
fileEditor() {
|
|
|
|
return getFileEditorOrDefault(this.fileEditors, this.file.path);
|
|
|
|
},
|
2020-12-18 00:10:04 +00:00
|
|
|
isBinaryFile() {
|
|
|
|
return !isTextFile(this.file);
|
|
|
|
},
|
2018-03-20 14:12:48 +00:00
|
|
|
shouldHideEditor() {
|
2020-12-18 00:10:04 +00:00
|
|
|
return this.file && !this.file.loading && this.isBinaryFile;
|
2018-03-20 14:12:48 +00:00
|
|
|
},
|
2018-06-13 09:35:52 +00:00
|
|
|
showContentViewer() {
|
|
|
|
return (
|
2019-06-27 17:42:02 +00:00
|
|
|
(this.shouldHideEditor || this.isPreviewViewMode) &&
|
2018-06-13 09:35:52 +00:00
|
|
|
(this.viewer !== viewerTypes.mr || !this.file.mrChange)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
showDiffViewer() {
|
|
|
|
return this.shouldHideEditor && this.file.mrChange && this.viewer === viewerTypes.mr;
|
|
|
|
},
|
2019-06-27 17:42:02 +00:00
|
|
|
isEditorViewMode() {
|
2020-11-02 18:09:03 +00:00
|
|
|
return this.fileEditor.viewMode === FILE_VIEW_MODE_EDITOR;
|
2019-06-27 17:42:02 +00:00
|
|
|
},
|
|
|
|
isPreviewViewMode() {
|
2020-11-02 18:09:03 +00:00
|
|
|
return this.fileEditor.viewMode === FILE_VIEW_MODE_PREVIEW;
|
2019-06-27 17:42:02 +00:00
|
|
|
},
|
2018-04-05 11:12:40 +00:00
|
|
|
editTabCSS() {
|
|
|
|
return {
|
2019-06-27 17:42:02 +00:00
|
|
|
active: this.isEditorViewMode,
|
2018-04-05 11:12:40 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
previewTabCSS() {
|
|
|
|
return {
|
2019-06-27 17:42:02 +00:00
|
|
|
active: this.isPreviewViewMode,
|
2018-04-05 11:12:40 +00:00
|
|
|
};
|
|
|
|
},
|
2019-06-27 17:42:02 +00:00
|
|
|
showEditor() {
|
|
|
|
return !this.shouldHideEditor && this.isEditorViewMode;
|
|
|
|
},
|
2020-01-06 15:07:26 +00:00
|
|
|
editorOptions() {
|
|
|
|
return {
|
|
|
|
renderWhitespace: this.renderWhitespaceInCode ? 'all' : 'none',
|
2020-02-15 21:08:49 +00:00
|
|
|
theme: this.editorTheme,
|
2020-01-06 15:07:26 +00:00
|
|
|
};
|
|
|
|
},
|
2020-05-13 21:08:55 +00:00
|
|
|
currentBranchCommit() {
|
|
|
|
return this.currentBranch?.commit.id;
|
|
|
|
},
|
2020-06-10 12:08:58 +00:00
|
|
|
previewMode() {
|
|
|
|
return viewerInformationForPath(this.file.path);
|
|
|
|
},
|
|
|
|
fileType() {
|
|
|
|
return this.previewMode?.id || '';
|
|
|
|
},
|
2018-03-20 14:12:48 +00:00
|
|
|
},
|
|
|
|
watch: {
|
2018-05-18 13:00:31 +00:00
|
|
|
file(newVal, oldVal) {
|
|
|
|
if (oldVal.pending) {
|
|
|
|
this.removePendingTab(oldVal);
|
|
|
|
}
|
|
|
|
|
2018-04-03 10:10:01 +00:00
|
|
|
// Compare key to allow for files opened in review mode to be cached differently
|
2018-05-18 13:00:31 +00:00
|
|
|
if (oldVal.key !== this.file.key) {
|
2018-06-08 04:56:39 +00:00
|
|
|
this.initEditor();
|
2018-05-01 13:42:55 +00:00
|
|
|
|
2020-02-18 06:09:06 +00:00
|
|
|
if (this.currentActivityView !== leftSidebarViews.edit.name) {
|
2020-11-02 18:09:03 +00:00
|
|
|
this.updateEditor({
|
2019-07-23 22:13:36 +00:00
|
|
|
viewMode: FILE_VIEW_MODE_EDITOR,
|
2018-05-01 13:42:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
currentActivityView() {
|
2020-02-18 06:09:06 +00:00
|
|
|
if (this.currentActivityView !== leftSidebarViews.edit.name) {
|
2020-11-02 18:09:03 +00:00
|
|
|
this.updateEditor({
|
2019-07-23 22:13:36 +00:00
|
|
|
viewMode: FILE_VIEW_MODE_EDITOR,
|
2018-05-01 13:42:55 +00:00
|
|
|
});
|
2018-03-20 14:12:48 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
viewer() {
|
2018-07-26 14:56:56 +00:00
|
|
|
if (!this.file.pending) {
|
|
|
|
this.createEditorInstance();
|
|
|
|
}
|
2018-03-20 14:12:48 +00:00
|
|
|
},
|
2018-03-28 14:06:50 +00:00
|
|
|
panelResizing() {
|
|
|
|
if (!this.panelResizing) {
|
2019-06-27 17:42:02 +00:00
|
|
|
this.refreshEditorDimensions();
|
2018-03-28 14:06:50 +00:00
|
|
|
}
|
|
|
|
},
|
2018-09-27 21:57:30 +00:00
|
|
|
rightPaneIsOpen() {
|
2019-06-27 17:42:02 +00:00
|
|
|
this.refreshEditorDimensions();
|
|
|
|
},
|
|
|
|
showEditor(val) {
|
|
|
|
if (val) {
|
|
|
|
// We need to wait for the editor to actually be rendered.
|
|
|
|
this.$nextTick(() => this.refreshEditorDimensions());
|
|
|
|
}
|
2018-06-12 13:12:39 +00:00
|
|
|
},
|
2020-05-15 00:08:06 +00:00
|
|
|
showContentViewer(val) {
|
|
|
|
if (!val) return;
|
|
|
|
|
|
|
|
if (this.fileType === 'markdown') {
|
|
|
|
const { content, images } = extractMarkdownImagesFromEntries(this.file, this.entries);
|
|
|
|
this.content = content;
|
|
|
|
this.images = images;
|
|
|
|
} else {
|
|
|
|
this.content = this.file.content || this.file.raw;
|
|
|
|
this.images = {};
|
|
|
|
}
|
|
|
|
},
|
2018-03-20 14:12:48 +00:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.editor.dispose();
|
|
|
|
},
|
|
|
|
mounted() {
|
2018-06-07 21:34:50 +00:00
|
|
|
if (!this.editor) {
|
2020-07-21 09:09:34 +00:00
|
|
|
this.editor = Editor.create(this.$store, this.editorOptions);
|
2018-03-20 14:12:48 +00:00
|
|
|
}
|
2018-06-08 04:56:39 +00:00
|
|
|
this.initEditor();
|
2020-06-01 12:08:28 +00:00
|
|
|
|
|
|
|
// listen in capture phase to be able to override Monaco's behaviour.
|
|
|
|
window.addEventListener('paste', this.onPaste, true);
|
|
|
|
},
|
|
|
|
destroyed() {
|
|
|
|
window.removeEventListener('paste', this.onPaste, true);
|
2018-03-20 14:12:48 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions([
|
2018-07-26 14:56:56 +00:00
|
|
|
'getFileData',
|
2018-03-20 14:12:48 +00:00
|
|
|
'getRawFileData',
|
|
|
|
'changeFileContent',
|
2018-05-18 13:00:31 +00:00
|
|
|
'removePendingTab',
|
2019-06-04 22:31:22 +00:00
|
|
|
'triggerFilesChange',
|
2020-06-01 12:08:28 +00:00
|
|
|
'addTempImage',
|
2018-03-20 14:12:48 +00:00
|
|
|
]),
|
2020-11-02 18:09:03 +00:00
|
|
|
...mapActions('editor', ['updateFileEditor']),
|
2018-06-08 04:56:39 +00:00
|
|
|
initEditor() {
|
2020-11-18 18:09:08 +00:00
|
|
|
performanceMarkAndMeasure({ mark: WEBIDE_MARK_REPO_EDITOR_START });
|
2019-07-03 12:14:44 +00:00
|
|
|
if (this.shouldHideEditor && (this.file.content || this.file.raw)) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-20 14:12:48 +00:00
|
|
|
|
|
|
|
this.editor.clearEditor();
|
|
|
|
|
2020-09-16 12:10:15 +00:00
|
|
|
this.registerSchemaForFile();
|
|
|
|
|
2020-06-10 18:09:15 +00:00
|
|
|
Promise.all([this.fetchFileData(), this.fetchEditorconfigRules()])
|
2018-03-20 14:12:48 +00:00
|
|
|
.then(() => {
|
|
|
|
this.createEditorInstance();
|
|
|
|
})
|
2020-12-24 00:10:25 +00:00
|
|
|
.catch((err) => {
|
2019-06-24 05:30:35 +00:00
|
|
|
flash(
|
|
|
|
__('Error setting up editor. Please try again.'),
|
|
|
|
'alert',
|
|
|
|
document,
|
|
|
|
null,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
);
|
2018-03-20 14:12:48 +00:00
|
|
|
throw err;
|
|
|
|
});
|
|
|
|
},
|
2019-10-04 15:06:38 +00:00
|
|
|
fetchFileData() {
|
|
|
|
if (this.file.tempFile) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.getFileData({
|
|
|
|
path: this.file.path,
|
|
|
|
makeFileActive: false,
|
2020-10-14 18:08:47 +00:00
|
|
|
toggleLoading: false,
|
2019-10-04 15:06:38 +00:00
|
|
|
}).then(() =>
|
|
|
|
this.getRawFileData({
|
|
|
|
path: this.file.path,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
},
|
2018-03-20 14:12:48 +00:00
|
|
|
createEditorInstance() {
|
2020-12-18 00:10:04 +00:00
|
|
|
if (this.isBinaryFile) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-20 14:12:48 +00:00
|
|
|
this.editor.dispose();
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
2018-05-04 12:03:35 +00:00
|
|
|
if (this.viewer === viewerTypes.edit) {
|
2018-03-20 14:12:48 +00:00
|
|
|
this.editor.createInstance(this.$refs.editor);
|
|
|
|
} else {
|
2020-06-11 09:08:16 +00:00
|
|
|
this.editor.createDiffInstance(this.$refs.editor);
|
2018-03-20 14:12:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.setupEditor();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
setupEditor() {
|
2020-06-19 15:08:39 +00:00
|
|
|
if (!this.file || !this.editor.instance || this.file.loading) return;
|
2018-03-20 14:12:48 +00:00
|
|
|
|
2018-04-06 21:48:52 +00:00
|
|
|
const head = this.getStagedFile(this.file.path);
|
|
|
|
|
|
|
|
this.model = this.editor.createModel(
|
|
|
|
this.file,
|
|
|
|
this.file.staged && this.file.key.indexOf('unstaged-') === 0 ? head : null,
|
|
|
|
);
|
2018-03-20 14:12:48 +00:00
|
|
|
|
2018-05-10 15:44:57 +00:00
|
|
|
if (this.viewer === viewerTypes.mr && this.file.mrChange) {
|
2018-03-23 10:45:43 +00:00
|
|
|
this.editor.attachMergeRequestModel(this.model);
|
|
|
|
} else {
|
|
|
|
this.editor.attachModel(this.model);
|
|
|
|
}
|
2018-03-20 14:12:48 +00:00
|
|
|
|
2020-06-10 18:09:15 +00:00
|
|
|
this.model.updateOptions(this.rules);
|
|
|
|
|
2020-12-24 00:10:25 +00:00
|
|
|
this.model.onChange((model) => {
|
2018-03-20 14:12:48 +00:00
|
|
|
const { file } = model;
|
2020-05-22 09:08:09 +00:00
|
|
|
if (!file.active) return;
|
2018-03-20 14:12:48 +00:00
|
|
|
|
2020-05-22 09:08:09 +00:00
|
|
|
const monacoModel = model.getModel();
|
|
|
|
const content = monacoModel.getValue();
|
2020-05-25 12:08:23 +00:00
|
|
|
this.changeFileContent({ path: file.path, content });
|
2018-03-20 14:12:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Handle Cursor Position
|
|
|
|
this.editor.onPositionChange((instance, e) => {
|
2020-11-02 18:09:03 +00:00
|
|
|
this.updateEditor({
|
2018-03-20 14:12:48 +00:00
|
|
|
editorRow: e.position.lineNumber,
|
|
|
|
editorColumn: e.position.column,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.editor.setPosition({
|
2020-11-02 18:09:03 +00:00
|
|
|
lineNumber: this.fileEditor.editorRow,
|
|
|
|
column: this.fileEditor.editorColumn,
|
2018-03-20 14:12:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Handle File Language
|
2020-11-02 18:09:03 +00:00
|
|
|
this.updateEditor({
|
2018-03-20 14:12:48 +00:00
|
|
|
fileLanguage: this.model.language,
|
|
|
|
});
|
2020-06-10 18:09:15 +00:00
|
|
|
|
|
|
|
this.$emit('editorSetup');
|
2020-10-05 15:08:56 +00:00
|
|
|
if (performance.getEntriesByName(WEBIDE_MARK_FILE_CLICKED).length) {
|
|
|
|
eventHub.$emit(WEBIDE_MEASURE_FILE_AFTER_INTERACTION);
|
|
|
|
} else {
|
2020-11-18 18:09:08 +00:00
|
|
|
performanceMarkAndMeasure({
|
|
|
|
mark: WEBIDE_MARK_REPO_EDITOR_FINISH,
|
|
|
|
measures: [
|
|
|
|
{
|
|
|
|
name: WEBIDE_MEASURE_REPO_EDITOR,
|
|
|
|
start: WEBIDE_MARK_REPO_EDITOR_START,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
2020-10-05 15:08:56 +00:00
|
|
|
}
|
2018-03-20 14:12:48 +00:00
|
|
|
},
|
2019-06-27 17:42:02 +00:00
|
|
|
refreshEditorDimensions() {
|
|
|
|
if (this.showEditor) {
|
|
|
|
this.editor.updateDimensions();
|
|
|
|
}
|
|
|
|
},
|
2020-06-10 18:09:15 +00:00
|
|
|
fetchEditorconfigRules() {
|
2020-12-24 00:10:25 +00:00
|
|
|
return getRulesWithTraversal(this.file.path, (path) => {
|
2020-06-10 18:09:15 +00:00
|
|
|
const entry = this.entries[path];
|
|
|
|
if (!entry) return Promise.resolve(null);
|
|
|
|
|
|
|
|
const content = entry.content || entry.raw;
|
|
|
|
if (content) return Promise.resolve(content);
|
|
|
|
|
|
|
|
return this.getFileData({ path: entry.path, makeFileActive: false }).then(() =>
|
|
|
|
this.getRawFileData({ path: entry.path }),
|
|
|
|
);
|
2020-12-24 00:10:25 +00:00
|
|
|
}).then((rules) => {
|
2020-06-10 18:09:15 +00:00
|
|
|
this.rules = mapRulesToMonaco(rules);
|
|
|
|
});
|
|
|
|
},
|
2020-06-01 12:08:28 +00:00
|
|
|
onPaste(event) {
|
|
|
|
const editor = this.editor.instance;
|
|
|
|
const reImage = /^image\/(png|jpg|jpeg|gif)$/;
|
|
|
|
const file = event.clipboardData.files[0];
|
|
|
|
|
|
|
|
if (editor.hasTextFocus() && this.fileType === 'markdown' && reImage.test(file?.type)) {
|
|
|
|
// don't let the event be passed on to Monaco.
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
|
2020-12-24 00:10:25 +00:00
|
|
|
return readFileAsDataURL(file).then((content) => {
|
2020-06-01 12:08:28 +00:00
|
|
|
const parentPath = getPathParent(this.file.path);
|
|
|
|
const path = `${parentPath ? `${parentPath}/` : ''}${file.name}`;
|
|
|
|
|
|
|
|
return this.addTempImage({ name: path, rawPath: content }).then(({ name: fileName }) => {
|
|
|
|
this.editor.replaceSelectedText(`![${fileName}](./${fileName})`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// do nothing if no image is found in the clipboard
|
|
|
|
return Promise.resolve();
|
|
|
|
},
|
2020-09-16 12:10:15 +00:00
|
|
|
registerSchemaForFile() {
|
|
|
|
const schema = this.getJsonSchemaForPath(this.file.path);
|
|
|
|
registerSchema(schema);
|
|
|
|
},
|
2020-11-02 18:09:03 +00:00
|
|
|
updateEditor(data) {
|
|
|
|
// Looks like our model wrapper `.dispose` causes the monaco editor to emit some position changes after
|
|
|
|
// when disposing. We want to ignore these by only capturing editor changes that happen to the currently active
|
|
|
|
// file.
|
|
|
|
if (!this.file.active) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateFileEditor({ path: this.file.path, data });
|
|
|
|
},
|
2018-03-20 14:12:48 +00:00
|
|
|
},
|
2018-05-04 12:03:35 +00:00
|
|
|
viewerTypes,
|
2019-07-23 22:13:36 +00:00
|
|
|
FILE_VIEW_MODE_EDITOR,
|
|
|
|
FILE_VIEW_MODE_PREVIEW,
|
2018-03-20 14:12:48 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2018-11-16 20:07:38 +00:00
|
|
|
<div id="ide" class="blob-viewer-container blob-editor-container">
|
2020-04-03 21:09:56 +00:00
|
|
|
<div v-if="!shouldHideEditor && isEditModeActive" class="ide-mode-tabs clearfix">
|
|
|
|
<ul class="nav-links float-left border-bottom-0">
|
2018-04-05 11:12:40 +00:00
|
|
|
<li :class="editTabCSS">
|
|
|
|
<a
|
|
|
|
href="javascript:void(0);"
|
|
|
|
role="button"
|
2020-11-02 18:09:03 +00:00
|
|
|
@click.prevent="updateEditor({ viewMode: $options.FILE_VIEW_MODE_EDITOR })"
|
2018-11-16 20:07:38 +00:00
|
|
|
>
|
2020-06-10 12:08:58 +00:00
|
|
|
{{ __('Edit') }}
|
2018-04-05 11:12:40 +00:00
|
|
|
</a>
|
|
|
|
</li>
|
2020-06-10 12:08:58 +00:00
|
|
|
<li v-if="previewMode" :class="previewTabCSS">
|
2018-04-05 11:12:40 +00:00
|
|
|
<a
|
|
|
|
href="javascript:void(0);"
|
|
|
|
role="button"
|
2020-11-02 18:09:03 +00:00
|
|
|
@click.prevent="updateEditor({ viewMode: $options.FILE_VIEW_MODE_PREVIEW })"
|
2020-06-10 12:08:58 +00:00
|
|
|
>{{ previewMode.previewTitle }}</a
|
2018-11-16 20:07:38 +00:00
|
|
|
>
|
2018-04-05 11:12:40 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
2018-03-20 14:12:48 +00:00
|
|
|
</div>
|
2018-11-16 20:07:38 +00:00
|
|
|
<file-templates-bar v-if="showFileTemplatesBar(file.name)" />
|
2018-03-20 14:12:48 +00:00
|
|
|
<div
|
2019-06-27 17:42:02 +00:00
|
|
|
v-show="showEditor"
|
2018-03-20 14:12:48 +00:00
|
|
|
ref="editor"
|
2018-05-01 09:46:28 +00:00
|
|
|
:class="{
|
|
|
|
'is-readonly': isCommitModeActive,
|
2018-07-26 14:56:56 +00:00
|
|
|
'is-deleted': file.deleted,
|
2018-11-16 20:07:38 +00:00
|
|
|
'is-added': file.tempFile,
|
2018-05-01 09:46:28 +00:00
|
|
|
}"
|
2018-06-11 09:49:47 +00:00
|
|
|
class="multi-file-editor-holder"
|
2020-03-16 12:09:12 +00:00
|
|
|
data-qa-selector="editor_container"
|
2019-06-04 22:31:22 +00:00
|
|
|
@focusout="triggerFilesChange"
|
2018-11-16 20:07:38 +00:00
|
|
|
></div>
|
2018-04-05 11:12:40 +00:00
|
|
|
<content-viewer
|
2018-06-13 09:35:52 +00:00
|
|
|
v-if="showContentViewer"
|
2020-05-15 00:08:06 +00:00
|
|
|
:content="content"
|
|
|
|
:images="images"
|
2018-04-10 15:48:02 +00:00
|
|
|
:path="file.rawPath || file.path"
|
2019-11-14 03:06:25 +00:00
|
|
|
:file-path="file.path"
|
2018-04-06 17:49:06 +00:00
|
|
|
:file-size="file.size"
|
2020-09-14 12:09:34 +00:00
|
|
|
:project-path="currentProjectId"
|
2020-05-13 21:08:55 +00:00
|
|
|
:commit-sha="currentBranchCommit"
|
2019-04-17 20:41:07 +00:00
|
|
|
:type="fileType"
|
2018-11-16 20:07:38 +00:00
|
|
|
/>
|
2018-06-13 09:35:52 +00:00
|
|
|
<diff-viewer
|
|
|
|
v-if="showDiffViewer"
|
|
|
|
:diff-mode="file.mrChange.diffMode"
|
|
|
|
:new-path="file.mrChange.new_path"
|
|
|
|
:new-sha="currentMergeRequest.sha"
|
|
|
|
:old-path="file.mrChange.old_path"
|
|
|
|
:old-sha="currentMergeRequest.baseCommitSha"
|
2020-09-14 12:09:34 +00:00
|
|
|
:project-path="currentProjectId"
|
2018-11-16 20:07:38 +00:00
|
|
|
/>
|
2018-03-20 14:12:48 +00:00
|
|
|
</div>
|
|
|
|
</template>
|