joethei / obsidian-plantuml

Generate PlantUML Diagrams inside Obsidian.md
MIT License
395 stars 23 forks source link

Force cleaning up cached diagrams for included PlantUML files #63

Open swoh816 opened 4 months ago

swoh816 commented 4 months ago

Is your feature request related to a problem? Please describe. I like modular architecture of document, so I make PlantUML file outside markdown, and import the file from the obsidian-plantuml codeblock inside markdown (using !include DIAGRAM.puml!DIAGRAM_ID). The problem is that if I make changes to the PlantUML file, the changes are not reflected in the diagram output displayed in markdown. I suspect it is because the obsidian-plantuml codeblock caches the result and does not clean it up as long as the codeblock doesn't change (i.e., the line !include DIAGRAM.puml!DIAGRAM_ID inside PlantUML codeblock doesn't change).

Describe the solution you'd like I want obsidian-plantuml to either

  1. automatically refresh/cleanup the PlantUML codeblock if it contains !include, or
  2. equip a function to manually refresh/cleanup cache.

I suspect it has something to do with cleanupCache function in main.ts: https://github.com/joethei/obsidian-plantuml/blob/2463d93539bcf207d7e31e0bf96b0ddde644d203/src/main.ts#L164

Describe alternatives you've considered So far, as a workaround, I add some comment to the codeblock so that the obsidian-plantuml recognizes the codeblock has changed.

I also thought about removing obsidian cache in ~/.config/obsidian/Cache/Cache_Data/, but on the second thought I decided not to, because it may remove other caches that are probably helpful for obsidian performance. Also, I thought just selectively removing obsidian-plantuml's cache would be more elegant solution. (I would've modify the code myself only if I knew typescript!)