Skip to content

Commit

Permalink
Merge branch 'release/0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
pipisebastian committed Nov 28, 2024
2 parents 6a6e268 + 314e673 commit 608a8a4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const TypeOptionModal = ({
case "Enter":
e.preventDefault();
onTypeSelect(options[selectedIndex].id);

onClose();
break;

Expand All @@ -60,35 +59,50 @@ export const TypeOptionModal = ({
if (!isOpen) return null;

return createPortal(
<motion.div
ref={modalRef}
tabIndex={0}
className={optionModal}
style={{
left: `${position.left}px`,
top: `${position.top}px`,
outline: "none",
}}
initial={modal.initial}
animate={modal.animate}
onKeyDown={handleKeyDown}
>
<div className={modalContainer}>
{options.map((option, index) => (
<button
key={option.id}
className={`${optionTypeButton} ${index === selectedIndex && "selected"}`}
onClick={() => {
onTypeSelect(option.id);
onClose();
}}
onMouseEnter={() => setSelectedIndex(index)}
>
{option.label}
</button>
))}
</div>
</motion.div>,
<>
<div
style={{
position: "fixed",
top: 0,
left: 0,
right: 0,
bottom: 0,
background: "transparent",
zIndex: 999,
}}
onClick={onClose}
/>
<motion.div
ref={modalRef}
tabIndex={0}
className={optionModal}
style={{
left: `${position.left}px`,
top: `${position.top}px`,
outline: "none",
zIndex: 1000,
}}
initial={modal.initial}
animate={modal.animate}
onKeyDown={handleKeyDown}
>
<div className={modalContainer}>
{options.map((option, index) => (
<button
key={option.id}
className={`${optionTypeButton} ${index === selectedIndex && "selected"}`}
onClick={() => {
onTypeSelect(option.id);
onClose();
}}
onMouseEnter={() => setSelectedIndex(index)}
>
{option.label}
</button>
))}
</div>
</motion.div>
</>,
document.body,
);
};
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 608a8a4

Please sign in to comment.