-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from HabitPay/fix/add_markdownEditor_and_code…
…_highlight#143 Fix/add markdown editor and code highlight#143
- Loading branch information
Showing
9 changed files
with
8,614 additions
and
5,080 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Markdown from "react-markdown"; | ||
import ReactMarkdown from "react-markdown"; | ||
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; | ||
import { materialOceanic } from "react-syntax-highlighter/dist/esm/styles/prism"; | ||
|
||
interface MarkdownRendererProps { | ||
content: string; // 마크다운 텍스트를 prop으로 받음 | ||
} | ||
|
||
const MarkdownRenderer: React.FC<MarkdownRendererProps> = ({ content }) => { | ||
return ( | ||
<ReactMarkdown | ||
components={{ | ||
code({ node, className, style, children, ref, ...props }) { | ||
const match = /language-(\w+)/.exec(className || ""); | ||
return match ? ( | ||
<SyntaxHighlighter | ||
style={materialOceanic} | ||
language={match[1]} | ||
PreTag="div" | ||
{...props} | ||
> | ||
{String(children).replace(/\n$/, "")} | ||
</SyntaxHighlighter> | ||
) : ( | ||
<code className={className} {...props}> | ||
{children} | ||
</code> | ||
); | ||
}, | ||
}} | ||
> | ||
{content} | ||
</ReactMarkdown> | ||
); | ||
}; | ||
|
||
export default MarkdownRenderer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
|
||
|
||
|
||
.w-md-editor-text-pre > code, | ||
.w-md-editor-text-input { | ||
font-size: 16px !important; | ||
line-height: 24px !important; | ||
} |