/**
 * KRA - Rich Text Viewer Component
 * Display rich text content
 */
import React from 'react';
import { Typography } from 'antd';

const { Paragraph } = Typography;

interface RichTextViewerProps {
  content?: string;
  className?: string;
  style?: React.CSSProperties;
}

const RichTextViewer: React.FC<RichTextViewerProps> = ({
  content,
  className,
  style,
}) => {
  if (!content) {
    return <div className={className} style={{ color: '#999', ...style }}>暂无内容</div>;
  }

  // If content is HTML, render it safely
  if (content.includes('<') && content.includes('>')) {
    return (
      <div
        className={className}
        style={style}
        dangerouslySetInnerHTML={{ __html: content }}
      />
    );
  }

  // Plain text with line breaks
  return (
    <Paragraph className={className} style={{ whiteSpace: 'pre-wrap', ...style }}>
      {content}
    </Paragraph>
  );
};

export default RichTextViewer;
