Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface App

App (Drafts)

The ThoughtAsylum library includes a set of extensions to the Drafts application's global instance of the App object.

Hierarchy

  • App

Index

Methods

TA_URLDecodeClipboard

  • TA_URLDecodeClipboard(): string
  • Updates the content of the clipboard to be URL decoded. This function is based on the JavaScript decodeURIComponent() function. Returns the updated content of the clipboard.

    // Example
    app.TA_URLDecodeClipboard();

    Returns string

TA_URLEncodeClipboard

  • TA_URLEncodeClipboard(): string
  • Updates the content of the clipboard to be URL encoded. This function is based on the JavaScript encodeURIComponent() function. It will encode all characters except for A-Z a-z 0-9 - _ . ! ~ * ' ( ). Returns the updated content of the clipboard.

    // Example
    app.TA_URLEncodeClipboard();

    Returns string

TA_actionGroupActionCount

  • TA_actionGroupActionCount(): number
  • Get the counts of actions in Drafts. Returns the total number of actions across all action groups.

    // Example
    alert(app.TA_actionGroupActionCount());

    Returns number

TA_actionGroupCounts

  • TA_actionGroupCounts(): number[]
  • Get the counts of actions and separators in Drafts. Returns a two element array, the first element being the count of actions and the second being the count of separators.

    // Example
    let aintCounts = app.TA_actionGroupCounts();
    alert("You have " + aintCounts[0] + " actions, and " + aintCounts[1] + " separators.");

    Returns number[]

TA_actionGroupNames

  • TA_actionGroupNames(): string[]
  • Return an array of all action group names in Drafts.

    // Example
    alert(app.TA_actionGroupNames().join(","));

    Returns string[]

TA_actionGroupSeparatorCount

  • TA_actionGroupSeparatorCount(): number
  • Get the counts of separators in Drafts. Returns the total number of separators across all action groups.

    // Example
    alert(app.TA_actionGroupSeparatorCount());

    Returns number

TA_actionNames

  • TA_actionNames(): string[]
  • Return an array of all action names in Drafts.

    // Example
    alert(app.TA_actionNames().join(","));

    Returns string[]

TA_actionSelectAndRun

  • TA_actionSelectAndRun(p_strKey: string): void
  • Display a list of actions from the library settings and run the selected action. The set of actions is built from a set of JSON within the TadLibrary.actions settings. The idea is to provide almost like a context or pop-up menu of options without having to search, or switch action groups.

    Parameters

    • p_strKey: string

      the name of the set of actions to run. It equates to a key within TadLibrary.actions.

      // Example
      app.TA_actionSelectAndRun("info");

    Returns void

TA_applyWorkspaceByName

  • TA_applyWorkspaceByName(p_strWorkspaceName: string, p_bShowDraftsList: boolean): boolean
  • Loads a workspace by name. Optionally able to specify whether or not the drafts list should be forced to be displayed

    Parameters

    • p_strWorkspaceName: string

      Name of the workspace to load.

    • p_bShowDraftsList: boolean

      When true this will force the drafts list to be shown. Defaults to false.

      // Example
      app.TA_applyWorkspaceByName("Meetings");

    Returns boolean

TA_clipboardAppend

  • TA_clipboardAppend(p_strAddToClipboard: string, p_strSeparator?: string): string
  • Append a string to the clipboard, with an optional separator. If the clipboard is empty, no separator will be used. Returns the resulting clipboard content.

    Parameters

    • p_strAddToClipboard: string

      string to append to the clipboard.

    • Optional p_strSeparator: string

      optional separator (defaults to an empty string) that will be added between the clipboard and the append string.

      // Example
      alert(app.TA_clipboardAppend("foo"));

    Returns string

TA_clipboardEmpty

  • TA_clipboardEmpty(): Boolean
  • Set the clipboard to an empty string. Returns true if the clipboard has been successfully set, otherwise, false.

    // Example
    app.TA_clipboardEmpty();

    Returns Boolean

TA_clipboardPrepend

  • TA_clipboardPrepend(p_strAddToClipboard: string, p_strSeparator?: string): string
  • Prepend a string to the clipboard, with an optional separator. If the clipboard is empty, no separator will be used. Returns the resulting clipboard content.

    Parameters

    • p_strAddToClipboard: string

      string to prepend to the clipboard.

    • Optional p_strSeparator: string

      optional separator (defaults to an empty string) that will be added between the prepend string and the clipboard.

      // Example
      alert(app.TA_clipboardPrepend("foo"));

    Returns string

