| 1 | import { cva, type VariantProps } from "class-variance-authority"; |
| 2 | import { PlateStatic, type PlateStaticProps } from "platejs/static"; |
| 3 | |
| 4 | import { cn } from "@/lib/utils"; |
| 5 | |
| 6 | const editorVariants = cva( |
| 7 | cn( |
| 8 | "group/editor", |
| 9 | "relative w-full cursor-text overflow-x-hidden wrap-break-word whitespace-pre-wrap select-text", |
| 10 | "rounded-md ring-offset-background focus-visible:outline-hidden", |
| 11 | "placeholder:text-muted-foreground/80 data-slate-placeholder:**:top-[auto_!important] data-slate-placeholder:**:text-muted-foreground/80 data-slate-placeholder:**:opacity-100!", |
| 12 | "[&_strong]:font-bold", |
| 13 | ), |
| 14 | { |
| 15 | defaultVariants: { |
| 16 | variant: "none", |
| 17 | }, |
| 18 | variants: { |
| 19 | disabled: { |
| 20 | true: "cursor-not-allowed opacity-50", |
| 21 | }, |
| 22 | focused: { |
| 23 | true: "ring-2 ring-ring ring-offset-2", |
| 24 | }, |
| 25 | variant: { |
| 26 | ai: "w-full px-0 text-base md:text-sm", |
| 27 | aiChat: |
| 28 | "max-h-[min(70vh,320px)] w-full max-w-175 overflow-y-auto px-5 py-3 text-base md:text-sm", |
| 29 | default: |
| 30 | "size-full px-16 pt-4 pb-72 text-base sm:px-[max(64px,calc(50%-350px))]", |
| 31 | demo: "size-full px-16 pt-4 pb-72 text-base sm:px-[max(64px,calc(50%-350px))]", |
| 32 | fullWidth: "size-full px-16 pt-4 pb-72 text-base sm:px-24", |
| 33 | none: "", |
| 34 | select: "px-3 py-2 text-base data-readonly:w-fit", |
| 35 | }, |
| 36 | }, |
| 37 | }, |
| 38 | ); |
| 39 | |
| 40 | export function EditorStatic({ |
| 41 | className, |
| 42 | variant, |
| 43 | ...props |
| 44 | }: PlateStaticProps & VariantProps<typeof editorVariants>) { |
| 45 | return ( |
| 46 | <PlateStatic |
| 47 | className={cn(editorVariants({ variant }), className)} |
| 48 | {...props} |
| 49 | /> |
| 50 | ); |
| 51 | } |
| 52 |