mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-10 22:41:17 +00:00
33 lines
834 B
TypeScript
33 lines
834 B
TypeScript
'use client';
|
|
|
|
import React from 'react';
|
|
|
|
import type { TLinkElement } from '@udecode/plate-link';
|
|
|
|
import { cn, withRef } from '@udecode/cn';
|
|
import { useElement } from '@udecode/plate-common/react';
|
|
import { useLink } from '@udecode/plate-link/react';
|
|
|
|
import { PlateElement } from './plate-element';
|
|
|
|
export const LinkElement = withRef<typeof PlateElement>(
|
|
({ children, className, ...props }, ref) => {
|
|
const element = useElement<TLinkElement>();
|
|
const { props: linkProps } = useLink({ element });
|
|
|
|
return (
|
|
<PlateElement
|
|
ref={ref}
|
|
as="a"
|
|
className={cn(
|
|
'font-medium text-primary underline decoration-primary underline-offset-4',
|
|
className
|
|
)}
|
|
{...(linkProps as any)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</PlateElement>
|
|
);
|
|
}
|
|
);
|