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