2017-08-03 13:30:25 -04:00
|
|
|
<script>
|
2017-09-22 09:42:05 -04:00
|
|
|
/* global LineHighlighter */
|
2017-10-26 06:14:31 -04:00
|
|
|
import { mapGetters } from 'vuex';
|
2017-08-03 13:30:25 -04:00
|
|
|
|
|
|
|
export default {
|
2017-08-03 16:31:49 -04:00
|
|
|
computed: {
|
2017-10-26 06:14:31 -04:00
|
|
|
...mapGetters([
|
|
|
|
'activeFile',
|
|
|
|
]),
|
2017-10-30 10:36:24 -04:00
|
|
|
renderErrorTooLarge() {
|
2017-10-30 12:25:32 -04:00
|
|
|
return this.activeFile.renderError === 'too_large';
|
2017-10-30 10:36:24 -04:00
|
|
|
},
|
2017-08-03 16:31:49 -04:00
|
|
|
},
|
2017-08-10 14:05:04 -04:00
|
|
|
methods: {
|
|
|
|
highlightFile() {
|
|
|
|
$(this.$el).find('.file-content').syntaxHighlight();
|
|
|
|
},
|
|
|
|
},
|
2017-09-22 09:42:05 -04:00
|
|
|
mounted() {
|
|
|
|
this.highlightFile();
|
|
|
|
this.lineHighlighter = new LineHighlighter({
|
|
|
|
fileHolderSelector: '.blob-viewer-container',
|
|
|
|
scrollFileHolder: true,
|
|
|
|
});
|
|
|
|
},
|
2017-10-26 06:14:31 -04:00
|
|
|
updated() {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.highlightFile();
|
|
|
|
});
|
2017-08-04 08:13:32 -04:00
|
|
|
},
|
|
|
|
};
|
2017-08-03 13:30:25 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2017-11-23 12:16:01 -05:00
|
|
|
<div>
|
2017-08-10 14:09:01 -04:00
|
|
|
<div
|
2017-10-26 11:54:44 -04:00
|
|
|
v-if="!activeFile.renderError"
|
2017-11-23 12:16:01 -05:00
|
|
|
v-html="activeFile.html"
|
|
|
|
class="multi-file-preview-holder"
|
|
|
|
>
|
2017-08-10 14:09:01 -04:00
|
|
|
</div>
|
2017-10-31 06:47:10 -04:00
|
|
|
<div
|
|
|
|
v-else-if="activeFile.tempFile"
|
|
|
|
class="vertical-center render-error">
|
|
|
|
<p class="text-center">
|
|
|
|
The source could not be displayed for this temporary file.
|
|
|
|
</p>
|
|
|
|
</div>
|
2017-08-10 14:09:01 -04:00
|
|
|
<div
|
2017-10-30 10:36:24 -04:00
|
|
|
v-else-if="renderErrorTooLarge"
|
2017-08-10 14:09:01 -04:00
|
|
|
class="vertical-center render-error">
|
|
|
|
<p class="text-center">
|
2017-10-26 11:54:44 -04:00
|
|
|
The source could not be displayed because it is too large. You can <a :href="activeFile.rawPath" download>download</a> it instead.
|
2017-08-10 14:09:01 -04:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
v-else
|
|
|
|
class="vertical-center render-error">
|
|
|
|
<p class="text-center">
|
2017-10-26 11:54:44 -04:00
|
|
|
The source could not be displayed because a rendering error occurred. You can <a :href="activeFile.rawPath" download>download</a> it instead.
|
2017-08-10 14:09:01 -04:00
|
|
|
</p>
|
2017-08-07 17:56:07 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-08-03 13:30:25 -04:00
|
|
|
</template>
|