File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121 -->
2222
2323<template >
24- <Editor :file-id =" fileid"
24+ <Editor v-if =" permissions.includes('W')"
25+ :file-id =" fileid"
2526 :relative-path =" filename"
2627 :active =" active"
2728 :autofocus =" autofocus"
2829 :share-token =" shareToken"
2930 :mime =" mime"
3031 :show-outline-outside =" showOutlineOutside" />
32+ <Component :is =" readerComponent" v-else :content =" content" />
3133</template >
3234
3335<script >
36+ import axios from ' @nextcloud/axios'
37+ import PlainTextReader from ' ./PlainTextReader.vue'
38+ import RichTextReader from ' ./RichTextReader.vue'
39+
3440import { getSharingToken } from ' ../helpers/token.js'
3541
3642export default {
3743 name: ' ViewerComponent' ,
3844 components: {
45+ RichTextReader,
46+ PlainTextReader,
3947 Editor : () => import (/* webpackChunkName: "editor" */ ' ./Editor.vue' ),
4048 },
4149 props: {
@@ -67,6 +75,36 @@ export default {
6775 type: Boolean ,
6876 default: false ,
6977 },
78+ permissions: {
79+ type: String ,
80+ default: ' ' ,
81+ },
82+ source: {
83+ type: String ,
84+ default: undefined ,
85+ },
86+ },
87+ data () {
88+ return {
89+ content: ' ' ,
90+ }
91+ },
92+ computed: {
93+ /** @return {boolean} */
94+ readerComponent () {
95+ return this .mime === ' text/markdown' ? RichTextReader : PlainTextReader
96+ },
97+ },
98+ beforeMount () {
99+ // FIXME Dirty fix to avoid recreating the component on stable16
100+ if (typeof this .$parent .$parent !== ' undefined' && this .$parent .$parent .onResize ) {
101+ window .removeEventListener (' resize' , this .$parent .$parent .onResize )
102+ }
103+ },
104+ async mounted () {
105+ const data = await axios .get (this .source )
106+ this .content = data
107+ this .$emit (' update:loaded' , true )
70108 },
71109}
72110 </script >
You can’t perform that action at this time.
0 commit comments