'use client'; import * as React from 'react'; import type { PlateElementProps } from 'platejs/react'; import { useTodoListElement, useTodoListElementState, } from '@platejs/list-classic/react'; import { type VariantProps, cva } from 'class-variance-authority'; import { PlateElement } from 'platejs/react'; import { Checkbox } from '@/components/ui/checkbox'; import { cn } from '@/lib/utils'; const listVariants = cva('m-0 py-1 ps-6', { variants: { variant: { ol: 'list-decimal', ul: 'list-disc [&_ul]:list-[circle] [&_ul_ul]:list-[square]', }, }, }); export function ListElement({ variant, ...props }: PlateElementProps & VariantProps) { return ( {props.children} ); } export function BulletedListElement(props: PlateElementProps) { return ; } export function NumberedListElement(props: PlateElementProps) { return ; } export function TaskListElement(props: PlateElementProps) { return ( {props.children} ); } export function ListItemElement(props: PlateElementProps) { const isTaskList = 'checked' in props.element; if (isTaskList) { return ; } return ; } export function BaseListItemElement(props: PlateElementProps) { return ( {props.children} ); } export function TaskListItemElement(props: PlateElementProps) { const { element } = props; const state = useTodoListElementState({ element }); const { checkboxProps } = useTodoListElement(state); const [firstChild, ...otherChildren] = React.Children.toArray(props.children); return (
{firstChild}
{otherChildren}
); }