-
Notifications
You must be signed in to change notification settings - Fork 9
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
순서 리스팅 버그 수정 #142
Conversation
- 변경된 검증함수로 구현
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 확인 부탁드립니다.
고생하셨습니다 ^^7
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; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regex
와 validateType
내 조건문을 함수로 만들어서 하나의 객체로 만들 수 있을거 같은데,
나중에 고려해 보시면 좋을 것 같아요.
// 예시
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;
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Good
There was a problem hiding this 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]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반영 감사합니다. :)
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; | ||
}; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
에구.. 제가 실수록 useFamily의 prevSiblings를 reverse 로 저장하게 해놨네요...
죄송합니다 ㅎㅎㅎ;.;
수정 부탁드립니다.
순서 리스팅 버그 수정
해당 이슈 📎
#141
변경 사항 🛠
블록 타입 검증함수 교체
테스트 ✨
없음
리뷰어 참고 사항 🙋♀️