Axios library for HTTP requests. See https://axios-http.com for documentation
cheerio library for HTML parsing and manipulation. See https://cheerio.js.org for documentation
Note where the script is currently executing. This comes into play when your script is spread in multiple code notes, the script starts in "startNote", but then through function calls may jump into another note (currentNote). A similar concept in C would be FILE Don't mix this up with the concept of active note.
day.js library for date manipulation. See https://day.js.org for documentation
Optional
originEntity whose event triggered this execution
sql
Optional
startNote where the script started executing (entrypoint). As an analogy, in C this would be the file which contains the main() function of the current process.
xml2js library for XML parsing. See https://github.com/Leonidas-from-XIV/node-xml2js for documentation
If the backupName is e.g. "now", then the backup will be written to "backup-now.db" file
resolves once the backup is finished
Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and JSON MIME type. See also createNewNote() for more options.
object contains newly created entities note and branch
create new note under this parent
Optional
attributes?: AttributeRow[]Optional
json?: booleanshould the note be JSON
object contains newly created entities note and branch
Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.
name of the boxicon to be used (e.g. "bx-time")
id of the launcher, only alphanumeric at least 6 characters long
if true, will be created in the "Visible launchers", otherwise in "Available launchers"
will activate the target note/script upon pressing, e.g. "ctrl+e"
for type "script"
for type "note"
one of
Optional
widgetNoteId?: stringfor type "customWidget"
Create text note. See also createNewNote() for more options.
If there's a branch between note and parent note, remove it. Otherwise, do nothing.
If there's no branch between note and parent note, create one. Otherwise, do nothing. Returns the new or existing branch.
if branch is created between note and parent note, set this prefix
escaped string
Instance name identifies particular Trilium instance. It can be useful for scripts if some action needs to happen on only one specific instance.
Retrieves notes with given label name & value
attribute name
Optional
value: stringattribute value
Retrieves first note with given label name & value
attribute name
Optional
value: stringattribute value
Returns root note of the calendar.
Log given message to trilium logs and log pane in UI
Return randomly generated string of given length. This random string generation is NOT cryptographically secure.
of the string
random string
Executes given anonymous function on the frontend(s). Internally, this serializes the anonymous function into string and sends it to frontend(s) via WebSocket. Note that there can be multiple connected frontend instances (e.g. in different tabs). In such case, all instances execute the given function.
script to be executed on the frontend
list of parameters to the anonymous function to be sent to frontend
no return value is provided.
Sync process can make data intermittently inconsistent. Scripts which require strong data consistency can use this function to wait for a possible sync process to finish and prevent new sync process from starting while it is running.
Because this is an async process, the inner callback doesn't have automatic transaction handling, so in case you need to make some DB changes, you need to surround your call with api.transactional(...)
function to be executed while sync process is not running
resolves once the callback is finished (callback is awaited)
This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See https://triliumnext.github.io/Docs/Wiki/search.html for full documentation for all options
This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See https://triliumnext.github.io/Docs/Wiki/search.html for full documentation for all options
This method finds note by its noteId and prefix and either sets it to the given parentNoteId or removes the branch (if parentNoteId is not given).
This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix.
Sort child notes of a given note.
Optional
foldersFirst?: booleanOptional
reverse?: booleanOptional
sortBy?: string'title', 'dateCreated', 'dateModified' or a label name See https://triliumnext.github.io/Docs/Wiki/sorting.html for details.
Based on the value, either create or remove branch between note and parent note.
true if we want the branch to exist, false if we want it gone
if branch is created between note and parent note, set this prefix
This functions wraps code which is supposed to be running in transaction. If transaction already exists, then we'll use that transaction.
result of func callback
to unescape
unescaped string
This object contains "at your risk" and "no BC guarantees" objects for advanced use cases.