| import { | import { | ||||
| memo, | memo, | ||||
| useEffect, | |||||
| useRef, | useRef, | ||||
| } from 'react' | } from 'react' | ||||
| import { useClickAway } from 'ahooks' | import { useClickAway } from 'ahooks' | ||||
| import { useStore } from './store' | import { useStore } from './store' | ||||
| import { usePanelInteractions } from './hooks' | import { usePanelInteractions } from './hooks' | ||||
| const PanelContextmenu = () => { | |||||
| const NodeContextmenu = () => { | |||||
| const ref = useRef(null) | const ref = useRef(null) | ||||
| const nodes = useNodes() | const nodes = useNodes() | ||||
| const { handleNodeContextmenuCancel } = usePanelInteractions() | |||||
| const { handleNodeContextmenuCancel, handlePaneContextmenuCancel } = usePanelInteractions() | |||||
| const nodeMenu = useStore(s => s.nodeMenu) | const nodeMenu = useStore(s => s.nodeMenu) | ||||
| const currentNode = nodes.find(node => node.id === nodeMenu?.nodeId) as Node | const currentNode = nodes.find(node => node.id === nodeMenu?.nodeId) as Node | ||||
| useEffect(() => { | |||||
| if (nodeMenu) | |||||
| handlePaneContextmenuCancel() | |||||
| }, [nodeMenu, handlePaneContextmenuCancel]) | |||||
| useClickAway(() => { | useClickAway(() => { | ||||
| handleNodeContextmenuCancel() | handleNodeContextmenuCancel() | ||||
| }, ref) | }, ref) | ||||
| ) | ) | ||||
| } | } | ||||
| export default memo(PanelContextmenu) | |||||
| export default memo(NodeContextmenu) |
| import { | import { | ||||
| memo, | memo, | ||||
| useEffect, | |||||
| useRef, | useRef, | ||||
| } from 'react' | } from 'react' | ||||
| import { useTranslation } from 'react-i18next' | import { useTranslation } from 'react-i18next' | ||||
| const clipboardElements = useStore(s => s.clipboardElements) | const clipboardElements = useStore(s => s.clipboardElements) | ||||
| const setShowImportDSLModal = useStore(s => s.setShowImportDSLModal) | const setShowImportDSLModal = useStore(s => s.setShowImportDSLModal) | ||||
| const { handleNodesPaste } = useNodesInteractions() | const { handleNodesPaste } = useNodesInteractions() | ||||
| const { handlePaneContextmenuCancel } = usePanelInteractions() | |||||
| const { handlePaneContextmenuCancel, handleNodeContextmenuCancel } = usePanelInteractions() | |||||
| const { handleStartWorkflowRun } = useWorkflowStartRun() | const { handleStartWorkflowRun } = useWorkflowStartRun() | ||||
| const { handleAddNote } = useOperator() | const { handleAddNote } = useOperator() | ||||
| const { exportCheck } = useDSL() | const { exportCheck } = useDSL() | ||||
| useEffect(() => { | |||||
| if (panelMenu) | |||||
| handleNodeContextmenuCancel() | |||||
| }, [panelMenu, handleNodeContextmenuCancel]) | |||||
| useClickAway(() => { | useClickAway(() => { | ||||
| handlePaneContextmenuCancel() | handlePaneContextmenuCancel() | ||||
| }, ref) | }, ref) |