Drafts defines a single global app object which provides access to application level functions.

Example

// toggle dark-light mode
if (app.currentThemeMode == 'dark') {
app.themeMode = 'light';
}
else {
app.themeMode = 'dark';
}

Hierarchy

  • App

Constructors

Properties - Deprecated

isActionListVisible: boolean

Deprecated

Use app.currentWindow.isActionListVisible

isDraftListVisible: boolean

Deprecated

Use app.currentWindow.isDraftListVisible

Properties - Interface

currentWindow: Window

Returns a window object configured representing the active window.

currentWorkspace: Workspace

Returns a workspace object configured like the workspace currently loaded in the draft list of the active window. Useful when creating logic which reacts contextually to the workspace loaded.

Properties - Live Activities

areLiveActivitiesSupported: boolean

Check if Live Activities are supported on the current device/platform.

Properties - System

isIdleDisabled: boolean

Is system sleep timer disabled preventing screen dimming/sleep.

isPro: boolean

Returns true if app has an active Drafts Pro subscription.

version: string

Version number of current installation of Drafts.

Properties - Theme

currentThemeMode: "light" | "dark"

Returns the active theme mode, light or dark, taking into account automatic switching of themes if active. If writing scripts to branch logic based on the current mode, this is the best property to use.

darkTheme: Theme

The current dark mode theme.

lightTheme: Theme

The current light mode theme.

themeMode: "light" | "dark" | "automatic"

Get or set themeMode.

Methods - Clipboard

  • Get current contents of the system clipboard.

    Parameters

    • Optional clipboardType: clipboardType

      Optionally specify a data type to fetch from the clipboard. Default: "string"

    Returns string

  • Set the contents of the system clipboard.

    Parameters

    • contents: string | object

      the data to set in the clipboard. If a string is passed it is set in the clipboard. Optionally an object with clipboardType keys and string values can be passed to set multiple data types in the clipboard.

    Returns void

Methods - Deprecated

  • Deprecated

    Use app.currentWindow.hideActionList

    Returns void

  • Deprecated

    Use app.currentWindow.hideDraftList

    Returns void

  • Deprecated

    replaced by loadActionBarGroup.

    Parameters

    Returns boolean

  • Deprecated

    Use app.currentWindow.showActionList

    Returns void

  • Deprecated

    Use app.currentWindow.showDraftInfo

    Parameters

    Returns void

  • Deprecated

    Use app.currentWindow.showDraftList

    Returns void

  • Deprecated

    Use app.currentWindow.showQuickSearch

    Parameters

    • Optional initialQuery: string

    Returns void

Methods - Interface

  • Apply the Workspace as if it was selected in draft list. Calling this function with no arguments will clear filters and apply the default workspace.

    Parameters

    Returns boolean

  • Show success banner notification with the message passed.

    Parameters

    • message: string

    Returns void

  • Load the ActionGroup in the action bar below editor.

    Parameters

    Returns boolean

  • Load the ActionGroup in the action list side bar.

    Parameters

    Returns boolean

  • Open draft selection interface and wait for user to select a draft. Returns the select draft object, or undefined if user cancelled.

    Parameters

    • Optional workspace: Workspace

      If provided, the workspace will define the default filtering, display, and sort options for the selection window.

    Returns Draft

Methods - Live Activities

  • Start a Live Activity for the selected Draft. Returns true if Live Activity started successfully. Returns false if Live Activity could not be started, or Live Activities are not supported on the device.

    Parameters

    • draft: Draft

      The draft to use in the Live Activity

    Returns boolean

  • Stop a Live Activity for the selected Draft. Returns true if Live Activity stopped successfully.

    Parameters

    • draft: Draft

      The draft to use in the Live Activity

    Returns boolean

Methods - Messages

  • Show error banner notification with the message passed.

    Parameters

    • message: string

    Returns void

  • Show info banner notification with the message passed.

    Parameters

    • message: string

    Returns void

  • Show warning banner notification with the message passed.

    Parameters

    • message: string

    Returns void

Methods - Utility

  • Takes HTML string and converts it to rich-text and places it in the system clipboard. Returns true if successful, false if an error occurred in conversion.

    Parameters

    • html: string

      a possibly-valid html string

    Returns boolean

  • Request system opens the URL passed. Returns true if URL was opened, false if the URL was invalid or no available app can open the URL on the device.

    Parameters

    • url: string

      url to open

    • Optional useSafari: boolean

      whether to use the Safari View Controller (true) or default browser (false).

    Returns boolean

  • Queues an action to run on a draft after the current action is complete.

    // lookup action and draft, and queue the action to run
    let a = Action.find("Copy");
    let d = Draft.find("UUID");
    app.queueAction(a, d);

    Parameters

    • action: Action

      Actions can be obtained using the Action.find(name) method.

    • draft: Draft

      A draft object.

    Returns boolean

  • Enable and disable the iOS system sleep timer to prevent screen dimming/sleep.

    Parameters

    • isDisabled: boolean

    Returns void

Generated using TypeDoc