refactoring

This commit is contained in:
Philipp Kühn
2021-03-15 09:00:44 +01:00
parent 385ee1d1f4
commit e765c8e981
10 changed files with 48 additions and 63 deletions

View File

@@ -1,21 +1,22 @@
import Vue from 'vue'
import { AnyObject } from '@tiptap/core'
import { VueConstructor } from 'vue/types/umd'
export class VueRenderer {
vm!: Vue
ref!: Vue
constructor(component: Vue | VueConstructor, props: any) {
const Component = Vue.extend(component)
this.vm = new Component(props).$mount()
this.ref = new Component(props).$mount()
}
get element() {
return this.vm.$el
return this.ref.$el
}
updateProps(props: { [key: string]: any } = {}) {
if (!this.vm.$props) {
updateProps(props: AnyObject = {}) {
if (!this.ref.$props) {
return
}
@@ -26,13 +27,13 @@ export class VueRenderer {
Object
.entries(props)
.forEach(([key, value]) => {
this.vm.$props[key] = value
this.ref.$props[key] = value
})
Vue.config.silent = originalSilent
}
destroy() {
this.vm.$destroy()
this.ref.$destroy()
}
}