Script-generated actions



I just wrote a few utilities for Drafts scripts, mostly aimed at generating actions and importing them in Drafts.

Usage looks like this (after including the “EDAPI” action):

var a = new EDAction("My action name", { icon: "notebook" });
a.addStep(EDActionStep.url("fancy-app://do-some-magic?text=" + encodeURIComponent(draft.title.toUpperCase())));

There’s also an easy way to ask the user for a choice with big buttons:

var mode = EDPrompt.choice(
  "Mode Selection",
  "Should we prepend or append?",
  ["prepend", "append"]
if (mode == false) context.cancel();
else {
  // do stuff based on `mode` (which will be either "prepend" or "append")

Feedback welcome! I hope it’s useful to someone :slight_smile: