URL link to a spot in a draft

I heard on a podcast Federico Viticci talking about how he creates a URL to link to a specific point in a draft. Anyone know of an Action that does this?

1 Like

I can’t answer the question but I will note this was the latest AppStories.

I don’t know exactly how Federico does his, but here’s a way it could be done.


Insert Reference

The first draft action prompts the user for a note. This note is then placed into the current draft at the cursor along with a unique identifier and some strings to delimit and separate the content.

The unique identifier is essentially made of the unique ID of the draft plus an epoch time index.

Once inserted, the action also copies an x-callback URL to the clipboard that can be used to jump back to this insertion; by way of the second action.

I’ve purposefully set this action up in such a way as you can easily modify it to do something other than copy the URL to the keyboard. You could get Drafts to programmatically put that URL in lots of places :wink:

Open Reference

This second action should only ever be called from a URL scheme really. The URL generated by the previous action will trigger Drafts to open with a piece of text and run this action. The text is the unique identifier in our earlier draft. The action splits the identifier, opens the draft specified by the UUID and locates the position of the unique position identifier and sets the cursor to the start of the identifier.

Example

Here’s some of my test case information:

Expand for original draft with the references in place

Here are the two URLs that were generated to access these references.

drafts5://x-callback-url/runAction?text=7DF21922-F3AD-4FA3-ADDE-0DEE951FCB85_1536092457646&action=OpenRef

drafts5://x-callback-url/runAction?text=7DF21922-F3AD-4FA3-ADDE-0DEE951FCB85_1536093449689&action=OpenRef

Federico’s Reminders Links

In the App Stories podcast that @martinpacker references, Federico mentions placing the URL into reminders so that he can have an actionable to do list. Reminders does not currently support (even in the iOS12 beta) simple actionable URLs; though you can ask Siri to remind you of things which have a similar effect.

I’m assuming that Federico is actually using GoodTasks 3 as an interface to his reminders lists for this particular aspect as I know he has been making use of it and it does support actionable URLs from reminders.


Anyway, that’s how I’d approach it, but I’m sure there could be other approaches out there too. Let me know if this helps anyone out on getting started with this.

Thanks for that. Will give it a try. I assumed also Federico uses GoodTask to make the links clickable. He also has a shortcut that pulls out all URLs for upcoming reminders which enables you to then click on the links without using GoodTask.

He was talking about this in the context of GoodTask so yes.