import { FC, memo, useRef } from 'react' import useDropdown from '../../../../shared/hooks/use-dropdown' import OLListGroup from '@/features/ui/components/ol/ol-list-group' import OLTooltip from '@/features/ui/components/ol/ol-tooltip' import OLOverlay from '@/features/ui/components/ol/ol-overlay' import OLPopover from '@/features/ui/components/ol/ol-popover' import { EditorView } from '@codemirror/view' import { emitToolbarEvent } from '../../extensions/toolbar/utils/analytics' import { useCodeMirrorViewContext } from '../codemirror-context' export const ToolbarButtonMenu: FC<{ id: string label: string icon: React.ReactNode altCommand?: (view: EditorView) => void }> = memo(function ButtonMenu({ icon, id, label, altCommand, children }) { const target = useRef(null) const { open, onToggle, ref } = useDropdown() const view = useCodeMirrorViewContext() const button = ( ) const overlay = ( onToggle(false)} > { onToggle(false) }} > {children} ) if (!label) { return ( <> {button} {overlay} ) } return ( <> {overlay} ) })