ArticleEditTools.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { Link } from "react-router";
  2. import { useIntl } from "react-intl";
  3. import { TeamOutlined } from "@ant-design/icons";
  4. import { Button, Space } from "antd";
  5. import ShareModal from "../share/ShareModal";
  6. import TplBuilder from "../tpl-builder/TplBuilder";
  7. import AddToAnthology from "../anthology/AddToAnthology";
  8. import { EResType } from "../share/utils";
  9. import { articlePath } from "../../utils";
  10. interface IWidget {
  11. studioName?: string;
  12. articleId?: string;
  13. title?: string;
  14. }
  15. const ArticleEditToolsWidget = ({
  16. studioName,
  17. articleId,
  18. title = "title",
  19. }: IWidget) => {
  20. const intl = useIntl();
  21. return (
  22. <Space>
  23. <TplBuilder trigger={<Button type="link">{"<t>"}</Button>} />
  24. {articleId ? (
  25. <AddToAnthology
  26. trigger={<Button type="link">加入文集</Button>}
  27. studioName={studioName}
  28. articleIds={[articleId]}
  29. />
  30. ) : undefined}
  31. {articleId ? (
  32. <ShareModal
  33. trigger={
  34. <Button type="link" icon={<TeamOutlined />}>
  35. {intl.formatMessage({
  36. id: "buttons.share",
  37. })}
  38. </Button>
  39. }
  40. resId={articleId}
  41. resType={EResType.article}
  42. />
  43. ) : undefined}
  44. <Link to={articlePath("article", articleId ?? "")} target="_blank">
  45. {intl.formatMessage({ id: "buttons.open.in.tab" })}
  46. </Link>
  47. <TplBuilder
  48. title={title}
  49. tpl="article"
  50. articleId={articleId}
  51. trigger={<Button type="link">获取模版</Button>}
  52. />
  53. </Space>
  54. );
  55. };
  56. export default ArticleEditToolsWidget;