Skip to content

Commit

Permalink
[#143] feat: useFamily의 prevSiblings 수정 및 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
YiSoJeong committed Dec 19, 2020
1 parent 3c73c7c commit 2262375
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions frontend/src/components/atoms/BlockContent/BlockContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,19 @@ function BlockContent(blockDTO: Block) {
if (focusId === blockDTO.id) contentEditableRef.current.focus();
}, [focusId]);

const upperBlocks: Array<Block> = prevSiblings?.reverse();

const isUpperBlockEqualToNumberList = (): boolean => {
if (prevSiblings.length) {
return prevSiblings[0].type === BlockType.NUMBERED_LIST;
if (upperBlocks.length) {
return upperBlocks[0].type === BlockType.NUMBERED_LIST;
}
return false;
};

const cntOfUpperNumberListBlock = (): number => {
let cnt = 0;
if (prevSiblings) {
for (const upperblock of prevSiblings) {
if (upperBlocks) {
for (const upperblock of upperBlocks) {
if (upperblock.type !== BlockType.NUMBERED_LIST) break;
cnt += 1;
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/useFamily.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const useFamily = (blockId: string): [BlockFamily, FamilyFunc] => {
);
const prevSibling = siblings?.[blockIndex - 1];
const nextSibling = siblings?.[blockIndex + 1];
const prevSiblings = siblings?.slice(0, blockIndex).reverse();
const prevSiblings = siblings?.slice(0, blockIndex);
const nextSiblings = siblings?.slice(blockIndex);

const findLastDescendant = (targetBlock: Block) => {
Expand Down

0 comments on commit 2262375

Please sign in to comment.