Skip to content

Commit

Permalink
fix: Apply viewer wrapper as we do it in text
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Knorr <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Dec 2, 2024
1 parent e035bbc commit e12a133
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/view/Office.vue
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export default {
FilesAppIntegration.updateFileInfo(undefined, Date.now())
}
disableScrollLock()
this.$parent.close()
this.$emit('close')
},
reload() {
this.loading = LOADING_STATE.LOADING
Expand Down
64 changes: 64 additions & 0 deletions src/view/Viewer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!--
- SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<!--
- This component is a wrapper around the Office component to be used in the viewer
- We currently need this to isolate the vue instances
-->
<template>
<Office :filename="filename"
:fileid="fileid"
:has-preview="hasPreview"
:source="source"
:mime="mime"
:permissions="permissions"
:is-embedded="isEmbedded"
@close="$parent.close()"
@update:loaded="$emit('update:loaded', $event)" />
</template>
<script>
import Vue from 'vue'
import Office from './Office.vue'

Vue.prototype.t = t
Vue.prototype.n = n

export default {
name: 'Viewer',
components: {
Office: Vue.extend(Office),
},
props: {
filename: {
type: String,
default: null,
},
fileid: {
type: Number,
default: null,
},
hasPreview: {
type: Boolean,
required: false,
default: () => false,
},
source: {
type: String,
default: null,
},
mime: {
type: String,
default: null,
},
permissions: {
type: String,
default: '',
},
isEmbedded: {
type: Boolean,
default: false,
},
},
}
</script>
5 changes: 2 additions & 3 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
import './init-shared.js'
import '../css/filetypes.scss'

import Vue from 'vue'
import Office from './view/Office.vue'
import { getCapabilities } from '@nextcloud/capabilities'
import Viewer from './view/Viewer.vue'

const supportedMimes = getCapabilities().richdocuments.mimetypes

Expand All @@ -35,7 +34,7 @@ if (OCA.Viewer) {
id: 'richdocuments',
group: null,
mimes: supportedMimes,
component: Vue.extend(Office),
component: Viewer,
theme: 'default',
canCompare: true,
})
Expand Down

0 comments on commit e12a133

Please sign in to comment.