improve some types, fix #213
This commit is contained in:
@@ -59,7 +59,7 @@ export default () => {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
onKeyDown(props) {
|
onKeyDown(props) {
|
||||||
return reactRenderer.ref.onKeyDown(props)
|
return reactRenderer.ref?.onKeyDown(props)
|
||||||
},
|
},
|
||||||
onExit() {
|
onExit() {
|
||||||
popup[0].destroy()
|
popup[0].destroy()
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
onKeyDown(props) {
|
onKeyDown(props) {
|
||||||
return component.ref.onKeyDown(props)
|
return component.ref?.onKeyDown(props)
|
||||||
},
|
},
|
||||||
onExit() {
|
onExit() {
|
||||||
popup[0].destroy()
|
popup[0].destroy()
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
onKeyDown(props) {
|
onKeyDown(props) {
|
||||||
return component.ref.onKeyDown(props)
|
return component.ref?.onKeyDown(props)
|
||||||
},
|
},
|
||||||
onExit() {
|
onExit() {
|
||||||
popup[0].destroy()
|
popup[0].destroy()
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
onKeyDown(props) {
|
onKeyDown(props) {
|
||||||
return component.ref.onKeyDown(props)
|
return component.ref?.onKeyDown(props)
|
||||||
},
|
},
|
||||||
onExit() {
|
onExit() {
|
||||||
popup[0].destroy()
|
popup[0].destroy()
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ export default () => {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
onKeyDown(props) {
|
onKeyDown(props) {
|
||||||
return reactRenderer.ref.onKeyDown(props)
|
return reactRenderer.ref?.onKeyDown(props)
|
||||||
},
|
},
|
||||||
onExit() {
|
onExit() {
|
||||||
popup[0].destroy()
|
popup[0].destroy()
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ export class VueRenderer {
|
|||||||
this.ref = new Component(props).$mount()
|
this.ref = new Component(props).$mount()
|
||||||
}
|
}
|
||||||
|
|
||||||
get element() {
|
get element(): Element {
|
||||||
return this.ref.$el
|
return this.ref.$el
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProps(props: AnyObject = {}) {
|
updateProps(props: AnyObject = {}): void {
|
||||||
if (!this.ref.$props) {
|
if (!this.ref.$props) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ export class VueRenderer {
|
|||||||
Vue.config.silent = originalSilent
|
Vue.config.silent = originalSilent
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy(): void {
|
||||||
this.ref.$destroy()
|
this.ref.$destroy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ export class VueRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get ref() {
|
get ref(): any {
|
||||||
return this.editor.contentComponent?.ctx.$refs[this.id]
|
return this.editor.contentComponent?.ctx.$refs[this.id]
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProps(props: AnyObject = {}) {
|
updateProps(props: AnyObject = {}): void {
|
||||||
Object
|
Object
|
||||||
.entries(props)
|
.entries(props)
|
||||||
.forEach(([key, value]) => {
|
.forEach(([key, value]) => {
|
||||||
@@ -52,7 +52,7 @@ export class VueRenderer {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy(): void {
|
||||||
this.editor.vueRenderers.delete(this.id)
|
this.editor.vueRenderers.delete(this.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import { EditorOptions } from '@tiptap/core'
|
|||||||
import { Editor } from './Editor'
|
import { Editor } from './Editor'
|
||||||
|
|
||||||
export const useEditor = (options: Partial<EditorOptions> = {}) => {
|
export const useEditor = (options: Partial<EditorOptions> = {}) => {
|
||||||
const editor = ref()
|
const editor = ref<Editor>()
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
editor.value = new Editor(options)
|
editor.value = new Editor(options)
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
editor.value.destroy()
|
editor.value?.destroy()
|
||||||
})
|
})
|
||||||
|
|
||||||
return editor
|
return editor
|
||||||
|
|||||||
Reference in New Issue
Block a user