From 2ef1ccafa3e52f74c5fb6ae18aafc2ddcdfdb025 Mon Sep 17 00:00:00 2001 From: Ludovico7 Date: Tue, 3 Dec 2024 03:19:10 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=95=9C=EA=B8=80=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EC=A7=95=EC=8B=9C=20=EC=9C=88=EB=8F=84=EC=9A=B0=EB=8F=84=20?= =?UTF-8?q?=EC=8A=A4=ED=8E=98=EC=9D=B4=EC=8A=A4=EB=B0=94=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=98=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: hyonun Co-authored-by: Jang seo yun Co-authored-by: minjungw00 --- client/src/features/editor/Editor.tsx | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/client/src/features/editor/Editor.tsx b/client/src/features/editor/Editor.tsx index 312adff..a369143 100644 --- a/client/src/features/editor/Editor.tsx +++ b/client/src/features/editor/Editor.tsx @@ -224,7 +224,6 @@ export const Editor = ({ onTitleChange, pageId, pageTitle, serializedEditorData blockId: block.id, pageId, }); - sendCharInsertOperation(block.crdt.localInsert(currentCaret + 1, "", block.id, pageId)); block.crdt.currentCaret = currentCaret; } @@ -246,22 +245,19 @@ export const Editor = ({ onTitleChange, pageId, pageTitle, serializedEditorData if (activeElement?.tagName.toLowerCase() === "input") { return; // input에 포커스가 있으면 캐럿 위치 변경하지 않음 } - if (isLocalChange.current || isSameLocalChange.current) { - setCaretPosition({ - blockId: editorCRDT.current.currentBlock.id, - linkedList: editorCRDT.current.LinkedList, - position: editorCRDT.current.currentBlock?.crdt.currentCaret, - pageId, - }); - isLocalChange.current = false; - if (composingCaret.current !== null) { - isSameLocalChange.current = true; - } else { + requestAnimationFrame(() => { + if (isLocalChange.current || isSameLocalChange.current) { + setCaretPosition({ + blockId: editorCRDT.current.currentBlock!.id, + linkedList: editorCRDT.current.LinkedList, + position: editorCRDT.current.currentBlock?.crdt.currentCaret, + pageId, + }); + isLocalChange.current = false; isSameLocalChange.current = false; + return; } - - return; - } + }); // 서윤님 피드백 반영 }, [editorCRDT.current.currentBlock?.id.serialize()]);