Skip to content

Commit

Permalink
Merge pull request #45 from Quorafind/refact/handle-robust
Browse files Browse the repository at this point in the history
Refact/handle robust
  • Loading branch information
Quorafind committed Jan 18, 2024
2 parents 35d3190 + 6619b48 commit 97f5ee1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
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.1.4",
"version": "0.1.5",
"minAppVersion": "1.4.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.1.4",
"version": "0.1.5",
"description": "A plugin to make your canvas work like a mindmap.",
"main": "main.js",
"scripts": {
Expand Down
20 changes: 10 additions & 10 deletions src/canvasMindMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,14 @@ export default class CanvasMindMap extends Plugin {


const patchCanvas = () => {
const canvasView = app.workspace.getLeavesOfType("canvas").first()?.view;

const canvasView = this.app.workspace.getLeavesOfType("canvas").first()?.view;
// @ts-ignore
const canvas = canvasView?.canvas;

if (!canvasView) return false;

const patchCanvasView = canvas.constructor;

console.log("patchCanvasView", patchCanvasView);

const canvasViewunistaller = around(canvasView.constructor.prototype, {
onOpen: (next) =>
async function () {
Expand Down Expand Up @@ -358,22 +357,23 @@ export default class CanvasMindMap extends Plugin {


const node = await createSiblingNode(this.canvas);

if (!node) return;

setTimeout(() => {
node.startEditing();
const realNode = this.canvas.nodes?.get(node.id);
realNode?.startEditing();
this.canvas.zoomToSelection();
}, 0);
});

this.scope.register([], "Tab", async () => {
const node = await createChildNode(this.canvas);

console.log(this, node);
if (!node) return;

setTimeout(() => {
node.startEditing();
const realNode = this.canvas.nodes?.get(node.id);
realNode?.startEditing();
this.canvas.zoomToSelection();
}, 0);
});
Expand Down Expand Up @@ -474,8 +474,8 @@ export default class CanvasMindMap extends Plugin {

this.app.workspace.onLayoutReady(() => {
if (!patchCanvas()) {
const evt = app.workspace.on("layout-change", () => {
patchCanvas() && app.workspace.offref(evt);
const evt = this.app.workspace.on("layout-change", () => {
patchCanvas() && this.app.workspace.offref(evt);
});
this.registerEvent(evt);
}
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"0.1.1": "1.1.0",
"0.1.2": "1.1.0",
"0.1.3": "1.1.0",
"0.1.4": "1.4.0"
"0.1.4": "1.4.0",
"0.1.5": "1.4.0"
}

0 comments on commit 97f5ee1

Please sign in to comment.