import Vue, { PropType } from 'vue' import { BubbleMenuPlugin, BubbleMenuPluginKey, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu' export const BubbleMenu = Vue.extend({ name: 'BubbleMenu', props: { editor: { type: Object as PropType, required: true, }, tippyOptions: { type: Object as PropType, default: () => ({}), }, }, watch: { editor: { immediate: true, handler(editor: BubbleMenuPluginProps['editor']) { if (!editor) { return } this.$nextTick(() => { editor.registerPlugin(BubbleMenuPlugin({ editor, element: this.$el as HTMLElement, tippyOptions: this.tippyOptions, })) }) }, }, }, render(createElement) { return createElement('div', { style: { visibility: 'hidden' } }, this.$slots.default) }, beforeDestroy() { this.editor.unregisterPlugin(BubbleMenuPluginKey) }, })