import { Button, Dropdown, message } from "antd"; import { useState } from "react"; import { EditOutlined, CopyOutlined, MoreOutlined, FieldTimeOutlined, LinkOutlined, CommentOutlined, FileMarkdownOutlined, } from "@ant-design/icons"; import type { MenuProps } from "antd"; import { ISentence } from "../SentEdit"; import SentHistoryModal from "../../corpus/SentHistoryModal"; import { HandOutlinedIcon, JsonOutlinedIcon } from "../../../assets/icon"; import { useIntl } from "react-intl"; interface IWidget { data: ISentence; children?: React.ReactNode; onModeChange?: Function; onConvert?: Function; onMenuClick?: Function; } const SentEditMenuWidget = ({ data, children, onModeChange, onConvert, onMenuClick, }: IWidget) => { const [isHover, setIsHover] = useState(false); const [timelineOpen, setTimelineOpen] = useState(false); const intl = useIntl(); const onClick: MenuProps["onClick"] = (e) => { if (typeof onMenuClick !== "undefined") { onMenuClick(e.key); } switch (e.key) { case "json": if (typeof onConvert !== "undefined") { onConvert("json"); } break; case "markdown": if (typeof onConvert !== "undefined") { onConvert("markdown"); } break; case "timeline": setTimelineOpen(true); break; default: break; } }; const items: MenuProps["items"] = [ { key: "timeline", label: "时间线", icon: , }, { type: "divider", }, { key: "suggestion", label: "suggestion", icon: , }, { key: "discussion", label: "discussion", icon: , }, { type: "divider", }, { key: "markdown", label: "To Markdown", icon: , disabled: data.contentType === "markdown", }, { key: "json", label: "To Json", icon: , disabled: data.contentType === "json", }, { type: "divider", }, { key: "copy-link", label: intl.formatMessage({ id: "buttons.copy.link", }), icon: , }, ]; return (
{ setIsHover(true); }} onMouseLeave={() => { setIsHover(false); }} > setTimelineOpen(false)} sentId={data.id} />
{children}
); }; export default SentEditMenuWidget;