Skip to content

Commit cc3bad1

Browse files
committed
fix: build 오류 해결
1 parent 7624819 commit cc3bad1

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { Canvas, type YNode } from "@/features/canvas/ui/Canvas";
1+
export { Canvas } from "@/features/canvas/ui/Canvas";
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as Y from "yjs";
2+
import { YEvent } from "yjs";
3+
4+
import { Node } from "@/entities/node";
5+
6+
export const updateNodesMapByYTextEvent = (
7+
event: YEvent<any>[],
8+
nodesMap: Y.Map<any>,
9+
key: "title" | "emoji",
10+
) => {
11+
if (!event[0].path.length) return;
12+
13+
const pageId = event[0].path[0].toString().split("_")[1];
14+
const value = event[0].target.toString();
15+
16+
const existingNode = nodesMap.get(pageId) as Node;
17+
if (!existingNode) return;
18+
19+
const newNode: Node = {
20+
...existingNode,
21+
data: { ...existingNode.data, id: pageId, [key]: value },
22+
selected: false,
23+
isHolding: false,
24+
};
25+
26+
nodesMap.set(pageId, newNode);
27+
};

apps/frontend/src/features/editor/model/useEditorTitle.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from "react";
22

3-
import { YNode } from "@/features/canvas";
3+
import { Node } from "@/entities/node";
44
import { Emoji } from "@/shared/ui";
55
import { useYDocStore, useYText } from "@/shared/model";
66

@@ -23,7 +23,7 @@ export const useEditorTitle = (currentPage: number) => {
2323
setYTitle(e.target.value);
2424

2525
const nodesMap = ydoc.getMap("nodes");
26-
const existingNode = nodesMap.get(currentPage.toString()) as YNode;
26+
const existingNode = nodesMap.get(currentPage.toString()) as Node;
2727

2828
if (existingNode) {
2929
const updatedNode = {
@@ -41,7 +41,7 @@ export const useEditorTitle = (currentPage: number) => {
4141
setYEmoji(native);
4242

4343
const nodesMap = ydoc.getMap("nodes");
44-
const existingNode = nodesMap.get(currentPage.toString()) as YNode;
44+
const existingNode = nodesMap.get(currentPage.toString()) as Node;
4545

4646
if (existingNode) {
4747
const updatedNode = {
@@ -63,7 +63,7 @@ export const useEditorTitle = (currentPage: number) => {
6363
setYEmoji("");
6464

6565
const nodesMap = ydoc.getMap("nodes");
66-
const existingNode = nodesMap.get(currentPage.toString()) as YNode;
66+
const existingNode = nodesMap.get(currentPage.toString()) as Node;
6767

6868
if (existingNode) {
6969
const updatedNode = {

0 commit comments

Comments
 (0)