mirror of
https://github.com/usememos/memos.git
synced 2025-02-15 02:40:53 +01:00
chore: fix renderer props
This commit is contained in:
parent
ce2d37b90c
commit
f563b58a85
@ -1,7 +1,8 @@
|
||||
import { Node } from "@/types/proto/api/v2/markdown_service";
|
||||
import Renderer from "./Renderer";
|
||||
import { BaseProps } from "./types";
|
||||
|
||||
interface Props {
|
||||
interface Props extends BaseProps {
|
||||
children: Node[];
|
||||
}
|
||||
|
||||
@ -9,7 +10,7 @@ const Blockquote: React.FC<Props> = ({ children }: Props) => {
|
||||
return (
|
||||
<blockquote>
|
||||
{children.map((child, index) => (
|
||||
<Renderer key={`${child.type}-${index}`} node={child} />
|
||||
<Renderer key={`${child.type}-${index}`} index={String(index)} node={child} />
|
||||
))}
|
||||
</blockquote>
|
||||
);
|
||||
|
@ -10,7 +10,7 @@ const Bold: React.FC<Props> = ({ children }: Props) => {
|
||||
return (
|
||||
<strong>
|
||||
{children.map((child, index) => (
|
||||
<Renderer key={`${child.type}-${index}`} node={child} />
|
||||
<Renderer key={`${child.type}-${index}`} index={String(index)} node={child} />
|
||||
))}
|
||||
</strong>
|
||||
);
|
||||
|
@ -4,8 +4,9 @@ import copy from "copy-to-clipboard";
|
||||
import hljs from "highlight.js";
|
||||
import toast from "react-hot-toast";
|
||||
import Icon from "../Icon";
|
||||
import { BaseProps } from "./types";
|
||||
|
||||
interface Props {
|
||||
interface Props extends BaseProps {
|
||||
language: string;
|
||||
content: string;
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Node } from "@/types/proto/api/v2/markdown_service";
|
||||
import Renderer from "./Renderer";
|
||||
import { BaseProps } from "./types";
|
||||
|
||||
interface Props {
|
||||
interface Props extends BaseProps {
|
||||
level: number;
|
||||
children: Node[];
|
||||
}
|
||||
@ -24,7 +25,7 @@ const Heading: React.FC<Props> = ({ level, children }: Props) => {
|
||||
return (
|
||||
<Head className={className}>
|
||||
{children.map((child, index) => (
|
||||
<Renderer key={`${child.type}-${index}`} node={child} />
|
||||
<Renderer key={`${child.type}-${index}`} index={String(index)} node={child} />
|
||||
))}
|
||||
</Head>
|
||||
);
|
||||
|
@ -1,4 +1,6 @@
|
||||
interface Props {
|
||||
import { BaseProps } from "./types";
|
||||
|
||||
interface Props extends BaseProps {
|
||||
symbol: string;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
interface Props {}
|
||||
import { BaseProps } from "./types";
|
||||
|
||||
interface Props extends BaseProps {}
|
||||
|
||||
const LineBreak: React.FC<Props> = () => {
|
||||
return <br />;
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Node } from "@/types/proto/api/v2/markdown_service";
|
||||
import Renderer from "./Renderer";
|
||||
import { BaseProps } from "./types";
|
||||
|
||||
interface Props {
|
||||
interface Props extends BaseProps {
|
||||
number: string;
|
||||
children: Node[];
|
||||
}
|
||||
@ -15,7 +16,7 @@ const OrderedList: React.FC<Props> = ({ number, children }: Props) => {
|
||||
</div>
|
||||
<div>
|
||||
{children.map((child, index) => (
|
||||
<Renderer key={`${child.type}-${index}`} node={child} />
|
||||
<Renderer key={`${child.type}-${index}`} index={String(index)} node={child} />
|
||||
))}
|
||||
</div>
|
||||
</li>
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Node } from "@/types/proto/api/v2/markdown_service";
|
||||
import Renderer from "./Renderer";
|
||||
import { BaseProps } from "./types";
|
||||
|
||||
interface Props {
|
||||
interface Props extends BaseProps {
|
||||
children: Node[];
|
||||
}
|
||||
|
||||
@ -9,7 +10,7 @@ const Paragraph: React.FC<Props> = ({ children }: Props) => {
|
||||
return (
|
||||
<p>
|
||||
{children.map((child, index) => (
|
||||
<Renderer key={`${child.type}-${index}`} node={child} />
|
||||
<Renderer key={`${child.type}-${index}`} index={String(index)} node={child} />
|
||||
))}
|
||||
</p>
|
||||
);
|
||||
|
@ -51,19 +51,19 @@ interface Props {
|
||||
const Renderer: React.FC<Props> = ({ index, node }: Props) => {
|
||||
switch (node.type) {
|
||||
case NodeType.LINE_BREAK:
|
||||
return <LineBreak />;
|
||||
return <LineBreak index={index} />;
|
||||
case NodeType.PARAGRAPH:
|
||||
return <Paragraph {...(node.paragraphNode as ParagraphNode)} />;
|
||||
return <Paragraph index={index} {...(node.paragraphNode as ParagraphNode)} />;
|
||||
case NodeType.CODE_BLOCK:
|
||||
return <CodeBlock {...(node.codeBlockNode as CodeBlockNode)} />;
|
||||
return <CodeBlock index={index} {...(node.codeBlockNode as CodeBlockNode)} />;
|
||||
case NodeType.HEADING:
|
||||
return <Heading {...(node.headingNode as HeadingNode)} />;
|
||||
return <Heading index={index} {...(node.headingNode as HeadingNode)} />;
|
||||
case NodeType.HORIZONTAL_RULE:
|
||||
return <HorizontalRule {...(node.horizontalRuleNode as HorizontalRuleNode)} />;
|
||||
return <HorizontalRule index={index} {...(node.horizontalRuleNode as HorizontalRuleNode)} />;
|
||||
case NodeType.BLOCKQUOTE:
|
||||
return <Blockquote {...(node.blockquoteNode as BlockquoteNode)} />;
|
||||
return <Blockquote index={index} {...(node.blockquoteNode as BlockquoteNode)} />;
|
||||
case NodeType.ORDERED_LIST:
|
||||
return <OrderedList {...(node.orderedListNode as OrderedListNode)} />;
|
||||
return <OrderedList index={index} {...(node.orderedListNode as OrderedListNode)} />;
|
||||
case NodeType.UNORDERED_LIST:
|
||||
return <UnorderedList {...(node.unorderedListNode as UnorderedListNode)} />;
|
||||
case NodeType.TASK_LIST:
|
||||
|
@ -15,7 +15,7 @@ const UnorderedList: React.FC<Props> = ({ children }: Props) => {
|
||||
</div>
|
||||
<div>
|
||||
{children.map((child, index) => (
|
||||
<Renderer key={`${child.type}-${index}`} node={child} />
|
||||
<Renderer key={`${child.type}-${index}`} index={String(index)} node={child} />
|
||||
))}
|
||||
</div>
|
||||
</li>
|
||||
|
@ -1 +1,6 @@
|
||||
export * from "./context";
|
||||
|
||||
export interface BaseProps {
|
||||
index: string;
|
||||
className?: string;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user