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();
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();
Get the counts of actions in Drafts. Returns the total number of actions across all action groups.
// Example
alert(app.TA_actionGroupActionCount());
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.");
Return an array of all action group names in Drafts.
// Example
alert(app.TA_actionGroupNames().join(","));
Get the counts of separators in Drafts. Returns the total number of separators across all action groups.
// Example
alert(app.TA_actionGroupSeparatorCount());
Return an array of all action names in Drafts.
// Example
alert(app.TA_actionNames().join(","));
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.
the name of the set of actions to run. It equates to a key within TadLibrary.actions
.
// Example
app.TA_actionSelectAndRun("info");
Loads a workspace by name. Optionally able to specify whether or not the drafts list should be forced to be displayed
Name of the workspace to load.
When true this will force the drafts list to be shown. Defaults to false.
// Example
app.TA_applyWorkspaceByName("Meetings");
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.
string to append to the clipboard.
optional separator (defaults to an empty string) that will be added between the clipboard and the append string.
// Example
alert(app.TA_clipboardAppend("foo"));
Set the clipboard to an empty string.
Returns true
if the clipboard has been successfully set, otherwise, false
.
// Example
app.TA_clipboardEmpty();
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.
string to prepend to the clipboard.
optional separator (defaults to an empty string) that will be added between the prepend string and the clipboard.
// Example
alert(app.TA_clipboardPrepend("foo"));
Updates MultiMarkdown clipboard content to HTML.
// Example
app.TA_clipboard_MMD2HTML();
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.
the AES encryption key to use for the edecryption.
// Example
app.TA_decryptAESClipboard("FFEEDDCCBBAA99887766554433221100");
Capture dictation and put it on the system clipboard. Returns true if any text is captured.
// Example
app.TA_dictateToClipboard();
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.
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");
Display an error message and log it to the console.
Uses the console.TA_logError
functions to log the content.
The text to be displayed in the message and wriiten to the console.
// Example
app.TA_displayErrorMessage("Error Message Here");
Display an information message and log it to the console.
Uses the console.TA_logInfo
functions to log the content.
The text to be displayed in the message and wriiten to the console.
// Example
app.TA_displayInfoMessage("Information Message Here");
Display a success message and log it to the console.
Uses the console.TA_logSuccess
function to log the content.
The text to be displayed in the message and wriiten to the console.
// Example
app.TA_displaySuccessMessage("Success Message Here");
Display a warning message and log it to the console.
Uses the console.TA_logWarn
functions to log the content.
The text to be displayed in the message and wriiten to the console.
// Example
app.TA_displayWarningMessage("Warning Message Here");
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.
the AES encryption key to use for the encryption.
// Example
app.TA_encryptAESClipboard("FFEEDDCCBBAA99887766554433221100");
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.
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/");
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.
the folder in the Drafts iCloud area to import files from.
an array of tag names to add to each imported draft.
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");
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(","));
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(","));
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.
the name of the action group to load.
// Example
app.TA_loadActionListByName("Writing");
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.
the name of the action group to load.
// Example
app.TA_loadActionListByName("Writing");
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.
The text to be displayed in the box and logged to the console.
// Example
tadLib.debugEnabled = true;
app.TA_msgDebug("Debug Message Here");
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.
The text to be displayed in the box.
// Example
app.TA_msgError("Error Message Here");
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.
The text to be displayed in the box.
// Example
app.TA_msgInfo("Information Message Here");
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.
The text to be displayed in the box.
// Example
app.TA_msgWarn("Warning Message Here");
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.
The title for the box.
The text to be displayed in the box.
// Example
app.TA_msgbox("Title Here", "Message Here");
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.
the cross-link string to process.
// Example
app.TA_processLink("Project XYZ/Heading A/B");
Queue up a named Drafts action to run on a specified draft.
Returns true
if the action was found and queued up.
the name of the action to queue up.
the draft to run it on.
app.TA_queueActionByName("TAD-Instructions");
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();
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.
The name of the tag to be removed.
The name of the filter to apply.
// Example
app.TA_removeTags("oldtag", "archive");
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();
Trash unflagged drafts in the box that are tagged with the specified tag. The function returns the number of drafts that were trashed.
The name of the tag to be found.
// Example
app.TA_trashUnflggedInboxDraftsTaggedDrafts("discourse");
App (Drafts)
The ThoughtAsylum library includes a set of extensions to the Drafts application's global instance of the App object.