feat: implement highlight renderer

This commit is contained in:
Steven
2024-01-15 22:54:18 +08:00
parent 3f4b361fad
commit ad94e8e3c6
8 changed files with 261 additions and 127 deletions

View File

@ -0,0 +1,9 @@
interface Props {
content: string;
}
const Highlight: React.FC<Props> = ({ content }: Props) => {
return <mark>{content}</mark>;
};
export default Highlight;

View File

@ -7,6 +7,7 @@ import {
CodeNode,
EscapingCharacterNode,
HeadingNode,
HighlightNode,
HorizontalRuleNode,
ImageNode,
ItalicNode,
@ -29,6 +30,7 @@ import Code from "./Code";
import CodeBlock from "./CodeBlock";
import EscapingCharacter from "./EscapingCharacter";
import Heading from "./Heading";
import Highlight from "./Highlight";
import HorizontalRule from "./HorizontalRule";
import Image from "./Image";
import Italic from "./Italic";
@ -92,6 +94,8 @@ const Renderer: React.FC<Props> = ({ index, node }: Props) => {
return <Strikethrough {...(node.strikethroughNode as StrikethroughNode)} />;
case NodeType.MATH:
return <Math {...(node.mathNode as MathNode)} />;
case NodeType.HIGHLIGHT:
return <Highlight {...(node.highlightNode as HighlightNode)} />;
case NodeType.ESCAPING_CHARACTER:
return <EscapingCharacter {...(node.escapingCharacterNode as EscapingCharacterNode)} />;
default:

View File

@ -1,4 +1,5 @@
import { Dropdown, IconButton, Menu, MenuButton, MenuItem } from "@mui/joy";
import { Link } from "@mui/joy";
import toast from "react-hot-toast";
import Icon from "@/components/Icon";
import showPreviewMarkdownDialog from "@/components/PreviewMarkdownDialog";
@ -93,6 +94,11 @@ const MarkdownMenu = (props: Props) => {
<Icon.GanttSquare className="w-4 h-auto" />
<span>Preview</span>
</MenuItem>
<div className="-mt-0.5 pl-2">
<Link fontSize={12} href="https://www.usememos.com/docs/getting-started/content-syntax" target="_blank">
Content syntax
</Link>
</div>
</Menu>
</Dropdown>
);