Creates new instance of TadBear class. The construction specifies default settings values.
The base callback URL is the one used to call the Bear app
The value defaults to bear://x-callback-url/
The base URL is the one used to call the Bear app
The value defaults to bear://
Defaults to false
, but when set to true
, will display the URL being called before calling it.
Used for debugging purposes only, and is not reset by a call to TA_reset()
.
Initialised to an array of available font names in Bear.
The set of parameters used to build the URL to control Bear. Parameters are added to this attribute as additional attributes and then compiled into the final call URL. After a call, any parameters can be checked individually by referencing them and of course all parameters are available as a set - though there are additional functions and attributes to help with debuggin activities.
Initialised to an array of available theme names in Bear.
This is initialised on each reset, but on each call, it is populated with a simplified URL without the x-callback parameters. You can display this after a call to see the basis of what call was sent.
Add a Boolean to yes
/no
based URL parameter to the instance's parameters.
The function takes the name of the parameter and the value and adds the name to the instance's
parameters
property as a new property, with the defined value translated to yes
(true
) or no
(false
).
This parameter will then be picked up in the subsequent URL call to bear and included in the URL request string.
the name of the parameter.
the value of the parameter - while it is true
/false
, these get converted automatically to yes
/no
as used by the Bear URL scheme.
// Example
let tb = new TadBear();
tb.TA_addParamBool("foo", true);
Add a string based URL parameter to the instance's parameters.
The function takes the name of the parameter and the value and adds the name to the instance's
parameters
property as a new property, with the defined value. This parameter will then be picked up
in the subsequent URL call to bear and included in the URL request string, at which point it will be
automatically URL encoded by the callback
functionality - i.e. there is no need to URL encode it when
passing the value to this function; if you do, it will be double encoded and lead to incompatibility issues.
the name of the parameter.
the value of the parameter.
// Example
let tb = new TadBear();
tb.TA_addParamString("foo", "bar");
Add the device API token as a parameter to the instance's parameters.
The token is always added as a parameter to the parameters
property as a sub-property called token
, and its value is
taken from Draft' credentials store.
// Example
let tb = new TadBear();
tb.TA_addParamToken();
Append to, prepend to, or replace the text of a Bear note identified by its title, ID, or current editing of. The type of update of a note is determined by the mode and there are numerous options for controlling the behaviour, all managed through the wide-range of parameters. While all parameters are optional, you must specify one of the first three parameters to determine which Bear note is to be updated and you must specify one of the following three parameters to detemine what content will be updated.
the unique identifier of the note to be updated. Defaults to an empty string.
the title of the note to be updated. Defaults to an empty string.
defaults to false
, but when set to true
will cause the function to seek to update the note currently loaded into the Bear editor.
the text to be used in the updating of the note. Defaults to an empty string.
defaults to false
, but uses the text on the clipboard to update the note, when set to true
.
the text to add to the header within the note. Defaults to an empty string.
the mode used to update the note. Defaults to append
.
defaults to true
, and when set to true
and the mode is set to append
, it will place a newline character between the existing content and the content being appended.
a comma separated list of tag names to apply to the note. Defaults to an empty string.
defaults to true
, and when set to true
excludes the updating of any matched note that is trashed.
defaults to false
, but when set to true
it will display the updated note in Bear's main or external window.
defaults to false
, but when set to true
on the Mac, it will open the updated note in a new Bear window.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
defaults to false
, but when set to true
, it will place the cursor inside Bear's note editor.
defaults to false
, but when set to true
, it will prepend the current date and time to the text to the additional/replacement text.
// Example
let tb = new TadBear();
let bncUpdated = tb.TA_addText("42E4B1E2-4772-4859-B613-ABBEC5F6F494-92147-00011C1079276C26", "", false, "lorem ipsum");
alert(bncUpdated.title);
alert(bncUpdated.note);
Move a Bear note (based on its ID) to the archive in Bear.
the unique identifier of the note to be archived.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_archiveNote("42E4B1E2-4772-4859-B613-ABBEC5F6F494-92147-00011C1079276C26");
Run an x-callback-url call to Bear.
This function executes an x-callback to Bear for the action passed into it, and the parameters
specified against the Bear object instance. The funtion also sets the url
property of the Bear instance to
match the calling URL (without the x-*
parameters). If the debug
property of the Bear instance is set to true
(not the default), the function will display the url property of the call in an alert
before issuing it.
The function returns the callback response on a successful call, but will return void
if the call failed or was cancelled.
The format of the response varies based on the type of call made.
the name of the Bear URL action.
specifies whether to wait for a response or not. Defaults to yes.
// Example
let tb = new TadBear();
tb.parameters.term = "foo";
alert(JSON.stringify(tb.TA_call("search")));
Change the font in Bear.
the name of the font.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_changeFont("Menlo");
Prompt user to change font in Bear app. The user is shown a prompt with a button for each available font. Selecting a font will trigger a URL call to set that as the font in the Bear app.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_changeFontPrompt();
Change the font in Bear.
the name of the theme.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_changeTheme("Cobalt");
Prompt user to change theme in Bear app. The user is shown a prompt with a button for each available theme. Selecting a theme will trigger a URL call to set that as the theme in the Bear app.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_changeThemePrompt();
Create a new note in Bear. While the parameters are all optional, you must populate at least one content parameter (the first three) to create a note.
the title of the note to be created. Defaults to an empty string.
the text to be used in the creation of the note. Defaults to an empty string.
defaults to false
, but uses the text on the clipboard to create the note, when set to true
.
a comma separated list of tag names to apply to the note. Defaults to an empty string.
defaults to false
, but when set to true
it will display the created note in Bear's main or external window.
defaults to false
, but when set to true
on the Mac, it will open the created note in a new Bear window.
defaults to false
, but when set to true
on the Mac, it will make the external Bear window float above other windows.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
defaults to false
, but when set to true
, it will mark the Bear note as pinned.
defaults to false
, but when set to true
, it will place the cursor inside Bear's note editor.
defaults to false
, but when set to true
, it will prepend the current date and time to the text to the additional/replacement text.
// Example
let tb = new TadBear();
let objResult = tb.TA_create("Note Title", "Note content");
alert(objResult.identifier);
alert(objResult.title);
Delete an existing tag in Bear. The tag must not be associated with any locked notes. If it is, the tag may not be deleted.
the name of the tag to be deleted.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_deleteTag("foo");
Retrieve/request API token for this device for interaction with Bear. The Bear token is unique to each device and any such tokens are stored in the Drafts credentials store. The ID for the token is generated by Drafts assigning a unique ID to every device and storing that ID in the device's local (file) storage for Drafts. When the ID is not present, it will be generated, and when the Bear API token is not set for that ID, it will be requested and the user should enter the API token. Details for where to find the token in different Bear client applications is available on the web site for Bear.
// Example
let tb = new TadBear();
alert(tb.TA_deviceTokenforBear());
Store a local device ID for use with storing Bear credentials.
Bear has a unique API key for each device, so if you have multiple devices, you would require multiple IDs.
Drafts does not have direct access to any unique identifiers of a device, so this function generates one.
The function checks for a file in local Drafts storage called LocalBearID.txt
. This file contains a single
entry - a standard v4 unique identifier. If the file does not exist, then a new identifier is generated. This
unique ID can then be used to distinguish between multiple Bear API tokens that get stored in Drafts' secure credentials
area. This function returns the unique identifier for the device from the file, generating a new identifier if one is
not present.
// Example
let tb = new TadBear();
alert(tb.TA_deviceUUIDforBear());
Export a draft into Bear.
The content of the draft is made the content of a new Bear note. Any tags in Drafts for the draft are added as
tags in Bear (leading #
is added automatically by Bear).
Returns the identifier for the new Bear note.
the draft to be exported.
// Example
let tb = new TadBear();
alert(tb.TA_exportDraftToBear(draft));
Export current selection into Bear. The currently selected content in Drafts, or the entire current draft content if there is no selection is made into a new Bear note. Returns the identifier for the new Bear note.
Get the content of a Bear note given its unique ID or a unique note title.
the unique identifier of the note content to be retrieved. Defaults to an empty string.
the title of the note content to be retrieved. Defaults to an empty string.
// Example
let tb = new TadBear();
alert(tb.TA_getNoteContent("42E4B1E2-4772-4859-B613-ABBEC5F6F494-92147-00011C1079276C26"));
Create a new Bear note with the content of a web page. This function triggers Bear to capture a simplified version of the web content specified by the URL and save it in a new note.
the URL for Bear to retrieve the content for.
a comma separated list of tags to assign to the new note. Defaults to an empty string indicating no tags.
defaults to false
, but when set to true
, it will mark the Bear note as pinned.
defaults to true
, and when set to that, it will return only when it can return the new note information. When set to false
, it will return immediately without that information.
// Example
let tb = new TadBear();
let bniResults = tb.TA_grabURL("https://tadpole.thoughtasylum.com");
alert(`${bniResults.title} (${bniResults.identifier})`);
Import a Bear note into Drafts.
The content of the Bear note specified by the ID is made the content of a new draft. Any tags in Bear are added as
tags in Drafts (no leading #
), and the creation date is set to the creation date from Bear.
The function also supports adding additional tags to an imported draft. This is useful for adding source tags and imported tags.
If no matching note is found, the function returnsvoid
, otherwise the UUID of the new draft is returned.
the unique identifier of the note to be imported.
an array of tag names to add to the draft when imported. Defaults to an empty array.
// Example
let tb = new TadBear();
alert(tb.TA_noteToDraft("0B99FBEB-E5D1-4A51-8130-3FAB6C418622-92147-0001245A3E66B009"));
Import all non-trashed Bear notes into Drafts matching a simple search.
A search term, and a single tag to restrict the search by can be passed to this function. All matching Bear notes are then
imported into Drafts. The content of each matched Bear note is made the content of a new draft. Any tags in Bear for the note are added as
tags in Drafts (no leading #
), and the creation date is set to the creation date of the note from Bear.
The function also supports adding additional tags to an imported draft. This is useful for adding source tags and imported tags.
If no matching notes are found, the function returnsvoid
, otherwise an array of the UUID of the new drafts is returned.
a search term to be searched for. Defaults to an empty string.
a single tag to restrict the searching where only notes tagged with a tag of that name are searched through. Defaults to an empty string which is no tag constraint.
an array of tag names to add to the draft when imported. Defaults to an empty array.
// Example
let tb = new TadBear();
alert(tb.TA_notesToDraft("foo", "bar", ["bear", "imported"]));
Retrieve the details for and optionally open a note in Bear. While the parameters are all optional, you must populate at least one content parameter (the first three) to create a note. Returns void if no match is found.
the unique identifier of the note to be opened. Defaults to an empty string.
the title of the note to be opened. Defaults to an empty string.
a header within the note. Defaults to an empty string.
defaults to true
, and when set to true
excludes the opening of any matched note that is trashed.
defaults to false
, but when set to true
on the Mac, it will open the note in a new Bear window.
defaults to false
, but when set to true
on the Mac, it will make the external Bear window float above other windows.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
defaults to false
, but when set to true
it will display the note in Bear's main or external window.
defaults to false
, but when set to true
will cause the function to seek to return the note currently loaded into the Bear editor.
defaults to false
, but when set to true
, it will mark the Bear note as pinned.
defaults to false
, but when set to true
, it will place the cursor inside Bear's note editor.
// Example
let tb = new TadBear();
let objResult = tb.TA_openNote("0B99FBEB-E5D1-4A51-8130-3FAB6C418622-92147-0001245A3E66B009");
alert(objResult.identifier);
alert(objResult.title);
alert(objResult.note);
alert(objResult.modificationDate);
alert(objResult.creationDate);
alert(objResult.isTrashed);
alert(objResult.tags.join("|"));
Search for a term in Bear across all notes or for a notes tagged with a specific tag.
While the openTag URL scheme documentation for Bear indicates that a comma separated list of tag names can be used,
experimentation with the Bear online URL builder showed that only the first tag is used. If you wish to search
for multiple tags, consider adding the tags prefixed by #
into the search option for that function.
Similarly, while the documentation indicates that Bear note data is returned, no data is returned on a successful
API call for openTag
. Again the search function will return note-related data.
a comma separated list of Bear tag names; though in actuality the API ignores anything after the first one.
// Example
let tb = new TadBear();
let abnmdResults = tb.TA_openTag("foo,bar");
alert(JSON.stringify(abnmdResults));
Generate the parameter string with URL encoding.
The function takes each defined parameter and builds the parameter string that would follow the ?
in a URL
call.
// Example
let tb = new TadBear();
alert(tb.TA_parameterString());
Rename an existing tag in Bear. The tag must not be associated with any locked notes. If it is, the tag may not be renamed.
the name of the tag to be renamed.
the new name of the tag being renamed.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_renameTag("foo");
Resets the Bear instance to an initialised state.
parameters
and url
attributes are reset ready for a call.
// Example
let tb = new TadBear();
tb.TA_reset();
Search for a term in Bear across all notes or for a notes tagged with a specific tag.
a search term to be searched for. Defaults to an empty string.
a single tag to restrict the searching where only notes tagged with a tag of that name are searched through. Defaults to an empty string which is no tag constraint.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
let abnmdResults = tb.TA_search("foo", "bar");
alert(JSON.stringify(abnmdResults));
Select the Archive sidebar item in Bear. The function can optionally provide a search filter to search that particular subset of Bear notes.
the optional search filter to populate in the Bear app. Defaults to an empty string.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_selectArchive("foo");
Select the locked sidebar item in Bear. The function can optionally provide a search filter to search that particular subset of Bear notes.
the optional search filter to populate in the Bear app. Defaults to an empty string.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_selectLocked("foo");
Select Bear tag.
The user is shown a prompt with a button for each available tag from Bear. Selecting a tag return it.
Cancelling will return null
.
// Example
let tb = new TadBear();
alert(tb.TA_selectTag());
Select the locked sidebar item in Bear. The function can optionally provide a search filter to search that particular subset of Bear notes.
the optional search filter to populate in the Bear app. Defaults to an empty string.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_selectToday("foo");
Select the todo sidebar item in Bear. The function can optionally provide a search filter to search that particular subset of Bear notes.
the optional search filter to populate in the Bear app. Defaults to an empty string.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_selectTodo("foo");
Select the Trash sidebar item in Bear. The function can optionally provide a search filter to search that particular subset of Bear notes.
the optional search filter to populate in the Bear app. Defaults to an empty string.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_selectTrash("foo");
Select the untagged sidebar item in Bear. The function can optionally provide a search filter to search that particular subset of Bear notes.
the optional search filter to populate in the Bear app. Defaults to an empty string.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_selectUntagged("foo");
Return all the tags currently displayed in Bear's sidebar. The tags are returned as an array of tag names.
// Example
let tb = new TadBear();
alert(tb.TA_tags().join(" | "));
Move a Bear note (based on its ID) to the trash in Bear.
the unique identifier of the note to be trashed.
defaults to false
, but on the Mac, when set to true
, it will force Bear's main window to open.
// Example
let tb = new TadBear();
tb.TA_trashNote("42E4B1E2-4772-4859-B613-ABBEC5F6F494-92147-00011C1079276C26");
Generate the URL call string. The function generates a basic call URL for the action and available parameters.
the name of the Bear URL action.
// Example
let tb = new TadBear();
tb.parameters.term = "foo";
alert(tb.TA_url("search"));
TadBear (Library)
This is a class that is used for interacting with the Bear app by Shiny Frog.