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); }} /> {"显示为:"}