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

rich_viewer.vue « blob_viewers « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 11ce6afbb1dd1de69c3d7f1026946e60a4e7c22a (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
<script>
import SafeHtml from '~/vue_shared/directives/safe_html';
import { handleBlobRichViewer } from '~/blob/viewer';
import MarkdownFieldView from '~/vue_shared/components/markdown/field_view.vue';
import { handleLocationHash } from '~/lib/utils/common_utils';
import ViewerMixin from './mixins';

export default {
  components: {
    MarkdownFieldView,
  },
  directives: {
    SafeHtml,
  },
  mixins: [ViewerMixin],
  data() {
    return {
      isLoading: true,
    };
  },
  mounted() {
    window.requestIdleCallback(async () => {
      /**
       * Rendering Markdown usually takes long due to the amount of HTML being parsed.
       * This ensures that content is loaded only when the browser goes into idle.
       * More details here: https://gitlab.com/gitlab-org/gitlab/-/issues/331448
       * */
      this.isLoading = false;
      await this.$nextTick();
      handleBlobRichViewer(this.$refs.content, this.type);
      handleLocationHash();
      this.$emit('richContentLoaded');
    });
  },
  safeHtmlConfig: {
    ADD_TAGS: ['gl-emoji', 'copy-code'],
  },
};
</script>
<template>
  <markdown-field-view
    v-if="!isLoading"
    ref="content"
    v-safe-html:[$options.safeHtmlConfig]="richViewer || content"
  />
</template>