Skip to content

Commit

Permalink
Merge pull request #243 from boostcampwm-2024/Hotfix/#242_마크다운_탐지_로직_수정
Browse files Browse the repository at this point in the history
Hotfix/#242 마크다운 탐지 로직 수정
  • Loading branch information
github-actions[bot] authored Nov 28, 2024
2 parents 0bea6af + 862eabe commit e76c496
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion client/src/features/editor/hooks/useMarkdownGrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,13 @@ export const useMarkdownGrammer = ({
const selection = window.getSelection();
if (!selection) return;
const currentContent = currentBlock.crdt.read();
const currentCaret = getAbsoluteCaretPosition(e.currentTarget);
const markdownElement = checkMarkdownPattern(currentContent);
if (markdownElement && currentBlock.type === "p") {
if (
markdownElement &&
currentCaret === markdownElement.length &&
currentBlock.type === "p"
) {
e.preventDefault();
// 마크다운 패턴 매칭 시 타입 변경하고 내용 비우기
currentBlock.type = markdownElement.type;
Expand Down
6 changes: 5 additions & 1 deletion client/src/features/editor/utils/domSyncUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ const setsEqual = (a: Set<string>, b: Set<string>): boolean => {
};

const sanitizeText = (text: string): string => {
return text.replace(/<br>/g, "\u00A0");
return text
.replace(/<br>/g, "\u00A0")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/&/g, "&amp;");
};

// 배열 비교 헬퍼 함수
Expand Down

0 comments on commit e76c496

Please sign in to comment.