(Array.from(collabs, ([id, collaborator]) => [
+ id as SocketId,
+ {
+ username: collaborator.username,
+ color: { background: collaborator.color, stroke: collaborator.color },
+ pointer: { ...collaborator.pointer, tool: 'pointer' },
+ },
+ ])));
},
});
@@ -140,8 +146,13 @@ export default function App() {
return () => {
collab.disconnect();
+ collabRef.current = null;
};
- }, [username, loading, room]);
+ }, [username, loading, room, excalidrawApi]);
+
+ useEffect(() => {
+ excalidrawApi?.updateScene({ collaborators });
+ }, [excalidrawApi, collaborators]);
// Handle scene changes
const handleChange = useCallback(
@@ -181,9 +192,7 @@ export default function App() {
return (
{
- excalidrawApiRef.current = api;
- }}
+ excalidrawAPI={setExcalidrawApi}
initialData={initialData || undefined}
onChange={handleChange}
onPointerUpdate={handlePointerUpdate}
diff --git a/plugins/draw/ui/src/main.tsx b/plugins/draw/ui/src/main.tsx
index c018515..5ec08fc 100644
--- a/plugins/draw/ui/src/main.tsx
+++ b/plugins/draw/ui/src/main.tsx
@@ -1,5 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
+import '@excalidraw/excalidraw/index.css';
import App from './App';
ReactDOM.createRoot(document.getElementById('root')!).render(
diff --git a/plugins/draw/ui/tsconfig.json b/plugins/draw/ui/tsconfig.json
index 1ada14b..f559cdf 100644
--- a/plugins/draw/ui/tsconfig.json
+++ b/plugins/draw/ui/tsconfig.json
@@ -4,6 +4,7 @@
"module": "ESNext",
"moduleResolution": "bundler",
"lib": ["ES2022", "DOM", "DOM.Iterable"],
+ "types": ["vite/client"],
"jsx": "react-jsx",
"strict": true,
"esModuleInterop": true,