Skip to content

Commit e8e241d

Browse files
committed
refactor: 블럭 선택 로직 수정
- data-id로 바로 접근하도록 수정 #2
1 parent 67c0f71 commit e8e241d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

client/src/utils/caretUtils.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,12 @@ export const setCaretPosition = ({
8585

8686
const currentPage = document.getElementById(pageId);
8787

88-
const blockElements = Array.from(
89-
currentPage?.querySelectorAll('.d_flex.pos_relative.w_full[data-group="true"]') || [],
88+
const targetElement = currentPage?.querySelector(
89+
`[data-id="${blockId.serialize().client}-${blockId.serialize().clock}"]`,
9090
);
91-
92-
const currentIndex = linkedList.spread().findIndex((b) => b.id === blockId);
93-
const targetElement = blockElements[currentIndex];
9491
if (!targetElement) return;
9592

96-
const editableDiv = targetElement.querySelector('[contenteditable="true"]') as HTMLDivElement;
93+
const editableDiv = targetElement.querySelector('[contenteditable="true"]') as HTMLElement;
9794
if (!editableDiv) return;
9895

9996
editableDiv.focus();

0 commit comments

Comments
 (0)