'use client';

import React from 'react';

import { cn, withRef } from '@udecode/cn';
import { PlateLeaf } from '@udecode/plate-common/react';

export const CodeLeaf = withRef<typeof PlateLeaf>(
  ({ children, className, ...props }, ref) => {
    return (
      <PlateLeaf
        ref={ref}
        as='code'
        className={cn(
          className,
          'whitespace-pre-wrap rounded-md bg-zinc-100 px-[0.3em] py-[0.2em] font-mono text-sm dark:bg-zinc-800'
        )}
        {...props}
      >
        {children}
      </PlateLeaf>
    );
  }
);