MdView.tsx 705 B

12345678910111213141516171819202122232425262728293031323334
  1. import { Typography } from "antd";
  2. import { TCodeConvertor, XmlToReact } from "./utilities";
  3. const { Paragraph, Text } = Typography;
  4. interface IWidget {
  5. html?: string;
  6. className?: string;
  7. placeholder?: string;
  8. wordWidget?: boolean;
  9. convertor?: TCodeConvertor;
  10. style?: React.CSSProperties;
  11. }
  12. const Widget = ({
  13. html,
  14. className,
  15. wordWidget = false,
  16. placeholder,
  17. convertor,
  18. style,
  19. }: IWidget) => {
  20. const jsx =
  21. html && html.trim() !== "" ? (
  22. XmlToReact(html, wordWidget, convertor)
  23. ) : (
  24. <Text type="secondary">{placeholder}</Text>
  25. );
  26. return (
  27. <Paragraph style={style} className={className}>
  28. {jsx}
  29. </Paragraph>
  30. );
  31. };
  32. export default Widget;