From 6c54f3c80435e9176feb1940819d9e9a63cb6a08 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 1 Sep 2024 16:31:05 +0300 Subject: [PATCH] client: Improve mind map saving & centering --- src/public/app/widgets/type_widgets/mind_map.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/public/app/widgets/type_widgets/mind_map.js b/src/public/app/widgets/type_widgets/mind_map.js index e9f5e0640..b5bc767c5 100644 --- a/src/public/app/widgets/type_widgets/mind_map.js +++ b/src/public/app/widgets/type_widgets/mind_map.js @@ -40,17 +40,19 @@ export default class MindMapWidget extends TypeWidget { this.#initLibrary(); } - await this.#loadData(note); + await this.#loadData(note); } cleanup() { this.triggeredByUserOperation = false; } - + async #loadData(note) { const blob = await note.getBlob(); - const content = blob.getJsonContent(); + const content = blob.getJsonContent() || MindElixir.new(); + this.mind.refresh(content); + this.mind.toCenter(); } #initLibrary() { @@ -63,7 +65,7 @@ export default class MindMapWidget extends TypeWidget { mind.init(MindElixir.new()); mind.bus.addListener("operation", (operation) => { this.triggeredByUserOperation = true; - if (operation.name !== "startEdit") { + if (operation.name !== "beginEdit") { this.spacedUpdate.scheduleUpdate(); } });