| 1 | "use client"; |
| 2 | |
| 3 | import { PlateElement, type PlateElementProps } from "platejs/react"; |
| 4 | |
| 5 | import { cn } from "@/lib/utils"; |
| 6 | import { type TBulletGroupElement } from "../plugins/bullet-plugin"; |
| 7 | import { columnSizeVariant, getDefaultColumnSize } from "../utils"; |
| 8 | |
| 9 | export function BulletsElement({ |
| 10 | element, |
| 11 | children, |
| 12 | className, |
| 13 | ref, |
| 14 | ...props |
| 15 | }: PlateElementProps<TBulletGroupElement>) { |
| 16 | const { alignment = "center" } = element; |
| 17 | const columnSize = |
| 18 | element.columnSize ?? getDefaultColumnSize(element.children.length); |
| 19 | |
| 20 | return ( |
| 21 | <PlateElement |
| 22 | ref={ref} |
| 23 | element={element} |
| 24 | className={cn("relative my-0", className)} |
| 25 | {...props} |
| 26 | > |
| 27 | <div |
| 28 | className={cn( |
| 29 | "max-w-full gap-6", |
| 30 | columnSizeVariant({ columnSize }), |
| 31 | alignment === "left" && "justify-start", |
| 32 | alignment === "right" && "justify-end", |
| 33 | alignment === "center" && "justify-center", |
| 34 | )} |
| 35 | > |
| 36 | {children} |
| 37 | </div> |
| 38 | </PlateElement> |
| 39 | ); |
| 40 | } |
| 41 |