feat: implement indent for list nodes

This commit is contained in:
Steven
2024-01-14 22:19:03 +08:00
parent d44e74bd1e
commit 98762be1e5
14 changed files with 310 additions and 167 deletions

View File

@ -1,22 +1,29 @@
import { repeat } from "lodash-es";
import { Node } from "@/types/proto/api/v2/markdown_service";
import Renderer from "./Renderer";
interface Props {
symbol: string;
indent: number;
children: Node[];
}
const UnorderedList: React.FC<Props> = ({ children }: Props) => {
const UnorderedList: React.FC<Props> = ({ indent, children }: Props) => {
return (
<ul>
<li className="grid grid-cols-[24px_1fr] gap-1">
<div className="w-7 h-6 flex justify-center items-center">
<span className="opacity-80"></span>
<li className="w-full flex flex-row">
<div className="block font-mono shrink-0">
<span>{repeat(" ", indent)}</span>
</div>
<div>
{children.map((child, index) => (
<Renderer key={`${child.type}-${index}`} index={String(index)} node={child} />
))}
<div className="w-auto grid grid-cols-[24px_1fr] gap-1">
<div className="w-7 h-6 flex justify-center items-center">
<span className="opacity-80"></span>
</div>
<div>
{children.map((child, index) => (
<Renderer key={`${child.type}-${index}`} index={String(index)} node={child} />
))}
</div>
</div>
</li>
</ul>