Members
$container
Properties:
Name |
Type |
Description |
container |
jQuery
|
of all the rendered script content |
- Source:
Properties:
Type |
Description |
BasicWidget
|
|
- Source:
Properties:
Type |
Description |
CollapsibleWidget
|
|
- Source:
currentNote
Properties:
Name |
Type |
Description |
note |
object
|
where script is currently executing |
- Source:
originEntity
Properties:
Name |
Type |
Description |
entity |
object
|
null
|
whose event triggered this execution |
- Source:
startNote
Properties:
Name |
Type |
Description |
note |
object
|
where script started executing |
- Source:
Properties:
Type |
Description |
TabAwareWidget
|
|
- Source:
Properties:
Type |
Description |
TabCachingWidget
|
|
- Source:
Methods
activateNewNote(notePath) → {Promise.<void>}
Activates newly created note. Compared to this.activateNote() also makes sure that frontend has been fully synced.
Parameters:
Name |
Type |
Description |
notePath |
string
|
(or noteId) |
- Source:
Returns:
-
Type
-
Promise.<void>
activateNote(notePath) → {Promise.<void>}
Activates note in the tree and in the note detail.
Parameters:
Name |
Type |
Description |
notePath |
string
|
(or noteId) |
- Source:
Returns:
-
Type
-
Promise.<void>
Adds new button the the plugin area.
Parameters:
- Source:
addTextToActiveTabEditor(text)
Adds given text to the editor cursor
Parameters:
Name |
Type |
Description |
text |
string
|
this must be clear text, HTML is not supported. |
- Source:
bindGlobalShortcut(keyboardShortcut, handler)
Parameters:
Name |
Type |
Description |
keyboardShortcut |
string
|
e.g. "ctrl+shift+a" |
handler |
function
|
|
- Source:
createNoteLink(notePath, noteTitleopt)
Create note link (jQuery object) for given note.
Parameters:
Name |
Type |
Attributes |
Description |
notePath |
string
|
|
(or noteId) |
noteTitle |
string
|
<optional>
|
if not present we'll use note title |
- Source:
Parameters:
Name |
Type |
Description |
date |
Date
|
|
- Source:
Returns:
date in YYYY-MM-DD format
-
Type
-
string
getActiveTabNote() → {NoteShort}
- Source:
Returns:
active note (loaded into right pane)
-
Type
-
NoteShort
getActiveTabNotePath() → {Promise.<(string|null)>}
- Source:
Returns:
returns note path of active note or null if there isn't active note
-
Type
-
Promise.<(string|null)>
getActiveTabTextEditor(callback)
See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance.
Parameters:
Name |
Type |
Description |
callback |
|
method receiving "textEditor" instance |
- Source:
getDateNote(date) → {Promise.<NoteShort>}
Returns date-note. If it doesn't exist, it is automatically created.
Parameters:
Name |
Type |
Description |
date |
string
|
e.g. "2019-04-29" |
- Source:
Returns:
-
Type
-
Promise.<NoteShort>
getInstanceName() → {string}
Instance name identifies particular Trilium instance. It can be useful for scripts
if some action needs to happen on only one specific instance.
- Source:
Returns:
-
Type
-
string
getMonthNote(month) → {Promise.<NoteShort>}
Returns month-note. If it doesn't exist, it is automatically created.
Parameters:
Name |
Type |
Description |
month |
string
|
e.g. "2019-04" |
- Source:
Returns:
-
Type
-
Promise.<NoteShort>
getNote(noteId) → {Promise.<NoteShort>}
Returns note by given noteId. If note is missing from cache, it's loaded.
*
Parameters:
Name |
Type |
Description |
noteId |
string
|
|
- Source:
Returns:
-
Type
-
Promise.<NoteShort>
getNotes(noteIds, silentNotFoundErroropt) → {Promise.<Array.<NoteShort>>}
Returns list of notes. If note is missing from cache, it's loaded.
This is often used to bulk-fill the cache with notes which would have to be picked one by one
otherwise (by e.g. createNoteLink())
Parameters:
Name |
Type |
Attributes |
Description |
noteIds |
Array.<string>
|
|
|
silentNotFoundError |
boolean
|
<optional>
|
don't report error if the note is not found |
- Source:
Returns:
-
Type
-
Promise.<Array.<NoteShort>>
getTodayNote() → {Promise.<NoteShort>}
Returns date-note for today. If it doesn't exist, it is automatically created.
- Source:
Returns:
-
Type
-
Promise.<NoteShort>
getYearNote(year) → {Promise.<NoteShort>}
Returns year-note. If it doesn't exist, it is automatically created.
Parameters:
Name |
Type |
Description |
year |
string
|
e.g. "2019" |
- Source:
Returns:
-
Type
-
Promise.<NoteShort>
parseDate(str) → {Date}
Parameters:
Name |
Type |
Description |
str |
string
|
|
- Source:
Returns:
parsed object
-
Type
-
Date
protectActiveNote()
- Deprecated:
- use protectNote and protectSubtree instead
- Source:
protectNote(noteId, protect)
Parameters:
Name |
Type |
Description |
noteId |
string
|
|
protect |
boolean
|
true to protect note, false to unprotect |
- Source:
protectSubTree(noteId, protect)
Parameters:
Name |
Type |
Description |
noteId |
string
|
|
protect |
boolean
|
true to protect subtree, false to unprotect |
- Source:
refreshIncludedNote(includedNoteId)
This will refresh all currently opened notes which have included note specified in the parameter
Parameters:
Name |
Type |
Description |
includedNoteId |
|
noteId of the included note |
- Source:
refreshTree()
- Deprecated:
- - this is now no-op since all the changes should be gracefully handled per widget
- Source:
reloadNotes(noteIds)
Update frontend tree (note) cache from the backend.
Parameters:
Name |
Type |
Description |
noteIds |
Array.<string>
|
|
- Source:
runOnBackend(script, params) → {Promise.<*>}
Executes given anonymous function on the backend.
Internally this serializes the anonymous function into string and sends it to backend via AJAX.
Parameters:
Name |
Type |
Description |
script |
string
|
script to be executed on the backend |
params |
Array.<?>
|
list of parameters to the anonymous function to be send to backend |
- Source:
Returns:
return value of the executed function on the backend
-
Type
-
Promise.<*>
runOnServer()
- Deprecated:
- new name of this API call is runOnBackend so use that
- Source:
searchForNote(searchString) → {Promise.<(NoteShort|null)>}
This is a powerful search method - you can search by attributes and their values, e.g.:
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
Parameters:
Name |
Type |
Description |
searchString |
string
|
|
- Source:
Returns:
-
Type
-
Promise.<(NoteShort|null)>
searchForNotes(searchString) → {Promise.<Array.<NoteShort>>}
This is a powerful search method - you can search by attributes and their values, e.g.:
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
Parameters:
Name |
Type |
Description |
searchString |
string
|
|
- Source:
Returns:
-
Type
-
Promise.<Array.<NoteShort>>
setHoistedNoteId(noteId) → {Promise}
Hoist note. See https://github.com/zadam/trilium/wiki/Note-hoisting
Parameters:
Name |
Type |
Description |
noteId |
string
|
set hoisted note. 'root' will effectively unhoist |
- Source:
Returns:
-
Type
-
Promise
Parameters:
Name |
Type |
Description |
$el |
object
|
jquery object on which to setup the tooltip |
- Source:
showError(message)
Show error message to the user.
Parameters:
Name |
Type |
Description |
message |
string
|
|
- Source:
showMessage(message)
Show info message to the user.
Parameters:
Name |
Type |
Description |
message |
string
|
|
- Source:
waitUntilSynced()
Trilium runs in backend and frontend process, when something is changed on the backend from script,
frontend will get asynchronously synchronized.
This method returns a promise which resolves once all the backend -> frontend synchronization is finished.
Typical use case is when new note has been created, we should wait until it is synced into frontend and only then activate it.
- Source: