From 10df00d62fbd578c3cc705b39a0d6e9e1bf906e9 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 1 Sep 2024 15:41:59 +0300 Subject: [PATCH] client: Save content of mind map --- .../app/widgets/type_widgets/mind_map.js | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/public/app/widgets/type_widgets/mind_map.js b/src/public/app/widgets/type_widgets/mind_map.js index ef7ac39b0..4a7e98125 100644 --- a/src/public/app/widgets/type_widgets/mind_map.js +++ b/src/public/app/widgets/type_widgets/mind_map.js @@ -29,16 +29,35 @@ export default class MindMapWidget extends TypeWidget { libraryLoader .requireLibrary(libraryLoader.MIND_ELIXIR) .then(() => { - const mind = new MindElixir({ - el: this.$content[0], - direction: MindElixir.LEFT - }); - mind.init(MindElixir.new()); + this.#onLibraryLoaded(); }); super.doRender(); } + #onLibraryLoaded() { + const mind = new MindElixir({ + el: this.$content[0], + direction: MindElixir.LEFT + }); + this.mind = mind; + mind.init(MindElixir.new()); + mind.bus.addListener("operation", (operation) => { + this.spacedUpdate.scheduleUpdate(); + }); + } + + async getData() { + const mind = this.mind; + if (!mind) { + return; + } + + return { + content: mind.getDataString() + }; + } + async entitiesReloadedEvent({loadResults}) { if (loadResults.isNoteReloaded(this.noteId)) { this.refresh();