Skip to content

Build your personal knowledge base with Trilium Notes

client: Save content of mind map

Elian Doran10df00d62fbd
diff --git a/src/public/app/widgets/type_widgets/mind_map.js b/src/public/app/widgets/type_widgets/mind_map.js
index ef7ac39b05..4a7e981258 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();