import { memo, useEffect, useMemo, useRef } from 'react' import { MiniMap } from 'reactflow' import UndoRedo from '../header/undo-redo' import ZoomInOut from './zoom-in-out' import VariableTrigger from '../variable-inspect/trigger' import VariableInspectPanel from '../variable-inspect' import { useStore } from '../store' export type OperatorProps = { handleUndo: () => void handleRedo: () => void } const Operator = ({ handleUndo, handleRedo }: OperatorProps) => { const bottomPanelRef = useRef(null) const workflowCanvasWidth = useStore(s => s.workflowCanvasWidth) const rightPanelWidth = useStore(s => s.rightPanelWidth) const setBottomPanelWidth = useStore(s => s.setBottomPanelWidth) const setBottomPanelHeight = useStore(s => s.setBottomPanelHeight) const bottomPanelWidth = useMemo(() => { if (!workflowCanvasWidth || !rightPanelWidth) return 'auto' return Math.max((workflowCanvasWidth - rightPanelWidth), 400) }, [workflowCanvasWidth, rightPanelWidth]) // update bottom panel height useEffect(() => { if (bottomPanelRef.current) { const resizeContainerObserver = new ResizeObserver((entries) => { for (const entry of entries) { const { inlineSize, blockSize } = entry.borderBoxSize[0] setBottomPanelWidth(inlineSize) setBottomPanelHeight(blockSize) } }) resizeContainerObserver.observe(bottomPanelRef.current) return () => { resizeContainerObserver.disconnect() } } }, [setBottomPanelHeight, setBottomPanelWidth]) return (
) } export default memo(Operator)