"use client"; import { isOrderedList } from "@platejs/list"; import { useTodoListElement, useTodoListElementState } from "@platejs/list/react"; import type { TListElement } from "platejs"; import { type PlateElementProps, type RenderNodeWrapper, useReadOnly } from "platejs/react"; import type React from "react"; import { Checkbox } from "@/components/ui/checkbox"; import { cn } from "@/lib/utils"; const config: Record< string, { Li: React.FC; Marker: React.FC; } > = { todo: { Li: TodoLi, Marker: TodoMarker, }, }; export const BlockList: RenderNodeWrapper = (props) => { if (!props.element.listStyleType) return; return (props) => ; }; function List(props: PlateElementProps) { const { listStart, listStyleType } = props.element as TListElement; const { Li, Marker } = config[listStyleType] ?? {}; const List = isOrderedList(props.element) ? "ol" : "ul"; return ( {Marker && } {Li ?
  • :
  • {props.children}
  • }
    ); } function TodoMarker(props: PlateElementProps) { const state = useTodoListElementState({ element: props.element }); const { checkboxProps } = useTodoListElement(state); const readOnly = useReadOnly(); return (
    ); } function TodoLi(props: PlateElementProps) { return (
  • {props.children}
  • ); }