Skip to content

Commit

Permalink
fix: should not leave parent node blank when there is no node
Browse files Browse the repository at this point in the history
  • Loading branch information
Quorafind committed Dec 23, 2022
1 parent 587072c commit f37bfbd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
51 changes: 26 additions & 25 deletions canvasMindMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,31 +102,32 @@ export default class CanvasMindMap extends Plugin {

tempEdge.render();
} else {
const canvasFile = await this.app.vault.cachedRead(canvas.view.file);
const canvasFileData = JSON.parse(canvasFile);

canvasFileData.edges.push({
id: random(16),
fromNode: node1.id,
fromSide:"right",
toNode: node2.id,
toSide: "left"
});
canvasFileData.nodes.push({
id: node2.id,
x: node2.x,
y: node2.y,
width: node2.width,
height: node2.height,
type: "text",
text: node2.text,
})

canvas.setData(canvasFileData);
canvas.requestSave();
canvas.requestUpdateFileOpen();

await this.app.vault.modify(canvas.view.file, JSON.stringify(canvasFileData, null, 2));
setTimeout(async () => {
const canvasFile = await this.app.vault.cachedRead(canvas.view.file);
const canvasFileData = JSON.parse(canvasFile);

canvasFileData.edges.push({
id: random(16),
fromNode: node1.id,
fromSide: "right",
toNode: node2.id,
toSide: "left"
});
canvasFileData.nodes.push({
id: node2.id,
x: node2.x,
y: node2.y,
width: node2.width,
height: node2.height,
type: "text",
text: node2.text,
})

canvas.setData(canvasFileData);
canvas.requestSave();

// await this.app.vault.modify(canvas.view.file, JSON.stringify(canvasFileData, null, 2));
}, 500);
}
}

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "canvas-mindmap",
"name": "Canvas Mindmap",
"version": "0.0.4",
"version": "0.0.5",
"minAppVersion": "1.1.0",
"description": "A plugin to make your canvas work like a mindmap.",
"author": "Boninall",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "canvas-mindmap",
"version": "0.0.4",
"version": "0.0.5",
"description": "A plugin to make your canvas work like a mindmap.",
"main": "main.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"0.0.1": "1.1.0",
"0.0.2": "1.1.0",
"0.0.3": "1.1.0",
"0.0.4": "1.1.0"
"0.0.4": "1.1.0",
"0.0.5": "1.1.0"
}

0 comments on commit f37bfbd

Please sign in to comment.