|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
import { TASK_LIST_CLASS, TASK_LIST_ITEM_CLASS } from "../constants";
|
|
|
|
|
import type { ReactMarkdownProps } from "./types";
|
|
|
|
|
|
|
|
|
|
interface ListProps extends React.HTMLAttributes<HTMLUListElement | HTMLOListElement>, ReactMarkdownProps {
|
|
|
|
|
@ -12,7 +13,7 @@ interface ListProps extends React.HTMLAttributes<HTMLUListElement | HTMLOListEle
|
|
|
|
|
*/
|
|
|
|
|
export const List = ({ ordered, children, className, node: _node, ...domProps }: ListProps) => {
|
|
|
|
|
const Component = ordered ? "ol" : "ul";
|
|
|
|
|
const isTaskList = className?.includes("contains-task-list");
|
|
|
|
|
const isTaskList = className?.includes(TASK_LIST_CLASS);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Component
|
|
|
|
|
@ -38,7 +39,7 @@ interface ListItemProps extends React.LiHTMLAttributes<HTMLLIElement>, ReactMark
|
|
|
|
|
* Applies specialized styling for task checkboxes
|
|
|
|
|
*/
|
|
|
|
|
export const ListItem = ({ children, className, node: _node, ...domProps }: ListItemProps) => {
|
|
|
|
|
const isTaskListItem = className?.includes("task-list-item");
|
|
|
|
|
const isTaskListItem = className?.includes(TASK_LIST_ITEM_CLASS);
|
|
|
|
|
|
|
|
|
|
if (isTaskListItem) {
|
|
|
|
|
return (
|
|
|
|
|
@ -48,7 +49,7 @@ export const ListItem = ({ children, className, node: _node, ...domProps }: List
|
|
|
|
|
// Task item styles: checkbox margins, inline paragraph, nested list indent
|
|
|
|
|
"[&>button]:mr-2 [&>button]:align-middle",
|
|
|
|
|
"[&>p]:inline [&>p]:m-0",
|
|
|
|
|
"[&>.contains-task-list]:pl-6",
|
|
|
|
|
`[&>.${TASK_LIST_CLASS}]:pl-6`,
|
|
|
|
|
className,
|
|
|
|
|
)}
|
|
|
|
|
{...domProps}
|
|
|
|
|
|