Skip to content

Commit 50fd5f2

Browse files
authored
Merge pull request #8233 from nextcloud/backport/8153/stable33
[stable33] fix(viewer): mount text vue instance explicitely
2 parents 4282d05 + 639a7b3 commit 50fd5f2

File tree

6 files changed

+51
-45
lines changed

6 files changed

+51
-45
lines changed

src/apis/connect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export async function open(
5353
/**
5454
* Update the guest name
5555
* @param guestName the name to use for the local user
56-
* @param connection connection to close
56+
* @param connection connection to update the guest name for
5757
*/
5858
export async function update(
5959
guestName: string,

src/components/Editor.singleton.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/components/ViewerComponent.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@
2626

2727
<script>
2828
import { getSharingToken } from '@nextcloud/sharing/public'
29-
import getEditorInstance from './Editor.singleton.js'
29+
import { defineComponent } from 'vue'
30+
import Editor from './Editor.vue'
3031
import SourceView from './SourceView.vue'
3132
32-
export default {
33+
export default defineComponent({
3334
name: 'ViewerComponent',
3435
components: {
3536
SourceView,
36-
Editor: getEditorInstance,
37+
Editor,
3738
},
39+
inheritAttrs: false,
3840
provide() {
3941
return {
4042
isEmbedded: this.isEmbedded,
@@ -65,10 +67,6 @@ export default {
6567
type: String,
6668
default: null,
6769
},
68-
permissions: {
69-
type: String,
70-
default: '',
71-
},
7270
source: {
7371
type: String,
7472
default: undefined,
@@ -112,7 +110,7 @@ export default {
112110
},
113111
t,
114112
},
115-
}
113+
})
116114
</script>
117115
<style lang="scss" scoped>
118116
.text-editor:not(.viewer__file--hidden) {

src/viewer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import { openMimetypesMarkdown, openMimetypesPlainText } from './helpers/mime.js
1212
* Wrapper for async registration of ViewerComponent.
1313
* Note: it should be named function - the name is used for component registration.
1414
*
15-
* @return {Promise<import('./components/ViewerComponent.vue')>} ViewerComponent
15+
* @return {Promise<import('./views/ViewerView.js')>} ViewerComponent
1616
*/
1717
function AsyncTextViewerComponent() {
18-
return import('./components/ViewerComponent.vue')
18+
return import('./views/ViewerView.js')
1919
}
2020

2121
if (typeof OCA.Viewer === 'undefined') {

src/views/RichWorkspace.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { t } from '@nextcloud/l10n'
3737
import { generateOcsUrl } from '@nextcloud/router'
3838
import { getSharingToken, isPublicShare } from '@nextcloud/sharing/public'
3939
40-
import getEditorInstance from '../components/Editor.singleton.js'
40+
import Editor from '../components/Editor.vue'
4141
import RichTextReader from '../components/RichTextReader.vue'
4242
4343
const IS_PUBLIC = isPublicShare()
@@ -58,7 +58,7 @@ export default {
5858
name: 'RichWorkspace',
5959
components: {
6060
RichTextReader,
61-
Editor: getEditorInstance,
61+
Editor,
6262
},
6363
props: {
6464
content: {

src/views/ViewerView.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import Vue, { defineComponent } from 'vue'
7+
import ViewerComponent from '../components/ViewerComponent.vue'
8+
9+
// The vue instance used inside text constructed with the import above.
10+
let innerVue
11+
12+
/**
13+
* This thin Component wrapper can be rendered inside the viewer.
14+
*
15+
* The viewers vue instance is used for this component as it simply exports
16+
* the options for the options api.
17+
*
18+
* When mounted this component constructs the vue instance
19+
* used inside text based on texts vue import.
20+
*/
21+
export default defineComponent({
22+
name: 'ViewerView',
23+
render: (h) => h('div'),
24+
props: ViewerComponent.props,
25+
mounted() {
26+
innerVue = new Vue({
27+
render: (h) => {
28+
return h(ViewerComponent, {
29+
attrs: this.$attrs,
30+
props: this.$props,
31+
on: this.$listeners,
32+
})
33+
},
34+
})
35+
innerVue.$mount(this.$el)
36+
},
37+
beforeDestroy() {
38+
innerVue.$destroy()
39+
},
40+
})

0 commit comments

Comments
 (0)