TA_clipboard_MMD2HTML

  • TA_clipboard_MMD2HTML(): void
  • Updates MultiMarkdown clipboard content to HTML.

    // Example
    app.TA_clipboard_MMD2HTML();

    Returns void

TA_dictateToClipboard

  • TA_dictateToClipboard(): boolean
  • Capture dictation and put it on the system clipboard. Returns true if any text is captured.

    // Example
    app.TA_dictateToClipboard();

    Returns boolean

TA_displayDebugMessage

  • TA_displayDebugMessage(p_strMessage: string): Boolean
  • Display a debug message and log it to the console. The message is only displayed if the debug mode has been enabled for the library object (tadLib.debugEnabled = true). As well as displaying the message to the user, the message is also written to the console log, using the console.TA_logSuccess function. Returns true if debug mode is enabled.

    Parameters

    • p_strMessage: string

      The text to be displayed as an information/debug message and logged to the console.

      // Example
      tadLib.debugEnabled = true;
      app.TA_displayDebugMessage("Debug Message Here");

    Returns Boolean

TA_displayErrorMessage

  • TA_displayErrorMessage(p_strMessage: string): void
  • Display an error message and log it to the console. Uses the console.TA_logError functions to log the content.

    Parameters

    • p_strMessage: string

      The text to be displayed in the message and wriiten to the console.

      // Example
      app.TA_displayErrorMessage("Error Message Here");

    Returns void

TA_displayInfoMessage

  • TA_displayInfoMessage(p_strMessage: string): void
  • Display an information message and log it to the console. Uses the console.TA_logInfo functions to log the content.

    Parameters

    • p_strMessage: string

      The text to be displayed in the message and wriiten to the console.

      // Example
      app.TA_displayInfoMessage("Information Message Here");

    Returns void

TA_displaySuccessMessage

  • TA_displaySuccessMessage(p_strMessage: string): void
  • Display a success message and log it to the console. Uses the console.TA_logSuccess function to log the content.

    Parameters

    • p_strMessage: string

      The text to be displayed in the message and wriiten to the console.

      // Example
      app.TA_displaySuccessMessage("Success Message Here");

    Returns void

TA_displayWarningMessage

  • TA_displayWarningMessage(p_strMessage: string): void
  • Display a warning message and log it to the console. Uses the console.TA_logWarn functions to log the content.

    Parameters

    • p_strMessage: string

      The text to be displayed in the message and wriiten to the console.

      // Example
      app.TA_displayWarningMessage("Warning Message Here");

    Returns void

TA_getActionGroupActionNames

  • TA_getActionGroupActionNames(): string[]
  • Return an array of all action names in a particular action group. The user selects the action group to list actions for from a drop down list of available action groups.

    // Example
    alert(app.TA_getActionGroupActions().join(","));

    Returns string[]

TA_getActionGroupSeparatorNames

  • TA_getActionGroupSeparatorNames(): string[]
  • Return an array of all separator names in a particular action group. The user selects the action group to list actions for from a drop down list of available action groups.

    // Example
    alert(app.TA_getActionGroupSeparatorNames().join(","));

    Returns string[]

TA_msgDebug

  • TA_msgDebug(p_strMessage: string): Boolean
  • Display a generic debug message box with a message. The message is only displayed if the debug mode has been enabled for the library object (tadLib.debugEnabled = true). As well as displaying the message to the user, the message is also written to the console log, where it is prefixed with tadLib.consoleDebugMarker. The title is set to display tadLib.msgTitleDebug, and it can be OK'd from the keyboard, using ⌘ + RETURN to OK. Returns true if debug mode is enabled.

    Parameters

    • p_strMessage: string

      The text to be displayed in the box and logged to the console.

      // Example
      tadLib.debugEnabled = true;
      app.TA_msgDebug("Debug Message Here");

    Returns Boolean

TA_msgError

  • TA_msgError(p_strMessage: string): void
  • Display a generic error message box with a message. The title is set to display tadLib.msgTitleError, and it can be OK'd from the keyboard, using ⌘ + RETURN to OK.

    Parameters

    • p_strMessage: string

      The text to be displayed in the box.

      // Example
      app.TA_msgError("Error Message Here");

    Returns void

