Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use our own vue instance rendering anything but the viewer component #5547

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/ViewerVue.js

This file was deleted.

6 changes: 5 additions & 1 deletion src/components/Editor.singleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ export default async function getEditorInstance() {
window._nc_text_editor_importing = true
}
const Editor = await import(/* webpackChunkName: "editor" */'./Editor.vue')
window._nc_text_editor_instance = Editor.default
const { default: Vue } = await import('vue')
Vue.prototype.t = window.t
Vue.prototype.OCA = window.OCA
const EditorConstructor = Vue.extend(Editor.default)
window._nc_text_editor_instance = EditorConstructor
}
return window._nc_text_editor_instance
}
2 changes: 1 addition & 1 deletion src/components/Editor/MarkdownContentEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default {
onCreate: ({ editor }) => {
this.$emit('ready')
this.$parent.$emit('ready')
}
},
})
},

Expand Down
10 changes: 0 additions & 10 deletions src/components/ViewerComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ import RichTextReader from './RichTextReader.vue'
import { getSharingToken } from '../helpers/token.js'
import getEditorInstance from './Editor.singleton.js'

import { setViewerVue } from '../ViewerVue.js'

export default {
name: 'ViewerComponent',
components: {
Expand Down Expand Up @@ -124,14 +122,6 @@ export default {
},
},

beforeCreate() {
// This component is rendered in the Viewer app
// Get Vue constructor from the Viewer app
// To reuse later as Vue constructor and not mix Text's Vue constructor and Viewer's Vue constructor in a single Virtual DOM
// Which is not fully supported by Vue
setViewerVue(this.$options._base)
},

mounted() {
this.loadFileContent()
},
Expand Down
8 changes: 1 addition & 7 deletions src/plugins/LinkBubblePluginView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import tippy from 'tippy.js'
import { domHref } from '../helpers/links.js'
import LinkBubbleView from '../components/Link/LinkBubbleView.vue'

import { getViewerVue } from '../ViewerVue.js'

class LinkBubblePluginView {

#component = null
Expand All @@ -14,11 +12,7 @@ class LinkBubblePluginView {
this.view = view
this.plugin = plugin

// When editor is used in Viewer component, it should render comopnent using Viewer's Vue constructor,
// Otherwise there are VNodes with different Vue constructors in a single Virtual DOM which is not fully supported by Vue
const ViewerVue = getViewerVue()
const LinkBubbleViewConstructor = ViewerVue ? ViewerVue.extend(LinkBubbleView) : LinkBubbleView
this.#component = new VueRenderer(LinkBubbleViewConstructor, {
this.#component = new VueRenderer(LinkBubbleView, {
parent: this.options.parent,
propsData: {
editor: this.options.editor,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/linkHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function activeLinkFromSelection({ selection, doc }) {
/**
* Active link object for the given node and nodeStart
* @param {object} node - node to check
* @param {Number} nodeStart - offset in the document
* @param {number} nodeStart - offset in the document
*/
function activeLink(node, nodeStart) {
const mark = linkMark(node)
Expand Down
Loading