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