diff --git a/src/pages/Templates.jsx b/src/pages/Templates.jsx index fe6ff81..9eb8265 100644 --- a/src/pages/Templates.jsx +++ b/src/pages/Templates.jsx @@ -176,6 +176,11 @@ export default function Templates() { newWindow.name = "t " + id; }; + const forkTemplate = (id) => { + const newWindow = window.open("/editor", "_blank"); + newWindow.name = "lt " + id; + }; + useEffect(() => { document.title = "Templates | drawDB"; }, []); @@ -225,7 +230,10 @@ export default function Templates() {
{t.title}
- @@ -252,7 +260,10 @@ export default function Templates() { {c.title}
-
diff --git a/src/pages/editor.jsx b/src/pages/editor.jsx index 63b8040..83887c1 100644 --- a/src/pages/editor.jsx +++ b/src/pages/editor.jsx @@ -493,7 +493,10 @@ export default function Editor() { return; } if (diagram) { - if (id === 0 && window.name === "") { + if ( + (id === 0 && window.name === "") || + window.name.split(" ")[0] === "lt" + ) { db.diagrams .add({ name: title, @@ -547,7 +550,7 @@ export default function Editor() { }; const name = window.name.split(" "); const op = name[0]; - const diagram = window.name === "" || op === "d"; + const diagram = window.name === "" || op === "d" || op === "lt"; save(diagram); }, [tables, relationships, notes, areas, types, title, id, state]); @@ -635,7 +638,7 @@ export default function Editor() { break; } case "lt": { - console.log("Loading template with id", did); + loadTemplate(did); break; } case "t": {