MdView.tsx 750 B

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