Skip to content

Commit b7e9fba

Browse files
committed
feat: 노드 정렬 기능 구현
1 parent b3b466e commit b7e9fba

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

apps/frontend/src/components/canvas/index.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ import {
1717
ReactFlowProvider,
1818
} from "@xyflow/react";
1919
import "@xyflow/react/dist/style.css";
20-
import { usePages } from "@/hooks/usePages";
21-
import { NoteNode } from "./NoteNode";
2220
import * as Y from "yjs";
21+
import ELK from "elkjs";
2322
import { SocketIOProvider } from "y-socket.io";
24-
import { cn } from "@/lib/utils";
2523
import { useQueryClient } from "@tanstack/react-query";
24+
25+
import { CollaborativeCursors } from "../CursorView";
26+
import { NoteNode } from "./NoteNode";
27+
28+
import { usePages } from "@/hooks/usePages";
29+
import { cn } from "@/lib/utils";
2630
import useYDocStore from "@/store/useYDocStore";
2731
import { useCollaborativeCursors } from "@/hooks/useCursor";
28-
import { CollaborativeCursors } from "../CursorView";
2932
import { calculateBestHandles } from "@/lib/calculateBestHandles";
3033

31-
import ELK from "elkjs";
32-
3334
const elk = new ELK();
3435

3536
const proOptions = { hideAttribution: true };
@@ -232,6 +233,12 @@ function Flow({ className }: CanvasProps) {
232233
};
233234
});
234235

236+
const nodesMap = ydoc.getMap("nodes");
237+
238+
updatedNodes.forEach((updateNode) => {
239+
nodesMap.set(updateNode.id, updateNode);
240+
});
241+
235242
setNodes(updatedNodes);
236243
};
237244

@@ -374,17 +381,8 @@ function Flow({ className }: CanvasProps) {
374381
selectNodesOnDrag={false}
375382
>
376383
<Controls />
377-
<div
378-
id="layout-button"
379-
style={{
380-
display: "flex",
381-
justifyContent: "center",
382-
marginBottom: "10px",
383-
zIndex: 999,
384-
position: "relative",
385-
}}
386-
>
387-
<button onClick={performLayout}>Layout</button>
384+
<div className="fixed bottom-5 left-16 z-30 h-4 w-4 text-neutral-50 hover:cursor-pointer">
385+
<button onClick={performLayout}>Sort</button>
388386
</div>
389387
<MiniMap />
390388
<Background variant={BackgroundVariant.Dots} gap={12} size={1} />

0 commit comments

Comments
 (0)