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

blob_edit_content.vue « components « blob « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 83303a373f35c94df5b349a1b9e31b3ad87e6ebb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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>