| 1 | /** biome-ignore-all lint/suspicious/noExplicitAny: This use requires any */ |
| 2 | "use client"; |
| 3 | |
| 4 | import { useLink } from "@platejs/link/react"; |
| 5 | import { type TLinkElement } from "platejs"; |
| 6 | import { PlateElement, type PlateElementProps } from "platejs/react"; |
| 7 | |
| 8 | export function LinkElement(props: PlateElementProps<TLinkElement>) { |
| 9 | const { props: linkProps } = useLink({ element: props.element }); |
| 10 | |
| 11 | return ( |
| 12 | <PlateElement |
| 13 | {...props} |
| 14 | as="a" |
| 15 | className="font-medium text-primary underline decoration-primary underline-offset-4" |
| 16 | attributes={{ |
| 17 | ...props.attributes, |
| 18 | ...(linkProps as any), |
| 19 | }} |
| 20 | > |
| 21 | {props.children} |
| 22 | </PlateElement> |
| 23 | ); |
| 24 | } |
| 25 |