@@ -43,6 +43,7 @@ import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
4343import PlainTextReader from ' ./PlainTextReader.vue'
4444import MarkdownContentEditor from ' ./Editor/MarkdownContentEditor.vue'
4545import { translate , translatePlural } from ' @nextcloud/l10n'
46+ import { getClient , getRootPath } from ' @nextcloud/files/dav'
4647
4748import getEditorInstance from ' ./Editor.singleton.js'
4849
@@ -116,16 +117,27 @@ export default {
116117 useSourceView () {
117118 return (
118119 this .source
119- && (this .fileVersion || ! this .fileid || this .isEmbedded )
120+ && (this .fileVersion
121+ || ! this .fileid
122+ || this .isEmbedded
123+ || this .isEncrypted )
120124 && ! this .hasToggledInteractiveEmbedding
121125 )
122126 },
123127
128+ isEncrypted () {
129+ return this .$attrs .e2EeIsEncrypted || false
130+ },
131+
132+ isMarkdown () {
133+ return (
134+ this .mime === ' text/markdown' || this .mime === ' text/x-web-markdown'
135+ )
136+ },
137+
124138 /** @return {boolean} */
125139 readerComponent () {
126- return this .mime === ' text/markdown'
127- ? MarkdownContentEditor
128- : PlainTextReader
140+ return this .isMarkdown ? MarkdownContentEditor : PlainTextReader
129141 },
130142 },
131143
@@ -143,15 +155,37 @@ export default {
143155 t: translate,
144156 async loadFileContent () {
145157 if (this .useSourceView ) {
146- const response = await axios .get (this .source )
147- this .content = response .data
148- this .contentLoaded = true
158+ if (this .isEncrypted ) {
159+ this .content = await this .fetchDecryptedContent ()
160+ this .contentLoaded = true
161+ } else {
162+ const response = await axios .get (this .source )
163+ this .content = response .data
164+ this .contentLoaded = true
165+ }
149166 }
150167 this .$emit (' update:loaded' , true )
151168 },
152169 toggleEdit () {
153170 this .hasToggledInteractiveEmbedding = true
154171 },
172+ async fetchDecryptedContent () {
173+ const client = getClient ()
174+ const response = await client .getFileContents (
175+ ` ${ getRootPath ()}${ this .filename } ` ,
176+ { details: true },
177+ )
178+ const blob = new Blob ([response .data ], {
179+ type: response .headers [' content-type' ],
180+ })
181+ const reader = new FileReader ()
182+ reader .readAsText (blob)
183+ return new Promise ((resolve ) => {
184+ reader .onload = () => {
185+ resolve (reader .result )
186+ }
187+ })
188+ },
155189 },
156190}
157191 </script >
0 commit comments