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.
Is the action list side panel is visible.
Is the draft list side panel is visible.
Is system sleep timer disabled preventing screen dimming/sleep.
Returns true if app has an active Drafts Pro subscription.
Version number of current installation of Drafts.
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.
The current dark mode theme.
The current light mode theme.
Get or set themeMode.
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.
Show success banner notification with the message passed.
Close action list side bar.
Close draft list side bar.
Load the ActionGroup in the action bar below editor.
Load the ActionGroup in the action list side bar.
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.
true
if successful. false
if unable to open a new window (as on iPhone).
Open draft selection interface and wait for user to select a draft. Returns the select draft object, or undefined
if user cancelled.
If provided, the workspace will define the default filtering, display, and sort options for the selection window.
Open action list side bar.
Open the "Get Info" view for a draft. If no draft is passed, the current active draft in the editor will be used.
Open draft list side bar.
Open quick search window, optionally providing a initial query value.
Show error banner notification with the message passed.
Show info banner notification with the message passed.
Show warning banner notification with the message passed.
Get current contents of the system clipboard.
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.
a possibly-valid html string
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.
url to open
whether to use the Safari View Controller (true) or default browser (false).
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);
Actions can be obtained using the Action.find(name)
method.
A draft object.
Set the contents of the system clipboard.
Enable and disable the iOS system sleep timer to prevent screen dimming/sleep.
Generated using TypeDoc
App
Drafts defines a single global
app
object which provides access to application level functions.Examples
// toggle dark-light mode if (app.currentThemeMode == 'dark') { app.themeMode = 'light'; } else { app.themeMode = 'dark'; }