import React, { useEffect, useRef } from 'react' import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu' export type FloatingMenuProps = Omit & { className?: string, } export const FloatingMenu: React.FC = props => { const element = useRef(null) useEffect(() => { const { pluginKey, editor, tippyOptions, shouldShow, } = props editor.registerPlugin(FloatingMenuPlugin({ pluginKey, editor, element: element.current as HTMLElement, tippyOptions, shouldShow, })) return () => { editor.unregisterPlugin(pluginKey) } }, []) return (
{props.children}
) }