diff --git a/src/components/control_panel.jsx b/src/components/control_panel.jsx index 782a6df..6fe2bb5 100644 --- a/src/components/control_panel.jsx +++ b/src/components/control_panel.jsx @@ -1,5 +1,4 @@ import { React, useState } from "react"; -import { menu } from "../data/data"; import { IconCaretdown, IconChevronRight, @@ -17,18 +16,241 @@ import { 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 && ( -