Skip to content

Commit

Permalink
feat: 중간에서 삭제시 커서 이동 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
pipisebastian committed Nov 26, 2024
1 parent d511786 commit 22370d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/src/features/editor/hooks/useBlockOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const useBlockOptionSelect = ({
sendCharInsertOperation,
}: useBlockOptionSelectProps) => {
const handleTypeSelect = (blockId: BlockId, type: ElementType) => {
let block = editorState.linkedList.getNode(blockId);
const block = editorState.linkedList.getNode(blockId);
if (!block) return;

block.type = type;
Expand Down
12 changes: 6 additions & 6 deletions client/src/features/editor/hooks/useMarkdownGrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const useMarkdownGrammer = ({
let targetBlock = findBlock(targetIndex);

while (targetBlock && targetBlock.type === "hr") {
targetIndex--;
targetIndex -= 1;
targetBlock = findBlock(targetIndex);
}

Expand Down Expand Up @@ -225,12 +225,12 @@ export const useMarkdownGrammer = ({
let targetBlock = findBlock(targetIndex);

while (targetBlock && targetBlock.type === "hr") {
targetIndex--;
targetIndex -= 1;
targetBlock = findBlock(targetIndex);
}

if (prevBlock.type === "hr") {
if (targetBlock && prevBlock.type === "hr") {
editorCRDT.currentBlock = targetBlock;
editorCRDT.currentBlock.crdt.currentCaret = targetBlock.crdt.read().length; // 커서 이동
updateEditorState();
break;
}
Expand Down Expand Up @@ -366,7 +366,7 @@ export const useMarkdownGrammer = ({
let targetBlock = findBlock(targetIndex);

while (targetBlock && targetBlock.type === "hr") {
targetIndex--;
targetIndex -= 1;
targetBlock = findBlock(targetIndex);
}

Expand All @@ -392,7 +392,7 @@ export const useMarkdownGrammer = ({
let targetBlock = findBlock(targetIndex);

while (targetBlock && targetBlock.type === "hr") {
targetIndex++;
targetIndex += 1;
targetBlock = findBlock(targetIndex);
}

Expand Down

0 comments on commit 22370d6

Please sign in to comment.