diff --git a/client/src/features/editor/components/TypeOptionModal/TypeOptionModal.tsx b/client/src/features/editor/components/TypeOptionModal/TypeOptionModal.tsx index e808271b..9ccaac93 100644 --- a/client/src/features/editor/components/TypeOptionModal/TypeOptionModal.tsx +++ b/client/src/features/editor/components/TypeOptionModal/TypeOptionModal.tsx @@ -40,7 +40,6 @@ export const TypeOptionModal = ({ case "Enter": e.preventDefault(); onTypeSelect(options[selectedIndex].id); - onClose(); break; @@ -60,35 +59,50 @@ export const TypeOptionModal = ({ if (!isOpen) return null; return createPortal( - -
- {options.map((option, index) => ( - - ))} -
-
, + <> +
+ +
+ {options.map((option, index) => ( + + ))} +
+
+ , document.body, ); }; diff --git a/client/src/features/editor/hooks/useMarkdownGrammer.ts b/client/src/features/editor/hooks/useMarkdownGrammer.ts index e6fb2eac..a3f5e714 100644 --- a/client/src/features/editor/hooks/useMarkdownGrammer.ts +++ b/client/src/features/editor/hooks/useMarkdownGrammer.ts @@ -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; diff --git a/client/src/features/editor/utils/domSyncUtils.ts b/client/src/features/editor/utils/domSyncUtils.ts index 53a4a4b9..fb5f4f5a 100644 --- a/client/src/features/editor/utils/domSyncUtils.ts +++ b/client/src/features/editor/utils/domSyncUtils.ts @@ -139,7 +139,11 @@ const setsEqual = (a: Set, b: Set): boolean => { }; const sanitizeText = (text: string): string => { - return text.replace(/
/g, "\u00A0"); + return text + .replace(/
/g, "\u00A0") + .replace(//g, ">") + .replace(/&/g, "&"); }; // 배열 비교 헬퍼 함수