import React from 'react'; import { CopyButton } from './CopyButton'; import { DownloadButton } from './DownloadButton'; interface CustomBlockquoteProps extends React.HTMLAttributes { isEditable?: boolean; 'data-show-copy'?: string | boolean; 'data-show-download'?: string | boolean; } export const CustomBlockquote: React.FC = ({ children, style, className = '', isEditable, 'data-show-copy': showCopyData, 'data-show-download': showDownloadData, ...props }) => { // Extract text content for copy button const getTextContent = (node: React.ReactNode): string => { if (typeof node === 'string') return node; if (Array.isArray(node)) return node.map(getTextContent).join(''); if (React.isValidElement(node)) return getTextContent((node as React.ReactElement).props.children); return ''; }; const quoteText = getTextContent(children); const showCopyButton = showCopyData === 'true' || showCopyData === true; const showDownloadButton = showDownloadData === 'true' || showDownloadData === true; // Ensure we have default styles if not provided, but respect overrides const computedStyle: React.CSSProperties = { position: 'relative', marginBottom: '1rem', display: 'flex', flexDirection: 'column', justifyContent: 'center', overflow: 'visible', maxWidth: '100%', boxSizing: 'border-box', ...style, // Allow style prop to override defaults }; // Handle width specifically to ensure it doesn't break layout if (computedStyle.width === 'auto' || !computedStyle.width) { computedStyle.width = '100%'; } return (
{children}
{showCopyButton && ( )} {showDownloadButton && ( )}
); };