jensmtg / obsidian-diagrams-net

This repository contains a plugin for Obsidian for inserting and editing diagrams.net (previously draw.io) diagrams.
MIT License
96 stars 14 forks source link

Fix diagram creation path and add setting option for naming the diagram as <current-file>-<timestamp> #15

Closed SPiCaRiA closed 6 months ago

SPiCaRiA commented 1 year ago

This PR does the following things:

  1. Fix the file creation path bug: when the Obsidian's attachment folder setting is "Same folder as current file", the new diagram will actually be created in the root vault folder. The reason is that vault.getAvailablePathForAttachments needs the active file (or null if no file has been opened yet) as its third argument to prepend the correct folder.
  2. Add a setting option to allow naming the newly created diagram in the format of ${currentFileName}-${timestamp}, which is a popular way of naming for attachments associated to a note.

Tests

Settings Page

Screen Shot 2023-04-11 at 10 00 51

Same folder as current file - default naming

https://user-images.githubusercontent.com/11176415/231243398-6941d20f-3859-4a05-84fe-f127d676e3ba.mov

Same folder as current file - timestamp naming

https://user-images.githubusercontent.com/11176415/231243487-90fc5f27-7be1-40f9-9285-5b8fdaf28562.mov

Resulting files * I'm using folder notes so technically the active file is testfolder/testfolder.md.

Screen Shot 2023-04-11 at 10 00 34