czottmann / obsidian-actions-uri

A plugin for Obsidian (https://obsidian.md) that adds additional `x-callback-url` endpoints to the app for common actions — it's a clean, super-charged addition to Obsidian URI.
https://zottmann.dev/obsidian-actions-uri/
MIT License
138 stars 6 forks source link

Option 'below-headline' does not create a new section nor makes operation fail if section wasn't found #91

Closed vitaly-rudenko closed 4 months ago

vitaly-rudenko commented 4 months ago

Hi! Thanks for building this amazing plugin.

Option 'below-headline' is very useful, although it seems that if no section was found with that headline, the operation still succeeds and file remains unchanged.

There are two options that I think would work well in this situation:

  1. Create a new section at the bottom of the file with the given headline (may require an additional option?)
  2. Fail the operation instead of calling the 'success' callback

I'd be happy to contribute if you don't have the capacity, but I first wanted to know which option sounds better (or if there's an alternative solution)

czottmann commented 4 months ago

@vitaly-rudenko Thanks for the report, and your offer, and I agree, this looks like a glaring oversight. I think option 1 is the better one, I'll look into it later today.

Apologies for the delay, and thank you for the offer, I do appreciate it! It's just that I work in cycles as I have more than one project, and I work on them in focussed blocks, and currently it's Action URI's time again. (I'm preparing the 1.6 release right now.)

czottmann commented 4 months ago

I've implemented a new optional parameter for /note/append/ and /note/prepend: if-headline-missing=add-headline|error|skip. If below-headline= is used, and the requested headline is missing, the following behavior is available:

Cool?

The changes will be live in the upcoming v1.6, later this week.

czottmann commented 4 months ago

Rolled out in https://github.com/czottmann/obsidian-actions-uri/releases/tag/1.6.0!