Skip to content

Commit 2c717a1

Browse files
committed
feat: Node 타입에 color 추가
1 parent 98ce563 commit 2c717a1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

apps/frontend/src/entities/node/model/nodeTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type NoteNodeData = {
88
title: string;
99
id: number;
1010
emoji: string;
11+
color: string;
1112
};
1213

1314
export type NoteNodeType = FlowNode<NoteNodeData, "note">;

apps/frontend/src/features/canvas/model/useCanvas.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ export const useCanvas = () => {
7878
const newNode: YNode = {
7979
id: existingNode.id,
8080
type: "note",
81-
data: { title: value, id: pageId, emoji: existingNode.data.emoji },
81+
data: {
82+
title: value,
83+
id: pageId,
84+
emoji: existingNode.data.emoji,
85+
color: existingNode.data.color,
86+
},
8287
position: existingNode.position,
8388
selected: false,
8489
isHolding: false,
@@ -99,7 +104,12 @@ export const useCanvas = () => {
99104
const newNode: YNode = {
100105
id: pageId,
101106
type: "note",
102-
data: { title: existingNode.data.title, id: pageId, emoji: value },
107+
data: {
108+
title: existingNode.data.title,
109+
id: pageId,
110+
emoji: value,
111+
color: existingNode.data.color,
112+
},
103113
position: existingNode.position,
104114
selected: false,
105115
isHolding: false,
@@ -108,6 +118,7 @@ export const useCanvas = () => {
108118
nodesMap.set(pageId, newNode);
109119
});
110120
}, [ydoc]);
121+
111122
useEffect(() => {
112123
if (!ydoc) return;
113124

@@ -131,7 +142,7 @@ export const useCanvas = () => {
131142
event.changes.keys.forEach((change, key) => {
132143
const nodeId = key;
133144
if (change.action === "add" || change.action === "update") {
134-
const updatedNode = nodesMap.get(nodeId) as Node;
145+
const updatedNode = nodesMap.get(nodeId) as YNode;
135146
setNodes((nds) => {
136147
const index = nds.findIndex((n) => n.id === nodeId);
137148
if (index === -1) {

0 commit comments

Comments
 (0)