import { React, useState } from "react"; import { IconCaretdown, IconChevronRight, IconShareStroked, IconChevronUp, IconChevronDown, IconCheckboxTick, } from "@douyinfe/semi-icons"; import { Link } from "react-router-dom"; import icon from "../assets/icon_dark_64.png"; import { Avatar, AvatarGroup, Button, Divider, Dropdown, Form, Image, Modal, } from "@douyinfe/semi-ui"; import { toPng } from "html-to-image"; import { saveAs } from "file-saver"; export default function ControlPanel() { const [showToolBar, setShowToolBar] = useState(true); const [visible, setVisible] = useState(false); const [dataUrl, setDataUrl] = useState(""); const [filename, setFilename] = useState( `diagram_${new Date().toISOString()}` ); const menu = { File: { New: { children: [], function: () => console.log("New"), }, "New window": { children: [], function: () => {}, }, Save: { children: [], function: () => {}, }, "Save as": { children: [], function: () => {}, }, Share: { children: [], function: () => {}, }, Rename: { children: [], function: () => {}, }, Import: { children: [], function: () => {}, }, "Export as": { children: [ { ".png": () => { toPng(document.getElementById("canvas")).then(function (dataUrl) { setDataUrl(dataUrl); }); setVisible(true); }, }, { ".jpg": () => {} }, { ".xml": () => {} }, { ".svg": () => {} }, { ".xml": () => {} }, ], function: () => {}, }, "Export source": { children: [ { MySQL: () => {} }, { PostgreSQL: () => {} }, { DBML: () => {} }, ], function: () => {}, }, Properties: { children: [], function: () => {}, }, Close: { children: [], function: () => {}, }, }, Edit: { Undo: { children: [], function: () => {}, }, Redo: { children: [], function: () => {}, }, Cut: { children: [], function: () => {}, }, Copy: { children: [], function: () => {}, }, "Copy as image": { children: [], function: () => {}, }, Paste: { children: [], function: () => {}, }, Delete: { children: [], function: () => {}, }, "Edit table": { children: [], function: () => {}, }, }, View: { Toolbar: { children: [], function: () => {}, }, Grid: { children: [], function: () => {}, }, Sidebar: { children: [], function: () => {}, }, Editor: { children: [], function: () => {}, }, "Strict mode": { children: [], function: () => {}, }, "Reset view": { children: [], function: () => {}, }, "View schema": { children: [], function: () => {}, }, Theme: { children: [{ Light: () => {} }, { Dark: () => {} }], function: () => {}, }, "Zoom in": { children: [], function: () => {}, }, "Zoom out": { children: [], function: () => {}, }, Fullscreen: { children: [], function: () => {}, }, }, Insert: { "New table": { children: [], function: () => {}, }, "New relationship": { children: [], function: () => {}, }, Note: { children: [], function: () => {}, }, Image: { children: [], function: () => {}, }, Textbox: { children: [], function: () => {}, }, Shape: { children: [], function: () => {}, }, }, Logs: { "Open logs": { children: [], function: () => {}, }, "Commit changes": { children: [], function: () => {}, }, "Revert changes": { children: [], function: () => {}, }, "View commits": { children: [], function: () => {}, }, }, Help: { Shortcuts: { children: [], function: () => {}, }, "Ask us on discord": { children: [], function: () => {}, }, "Tweet us": { children: [], function: () => {}, }, "Found a bug": { children: [], function: () => {}, }, }, }; return ( <> {showToolBar && ( )}
}> Header }> Overview }> Services }> Fullscreen } trigger="click" >
Fit window {[ "25%", "50%", "75%", "100%", "125%", "150%", "200%", "300%", ].map((e, i) => ( {e} ))}
%
} /> } trigger="click" >
zoom
Table Note Subject area Text } trigger="click" >
saveAs(dataUrl, `${filename}.png`)} afterClose={() => setFilename(`diagram_${new Date().toISOString()}`)} onCancel={() => setVisible(false)} centered closeOnEsc={true} okText="Export" cancelText="Cancel" width={470} > Diagram
{ console.log(value.values); setFilename(value.values["filename"]); }} > .png} initValue={filename} />
); }