mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
client: Fix first show in mindmap
This commit is contained in:
parent
ff3d01f2c7
commit
1b08487ee9
@ -24,39 +24,51 @@ export default class MindMapWidget extends TypeWidget {
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$content = this.$widget.find(".mind-map-container");
|
||||
|
||||
libraryLoader
|
||||
.requireLibrary(libraryLoader.MIND_ELIXIR)
|
||||
.then(() => {
|
||||
this.#onLibraryLoaded();
|
||||
});
|
||||
this.$content = this.$widget.find(".mind-map-container");
|
||||
|
||||
super.doRender();
|
||||
}
|
||||
|
||||
#onLibraryLoaded() {
|
||||
async doRefresh(note) {
|
||||
if (this.triggeredByUserOperation) {
|
||||
this.triggeredByUserOperation = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!window.MindElixir) {
|
||||
await libraryLoader.requireLibrary(libraryLoader.MIND_ELIXIR);
|
||||
this.#initLibrary();
|
||||
}
|
||||
|
||||
await this.#loadData(note);
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
this.triggeredByUserOperation = false;
|
||||
}
|
||||
|
||||
async #loadData(note) {
|
||||
const blob = await note.getBlob();
|
||||
const content = blob.getJsonContent();
|
||||
this.mind.refresh(content);
|
||||
}
|
||||
|
||||
#initLibrary() {
|
||||
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();
|
||||
this.triggeredByUserOperation = true;
|
||||
if (operation.name !== "startEdit") {
|
||||
this.spacedUpdate.scheduleUpdate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async doRefresh(note) {
|
||||
if (!this.mind) {
|
||||
return;
|
||||
}
|
||||
|
||||
const blob = await note.getBlob();
|
||||
const content = blob.getJsonContent();
|
||||
this.mind.refresh(content);
|
||||
}
|
||||
|
||||
async getData() {
|
||||
const mind = this.mind;
|
||||
if (!mind) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user