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/blob/components/blob_edit_content.vue')
-rw-r--r--app/assets/javascripts/blob/components/blob_edit_content.vue49
1 files changed, 49 insertions, 0 deletions
diff --git a/app/assets/javascripts/blob/components/blob_edit_content.vue b/app/assets/javascripts/blob/components/blob_edit_content.vue
new file mode 100644
index 00000000000..83303a373f3
--- /dev/null
+++ b/app/assets/javascripts/blob/components/blob_edit_content.vue
@@ -0,0 +1,49 @@
+<script>
+import { initEditorLite } from '~/blob/utils';
+
+export default {
+ props: {
+ value: {
+ type: String,
+ required: true,
+ },
+ fileName: {
+ type: String,
+ required: false,
+ default: '',
+ },
+ },
+ data() {
+ return {
+ content: this.value,
+ editor: null,
+ };
+ },
+ watch: {
+ fileName(newVal) {
+ this.editor.updateModelLanguage(newVal);
+ },
+ },
+ mounted() {
+ this.editor = initEditorLite({
+ el: this.$refs.editor,
+ blobPath: this.fileName,
+ blobContent: this.content,
+ });
+ },
+ methods: {
+ triggerFileChange() {
+ const val = this.editor.getValue();
+ this.content = val;
+ this.$emit('input', val);
+ },
+ },
+};
+</script>
+<template>
+ <div class="file-content code">
+ <pre id="editor" ref="editor" data-editor-loading @focusout="triggerFileChange">{{
+ content
+ }}</pre>
+ </div>
+</template>