Skip to content

Commit

Permalink
log clean up, canvas modification event handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ifree committed Feb 12, 2024
1 parent 89ed895 commit ae5eb16
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, Plugin, PluginSettingTab, Setting } from 'obsidian';
import { App, TAbstractFile, Plugin, PluginSettingTab, Setting } from 'obsidian';
import * as d3 from "d3";

class Vector2 {
Expand Down Expand Up @@ -124,6 +124,16 @@ export default class CanvasMinimap extends Plugin {
this.app.workspace.on('active-leaf-change', () => {
this.reloadMinimap()
})
this.app.vault.on('modify', (file: TAbstractFile) => {
if(!this.getActiveCanvas())
return
const activeFile = this.app.workspace.getActiveFile()
// check if the file is the active file
if (activeFile && file.path === activeFile.path)
{
this.reloadMinimap()
}
})
}

renderMinimap(svg: any, canvas: any) {
Expand Down Expand Up @@ -187,9 +197,7 @@ export default class CanvasMinimap extends Plugin {
}
rect.attr("stroke", "darkblue");
rect.attr("fill", this.settings.groupColor);
rect.on('click', (e: any) => {
console.log('clicked', n)
})


const label: string = n.label
if (label) {
Expand Down Expand Up @@ -235,7 +243,7 @@ export default class CanvasMinimap extends Plugin {
source: [fromPos.x, fromPos.y],
target: [toPos.x, toPos.y]
});
console.log(e, fromPos, toPos, link)
//console.log(e, fromPos, toPos, link)
svg
.append("path")
.attr("d", link)
Expand Down

0 comments on commit ae5eb16

Please sign in to comment.