2727 :active =" active || isEmbedded"
2828 :autofocus =" autofocus"
2929 :share-token =" shareToken"
30+ :class =" { 'text-editor--embedding': isEmbedded }"
3031 :mime =" mime"
3132 :show-outline-outside =" showOutlineOutside" />
3233 <div v-else
3334 id =" editor-container"
3435 data-text-el =" editor-container"
3536 class =" text-editor source-viewer" >
3637 <Component :is =" readerComponent" :content =" content" />
38+ <NcButton v-if =" isEmbedded" class =" toggle-interactive" @click =" toggleEdit" >
39+ {{ t('text', 'Edit') }}
40+ <template #icon >
41+ <PencilIcon />
42+ </template >
43+ </NcButton >
3744 </div >
3845</template >
3946
4047<script >
48+ import Vue from ' vue'
4149import axios from ' @nextcloud/axios'
50+ import PencilIcon from ' vue-material-design-icons/Pencil.vue'
51+ import NcButton from ' @nextcloud/vue/dist/Components/NcButton.js'
4252import PlainTextReader from ' ./PlainTextReader.vue'
4353import RichTextReader from ' ./RichTextReader.vue'
54+ import { translate , translatePlural } from ' @nextcloud/l10n'
4455
4556import { getSharingToken } from ' ../helpers/token.js'
4657import getEditorInstance from ' ./Editor.singleton.js'
4758
59+ Vue .prototype .t = translate
60+ Vue .prototype .n = translatePlural
61+
4862export default {
4963 name: ' ViewerComponent' ,
5064 components: {
51- RichTextReader,
52- PlainTextReader,
65+ NcButton: Vue .extend (NcButton),
66+ PencilIcon: Vue .extend (PencilIcon),
67+ RichTextReader: Vue .extend (RichTextReader),
68+ PlainTextReader: Vue .extend (PlainTextReader),
5369 Editor: getEditorInstance,
5470 },
5571 provide () {
@@ -102,12 +118,13 @@ export default {
102118 data () {
103119 return {
104120 content: ' ' ,
121+ hasToggledInteractiveEmbedding: false ,
105122 }
106123 },
107124 computed: {
108125 /** @return {boolean} */
109126 useSourceView () {
110- return this .source && (this .fileVersion || ! this .fileid )
127+ return this .source && (this .fileVersion || ! this .fileid || this . isEmbedded ) && ! this . hasToggledInteractiveEmbedding
111128 },
112129
113130 /** @return {boolean} */
@@ -127,6 +144,7 @@ export default {
127144 },
128145
129146 methods: {
147+ t: translate,
130148 async loadFileContent () {
131149 if (this .useSourceView ) {
132150 const response = await axios .get (this .source )
@@ -135,6 +153,9 @@ export default {
135153 }
136154 this .$emit (' update:loaded' , true )
137155 },
156+ toggleEdit () {
157+ this .hasToggledInteractiveEmbedding = true
158+ },
138159 },
139160}
140161 </script >
@@ -151,10 +172,26 @@ export default {
151172 background-color : var (--color-main-background );
152173
153174 & .source-viewer {
175+ display : block ;
176+
154177 .text-editor__content-wrapper {
155178 margin-top : var (--header-height );
156179 }
180+
181+ .toggle-interactive {
182+ position : sticky ;
183+ bottom : 0 ;
184+ right : 0 ;
185+ z-index : 1 ;
186+ margin-left : auto ;
187+ margin-right : 0 ;
188+ }
189+ }
190+
191+ & .text-editor--embedding {
192+ min-height : 400px ;
157193 }
194+
158195}
159196 </style >
160197<style lang="scss">
0 commit comments