TIP: Advanced "Share" Actions

Drafts provides a Share action step that allows text to be sent to the system share sheet. The app ships with a Share action which utilizes this action step to send the entire text of the current draft to the system share sheet. This is the most common use case for sharing from Drafts, but there are some other customization and options available. Let’s discuss a couple of these cases.

Customizing the Share Action

Like most action steps in Drafts, the Share action step has a template which controls what text to include when sharing. The default actions has a template with the tag [[draft]], which tells it to include the full text of the current draft.

Screen Shot 2020-01-15 at 7.46.09 AM

Sometimes it’s useful to share something else, however. The most common other case would be to share only the selected text in a draft. This can be accomplished by altering the template to use the [[selection]] tag in place of the [[draft]] tag. (Example Share (selection) acton).

For more on templates, read the Using Drafts Templates article.

Sharing as File or URL

Drafts also includes a Share script object that enables a couple of more advanced sharing options. Specifically sharing as a file or URL instead of as text. These example actions demonstrate uses for these features:

  • Share as Text File
    • Creates a text file containing the text and shares the file instead of the text. Share extensions provided by other apps handle files differently, but, for example, using this option and selecting to Mail or Message in the share sheet will result in the file sent as an attachment, rather than the text just being included inline.
  • Share Draft Link
    • URLs are also treated differently by many share extensions. This example shares the link to the current draft as a URL.