File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Panel } from "@xyflow/react" ;
2+ import { useReactFlow } from "@xyflow/react" ;
3+ import { type AwarenessState } from "@/hooks/useCursor" ;
4+ import Cursor from "./cursor" ;
5+
6+ interface CollaborativeCursorsProps {
7+ cursors : Map < number , AwarenessState > ;
8+ }
9+
10+ export function CollaborativeCursors ( { cursors } : CollaborativeCursorsProps ) {
11+ const { flowToScreenPosition } = useReactFlow ( ) ;
12+
13+ return (
14+ < Panel position = "top-left" className = "pointer-events-none" >
15+ { Array . from ( cursors . values ( ) ) . map ( ( cursor ) => {
16+ if ( ! cursor . cursor ) return null ;
17+
18+ const position = flowToScreenPosition ( {
19+ x : cursor . cursor . x ,
20+ y : cursor . cursor . y ,
21+ } ) ;
22+
23+ return (
24+ < Cursor key = { cursor . clientId } coors = { position } color = { cursor . color } />
25+ ) ;
26+ } ) }
27+ </ Panel >
28+ ) ;
29+ }
You can’t perform that action at this time.
0 commit comments