import React, { useEffect, useRef } from 'react' import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu' type Optional = Pick, K> & Omit export type BubbleMenuProps = Omit, 'element'> & { className?: string, } export const BubbleMenu: React.FC = props => { const element = useRef(null) useEffect(() => { const { pluginKey = 'bubbleMenu', editor, tippyOptions = {}, shouldShow = null, } = props editor.registerPlugin(BubbleMenuPlugin({ pluginKey, editor, element: element.current as HTMLElement, tippyOptions, shouldShow, })) return () => { editor.unregisterPlugin(pluginKey) } }, []) return (
{props.children}
) }