WordCardByDict.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { Button, Card, Popover, Space, Tabs } from "antd";
  2. import { Typography } from "antd";
  3. import { InfoCircleOutlined } from "@ant-design/icons";
  4. import Marked from "../general/Marked";
  5. import MdView from "../template/MdView";
  6. import "./style.css";
  7. import DictInfoCopyRef from "./DictInfoCopyRef";
  8. const { Title, Text } = Typography;
  9. export interface IWordByDict {
  10. dictname: string;
  11. description?: string;
  12. meta?: IDictInfo;
  13. word?: string;
  14. note?: string;
  15. anchor: string;
  16. }
  17. export interface IDictInfo {
  18. author: string;
  19. publisher: string;
  20. published?: string;
  21. url: string;
  22. }
  23. interface IWidgetWordCardByDict {
  24. data: IWordByDict;
  25. children?: React.ReactNode;
  26. }
  27. const WordCardByDictWidget = ({ data, children }: IWidgetWordCardByDict) => {
  28. return (
  29. <Card>
  30. <Space>
  31. <Title level={5} id={data.anchor}>
  32. {data.dictname}
  33. </Title>
  34. <Popover
  35. overlayStyle={{ maxWidth: 600 }}
  36. content={
  37. <div>
  38. <Tabs
  39. size="small"
  40. style={{ width: 600 }}
  41. items={[
  42. {
  43. label: "详情",
  44. key: "info",
  45. children: (
  46. <div>
  47. <div>
  48. <Text strong>{data.dictname}</Text>
  49. </div>
  50. <div>
  51. <Text type="secondary">Author:</Text>
  52. <Text>{data.meta?.author}</Text>
  53. </div>
  54. <div>
  55. <Text type="secondary">Publish:</Text>
  56. <Text>{data.meta?.publisher}</Text>
  57. </div>
  58. <div>
  59. <Text type="secondary">At:</Text>
  60. <Text>{data.meta?.published}</Text>
  61. </div>
  62. <Marked text={data.description} />
  63. </div>
  64. ),
  65. },
  66. {
  67. label: "复制引用信息",
  68. key: "reference",
  69. children: <DictInfoCopyRef data={data} />,
  70. },
  71. ]}
  72. />
  73. </div>
  74. }
  75. placement="bottom"
  76. >
  77. <Button type="link" icon={<InfoCircleOutlined />} />
  78. </Popover>
  79. </Space>
  80. <div className="dict_content">
  81. <MdView html={data.note} />
  82. </div>
  83. {children}
  84. </Card>
  85. );
  86. };
  87. export default WordCardByDictWidget;