add tippy

This commit is contained in:
Philipp Kühn
2021-01-18 12:40:13 +01:00
parent 06b88977fc
commit f96dff1f0f
5 changed files with 87 additions and 22 deletions

View File

@@ -5,6 +5,8 @@
</template>
<script>
import Vue from 'vue'
import tippy, { sticky } from 'tippy.js'
import { Editor } from '@tiptap/core'
import { EditorContent } from '@tiptap/vue'
import Document from '@tiptap/extension-document'
@@ -29,7 +31,53 @@ export default {
Document,
Paragraph,
Text,
Mention,
Mention.configure({
items: query => {
console.log('items', query)
return [query]
},
renderer: () => {
let popup
const Component = new (Vue.extend({
template: '<div>YAAAAY</div>',
}))().$mount()
return {
onStart(props) {
console.log('start')
popup = tippy('.app', {
getReferenceClientRect: () => props.virtualNode.getBoundingClientRect(),
appendTo: () => document.body,
interactive: true,
sticky: true, // make sure position of tippy is updated when content changes
plugins: [sticky],
content: Component.$el,
trigger: 'mouseenter', // manual
showOnCreate: true,
theme: 'dark',
placement: 'top-start',
inertia: true,
duration: [400, 200],
})
},
onUpdate(props) {
console.log('update', props)
},
onExit(props) {
console.log('exit', props)
if (popup) {
popup[0].destroy()
}
Component.$destroy()
},
}
},
}),
],
content: `
<p>text <span data-mention></span></p>