Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

Fixed save for diagrams

1ilit50d82fb4352e
diff --git a/src/components/ControlPanel.jsx b/src/components/ControlPanel.jsx
index 680f1b51..80e99fe8 100644
--- a/src/components/ControlPanel.jsx
+++ b/src/components/ControlPanel.jsx
@@ -666,15 +666,29 @@ export default function ControlPanel({ diagramId, setDiagramId }) {
del();
};
const save = () => {
- db.diagrams.add({
- name: title,
- lastModified: new Date(),
- tables: tables,
- references: relationships,
- types: types,
- notes: notes,
- areas: areas,
- });
+ if (diagramId === 0) {
+ db.diagrams
+ .add({
+ name: title,
+ lastModified: new Date(),
+ tables: tables,
+ references: relationships,
+ types: types,
+ notes: notes,
+ areas: areas,
+ })
+ .then((id) => setDiagramId(id));
+ } else {
+ db.diagrams.update(diagramId, {
+ name: title,
+ lastModified: new Date(),
+ tables: tables,
+ references: relationships,
+ types: types,
+ notes: notes,
+ areas: areas,
+ });
+ }
};
const open = () => setVisible(MODAL.OPEN);
const saveDiagramAs = () => setVisible(MODAL.SAVEAS);
@@ -1091,7 +1105,7 @@ export default function ControlPanel({ diagramId, setDiagramId }) {
case MODAL.IMPORT:
return "Import diagram";
case MODAL.CODE:
- return "Export diagram";
+ return "Export source";
case MODAL.IMG:
return "Export image";
case MODAL.RENAME:
diff --git a/src/pages/shortcuts.jsx b/src/pages/shortcuts.jsx
index 03066a61..f2cffd23 100644
--- a/src/pages/shortcuts.jsx
+++ b/src/pages/shortcuts.jsx
@@ -5,6 +5,13 @@ import { AutoComplete, Button } from "@douyinfe/semi-ui";
import { IconSearch, IconSun, IconMoon } from "@douyinfe/semi-icons";
const shortcuts = [
+ { shortcut: "CTRL+S", title: "Save diagram", description: "" },
+ { shortcut: "CTRL+Shift+S", title: "Save diagram as", description: "" },
+ {
+ shortcut: "CTRL+O",
+ title: "Open a diagram",
+ description: "Load a saved diagram",
+ },
{ shortcut: "CTRL+C", title: "Copy selected element", description: "" },
{ shortcut: "CTRL+V", title: "Paste selected element", description: "" },
{ shortcut: "CTRL+X", title: "Cut selected element", description: "" },
@@ -180,6 +187,14 @@ export default function Shortcuts() {
</div>
))}
</div>
+ <hr
+ className={`${
+ theme === "dark" ? "border-zinc-700" : "border-zinc-300"
+ } my-1`}
+ />
+ <div className="text-center text-sm py-3">
+ &copy; 2024 <strong>drawDB</strong> - All right reserved.
+ </div>
</>
);
}