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_decryptAESClipboard

  • TA_decryptAESClipboard(p_strKey: string): void
  • Decrypt the content of the clipboard using AES encryption. This is a key-based encryption and uses the crypto-js library to do the decryption. Please choose an appropriate AES key length when encrypting (128/192/256-bit) - e.g. a 64 character hexadecimal string for 256-bit encryption.

    Parameters

    • p_strKey: string

      the AES encryption key to use for the edecryption.

      // Example
      app.TA_decryptAESClipboard("FFEEDDCCBBAA99887766554433221100");
      

    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_encryptAESClipboard

  • TA_encryptAESClipboard(p_strKey: string): void
  • Encrypt the content of the clipboard using AES encryption. This is a key-based encryption and uses the crypto-js library to do the encryption. Please choose an appropriate AES key length when encrypting (128/192/256-bit) - e.g. a 64 character hexadecimal string for 256-bit encryption.

    Parameters

    • p_strKey: string

      the AES encryption key to use for the encryption.

      // Example
      app.TA_encryptAESClipboard("FFEEDDCCBBAA99887766554433221100");
      

    Returns void

TA_fileImporterBasic

  • TA_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.TA_fileImporterBasic("/import/");
      

    Returns number

TA_fileImporterTagEnabled

  • TA_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.TA_fileImporterTagEnabled("/import/", ["importer"], "tags");
      

    Returns number

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_loadActionBarByName

  • TA_loadActionBarByName(p_strActionGroupName: string): Boolean
  • Load an action group by name into the action bar. Returns true if the action group is successfully loaded, otherwise false. If the named action group is not found, an error line will be written to the console log.

    Parameters

    • p_strActionGroupName: string

      the name of the action group to load.

      // Example
      app.TA_loadActionListByName("Writing");
      

    Returns Boolean

TA_loadActionListByName

  • TA_loadActionListByName(p_strActionGroupName: string): Boolean
  • Load an action group by name into the action list. Returns true if the action group is successfully loaded, otherwise false. If the named action group is not found, an error line will be written to the console log.

    Parameters

    • p_strActionGroupName: string

      the name of the action group to load.

      // Example
      app.TA_loadActionListByName("Writing");
      

    Returns Boolean

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_processCrossLink

  • TA_processCrossLink(p_strLink: string): void
  • Process a cross-link. This function takes a cross-link and begins by removing any [[]] wrapper. It then identifies the basic type of cross-link - (u) draft by UUID, (s) search, (w) workspace, (d / null) draft by title, (url) url, (google) Google search, (wikipedia) Wikipedia search, or (bear) Bear app note link. Once identified, the function will carry out the necessary operation to reproduce the effect of clicking/tapping on the cross-link directly. For the draft title-base links, the function also tries its best to match the text based on the any navigation marker/heading identifiers (indicated by a forward slash). Because forward slashes can exist in the title and headings too, the function actually works through all combinations of the title and navigation marker/heading, and accommodates titles beginning with multiple forward slashes (such as a JavaScript comment). Should a single high quality match be identified, that will be loaded. If multiple matches of equal quality (quality based on a simple full match/partial match premise), a draft search pre-populated with the simplest possible title will be executed. Should no match for a draft link be identified, the function will automatically create a new draft with the full search link as the title. If the passed in text should happen to not in any way match any viable link, an unknown link message will be displayed to the user. The processing employed by this function is a little sticter than the manual link processing as it applies additional checks to find the most precise match on behalf of the user rather than defaulting to a fallback search to choose from a selection of exact and partial matches. Whenever a single exact match is found it will take precedence over any partial matches.

    Parameters

    • p_strLink: string

      the cross-link string to process.

      // Example
      app.TA_processLink("Project XYZ/Heading A/B");
      

    Returns void

TA_queueActionByName

  • TA_queueActionByName(p_strName: string, p_draft: Draft): Boolean
  • Queue up a named Drafts action to run on a specified draft. Returns true if the action was found and queued up.

    Parameters

    • p_strName: string

      the name of the action to queue up.

    • p_draft: Draft

      the draft to run it on.

      app.TA_queueActionByName("TAD-Instructions");
      

    Returns Boolean

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