Send Clipboard contents through an action - Drafts 5


#1

On a phone yesterday, the hospital setup 3 different treatments. I typed this in Drafts 5 which I keep open on my iPad Pro 12.9. It would have been great to select, t or copy to clipboard the 1st appointment and then send to Fantastical. It would be nice to have been able to select the next appointment, copy to Fantastical, etc. As it is now, I have to create a Draft for each appointment and send to Fanstastical.

In the same way, it would be helpful to copy a paragraph from a longer text and use a Drafts 5 action to send in an email, text message, etc.

Jim


#2

You could probably build something like this fairly easily using the getClipboard() function (documentation) in an action, ideally one in a group set to be used as a keyboard. Your workflow would then be launch Drafts, tap the keyboard action button to have the clipboard contents processed by that action.

You might want to consider using Workflow to automate this, especially if you just want only the clipboard. Here’s a quick Workflow action which will create a calendar event from the current clipboard.


#3

Here’s a basic Add Clipboard to Fantastical action.

UPDATE: Now encoding the clipboard contents using the Javascript function encodeURI(). This was likely the cause of the error.


#4

Brooks,
Thank you! It fails and I’m not sure if there is something in Drafts that will let me look at a log to debug.
Jim


#5

See updated version above for a probable fix. Also, you might find my Add Selection to Clipboard action to be useful.


#6

Brooks,
That worked as did the Workflow which I run from the share sheet.
Again, thank you a bunch
Jim


#7

Another possibly helpful action in your situation avoids going back and forth manually is Add Events to Fantastical.


#8

why not just use the URL capability built directly into Drafts. A simple action will post the selected line to Fantastical…

fantastical2://x-callback-url/parse/?sentence=[[selection]]


#9

Thul,
The Event in Fantastical action puts all dates in one calendar event, rather than an event for each date.
Thanks for replying
Jim


#10

Using format I showed, If your selection has date it should be parsed properly on the Fantastical side … I used “May 5th” to save event yesterday and it got to right spot!


#11

Bricoleur,
Would I put the line of code in a url callback script? I’ve not created my own before.


#12

Yes, that’s correct.

(This method doesn’t handle notes though - the Fantastical app parses the selection and selects date, time for use in setting up the event)


#13

@adamsjw2 The one I linked does not group lines into one event, it creates a new event per line (thus the name Events, not Event)

Edit: It doesn’t parse dates in the text though, just creates a new event per line. It does use fantastical to then parse the whole item so dates should work, but maybe it still doesn’t do what’s necessary for this use case.

I use drafts with fantastical all the time so I’ll keep an eye on this thread to see what you guys come up with. :nerd_face:


#14

Hey!! The script does work. I don’t know what I was doing wrong yesterday. I tried it with no line spacing and with blank lines between each entry and it worked fine.
Thanks for your help. This thread now has three solutions to a single problem.
Jim