Has anyone created a file-based action for sending from Drafts to a particular place in today’s Obsidian Mobile daily note? (rather than simply append or prepend to it)
I’ve found the Obsidian QuickAdd plugin macro to insert content, say, after “## Log” in daily note within Obsidian. But I’d love to do from Drafts without having to launch Obsidian Mobile app. (As file-based action ‘Save in Obsidian’ does nicely for new notes.) Thanks.
I also thought about that - the only „problem“ with that is that users might have different formats for the daily note filename so it’s something that a user would need to configure before using the action.
For some reason, in my Obsidian setup in macOS, the “\n” adds too many line breaks, so I removed them. In contrast, they’re needed in my Obsidian setup in iOS.
That’s weird…
Are you sure that it adds more newlines and it’s not a display thing on macOS?
Maybe also a plug-in that affects it on macOS?
I can’t test it right now on a Mac since I don’t have access to my own for some time.
The action only adds the newlines to the file so it should work similar on macOS and iOS…
Sure you did not just have extra line feeds in the text of the draft you were testing with on the Mac? It looks like the action just passes along the full content of the draft, it would not strip out extra feeds in the draft.
Could easily be the heavy plugin/CSS customization I have in my macOS instance of vault that’s not present in my sync’d Obsidian Mobile instance. Sending from iOS Drafts to sync’d Obsidian vault for use in macOS is my main use case, and that’s landing perfectly (in my case, as bulleted list item, no space before or after, under “### Log”).
I’m excited about this, and am expecting to use it a lot. Thank you!
It shouldnt append it to the end of the note - if I should look into it I’d need the exact configuration and also your template for the daily note if it works for you now that’s fine, too
Are the “Alerts” of second section and relevant text for development purposes only? (I commented them out )
When doing an append, the script adds a new line right after the section, is it necessary? Below is a context:
I’m doing an “append” on “## Jounral” section in daily notes.
My note is like this:
## Tasks
*top three tasks*
## Journal
*Time-based journal along the day*
- something maybe already here
- another thing
## Dataview summary
...etc
When I trigger the action, the journal section becomes:
## Journal
[ ] <-- New Empty line gets added here
*Time-based journal along the day*
- something already here
- another thing
- **New text from Drafts Action**
## Dataview summary
...etc
It’s not a big issue, but got me interested to ask about it.
I thought there are only alerts when an error happened in the action. Could you let me know which ones you’re talking about?
the beeline is added since this is (as far as I know) correct markdown style to have newlines around a heading. It should be possible to remove that from the script if you’re annoyed by it.
Finding the sections and adding text to it wasn’t too easy and caused some issues for different section headings.
Ah got it, didn’t expect the beeline (just learned the name!) in an append. I’ll test things out the coming days. It might be caused due to my .md structure.
Made quick screen recording showing the flow and alerts (link)
For the alerts, those two:
let textToInsert = ""
let linesToInsert = [gFirstSection,gSecondSection]
// distinguish newline amount if there is currently no text between the two sections:
alert(gSecondSection) // <-- first alert
let firstSectionInsert = ""
let secondSectionInsert = ""
// check text add mode and add text accordingly:
if (textAddMode == "append") {
alert(relevantText) // <-- second alert
Also i fixed the new line thing for me if anyone mildly annoyed by it.
Just changing this:
firstSectionInsert = gFirstSection + "\n\n"
to this:
firstSectionInsert = gFirstSection + "\n" // removed extra \n
I feel it’s there to handle a certain edge case for some markdown structures use-cases, but couldn’t know what. Any how this solved it for my structure.
This action + apple drafts shortcuts (run background action with text) is life savior!