import { useEffect, useState } from "react";
import { useIntl } from "react-intl";
import {
Button,
Divider,
Input,
Modal,
Select,
Space,
Tabs,
Typography,
} from "antd";
import { FolderOpenOutlined } from "@ant-design/icons";
import type { TDisplayStyle } from "../Article";
import { VideoCtl } from "../Video";
import AttachmentDialog from "../../attachment/AttachmentDialog";
import type { IAttachmentRequest } from "../../../api/Attachments";
const { TextArea } = Input;
const { Paragraph } = Typography;
interface IWidget {
url?: string;
title?: string;
style?: TDisplayStyle;
onSelect?: Function;
onCancel?: Function;
}
const VideoTplWidget = ({ url, title, style = "modal" }: IWidget) => {
const intl = useIntl(); //i18n
const [currTitle, setCurrTitle] = useState(title);
const [styleText, setStyleText] = useState(style);
const [urlText, setUrlText] = useState(url);
const [tplText, setTplText] = useState("");
useEffect(() => {
setCurrTitle(title);
}, [title]);
useEffect(() => {
let tplText = `{{v|\n`;
tplText += `url=${urlText}|\n`;
tplText += `title=${currTitle}|\n`;
tplText += `style=${styleText}`;
tplText += "}}";
setTplText(tplText);
}, [currTitle, styleText, urlText]);
return (
<>
}>网盘}
onSelect={(value: IAttachmentRequest) => {
console.debug("VideoTpl onSelect", value);
setCurrTitle(value.title);
setUrlText(value.url);
}}
/>
{"标题:"}
) => {
setCurrTitle(event.target.value);
}}
/>
{"Url"}
) => {
setUrlText(event.target.value);
}}
/>
{"显示为:"}
),
},
{
label: `Code`,
key: "code",
children: (
),
},
]}
/>
复制到剪贴板
>
);
};
interface IModalWidget {
url?: string;
title?: string;
style?: TDisplayStyle;
trigger?: JSX.Element;
}
export const VideoTplModal = ({
url,
title,
style = "modal",
trigger,
}: IModalWidget) => {
const [isModalOpen, setIsModalOpen] = useState(false);
const showModal = () => {
setIsModalOpen(true);
};
const handleOk = () => {
setIsModalOpen(false);
};
const handleCancel = () => {
setIsModalOpen(false);
};
return (
<>
{trigger}
>
);
};
export default VideoTplWidget;