add basic floating menu

This commit is contained in:
Philipp Kühn
2021-04-01 15:19:31 +02:00
parent 0e11fa6cff
commit 007e6f855b
10 changed files with 370 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import Vue, { PropType } from 'vue'
import { FloatingMenuPlugin, FloatingMenuPluginKey, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'
export const FloatingMenu = Vue.extend({
name: 'FloatingMenu',
props: {
editor: {
type: Object as PropType<FloatingMenuPluginProps['editor']>,
required: true,
},
},
watch: {
editor: {
immediate: true,
handler(editor: FloatingMenuPluginProps['editor']) {
if (!editor) {
return
}
this.$nextTick(() => {
editor.registerPlugin(FloatingMenuPlugin({
editor,
element: this.$el as HTMLElement,
}))
})
},
},
},
render(createElement) {
return createElement('div', {}, this.$slots.default)
},
beforeDestroy() {
this.editor.unregisterPlugin(FloatingMenuPluginKey)
},
})