feat: support markdown
This commit is contained in:
parent
bd230ddd4f
commit
85d144a1e9
34 changed files with 2350 additions and 4 deletions
39
ui/components/Markdown/renderer/listItem.tsx
Normal file
39
ui/components/Markdown/renderer/listItem.tsx
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { css, cx } from "@emotion/css";
|
||||
import type { ListItem, Node } from "@yozora/ast";
|
||||
import React from "react";
|
||||
import { astClasses } from "../context";
|
||||
import { NodesRenderer } from "../NodesRenderer";
|
||||
|
||||
/**
|
||||
* Render `listItem`.
|
||||
*
|
||||
* @see https://www.npmjs.com/package/@yozora/ast#listitem
|
||||
* @see https://www.npmjs.com/package/@yozora/tokenizer-list-item
|
||||
*/
|
||||
export class ListItemRenderer extends React.Component<ListItem> {
|
||||
public override shouldComponentUpdate(nextProps: Readonly<ListItem>): boolean {
|
||||
const props = this.props;
|
||||
return props.children !== nextProps.children;
|
||||
}
|
||||
|
||||
public override render(): React.ReactElement {
|
||||
const childNodes: Node[] = this.props.children;
|
||||
return (
|
||||
<li className={cls}>
|
||||
<NodesRenderer nodes={childNodes} />
|
||||
</li>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const cls = cx(
|
||||
astClasses.listItem,
|
||||
css({
|
||||
position: "relative",
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
"> :last-child": {
|
||||
marginBottom: 0,
|
||||
},
|
||||
}),
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue