That’s a good lead. Thanks for posting @martinewski. Hoping this integration can be resolved, though, as it’s frustrating to break flow to ensure the Drafts window is open before invoking Hook.
I really like the idea of all my Hook notes being tagged so that I can see them in a Drafts workspace, @MartinPacker. That’s a great idea. Do you tag them manually? And if so, might there be a way to modify the Hook script, @LucB, so that that Draft notes could be tagged as part of the integration?
My “daily writing” is automatically tagged - as I use a Drafts action that ropes in calendar and Omnifocus stuff, via Shortcuts. (I’d like to slacken that to avoid round trips to Shortcuts but never mind.) This action does the tagging.
My blog entries I’m writing I manually tag with “blog” when I start them.
My other drafts get manually tagged as well.
My scenario here (for Hook) is to create a bunch of files in folders and also create hookable Drafts. The folders - via my mdpre and md2pptx tools (sorry to advertise) contain Markdown etc to make into client workshop presentations. The drafts would be my analysis notes - that would contribute to the Markdown I build my presentations from.
Right now I don’t think I can create these Hookable drafts.
If anyone is interested in a temporary solution, I added the highlighted text to the script so it opens Drafts main window before trying the rest of the script. It’ll work as long as Drafts is running in background.
we provided an alternative script for OmniFocus a while ago to add a tag to hooked OmniFocus tasks , which illustrates the concept: Configurable Tags.
So if the Drafts AppleScript dictionary allows it, it would be trivial to add.
Personally, I think this should be the default for all apps that support tagging, but I know not everyone agrees.
I’ll ask someone here to have a look. meanwhile we have some volunteer liaisons for Obsidian, and hope to have one for each major app, like Drafts, who would check for things like this, and interact with the other dev’s community if needed.
Unfortunately, that doesn’t work for me, @martinewski. I still get “Error linking new document, No address returned” errors with macOS 11.1 and Drafts 24.2.10.
All is fine, however, if the Drafts window is actually open somewhere on my computer. The trouble, of course, is that it’s natural and almost automatic for me to take a note and then dismiss the Drafts window.
FYI: we’ve found some API of theirs we think we can use to make Hook to New work with Drafts. I’ll try to update this topic by end of evening. Meanwhile, it’s not worth customers fiddling with this.
You know, it seems to me that if we can hook up to Omni apps and Obsidian via a JavaScript style of interface, that we should have access to Drafts’ full suite of JavaScripting powers…so maybe this is already doable, possibly without AppleScript? Alternately, at one point, I did successfully hook up Hook with Drafts’ AppleScript to create a new draft, but I could never figure out how to grab its URL for linkage.
This should solve the Hook to New > Drafts issue because it uses Draft’s automation. As noted in the release notes, we still need to update Hook’s get address (if possible) to use Draft’s API rather than UI scripting.
The great part is that it’s now much easier to customize the resulting new draft. I quickly edited the script to add a Markdown header and some new lines.
There’s Linking Drafts - Drafts User Guide. We’re looking into whether it’s possible to add those links through automation. Anyone here use Drafts automation?
and the answer comes from one of our own here, it can be done such as:
tell application "Drafts"
activate
set obj to make new draft with properties
{content:"[[url:bookends://sonnysoftware.com/8253]]", tags:{"hook"}}
set rec to obj as record
return "drafts5://open?uuid=" & «class seld» of rec
end tell
In case anyone wants to try it, here’s a new version of Hook to New > Drafts
tell application "Drafts"
activate
set obj to make new draft with properties {content:"[$title]($link)", tags:{"hook"}}
set rec to obj as record
return "drafts5://open?uuid=" & «class seld» of rec
end tell
Instead of the new note having a vanilla title , it is a link back to the source. That means on iPad and iPhone you can use the links to get back to the source.