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