diff --git a/src/components/ControlPanel.jsx b/src/components/ControlPanel.jsx
index 6c30026..7c1e658 100644
--- a/src/components/ControlPanel.jsx
+++ b/src/components/ControlPanel.jsx
@@ -729,6 +729,23 @@ export default function ControlPanel({
function: saveDiagramAs,
shortcut: "Ctrl+Shift+S",
},
+ "Save as template": {
+ function: () => {
+ db.templates
+ .add({
+ title: title,
+ tables: tables,
+ relationships: relationships,
+ types: types,
+ notes: notes,
+ subjectAreas: areas,
+ custom: 1,
+ })
+ .then(() => {
+ Toast.success("Template saved!");
+ });
+ },
+ },
Share: {
function: () => {},
},
@@ -756,18 +773,6 @@ export default function ControlPanel({
.catch(() => Toast.error("Oops! Something went wrong."));
},
},
- "Flush storage": {
- function: async () => {
- db.delete()
- .then(() => {
- Toast.success("Storage flushed");
- window.location.reload(false);
- })
- .catch(() => {
- Toast.error("Oops! Something went wrong.");
- });
- },
- },
Import: {
function: fileImport,
shortcut: "Ctrl+I",
@@ -935,6 +940,18 @@ export default function ControlPanel({
return { ...prev, panning: !prev.panning };
}),
},
+ {
+ "Flush storage": async () => {
+ db.delete()
+ .then(() => {
+ Toast.success("Storage flushed");
+ window.location.reload(false);
+ })
+ .catch(() => {
+ Toast.error("Oops! Something went wrong.");
+ });
+ },
+ },
],
},
Exit: {
diff --git a/src/data/db.js b/src/data/db.js
index 62bac55..db1ba0a 100644
--- a/src/data/db.js
+++ b/src/data/db.js
@@ -5,7 +5,7 @@ const db = new Dexie("drawDB");
db.version(2).stores({
diagrams: "++id, lastModified",
- templates: "++id",
+ templates: "++id, custom",
});
db.on("populate", (transaction) => {
diff --git a/src/pages/Templates.jsx b/src/pages/Templates.jsx
index 4ade8ae..c112540 100644
--- a/src/pages/Templates.jsx
+++ b/src/pages/Templates.jsx
@@ -1,19 +1,18 @@
-import { useEffect } from "react";
+import { useEffect, useState } from "react";
import logo_light from "../assets/logo_light_46.png";
import { Link } from "react-router-dom";
import { Tabs, TabPane } from "@douyinfe/semi-ui";
-import { useLiveQuery } from "dexie-react-hooks";
import { db } from "../data/db";
import { calcPath } from "../utils";
-function Thumbnail({ diagram }) {
+function Thumbnail({ diagram, i }) {
const zoom = 0.3;
return (
-
+