Skip to content

Commit 710d12e

Browse files
committed
save template on close
Signed-off-by: Teo Koon Peng <[email protected]>
1 parent 7f730d1 commit 710d12e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

diagram-editor/frontend/diagram-editor.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ import { allowEdges as getAllowEdges } from './utils/connection';
5252
import { exhaustiveCheck } from './utils/exhaustive-check';
5353
import { calculateScopeBounds, LAYOUT_OPTIONS } from './utils/layout';
5454
import { loadDiagramJson, loadEmpty, loadTemplate } from './utils/load-diagram';
55+
import { exportTemplate } from './utils/export-diagram';
56+
import { NodeManager } from './node-manager';
5557

5658
const NonCapturingPopoverContainer = ({
5759
children,
@@ -631,7 +633,17 @@ function DiagramEditor() {
631633
color="primary"
632634
aria-label="Save"
633635
sx={{ position: 'absolute', right: 64, bottom: 64 }}
634-
onClick={() => updateEditorModeAction({ mode: EditorMode.Normal })}
636+
onClick={() => {
637+
const exportedTemplate = exportTemplate(
638+
new NodeManager(nodes),
639+
edges,
640+
);
641+
setTemplates((prev) => ({
642+
...prev,
643+
[editorMode.templateId]: exportedTemplate,
644+
}));
645+
updateEditorModeAction({ mode: EditorMode.Normal });
646+
}}
635647
>
636648
<MaterialSymbol symbol="check" />
637649
</Fab>

0 commit comments

Comments
 (0)