diff --git a/src/components/control_panel.jsx b/src/components/control_panel.jsx index 52434c4..88c0f8b 100644 --- a/src/components/control_panel.jsx +++ b/src/components/control_panel.jsx @@ -34,6 +34,7 @@ import { enterFullscreen, exitFullscreen, ddbDiagramIsValid, + dataURItoBlob, } from "../utils"; import { AreaContext, @@ -246,6 +247,15 @@ export default function ControlPanel(props) { children: [], function: () => {}, }, + Clear: { + children: [], + function: () => { + setTables([]); + setRelationships([]); + setAreas([]); + setNotes([]); + }, + }, Cut: { children: [], function: () => {}, @@ -254,14 +264,26 @@ export default function ControlPanel(props) { children: [], function: () => {}, }, - "Copy as image": { - children: [], - function: () => {}, - }, Paste: { children: [], function: () => {}, }, + "Copy as image": { + children: [], + function: () => { + toPng(document.getElementById("canvas")).then(function (dataUrl) { + const blob = dataURItoBlob(dataUrl); + navigator.clipboard + .write([new ClipboardItem({ "image/png": blob })]) + .then(() => { + Toast.success("Copied to clipboard."); + }) + .catch((error) => { + Toast.error("Could not copy to clipboard."); + }); + }); + }, + }, Delete: { children: [], function: () => {}, diff --git a/src/components/editor_panel.jsx b/src/components/editor_panel.jsx index 4bc1b84..3a358ad 100644 --- a/src/components/editor_panel.jsx +++ b/src/components/editor_panel.jsx @@ -60,7 +60,7 @@ const EditorPanel = (props) => { return (