Options
All
  • Public
  • Public/Protected
  • All
Menu

Drafts Script Reference

Typescript declarations for Drafts custom JavaScript types for use in Drafts action scripting.

Sample build.sh builds Typedoc documentation.

Index

Type aliases

capitalizationTypes

capitalizationTypes: "none" | "sentences" | "words"

keyboardTypes

keyboardTypes: "default" | "numbersAndPunctuation" | "numberPad" | "phonePad" | "namePhonePad" | "emailAddress" | "decimalPad" | "webSearch" | "URL"

selectionRange

selectionRange: Array<number>

An array of numbers containing the location (index in string), and length (number of characters) of a text selection.

sortDirections

sortDirections: "created" | "modified" | "accessed" | "name"

Variables

Const action

action: Action

The current running action.

Const app

app: App

Reference to current app object.

Const context

context: Context

Const device

device: Device

Current device.

Const draft

draft: Draft

The current draft points to the draft open in the editor when the action was run.

Const editor

editor: Editor

The active editor

Functions

alert

  • alert(message: string): void
  • Shows a simple alert dialog containing the message.

    Parameters

    • message: string

    Returns void

require

  • require(path: string): void
  • Include the contents of a script loaded from iCloud Drive. The contents of the script will be evaluated as if they were inline with the current script. Useful for loading reusable libraries and utility scripts.

    Parameters

    • path: string

      relative path to javascript file in the iCloud Drive /Drafts/Library/Scripts folder. For example, to load the script in the file test.js in the iCloud Drive/Drafts/Library/Scripts/Utilities/ folder, use the path parameter Utilities/test.js.

    Returns void

strftime

  • strftime(date: Date, format: string): string

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc