Skip to content

Commit

Permalink
[#134] fix: caret offset이 0일 때 / 입력시 에러가 발생하는 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
domino8788 committed Dec 19, 2020
1 parent 06a28ac commit 9ceef90
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions frontend/src/components/atoms/BlockContent/BlockContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ function BlockContent(blockDTO: Block) {
const numberListUpperBlock = isUpperBlockEqualToNumberList();
if (!numberListUpperBlock && content[0] !== FIRST_LIST_NUMBER)
return;
// if (
// numberListUpperBlock &&
// cntOfUpperNumberListBlock() + 1 !== +content[0]
// )
// return;
if (
numberListUpperBlock &&
cntOfUpperNumberListBlock() + 1 !== +content[0]
)
return;
}
}
const slicedContent = content.slice(
Expand All @@ -200,13 +200,15 @@ function BlockContent(blockDTO: Block) {
} else if (event.key === '/') {
let nowLetterIdx = window.getSelection().focusOffset;
if (!nowLetterIdx) nowLetterIdx += 1;
const rect = window.getSelection().getRangeAt(0).getClientRects()[0];
setModal({
isOpen: true,
top: rect.top,
left: rect.left,
caretOffset: nowLetterIdx,
blockId: blockDTO.id,
setTimeout(() => {
const rect = window.getSelection().getRangeAt(0).getClientRects()[0];
setModal({
isOpen: true,
top: rect.top,
left: rect.left,
caretOffset: nowLetterIdx,
blockId: blockDTO.id,
});
});
} else if (modal.isOpen) {
setModal({ ...modal, isOpen: false });
Expand Down

0 comments on commit 9ceef90

Please sign in to comment.