TA_msgInfo

  • TA_msgInfo(p_strMessage: string): void
  • Display a generic information message box with a message. The title is set to display tadLib.msgTitleInfo, and it can be OK'd from the keyboard, using ⌘ + RETURN to OK.

    Parameters

    • p_strMessage: string

      The text to be displayed in the box.

      // Example
      app.TA_msgInfo("Information Message Here");

    Returns void

TA_msgWarn

  • TA_msgWarn(p_strMessage: string): void
  • Display a generic warning message box with a message. The title is set to display tadLib.msgTitleWarn, and it can be OK'd from the keyboard, using ⌘ + RETURN to OK.

    Parameters

    • p_strMessage: string

      The text to be displayed in the box.

      // Example
      app.TA_msgWarn("Warning Message Here");

    Returns void

TA_msgbox

  • TA_msgbox(p_strTitle: string, p_strMessage: string): void
  • Display a generic message box with a title and message. Unlike alert(), the title can be changed and it can be OK'd from the keyboard, using ⌘ + RETURN to OK.

    Parameters

    • p_strTitle: string

      The title for the box.

    • p_strMessage: string

      The text to be displayed in the box.

      // Example
      app.TA_msgbox("Title Here", "Message Here");

    Returns void

TA_removeRunTagFromArchive

  • TA_removeRunTagFromArchive(): number
  • Remove the in-situ coding run tag from any archived drafts. Unlike `alert the title can be changed and it can be OK'd from the keyboard. The function returns the number of drafts that were trashed.

    // Example
    app.TA_removeRunTagFromArchive();

    Returns number

TA_removeTags

  • TA_removeTags(p_strDelTag: string, p_strFromFilter: TYPE_strFilter): number
  • Remove all tag instances from filtered Drafts. A filter is passed to the function along with the name of a single tag. The drafts matching the filter, and containing the tag. The tag is subsequently removed from each of the identified drafts, and the number of matched removals is returned.

    Parameters

    • p_strDelTag: string

      The name of the tag to be removed.

    • p_strFromFilter: TYPE_strFilter

      The name of the filter to apply.

      // Example
      app.TA_removeTags("oldtag", "archive");

    Returns number

TA_toggleThemeMode

  • TA_toggleThemeMode(): string
  • Toggle the application theme mode between light and dark. It will always apply a manual setting, never an automatic setting Returns light or dark as the new theme mode.

    // Example
    app.TA_toggleThemeMode();

    Returns string

TA_trashUnflggedInboxDraftsTaggedDrafts

  • TA_trashUnflggedInboxDraftsTaggedDrafts(p_strTag: string): number
  • Trash unflagged drafts in the box that are tagged with the specified tag. The function returns the number of drafts that were trashed.

    Parameters

    • p_strTag: string

      The name of the tag to be found.

      // Example
      app.TA_trashUnflggedInboxDraftsTaggedDrafts("discourse");

    Returns number

fileImporterBasic

  • fileImporterBasic(p_strImportPath: string): number
  • Import files from a folder into Drafts maintaining file dates. Creation date and modification date are set from the file; last accessed is not. The function returns the number of files imported.

    Parameters

    • p_strImportPath: string

      the folder in the Drafts iCloud area to import files from.

      // Example - import from `import` folder in root of Drafts iCloud directory.
      app.fileImporterBasic("/import/");

    Returns number

fileImporterTagEnabled

  • fileImporterTagEnabled(p_strImportPath: string, p_astrTags: string[], p_strKey?: string): number
  • Import files from a folder into Drafts maintaining file dates and applying tags. Creation date and modification date are set from the file; last accessed is not. The function will add new, common tags, based on the array that is passed into it. In addition, the function will look for front matter in the file content. If it exists, and if there is a key as specified by the (optional) p_strKey parameter, the content will be read in and processed as a list of comma separated tag names to be added to that particular draft. The function returns the number of files imported.

    Parameters

    • p_strImportPath: string

      the folder in the Drafts iCloud area to import files from.

    • p_astrTags: string[]

      an array of tag names to add to each imported draft.

    • Optional p_strKey: string

      the simple root level front matter key to use to retrieve a CSV list of tags from the file. Defaults to an empty string.

      // Example - import from `import` folder in root of Drafts iCloud directory.
      app.fileImporterTagEnabled("/import/", ["importer"], "tags");

    Returns number