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 { key, editor, tippyOptions, shouldShow, } = props editor.registerPlugin(FloatingMenuPlugin({ key, editor, element: element.current as HTMLElement, tippyOptions, shouldShow, })) return () => { editor.unregisterPlugin(key) } }, []) return (
{props.children}
) }