import { h, ref, PropType, onMounted, onBeforeUnmount, defineComponent, } from 'vue' import { FloatingMenuPlugin, FloatingMenuPluginKey, FloatingMenuPluginProps, } from '@tiptap/extension-floating-menu' export const FloatingMenu = defineComponent({ name: 'FloatingMenu', props: { editor: { type: Object as PropType, required: true, }, }, setup({ editor }, { slots }) { const root = ref(null) onMounted(() => { editor.registerPlugin(FloatingMenuPlugin({ editor, element: root.value as HTMLElement, })) }) onBeforeUnmount(() => { editor.unregisterPlugin(FloatingMenuPluginKey) }) return () => h('div', { ref: root }, slots.default?.()) }, })