Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

순서 리스팅 버그 수정 #142

Merged
merged 3 commits into from
Dec 19, 2020
Merged

순서 리스팅 버그 수정 #142

merged 3 commits into from
Dec 19, 2020

Conversation

YiSoJeong
Copy link
Collaborator

순서 리스팅 버그 수정

해당 이슈 📎

#141

변경 사항 🛠

블록 타입 검증함수 교체

테스트 ✨

없음

리뷰어 참고 사항 🙋‍♀️

@YiSoJeong YiSoJeong added 🐛 bug Something isn't working 🔧 refactor 💯 must 🌈 frontend Frontend issue labels Dec 19, 2020
@YiSoJeong YiSoJeong added this to the 4차 릴리즈 milestone Dec 19, 2020
@YiSoJeong YiSoJeong self-assigned this Dec 19, 2020
Copy link
Collaborator

@skid901 skid901 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 확인 부탁드립니다.
고생하셨습니다 ^^7

Comment on lines 8 to 27
export const regex: { [key: string]: RegExp } = {
heading1: /^#\s[^\s.]*/gm,
heading2: /^##\s[^\s.]*/gm,
heading3: /^###\s[^\s.]*/gm,
bulletedlist: /^[-,+]\s[^\s.]*/gm,
numberedlist: /^\d.\s[^\s.]*/gm,
togglelist: /^>\s[^\s.]*/gm,
quote: /^\|\s[^\s.]*/gm,
heading1: /^#/gm,
heading2: /^##/gm,
heading3: /^###/gm,
bulletedlist: /^[-,+]/gm,
numberedlist: /^\d+\./gm,
togglelist: /^>/gm,
quote: /^\|/gm,
};

export const validateType = (content: string): BlockType => {
if (content === '#') return BlockType.HEADING1;
if (content === '##') return BlockType.HEADING2;
if (content === '###') return BlockType.HEADING3;
if (content === '-' || content === '+') return BlockType.BULLETED_LIST;
if (/^\d+\./gm.test(content)) return BlockType.NUMBERED_LIST;
if (content === '>') return BlockType.TOGGLE_LIST;
if (content === '|') return BlockType.QUOTE;
return null;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regexvalidateType 내 조건문을 함수로 만들어서 하나의 객체로 만들 수 있을거 같은데,
나중에 고려해 보시면 좋을 것 같아요.

// 예시
const typeValidator = {
  [ BlockType.HEADING1 ]: { regex: /^#/gm, validator: content => content === '#' };
};

const validateType = (content: string): BlockType => {
  for (const [key, { validator }] of Object.entries(typeValidator)) {
    if(validator(content)) return key;
  }
  return null;
};

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Good

Copy link
Collaborator

@domino8788 domino8788 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다.
오늘도 내일도 화이팅!

@@ -250,7 +247,7 @@ function BlockContent(blockDTO: Block) {
listCnt.current = cntOfUpperNumberListBlock() + 1;
}
}
}, [blockDTO.value]);
}, [blockDTO.type]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영 감사합니다. :)

Comment on lines 8 to 27
export const regex: { [key: string]: RegExp } = {
heading1: /^#\s[^\s.]*/gm,
heading2: /^##\s[^\s.]*/gm,
heading3: /^###\s[^\s.]*/gm,
bulletedlist: /^[-,+]\s[^\s.]*/gm,
numberedlist: /^\d.\s[^\s.]*/gm,
togglelist: /^>\s[^\s.]*/gm,
quote: /^\|\s[^\s.]*/gm,
heading1: /^#/gm,
heading2: /^##/gm,
heading3: /^###/gm,
bulletedlist: /^[-,+]/gm,
numberedlist: /^\d+\./gm,
togglelist: /^>/gm,
quote: /^\|/gm,
};

export const validateType = (content: string): BlockType => {
if (content === '#') return BlockType.HEADING1;
if (content === '##') return BlockType.HEADING2;
if (content === '###') return BlockType.HEADING3;
if (content === '-' || content === '+') return BlockType.BULLETED_LIST;
if (/^\d+\./gm.test(content)) return BlockType.NUMBERED_LIST;
if (content === '>') return BlockType.TOGGLE_LIST;
if (content === '|') return BlockType.QUOTE;
return null;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Good

}
return false;
};

const cntOfUpperNumberListBlock = (): number => {
let cnt = 0;
if (upperBlocks) {
for (const upperblock of upperBlocks) {
if (prevSiblings) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

에구.. 제가 실수록 useFamily의 prevSiblings를 reverse 로 저장하게 해놨네요...
죄송합니다 ㅎㅎㅎ;.;
수정 부탁드립니다.

@domino8788 domino8788 merged commit c30052f into dev-frontend Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🌈 frontend Frontend issue 🔧 refactor 💯 must
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants