mirror of
https://github.com/usememos/memos.git
synced 2025-12-19 07:08:55 +08:00
make margin left based on number in ol
This commit is contained in:
parent
9f8921d3b9
commit
f645a86699
1 changed files with 16 additions and 5 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { useMemo } from "react";
|
||||||
import { Node } from "@/types/proto/api/v1/markdown_service";
|
import { Node } from "@/types/proto/api/v1/markdown_service";
|
||||||
import Renderer from "./Renderer";
|
import Renderer from "./Renderer";
|
||||||
import { BaseProps } from "./types";
|
import { BaseProps } from "./types";
|
||||||
|
|
@ -8,12 +9,22 @@ interface Props extends BaseProps {
|
||||||
children: Node[];
|
children: Node[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const OrderedListItem: React.FC<Props> = ({ children }: Props) => {
|
const OrderedListItem: React.FC<Props> = ({ children, number }: Props) => {
|
||||||
|
const ml = useMemo(
|
||||||
|
() =>
|
||||||
|
number.length > 1
|
||||||
|
? {
|
||||||
|
marginLeft: 8 * (number.length - 1),
|
||||||
|
}
|
||||||
|
: {},
|
||||||
|
[number],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li>
|
<li style={ml}>
|
||||||
{children.map((child, index) => (
|
{children.map((child, index) => {
|
||||||
<Renderer key={`${child.type}-${index}`} index={String(index)} node={child} />
|
return <Renderer key={`${child.type}-${index}`} index={String(index)} node={child} />;
|
||||||
))}
|
})}
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue