refactoring
This commit is contained in:
committed by
Hans Pagel
parent
3cb4b0f71f
commit
1892b8f893
@@ -32,33 +32,32 @@ export default {
|
|||||||
Text,
|
Text,
|
||||||
Mention.configure({
|
Mention.configure({
|
||||||
items: query => {
|
items: query => {
|
||||||
return ['foo', 'bar']
|
return ['foo', 'bar'].filter(item => item.startsWith(query))
|
||||||
},
|
},
|
||||||
renderer: () => {
|
renderer: () => {
|
||||||
let component
|
let component
|
||||||
let popup
|
let popup
|
||||||
|
|
||||||
return {
|
return {
|
||||||
onStart(props) {
|
onStart: props => {
|
||||||
component = new VueRenderer(MentionList, props)
|
component = new VueRenderer(MentionList, {
|
||||||
|
parent: this,
|
||||||
|
propsData: props,
|
||||||
|
})
|
||||||
|
|
||||||
popup = tippy('.app', {
|
popup = tippy('body', {
|
||||||
getReferenceClientRect: () => props.virtualNode.getBoundingClientRect(),
|
getReferenceClientRect: () => props.virtualNode.getBoundingClientRect(),
|
||||||
appendTo: () => document.body,
|
appendTo: () => document.body,
|
||||||
interactive: true,
|
|
||||||
sticky: true,
|
|
||||||
plugins: [sticky],
|
|
||||||
content: component.element,
|
content: component.element,
|
||||||
trigger: 'mouseenter',
|
|
||||||
showOnCreate: true,
|
showOnCreate: true,
|
||||||
theme: 'dark',
|
interactive: true,
|
||||||
|
trigger: 'manual',
|
||||||
placement: 'top-start',
|
placement: 'top-start',
|
||||||
inertia: true,
|
|
||||||
duration: [400, 200],
|
duration: [400, 200],
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onUpdate(props) {
|
onUpdate(props) {
|
||||||
component.update(props)
|
component.updateProps(props)
|
||||||
},
|
},
|
||||||
onExit() {
|
onExit() {
|
||||||
popup[0].destroy()
|
popup[0].destroy()
|
||||||
|
|||||||
@@ -7,17 +7,14 @@ export default class VueRenderer {
|
|||||||
constructor(component: Vue | VueConstructor, props: any) {
|
constructor(component: Vue | VueConstructor, props: any) {
|
||||||
const Component = Vue.extend(component)
|
const Component = Vue.extend(component)
|
||||||
|
|
||||||
this.vm = new Component({
|
this.vm = new Component(props).$mount()
|
||||||
// parent,
|
|
||||||
propsData: props,
|
|
||||||
}).$mount()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get element() {
|
get element() {
|
||||||
return this.vm.$el
|
return this.vm.$el
|
||||||
}
|
}
|
||||||
|
|
||||||
update(data: { [key: string]: any } = {}) {
|
updateProps(props: { [key: string]: any } = {}) {
|
||||||
if (!this.vm.$props) {
|
if (!this.vm.$props) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -27,7 +24,7 @@ export default class VueRenderer {
|
|||||||
Vue.config.silent = true
|
Vue.config.silent = true
|
||||||
|
|
||||||
Object
|
Object
|
||||||
.entries(data)
|
.entries(props)
|
||||||
.forEach(([key, value]) => {
|
.forEach(([key, value]) => {
|
||||||
this.vm.$props[key] = value
|
this.vm.$props[key] = value
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user