|
@@ -1,4 +1,4 @@
|
|
|
-import { Button, Dropdown } from "antd";
|
|
|
|
|
|
|
+import { Button, Dropdown, message } from "antd";
|
|
|
import { useState } from "react";
|
|
import { useState } from "react";
|
|
|
import {
|
|
import {
|
|
|
EditOutlined,
|
|
EditOutlined,
|
|
@@ -6,28 +6,35 @@ import {
|
|
|
MoreOutlined,
|
|
MoreOutlined,
|
|
|
FieldTimeOutlined,
|
|
FieldTimeOutlined,
|
|
|
LinkOutlined,
|
|
LinkOutlined,
|
|
|
|
|
+ CommentOutlined,
|
|
|
|
|
+ FileMarkdownOutlined,
|
|
|
} from "@ant-design/icons";
|
|
} from "@ant-design/icons";
|
|
|
import type { MenuProps } from "antd";
|
|
import type { MenuProps } from "antd";
|
|
|
import { ISentence } from "../SentEdit";
|
|
import { ISentence } from "../SentEdit";
|
|
|
import SentHistoryModal from "../../corpus/SentHistoryModal";
|
|
import SentHistoryModal from "../../corpus/SentHistoryModal";
|
|
|
|
|
+import { HandOutlinedIcon, JsonOutlinedIcon } from "../../../assets/icon";
|
|
|
|
|
|
|
|
interface IWidget {
|
|
interface IWidget {
|
|
|
data: ISentence;
|
|
data: ISentence;
|
|
|
children?: React.ReactNode;
|
|
children?: React.ReactNode;
|
|
|
onModeChange?: Function;
|
|
onModeChange?: Function;
|
|
|
onConvert?: Function;
|
|
onConvert?: Function;
|
|
|
|
|
+ onMenuClick?: Function;
|
|
|
}
|
|
}
|
|
|
const SentEditMenuWidget = ({
|
|
const SentEditMenuWidget = ({
|
|
|
data,
|
|
data,
|
|
|
children,
|
|
children,
|
|
|
onModeChange,
|
|
onModeChange,
|
|
|
onConvert,
|
|
onConvert,
|
|
|
|
|
+ onMenuClick,
|
|
|
}: IWidget) => {
|
|
}: IWidget) => {
|
|
|
const [isHover, setIsHover] = useState(false);
|
|
const [isHover, setIsHover] = useState(false);
|
|
|
const [timelineOpen, setTimelineOpen] = useState(false);
|
|
const [timelineOpen, setTimelineOpen] = useState(false);
|
|
|
|
|
|
|
|
const onClick: MenuProps["onClick"] = (e) => {
|
|
const onClick: MenuProps["onClick"] = (e) => {
|
|
|
- console.log(e);
|
|
|
|
|
|
|
+ if (typeof onMenuClick !== "undefined") {
|
|
|
|
|
+ onMenuClick(e.key);
|
|
|
|
|
+ }
|
|
|
switch (e.key) {
|
|
switch (e.key) {
|
|
|
case "json":
|
|
case "json":
|
|
|
if (typeof onConvert !== "undefined") {
|
|
if (typeof onConvert !== "undefined") {
|
|
@@ -55,14 +62,29 @@ const SentEditMenuWidget = ({
|
|
|
{
|
|
{
|
|
|
type: "divider",
|
|
type: "divider",
|
|
|
},
|
|
},
|
|
|
|
|
+ {
|
|
|
|
|
+ key: "suggestion",
|
|
|
|
|
+ label: "suggestion",
|
|
|
|
|
+ icon: <HandOutlinedIcon />,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ key: "discussion",
|
|
|
|
|
+ label: "discussion",
|
|
|
|
|
+ icon: <CommentOutlined />,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ type: "divider",
|
|
|
|
|
+ },
|
|
|
{
|
|
{
|
|
|
key: "markdown",
|
|
key: "markdown",
|
|
|
- label: "Markdown",
|
|
|
|
|
|
|
+ label: "To Markdown",
|
|
|
|
|
+ icon: <FileMarkdownOutlined />,
|
|
|
disabled: data.contentType === "markdown",
|
|
disabled: data.contentType === "markdown",
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
key: "json",
|
|
key: "json",
|
|
|
- label: "Json",
|
|
|
|
|
|
|
+ label: "To Json",
|
|
|
|
|
+ icon: <JsonOutlinedIcon />,
|
|
|
disabled: data.contentType === "json",
|
|
disabled: data.contentType === "json",
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -91,8 +113,8 @@ const SentEditMenuWidget = ({
|
|
|
/>
|
|
/>
|
|
|
<div
|
|
<div
|
|
|
style={{
|
|
style={{
|
|
|
- marginTop: "-1.2em",
|
|
|
|
|
- right: "0",
|
|
|
|
|
|
|
+ marginTop: "-4.2em",
|
|
|
|
|
+ right: 30,
|
|
|
position: "absolute",
|
|
position: "absolute",
|
|
|
display: isHover ? "block" : "none",
|
|
display: isHover ? "block" : "none",
|
|
|
}}
|
|
}}
|
|
@@ -100,13 +122,22 @@ const SentEditMenuWidget = ({
|
|
|
<Button
|
|
<Button
|
|
|
icon={<EditOutlined />}
|
|
icon={<EditOutlined />}
|
|
|
size="small"
|
|
size="small"
|
|
|
|
|
+ title="edit"
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
if (typeof onModeChange !== "undefined") {
|
|
if (typeof onModeChange !== "undefined") {
|
|
|
onModeChange("edit");
|
|
onModeChange("edit");
|
|
|
}
|
|
}
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
- <Button icon={<CopyOutlined />} size="small" />
|
|
|
|
|
|
|
+ <Button
|
|
|
|
|
+ icon={<CopyOutlined />}
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ onClick={() => {
|
|
|
|
|
+ navigator.clipboard.writeText(data.content).then(() => {
|
|
|
|
|
+ message.success("已经拷贝到剪贴板");
|
|
|
|
|
+ });
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
<Dropdown menu={{ items, onClick }} placement="bottomRight">
|
|
<Dropdown menu={{ items, onClick }} placement="bottomRight">
|
|
|
<Button icon={<MoreOutlined />} size="small" />
|
|
<Button icon={<MoreOutlined />} size="small" />
|
|
|
</Dropdown>
|
|
</Dropdown>
|