Drafts 5.4: Siri Shortcuts, WordPress, and More

Yesterday, I posted on MacStories about the Drafts 5.4 update (and the subsequent 5.4.1 release as well).

I cover the big topics:

  • Siri shortcuts: several actions are listed to customize and add to Siri which provide dictation possibilities that are improved over Shortcuts.app
  • WordPress publishing: customizable actions for posting to WordPress, with a site preview, and pulls in your categories and tags for selection.
  • Other Improvements: Separators are great for organization. I’m using it a lot to organize actions by area as well as by app. Dropbox API support is there and Google Drive has been added.

If you’re interested in the new stuff, giving this a read might be for you.

3 Likes

Is there way to make a Siri shortcut to the most recently edited draft?

There are Siri shortcuts to open a specific draft, but not the most recent. There may be a way to pull in the most recent via scripting, but looking through the draft script object documentation, I don’t see an easy way.

2 Likes

Here’s a Drafts action that will load the last modified draft in Drafts 5.

Expand for JavaScript used in the Drafts action
//Function to compare draft objects by modified date and return them in reverse chronological order
function draft_marev_compare(a, b) {
  const modatA = a.modifiedAt;
  const modatB = b.modifiedAt

  let modatComparison = 0;
  if (modatA < modatB) {
    modAtComparison = 1;
  } else if (modatA > modatB) {
    modAtComparison = -1;
  }
  return modAtComparison;
}

function lastModifiedDraft()
{
	//Get all drafts
	let arrAllDrafts = Draft.query("", "all", []);
	
	//Sort all drafts by last modified date in reverse Chronological Order
	arrAllDrafts.sort(draft_marev_compare);
	
	//Return the UUID of the first draft object
	return arrAllDrafts[0];
}

//Load the last modified draft
editor.load(lastModifiedDraft());
editor.activate();

Here’s the Shortcuts shortcut that will call the action in Drafts 5.

Select to reveal screen shots of the Shortcut

Here’s the actions in the shortcut. I put the action out as separate text to make it easier to maintain if you rename it as it needs to be URL encoded for it to be called via URL.

Note we’re just calling the action in Drafts, we don’t want to return from it.

Here’s the settings and you can see where I set a Siri Phase for it.

Hopefully that has you sorted.

3 Likes

@sylumer This is exactly what I was looking for! Thanks.