Options
All
  • Public
  • Public/Protected
  • All
Menu

Class App

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

Hierarchy

  • App

Index

Properties

Readonly currentThemeMode

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.

currentWorkspace

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.

Readonly isActionListVisible

isActionListVisible: boolean

Is the action list side panel is visible.

Readonly isDraftListVisible

isDraftListVisible: boolean

Is the draft list side panel is visible.

isIdleDisabled

isIdleDisabled: boolean

Is system sleep timer disabled preventing screen dimming/sleep.

Readonly isPro

isPro: boolean

Returns true if app has an active Drafts Pro subscription.

themeMode

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

Get or set themeMode.

Readonly version

version: string

Version number of current installation of Drafts.

Methods

applyWorkspace

  • applyWorkspace(workspace?: Workspace): boolean
  • 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

displayErrorMessage

  • displayErrorMessage(message: string): void
  • Show error banner notification with the message passed.

    Parameters

    • message: string

    Returns void

displayInfoMessage

  • displayInfoMessage(message: string): void
  • Show info banner notification with the message passed.

    Parameters

    • message: string

    Returns void

displaySuccessMessage

  • displaySuccessMessage(message: string): void
  • Show success banner notification with the message passed.

    Parameters

    • message: string

    Returns void

displayWarningMessage

  • displayWarningMessage(message: string): void
  • Show warning banner notification with the message passed.

    Parameters

    • message: string

    Returns void

getClipboard

  • getClipboard(): string
  • Get current contents of the system clipboard.

    Returns string

hideActionList

  • hideActionList(): void
  • Close action list side bar.

    Returns void

hideDraftList

  • hideDraftList(): void
  • Close draft list side bar.

    Returns void

htmlToClipboard

  • htmlToClipboard(html: string): boolean
  • 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

loadActionBarGroup

  • loadActionBarGroup(actionGroup: ActionGroup): boolean
  • deprecated

    Load the ActionGroup in the action bar below editor.

    Parameters

    Returns boolean

loadActionGroup

  • Load the ActionGroup in the action list side bar.

    Parameters

    Returns boolean

loadKeyboardActionGroup

  • loadKeyboardActionGroup(actionGroup: ActionGroup): boolean
  • deprecated

    replaced by loadActionBarGroup.

    Parameters

    Returns boolean

openInNewWindow

  • openInNewWindow(draft: Draft): boolean
  • If able, open the requested draft in a new window. This method only functions on iPad and Mac. The ability to open new windows is not available on iPhone.

    Parameters

    Returns boolean

    true if successful. false if unable to open a new window (as on iPhone).

openURL

  • openURL(url: string, useSafari?: boolean): 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

queueAction

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

    Parameters

    • action: Action

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

    • draft: Draft

      A draft object.

    Returns boolean

selectDraft

  • 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 | undefined

setClipboard

  • setClipboard(contents: string): void
  • Set the contents of the system clipboard.

    Parameters

    • contents: string

    Returns void

setIdleDisabled

  • setIdleDisabled(isDisabled: boolean): void
  • Enable and disable the iOS system sleep timer to prevent screen dimming/sleep.

    Parameters

    • isDisabled: boolean

    Returns void

showActionList

  • showActionList(): void
  • Open action list side bar.

    Returns void

showDraftInfo

  • showDraftInfo(draft?: Draft): void
  • Open the "Get Info" view for a draft. If no draft is passed, the current active draft in the editor will be used.

    Parameters

    Returns void

showDraftList

  • showDraftList(): void
  • Open draft list side bar.

    Returns void

showQuickSearch

  • showQuickSearch(initialQuery?: string): void
  • Open quick search window, optionally providing a initial query value.

    Parameters

    • Optional initialQuery: string

    Returns void

Generated using TypeDoc