feat(docs): reorganize scripting notes and finalize attribute reference

This commit is contained in:
Elian Doran 2025-04-07 11:16:10 +03:00
parent cdf9fa5b4a
commit 72f0bc32df
No known key found for this signature in database
63 changed files with 1878 additions and 1381 deletions

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ New tasks are created in the TODO note which has `~child:template` [relation](..
### Attributes
Task template defines several [promoted attributes](../Attributes/Promoted%20Attributes.md) - todoDate, doneDate, tags, location. Importantly it also defines `~runOnAttributeChange` relation - [event](../../Note%20Types/Code/Events.md) handler which is run on attribute change. This [script](../../Scripting.md) handles when e.g. we fill out the doneDate attribute - meaning the task is done and should be moved to "Done" note and removed from TODO, locations and tags.
Task template defines several [promoted attributes](../Attributes/Promoted%20Attributes.md) - todoDate, doneDate, tags, location. Importantly it also defines `~runOnAttributeChange` relation - [event](../../Scripting/Events.md) handler which is run on attribute change. This [script](../../Scripting.md) handles when e.g. we fill out the doneDate attribute - meaning the task is done and should be moved to "Done" note and removed from TODO, locations and tags.
### New task button

View File

@ -1,7 +1,7 @@
# Weight Tracker
![](Weight%20Tracker_image.png)
The `Weight Tracker` is a [Script API](../../Note%20Types/Code/Script%20API.md) showcase present in the [demo notes](../Database.md).
The `Weight Tracker` is a [Script API](../../Scripting/Script%20API.md) showcase present in the [demo notes](../Database.md).
By adding `weight` as a [promoted attribute](../Attributes/Promoted%20Attributes.md) in the [template](../Templates.md) from which [day notes](Day%20Notes.md) are created, you can aggregate the data and plot weight change over time.

View File

@ -20,6 +20,8 @@ Labels are also searchable, enhancing note retrieval.
### Common Labels for Advanced Configuration
See the corresponding section in <a class="reference-link" href="Attributes/Attribute%20Reference.md">Attribute Reference</a> for a comprehensive list of attributes.
## Relations
Relations define connections between notes, similar to links.
@ -31,8 +33,7 @@ Relations define connections between notes, similar to links.
### Common Relations
* **Event-based Relations**: Such as `runOnNoteCreation` or `runOnNoteChange`, which trigger scripts on specific actions
* **Other Relations**: Include `template`, `renderNote`, `widget`, and sharing-related relations
See the corresponding section in <a class="reference-link" href="Attributes/Attribute%20Reference.md">Attribute Reference</a> for a comprehensive list of relations.
## Multiplicity

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,19 @@
# Trilium instance
A Trilium instance represents a server. If <a class="reference-link" href="../../Installation%20%26%20Setup/Synchronization.md">Synchronization</a> is set up, since multiple servers are involved (the one from the desktop client and the one the synchronisation is set up with), sometimes it can be useful to distinguish the instance you are running on.
## Setting the instance name
To set up a name for the instance, modify the `config.ini`:
```
[General]
instanceName=Hello
```
## Distinguishing the instance on back-end
Use `api.getInstanceName()` to obtain the instance name of the current server, as specified in the config file or in environment variables.
## Limiting script runs based on instance
For a script that is run periodically or on a certain event, it's possible to limit it to certain instances without having to change the code. Just add `runOnInstance` and set as the value the instance name where the script should run. To run on multiple named instances, simply add the label multiple times.

View File

@ -53,7 +53,7 @@ Trilium will then find our code note created above and execute it. `api.req`, `a
In the code note we check the request method and then use trivial authentication - keep in mind that these endpoints are by default totally unauthenticated, and you need to take care of this yourself.
Once we pass these checks we will just create the desired note using [Script API](../Note%20Types/Code/Script%20API.md).
Once we pass these checks we will just create the desired note using [Script API](../Scripting/Script%20API.md).
## Custom resource provider

View File

@ -17,14 +17,16 @@ And all children of "2022 Books" will be created with initial title "\[Author na
The value of `#titleTemplate` is evaluated at the point of note's creation as a JavaScript string, which means it can be enriched with the help of JS string interpolation with dynamic data.
As an example, imagine you collect server outage incidents and write some notes. It looks like this:
Second variable injected is `parentNote` which gives access to the parent [`FNote`](../Scripting/Script%20API/Frontend%20API/FNote.md).
* Incidents
See also <a class="reference-link" href="Templates.md">Templates</a> which provides similar capabilities, including default note's content.
### Examples
* Imagine you collect server outage incidents and write some notes. It looks like this:
* Incidents
* 2022-05-09: System crash
* 2022-05-15: Backup delay
You can automatize the date assignment by assigning a label `#titleTemplate="${now.format('YYYY-MM-DD')}: "` to the parent note "Incidents". Whenever a new child note is created, the title template is evaluated with the injected [now](https://day.js.org/docs/en/display/format) object.
Second variable injected is [parentNote](https://triliumnext.github.io/Notes/backend_api/BNote.html), an example could be `#titleTemplate="${parentNote.getLabelValue('authorName')}'s literary works"`.
See also \[\[[template](Templates.md)\]\] which provides similar capabilities, including default note's content.
* You can automatize the date assignment by assigning a label `#titleTemplate="${now.format('YYYY-MM-DD')}: "` to the parent note "Incidents". Whenever a new child note is created, the title template is evaluated with the injected [now](https://day.js.org/docs/en/display/format) object.
* To use a parent's attribute in the title of new notes: `#titleTemplate="${parentNote.getLabelValue('authorName')}'s literary works"`
* To mirror the parent's note title: `${parentNote.title}`

View File

@ -3,7 +3,7 @@ Trilium allows you to share selected notes as **publicly accessible** read-only
## Prerequisites
To use the sharing feature, you must have a [server installation](../Installation%20%26%20Setup/Server%20Installation.md) of Trilium. This is necessary because the notes will be hosted from the server.
To use the sharing feature, you must have a <a class="reference-link" href="../Installation%20%26%20Setup/Server%20Installation.md">Server Installation</a> of Trilium. This is necessary because the notes will be hosted from the server.
## How to Share a Note
@ -40,7 +40,7 @@ To protect shared notes with a username and password, you can use the `#shareCre
The default shared page is basic in design, but you can customize it using your own CSS:
* **Custom CSS**: Link a CSS [code note](../Note%20Types/Code.md) to the shared page by adding a `~shareCss` relation to the note. If you want this style to apply to the entire subtree, make the label inheritable. You can hide the CSS code note from the tree navigation by adding the `#shareHiddenFromTree` label.
* **Custom CSS**: Link a CSS <a class="reference-link" href="../Note%20Types/Code.md">Code</a> note to the shared page by adding a `~shareCss` relation to the note. If you want this style to apply to the entire subtree, make the label inheritable. You can hide the CSS code note from the tree navigation by adding the `#shareHiddenFromTree` label.
* **Omitting Default CSS**: For extensive styling changes, use the `#shareOmitDefaultCss` label to avoid conflicts with Trilium's [default stylesheet](../Basic%20Concepts%20and%20Features/Themes.md).
### Adding JavaScript
@ -81,12 +81,6 @@ To customize the favicon for your shared pages, create a relation `~shareFavicon
You can designate a specific note or folder as the root of your shared content by adding the `#shareRoot` label. This note will be linked when visiting `[http://domain.tld/share](http://domain/share)`, making it easier to use Trilium as a fully-fledged website. Consider combining this with the `#shareIndex` label, which will display a list of all shared notes.
## Additional Options
* **Raw Note Sharing**: Use the `#shareRaw` label to share a note without any HTML wrapper.
* **Disallow Robot Indexing**: Add the `#shareDisallowRobotIndexing` label to prevent search engines from indexing the shared page by including a `noindex, follow` meta tag and `X-Robots-Tag: noindex` header.
* **Shared Notes Index**: For text notes with the `#shareIndex` label, the content will display a list of all shared note roots.
## Limitations
While the sharing feature is powerful, it has some limitations:
@ -99,3 +93,7 @@ While the sharing feature is powerful, it has some limitations:
* **Include Notes**: Not supported.
Some of these limitations may be addressed in future updates.
## Attribute reference
<figure class="table"><table><thead><tr><th>Attribute</th><th>Description</th></tr></thead><tbody><tr><td><code>shareHiddenFromTree</code></td><td>this note is hidden from left navigation tree, but still accessible with its URL</td></tr><tr><td><code>shareExternalLink</code></td><td>note will act as a link to an external website in the share tree</td></tr><tr><td><code>shareAlias</code></td><td>define an alias using which the note will be available under <code>https://your_trilium_host/share/[your_alias]</code></td></tr><tr><td><code>shareOmitDefaultCss</code></td><td>default share page CSS will be omitted. Use when you make extensive styling changes.</td></tr><tr><td><code>shareRoot</code></td><td>marks note which is served on /share root.</td></tr><tr><td><code>shareDescription</code></td><td>define text to be added to the HTML meta tag for description</td></tr><tr><td><code>shareRaw</code></td><td>Note will be served in its raw format, without HTML wrapper. See also&nbsp;<a class="reference-link" href="Sharing/Serving%20directly%20the%20content%20o.md">Serving directly the content of a note</a>&nbsp;for an alternative method without setting an attribute.</td></tr><tr><td><code>shareDisallowRobotIndexing</code></td><td><p>Indicates to web crawlers that the page should not be indexed of this note by:</p><ul><li>Setting the <code>X-Robots-Tag: noindex</code> HTTP header.</li><li>Setting the <code>noindex, follow</code> meta tag.</li></ul></td></tr><tr><td><code>shareCredentials</code></td><td>require credentials to access this shared note. Value is expected to be in format <code>username:password</code>. Don't forget to make this inheritable to apply to child-notes/images.</td></tr><tr><td><code>shareIndex</code></td><td>Note with this label will list all roots of shared notes.</td></tr></tbody></table></figure>

View File

@ -23,7 +23,7 @@ To create an instance note through the UI:
![show child note templates](Templates_template-create-.png)
For the template to appear in the menu, the template note must have the `#template` label. Do not confuse this with the `~template` relation, which links the instance note to the template note. If you use [workspaces](../Basic%20Concepts%20and%20Features/Navigation/Workspace.md), you can also mark templates with `#workspaceTemplate` to display them only in the workspace.
For the template to appear in the menu, the template note must have the `#template` label. Do not confuse this with the `~template` relation, which links the instance note to the template note. If you use [workspaces](../Basic%20Concepts%20and%20Features/Navigation/Workspaces.md), you can also mark templates with `#workspaceTemplate` to display them only in the workspace.
Templates can also be added or changed after note creation by creating a `~template` relation pointing to the desired template note.

View File

@ -5,4 +5,4 @@ Hoisting is a standard outliner feature which allows you to focus on (or "zoom i
In addition to showing only this subtree, this also narrows both full text search and [“jump to note”](Note%20Navigation.md) to just notes present in hoisted subtree.
See also [Workspace](Workspace.md) which extends this feature.
See also [Workspace](Workspaces.md) which extends this feature.

View File

@ -1,24 +0,0 @@
# Workspace
Workspace is a concept built up on top of [note hoisting](Note%20Hoisting.md). It is based on the idea that a user has several distinct spheres of interest. An example might be "Personal" and "Work", these two spheres are quite distinct and don't interact together. When I focus on Work, I don't really care about personal notes.
So far workspace consists of these features:
* [note hoisting](Note%20Hoisting.md) - you can "zoom" into a workspace subtree to focus only on the relevant notes
* easy entering of workspace: 
![](1_Workspace_image.png)
* visual identification of workspace in tabs:
![](Workspace_image.png)
### How to use workspaces
Let's say you have identified the workspaces and their subtrees. Define on the root of this subtree following labels:
* `#workspace` - Marks this note as a workspace, button to enter the workspace is controlled by this
* `#workspaceIconClass` - controls the box icon to be displayed in the tree and tabs, example `bx bx-home`. See [https://boxicons.com/](https://boxicons.com/)
* `#workspaceTabBackgroundColor` - Background color of the tab, use any CSS color format, e.g. "lightblue" or "#ddd". See [https://www.w3schools.com/cssref/css\_colors.asp](https://www.w3schools.com/cssref/css_colors.asp).
* `#workspaceCalendarRoot` - marking a note with this label will define a new per-workspace calendar. If there's no such note, the global calendar will be used.
* `#workspaceTemplate` - This note will appear in the selection of available templates when creating a new note, but only when you are currently hoisted into a workspace containing this template.

View File

@ -0,0 +1,16 @@
# Workspaces
Workspace is a concept built up on top of [note hoisting](Note%20Hoisting.md). It is based on the idea that a user has several distinct spheres of interest. An example might be "Personal" and "Work", these two spheres are quite distinct and don't interact together. When I focus on Work, I don't really care about personal notes.
So far workspace consists of these features:
* [note hoisting](Note%20Hoisting.md) - you can "zoom" into a workspace subtree to focus only on the relevant notes
* easy entering of workspace: 
![](1_Workspaces_image.png)
* visual identification of workspace in tabs:
![](Workspaces_image.png)
### Configuration
<figure class="table"><table><thead><tr><th>Label</th><th>Description</th></tr></thead><tbody><tr><td><code>workspace</code></td><td>Marks this note as a workspace, button to enter the workspace is controlled by this</td></tr><tr><td><code>workspaceIconClass</code></td><td>defines box icon CSS class which will be used in tab when hoisted to this note</td></tr><tr><td><code>workspaceTabBackgroundColor</code></td><td>CSS color used in the note tab when hoisted to this note, use any CSS color format, e.g. "lightblue" or "#ddd". See <a href="https://www.w3schools.com/cssref/css_colors.asp">https://www.w3schools.com/cssref/css_colors.asp</a>.</td></tr><tr><td><code>workspaceCalendarRoot</code></td><td>Marking a note with this label will define a new per-workspace calendar for&nbsp;<a class="reference-link" href="../../Advanced%20Usage/Advanced%20Showcases/Day%20Notes.md">Day Notes</a>. If there's no such note, the global calendar will be used.</td></tr><tr><td><code>workspaceTemplate</code></td><td>This note will appear in the selection of available template when creating new note, but only when hoisted into a workspace containing this template</td></tr><tr><td><code>workspaceSearchHome</code></td><td>new search notes will be created as children of this note when hoisted to some ancestor of this workspace note</td></tr><tr><td><code>workspaceInbox</code></td><td>default inbox location for new notes when hoisted to some ancestor of this workspace note</td></tr></tbody></table></figure>

View File

@ -1,9 +1,10 @@
# Note List
When a note has one or more child notes, they will be listed at the end of the note for easy navigation.
## Hide the note list for a given note
## Configuration
If the note list is not desireable for a particular note, simply apply the `hideChildrenOverview` [label](../../Advanced%20Usage/Attributes.md).
* To hide the note list for a particular note, simply apply the `hideChildrenOverview` [label](../../Advanced%20Usage/Attributes.md).
* For some view types, such as Grid view, only a subset of notes will be displayed and pagination can be used to navigate through all of them for performance reasons. To adjust the number of notes per page, set `pageSize` to the desired number.
## View types

View File

@ -56,7 +56,7 @@ Right click either the _Available launchers_ or _Visible launchers_ sections and
2. Optionally, set a `keyboardShortcut` to trigger the launcher.
3. **Custom Widget**
Allows defining a custom widget to be rendered inside the launcher. See [Widget Basics](../../Scripting/Widget%20Basics.md) for more information.
Allows defining a custom widget to be rendered inside the launcher. See [Widget Basics](../../Scripting/Custom%20Widgets/Widget%20Basics.md) for more information.
4. **Spacers**
Launchers that create some distance between other launchers for better visual distinction.

View File

@ -62,3 +62,5 @@ This section displays information about the current note:
### Edited notes
This section pops automatically when entering a [day note](../../Advanced%20Usage/Advanced%20Showcases/Day%20Notes.md) and shows the notes that were edited that day.
It is possible to disable this behavior from settings, by going to <a class="reference-link" href="#root/_hidden/_options/_optionsAppearance">Appearance</a> settings and looking for the _Ribbon widgets_ section.

View File

@ -1,29 +0,0 @@
# Events
[Script](../../Scripting.md) notes can be triggered by events. Note that these are backend events and thus relation need to point to the "JS backend" code note.
## Global events
Global events are attached to the script note via label. Simply create e.g. "run" label with some of these values and script note will be executed once the event occurs.
* `run`
* `frontendStartup` - executes on frontend upon startup
* `mobileStartup` - executes on mobile frontend upon startup
* `backendStartup` - executes on backend upon startup
* `hourly` - executes once an hour on backend
* `daily` - executes once a day on backend
## Entity events
Other events are bound to some entity, these are defined as [relations](../../Advanced%20Usage/Attributes.md) - meaning that script is triggered only if note has this script attached to it through relations (or it can inherit it).
* `runOnNoteCreation` - executes when note is created on backend
* `runOnNoteTitleChange` - executes when note title is changed (includes note creation as well)
* `runOnNoteContentChange` - executes when note content is changed (includes note creation as well).
* `runOnNoteChange` - executes when note is changed (includes note creation as well)
* `runOnNoteDeletion` - executes when note is being deleted
* `runOnBranchCreation` - executes when a branch is created. Branch is a link between parent note and child note and is created e.g. when cloning or moving note.
* `runOnBranchChange` (since v0.62) - executes when a branch is changed - either expanded status or prefix are changed.
* `runOnBranchDeletion` - executes when a branch is delete. Branch is a link between parent note and child note and is deleted e.g. when moving note (old branch/link is deleted).
* `runOnChildNoteCreation` - executes when new note is created under _this_ note
* `runOnAttributeCreation` - executes when new attribute is created under _this_ note
* `runOnAttributeChange` - executes when attribute is changed under _this_ note

View File

@ -5,4 +5,4 @@ Trilium allows you to save common searches as notes within the note tree. The se
## Location
By default, saved searches are stored in the day note. However, you can designate a different note to store saved searches by marking it with the `#searchHome` label. Additionally, for [workspaces](../Basic%20Concepts%20and%20Features/Navigation/Workspace.md), you can use the `#workspaceSearchHome` label to specify a storage location for saved searches within that workspace.
By default, saved searches are stored in the day note. However, you can designate a different note to store saved searches by marking it with the `#searchHome` label. Additionally, for [workspaces](../Basic%20Concepts%20and%20Features/Navigation/Workspaces.md), you can use the `#workspaceSearchHome` label to specify a storage location for saved searches within that workspace.

View File

@ -1,5 +1,5 @@
# Scripting
Trilium supports creating <a class="reference-link" href="Note%20Types/Code.md">Code</a> notes, i.e. notes which allow you to store some programming code and highlight it. Special case is JavaScript code notes which can also be executed inside Trilium which can in conjunction with <a class="reference-link" href="Note%20Types/Code/Script%20API.md">Script API</a> provide extra functionality.
Trilium supports creating <a class="reference-link" href="Note%20Types/Code.md">Code</a> notes, i.e. notes which allow you to store some programming code and highlight it. Special case is JavaScript code notes which can also be executed inside Trilium which can in conjunction with <a class="reference-link" href="Scripting/Script%20API.md">Script API</a> provide extra functionality.
## Scripting
@ -34,8 +34,8 @@ You can see more scripting with explanation in <a class="reference-link" href="
## Events
See <a class="reference-link" href="Note%20Types/Code/Events.md">Events</a>.
See <a class="reference-link" href="Scripting/Events.md">Events</a>.
## Script API
See <a class="reference-link" href="Note%20Types/Code/Script%20API.md">Script API</a>.
See <a class="reference-link" href="Scripting/Script%20API.md">Script API</a>.

View File

@ -22,10 +22,10 @@ module.exports = new MyWidget();
To implement this widget:
1. Create a new `JS Frontend` note in Trilium and paste in the code above.
2. Assign the `#widget` [attribute](../Advanced%20Usage/Attributes.md) to the [note](../Basic%20Concepts%20and%20Features/Notes.md).
2. Assign the `#widget` [attribute](../../Advanced%20Usage/Attributes.md) to the [note](../../Basic%20Concepts%20and%20Features/Notes.md).
3. Restart Trilium or reload the window.
To verify that the widget is working, open the developer tools (`Cmd` + `Shift` + `I`) and run `document.querySelector("#my-widget")`. If the element is found, the widget is functioning correctly. If `undefined` is returned, double-check that the [note](../Basic%20Concepts%20and%20Features/Notes.md) has the `#widget` [attribute](../Advanced%20Usage/Attributes.md).
To verify that the widget is working, open the developer tools (`Cmd` + `Shift` + `I`) and run `document.querySelector("#my-widget")`. If the element is found, the widget is functioning correctly. If `undefined` is returned, double-check that the [note](../../Basic%20Concepts%20and%20Features/Notes.md) has the `#widget` [attribute](../../Advanced%20Usage/Attributes.md).
### Step 2: Adding an UI Element
@ -85,7 +85,7 @@ After reloading Trilium, the button should now appear at the bottom left of the
### Step 4: Adding User Interaction
Lets make the button interactive by showing a message when its clicked. We'll use the `api.showMessage` method from the [Script API](../Note%20Types/Code/Script%20API.md).
Lets make the button interactive by showing a message when its clicked. We'll use the `api.showMessage` method from the [Script API](../Script%20API.md).
```
class MyWidget extends api.BasicWidget {

View File

@ -1,8 +1,8 @@
# Word count widget
> [!TIP]
> This widget is also present in new installations in the <a class="reference-link" href="../../../Advanced%20Usage/Database/Demo%20Notes.md">Demo Notes</a>.
> This widget is also present in new installations in the <a class="reference-link" href="../../Advanced%20Usage/Database/Demo%20Notes.md">Demo Notes</a>.
Create a <a class="reference-link" href="../../Code.md">Code</a> note of type JS frontend and **give it a** `#widget` **label**.
Create a <a class="reference-link" href="../../Note%20Types/Code.md">Code</a> note of type JS frontend and **give it a** `#widget` **label**.
```
/*
@ -82,7 +82,7 @@ class WordCountWidget extends api.NoteContextAwareWidget {
module.exports = new WordCountWidget();
```
After you make changes it is necessary to [restart Trilium](../../../Troubleshooting/Refreshing%20the%20application.md) so that the layout can be rebuilt.
After you make changes it is necessary to [restart Trilium](../../Troubleshooting/Refreshing%20the%20application.md) so that the layout can be rebuilt.
At the bottom of the note you can see the resulting widget:

View File

@ -0,0 +1,14 @@
# Events
[Script](../Scripting.md) notes can be triggered by events. Note that these are backend events and thus relation need to point to the "JS backend" code note.
## Global events
Global events are attached to the script note via label. Simply create e.g. "run" label with some of these values and script note will be executed once the event occurs.
<figure class="table"><table><thead><tr><th>Label</th><th>Description</th></tr></thead><tbody><tr><td><code>run</code></td><td><p>Defines on which events script should run. Possible values are:</p><ul><li><code>frontendStartup</code> - when Trilium frontend starts up (or is refreshed), but not on mobile.</li><li><code>mobileStartup</code> - when Trilium frontend starts up (or is refreshed), on mobile.</li><li><code>backendStartup</code> - when Trilium backend starts up</li><li><code>hourly</code> - run once an hour. You can use additional label <code>runAtHour</code> to specify at which hour, on the back-end.</li><li><code>daily</code> - run once a day, on the back-end</li></ul></td></tr><tr><td><code>runOnInstance</code></td><td>Specifies that the script should only run on a particular&nbsp;<a class="reference-link" href="../Advanced%20Usage/Configuration%20(config.ini%20or%20environment%20variables)/Trilium%20instance.md">Trilium instance</a>.</td></tr><tr><td><code>runAtHour</code></td><td>On which hour should this run. Should be used together with <code>#run=hourly</code>. Can be defined multiple times for more runs during the day.</td></tr></tbody></table></figure>
## Entity events
Other events are bound to some entity, these are defined as [relations](../Advanced%20Usage/Attributes.md) - meaning that script is triggered only if note has this script attached to it through relations (or it can inherit it).
<figure class="table"><table><thead><tr><th>Relation</th><th>Description</th></tr></thead><tbody><tr><td><code>runOnNoteCreation</code></td><td>executes when note is created on backend. Use this relation if you want to run the script for all notes created under a specific subtree. In that case, create it on the subtree root note and make it inheritable. A new note created within the subtree (any depth) will trigger the script.</td></tr><tr><td><code>runOnChildNoteCreation</code></td><td>executes when new note is created under the note where this relation is defined</td></tr><tr><td><code>runOnNoteTitleChange</code></td><td>executes when note title is changed (includes note creation as well)</td></tr><tr><td><code>runOnNoteContentChange</code></td><td>executes when note content is changed (includes note creation as well).</td></tr><tr><td><code>runOnNoteChange</code></td><td>executes when note is changed (includes note creation as well). Does not include content changes</td></tr><tr><td><code>runOnNoteDeletion</code></td><td>executes when note is being deleted</td></tr><tr><td><code>runOnBranchCreation</code></td><td>executes when a branch is created. Branch is a link between parent note and child note and is created e.g. when cloning or moving note.</td></tr><tr><td><code>runOnBranchChange</code></td><td>executes when a branch is updated. (since v0.62)</td></tr><tr><td><code>runOnBranchDeletion</code></td><td>executes when a branch is deleted. Branch is a link between parent note and child note and is deleted e.g. when moving note (old branch/link is deleted).</td></tr><tr><td><code>runOnAttributeCreation</code></td><td>executes when new attribute is created for the note which defines this relation</td></tr><tr><td><code>runOnAttributeChange</code></td><td>executes when the attribute is changed of a note which defines this relation. This is triggered also when the attribute is deleted</td></tr></tbody></table></figure>

View File

@ -1,7 +1,7 @@
# Frontend Basics
## Frontend API
The frontend api supports two styles, regular scripts that are run with the current app and note context, and widgets that export an object to Trilium to be used in the UI. In both cases, the frontend api of Trilium is available to scripts running in the frontend context as global variable `api`. The members and methods of the api can be seen on the [Script API](../Note%20Types/Code/Script%20API.md) page.
The frontend api supports two styles, regular scripts that are run with the current app and note context, and widgets that export an object to Trilium to be used in the UI. In both cases, the frontend api of Trilium is available to scripts running in the frontend context as global variable `api`. The members and methods of the api can be seen on the [Script API](Script%20API.md) page.
## Scripts
@ -54,4 +54,4 @@ Conversely to scripts, widgets do have some specific requirements in order to wo
### Tutorial
For more information on building widgets, take a look at [Widget Basics](Widget%20Basics.md).
For more information on building widgets, take a look at [Widget Basics](Custom%20Widgets/Widget%20Basics.md).

View File

@ -21,7 +21,7 @@ TRILIUM_START_NOTE_ID=root ./trilium
## Broken Script Prevents Application Startup
If a custom script causes Triliumto crash, and it is set as a startup script or in an active [custom widget](Note%20Types/Code/Custom%20Widgets.md), start Triliumin "safe mode" to prevent any custom scripts from executing:
If a custom script causes Triliumto crash, and it is set as a startup script or in an active [custom widget](Scripting/Custom%20Widgets.md), start Triliumin "safe mode" to prevent any custom scripts from executing:
```
TRILIUM_SAFE_MODE=true ./trilium

File diff suppressed because it is too large Load Diff

View File

@ -36,8 +36,8 @@
<h3>Attributes</h3>
<p>Task template defines several <a href="../Attributes/Promoted%20Attributes.html">promoted attributes</a> -
todoDate, doneDate, tags, location. Importantly it also defines <code>~runOnAttributeChange</code> relation
- <a href="../../Note%20Types/Code/Events.html">event</a> handler which is
run on attribute change. This <a href="../../Scripting.html">script</a> handles
- <a href="../../Scripting/Events.html">event</a> handler which is run on
attribute change. This <a href="../../Scripting.html">script</a> handles
when e.g. we fill out the doneDate attribute - meaning the task is done
and should be moved to "Done" note and removed from TODO, locations and
tags.</p>

View File

@ -16,7 +16,7 @@
<p>
<img src="Weight Tracker_image.png">
</p>
<p>The <code>Weight Tracker</code> is a <a href="../../Note%20Types/Code/Script%20API.html">Script API</a> showcase
<p>The <code>Weight Tracker</code> is a <a href="../../Scripting/Script%20API.html">Script API</a> showcase
present in the <a href="../Database.html">demo notes</a>.</p>
<p>By adding <code>weight</code> as a <a href="../Attributes/Promoted%20Attributes.html">promoted attribute</a> in
the <a href="../Templates.html">template</a> from which <a href="Day%20Notes.html">day notes</a> are

View File

@ -37,9 +37,8 @@
</ul>
<p>Labels are also searchable, enhancing note retrieval.</p>
<h3>Common Labels for Advanced Configuration</h3>
<ul>
<li>&nbsp;</li>
</ul>
<p>See the corresponding section in&nbsp;<a class="reference-link" href="Attributes/Attribute%20Reference.html">Attribute Reference</a>&nbsp;for
a comprehensive list of attributes.</p>
<h2>Relations</h2>
<p>Relations define connections between notes, similar to links.</p>
<h3>Uses</h3>
@ -50,12 +49,8 @@
related to the note</li>
</ul>
<h3>Common Relations</h3>
<ul>
<li><strong>Event-based Relations</strong>: Such as <code>runOnNoteCreation</code> or <code>runOnNoteChange</code>,
which trigger scripts on specific actions</li>
<li><strong>Other Relations</strong>: Include <code>template</code>, <code>renderNote</code>, <code>widget</code>,
and sharing-related relations</li>
</ul>
<p>See the corresponding section in&nbsp;<a class="reference-link" href="Attributes/Attribute%20Reference.html">Attribute Reference</a>&nbsp;for
a comprehensive list of relations.</p>
<h2>Multiplicity</h2>
<p>Attributes in Trilium can be "multivalued", meaning multiple attributes
with the same name can coexist.</p>

View File

@ -14,6 +14,11 @@
<div class="ck-content">
<h2>Labels</h2>
<aside class="admonition tip">
<p>Some labels presented here end with a <code>*</code>. That means that there
are multiple labels with the same prefix, consult the specific page linked
in the description of that label for more information.</p>
</aside>
<figure class="table" style="width:100%;">
<table class="ck-table-resized">
<colgroup>
@ -30,9 +35,15 @@
<tr>
<td><code>disableVersioning</code>
</td>
<td>Disables automatic creation of&nbsp;<a class="reference-link" href="../../Basic%20Concepts%20and%20Features/Notes/Note%20Revisions.html">Note Revisions</a>.
Useful for e.g. large, but unimportant notes - e.g. large JS libraries
used for scripting.</td>
<td>Disables automatic creation of&nbsp;<a class="reference-link" href="../../Basic%20Concepts%20and%20Features/Notes/Note%20Revisions.html">Note Revisions</a>&nbsp;for
a particular note. Useful for e.g. large, but unimportant notes - e.g.
large JS libraries used for scripting.</td>
</tr>
<tr>
<td><code>versioningLimit</code>
</td>
<td>Limits the maximum number of&nbsp;<a class="reference-link" href="../../Basic%20Concepts%20and%20Features/Notes/Note%20Revisions.html">Note Revisions</a>&nbsp;for
a particular note, overriding the global settings.</td>
</tr>
<tr>
<td><code>calendarRoot</code>
@ -50,35 +61,12 @@
<tr>
<td><code>excludeFromExport</code>
</td>
<td>Notes (with their sub-tree) won't be included when exporting.</td>
<td>Excludes this note and its children when exporting.</td>
</tr>
<tr>
<td><code>run</code>
<td><code>run</code>, <code>runOnInstance</code>, <code>runAtHour</code>
</td>
<td>
<p>Defines on which events script should run. Possible values are:</p>
<ul>
<li><code>frontendStartup</code> - when Trilium frontend starts up (or is refreshed),
but not on mobile.</li>
<li><code>mobileStartup</code> - when Trilium frontend starts up (or is refreshed),
on mobile.</li>
<li><code>backendStartup</code> - when Trilium backend starts up</li>
<li><code>hourly</code> - run once an hour. You can use additional label <code>runAtHour</code> to
specify at which hour.</li>
<li><code>daily</code> - run once a day</li>
</ul>
</td>
</tr>
<tr>
<td><code>runOnInstance</code>
</td>
<td>Define which trilium instance should run this on. Default to all instances.</td>
</tr>
<tr>
<td><code>runAtHour</code>
</td>
<td>On which hour should this run. Should be used together with <code>#run=hourly</code>.
Can be defined multiple times for more runs during the day.</td>
<td>See&nbsp;<a class="reference-link" href="../../Scripting/Events.html">Events</a>.</td>
</tr>
<tr>
<td><code>disableInclusion</code>
@ -122,7 +110,8 @@
<td><code>hidePromotedAttributes</code>
</td>
<td>Hide&nbsp;<a class="reference-link" href="Promoted%20Attributes.html">Promoted Attributes</a>&nbsp;on
this note.</td>
this note. Generally useful when defining inherited attributes, but the
parent note doesn't need them.</td>
</tr>
<tr>
<td><code>readOnly</code>
@ -133,21 +122,23 @@
<tr>
<td><code>autoReadOnlyDisabled</code>
</td>
<td>text/code notes can be set automatically into read mode when they are
too large. You can disable this behavior on per-note basis by adding this
label to the note</td>
<td>Disables automatic <a href="../../Basic%20Concepts%20and%20Features/Notes/Read-Only%20Notes.html">read-only mode</a> for
the given note.</td>
</tr>
<tr>
<td><code>appCss</code>
</td>
<td>marks CSS notes which are loaded into the Trilium application and can
thus be used to modify Trilium's looks.</td>
<td>Marks CSS notes which are loaded into the Trilium application and can
thus be used to modify Trilium's looks. See&nbsp;<a class="reference-link"
href="../../Theme%20development/Custom%20app-wide%20CSS.html">Custom app-wide CSS</a>&nbsp;for
more info.</td>
</tr>
<tr>
<td><code>appTheme</code>
</td>
<td>marks CSS notes which are full Trilium themes and are thus available in
Trilium options.</td>
<td>Marks CSS notes which are full Trilium themes and are thus available in
Trilium options. See&nbsp;<a class="reference-link" href="../../Theme%20development">Theme development</a>&nbsp;for
more information.</td>
</tr>
<tr>
<td><code>appThemeBase</code>
@ -161,9 +152,9 @@
<tr>
<td><code>cssClass</code>
</td>
<td>value of this label is then added as CSS class to the node representing
given note in the tree. This can be useful for advanced theming. Can be
used in template notes.</td>
<td>Value of this label is then added as CSS class to the node representing
given note in the&nbsp;<a class="reference-link" href="../../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree.html">Note Tree</a>.
This can be useful for advanced theming. Can be used in template notes.</td>
</tr>
<tr>
<td><code>iconClass</code>
@ -175,7 +166,8 @@
<tr>
<td><code>pageSize</code>
</td>
<td>number of items per page in note listing</td>
<td>Specifies the number of items per page in&nbsp;<a class="reference-link"
href="../../Basic%20Concepts%20and%20Features/Notes/Note%20List.html">Note List</a>.</td>
</tr>
<tr>
<td><code>customRequestHandler</code>
@ -190,47 +182,20 @@
<tr>
<td><code>widget</code>
</td>
<td>marks this note as a custom widget which will be added to the Trilium
component tree. See&nbsp;<a class="reference-link" href="../../Note%20Types/Code/Custom%20Widgets.html">Custom Widgets</a>&nbsp;for
<td>Marks this note as a custom widget which will be added to the Trilium
component tree. See&nbsp;<a class="reference-link" href="../../Scripting/Custom%20Widgets.html">Custom Widgets</a>&nbsp;for
more information.</td>
</tr>
<tr>
<td><code>workspace</code>
</td>
<td>marks this note as a workspace which allows easy hoisting</td>
</tr>
<tr>
<td><code>workspaceIconClass</code>
</td>
<td>defines box icon CSS class which will be used in tab when hoisted to this
note</td>
</tr>
<tr>
<td><code>workspaceTabBackgroundColor</code>
</td>
<td>CSS color used in the note tab when hoisted to this note</td>
</tr>
<tr>
<td><code>workspaceCalendarRoot</code>
</td>
<td>Defines per-workspace calendar root</td>
</tr>
<tr>
<td><code>workspaceTemplate</code>
</td>
<td>This note will appear in the selection of available template when creating
new note, but only when hoisted into a workspace containing this template</td>
</tr>
<tr>
<td><code>searchHome</code>
</td>
<td>new search notes will be created as children of this note</td>
<td>New search notes will be created as children of this note (see&nbsp;
<a
class="reference-link" href="../../Note%20Types/Saved%20Search.html">Saved Search</a>).</td>
</tr>
<tr>
<td><code>workspaceSearchHome</code>
</td>
<td>new search notes will be created as children of this note when hoisted
to some ancestor of this workspace note</td>
<td><code>workspace</code> and related attributes</td>
<td>See&nbsp;<a class="reference-link" href="../../Basic%20Concepts%20and%20Features/Navigation/Workspaces.html">Workspaces</a>.</td>
</tr>
<tr>
<td><code>inbox</code>
@ -239,90 +204,35 @@
in the sidebar, notes will be created as child notes in the note marked
as with <code>#inbox</code> label.</td>
</tr>
<tr>
<td><code>workspaceInbox</code>
</td>
<td>default inbox location for new notes when hoisted to some ancestor of
this workspace note</td>
</tr>
<tr>
<td><code>sqlConsoleHome</code>
</td>
<td>default location of&nbsp;<a class="reference-link" href="#root/_hidden/_help/_help_tC7s2alapj8V/_help_wX4HbRucYSDD/_help_oyIAJ9PvvwHX/_help_YKWqdJhzi2VY">SQL Console</a>&nbsp;notes</td>
<td>Default location of&nbsp;<a class="reference-link" href="#root/_hidden/_help/_help_tC7s2alapj8V/_help_wX4HbRucYSDD/_help_oyIAJ9PvvwHX/_help_YKWqdJhzi2VY">SQL Console</a>&nbsp;notes</td>
</tr>
<tr>
<td><code>bookmarked</code>
</td>
<td>Indicates this note is a <a href="../../Basic%20Concepts%20and%20Features/Navigation/Bookmarks.html">bookmark</a>.</td>
</tr>
<tr>
<td><code>bookmarkFolder</code>
</td>
<td>note with this label will appear in bookmarks as folder (allowing access
to its children)</td>
<td>Note with this label will appear in bookmarks as folder (allowing access
to its children). See&nbsp;<a class="reference-link" href="../../Basic%20Concepts%20and%20Features/Navigation/Bookmarks.html">Bookmarks</a>&nbsp;for
more information.</td>
</tr>
<tr>
<td><code>shareHiddenFromTree</code>
<td><code>share*</code>
</td>
<td>this note is hidden from left navigation tree, but still accessible with
its URL</td>
<td>See the attribute reference in&nbsp;<a class="reference-link" href="../Sharing.html">Sharing</a>.</td>
</tr>
<tr>
<td><code>shareExternalLink</code>
<td><code>displayRelations</code>, <code>hideRelations</code>
</td>
<td>note will act as a link to an external website in the share tree</td>
</tr>
<tr>
<td><code>shareAlias</code>
</td>
<td>define an alias using which the note will be available under <code>https://your_trilium_host/share/[your_alias]</code>
</td>
</tr>
<tr>
<td><code>shareOmitDefaultCss</code>
</td>
<td>default share page CSS will be omitted. Use when you make extensive styling
changes.</td>
</tr>
<tr>
<td><code>shareRoot</code>
</td>
<td>marks note which is served on /share root.</td>
</tr>
<tr>
<td><code>shareDescription</code>
</td>
<td>define text to be added to the HTML meta tag for description</td>
</tr>
<tr>
<td><code>shareRaw</code>
</td>
<td>note will be served in its raw format, without HTML wrapper</td>
</tr>
<tr>
<td><code>shareDisallowRobotIndexing</code>
</td>
<td>will forbid robot indexing of this note by setting the <code>X-Robots-Tag: noindex</code> HTTP
header.</td>
</tr>
<tr>
<td><code>shareCredentials</code>
</td>
<td>require credentials to access this shared note. Value is expected to be
in format <code>username:password</code>. Don't forget to make this inheritable
to apply to child-notes/images.</td>
</tr>
<tr>
<td><code>shareIndex</code>
</td>
<td>note with this label will list all roots of shared notes</td>
</tr>
<tr>
<td><code>displayRelations</code>
</td>
<td>comma delimited names of relations which should be displayed. All other
ones will be hidden.</td>
</tr>
<tr>
<td><code>hideRelations</code>
</td>
<td>comma delimited names of relations which should be hidden. All other ones
will be displayed.</td>
<td>Comma delimited names of relations which should be displayed/hidden in
a&nbsp;<a class="reference-link" href="../../Note%20Types/Relation%20Map.html">Relation Map</a>&nbsp;(both
the note type and the&nbsp;<a class="reference-link" href="../Note%20Map%20(Link%20map%2C%20Tree%20map).html">Note Map (Link map, Tree map)</a>&nbsp;general
functionality).</td>
</tr>
<tr>
<td><code>titleTemplate</code>
@ -337,15 +247,18 @@
</li>
<li><code>Log for ${now.format('YYYY-MM-DD HH:mm:ss')}</code>
</li>
<li><code>${parentNote.title}</code> to mirror the parent's template.</li>
<li>to mirror the parent's template.</li>
</ul>
<p>See&nbsp;<a class="reference-link" href="../Default%20Note%20Title.html">Default Note Title</a>&nbsp;for
more info.</p>
</td>
</tr>
<tr>
<td><code>template</code>
</td>
<td>This note will appear in the selection of available template when creating
new note</td>
new note. See&nbsp;<a class="reference-link" href="../Templates.html">Templates</a>&nbsp;for
more information.</td>
</tr>
<tr>
<td><code>toc</code>
@ -398,7 +311,13 @@
<tr>
<td><code>hideHighlightWidget</code>
</td>
<td>Hide Highlight List widget</td>
<td>Hides the&nbsp;<a class="reference-link" href="../../Note%20Types/Text/Highlights%20list.html">Highlights list</a>&nbsp;widget</td>
</tr>
<tr>
<td><code>hideChildrenOverview</code>
</td>
<td>Hides the&nbsp;<a class="reference-link" href="../../Basic%20Concepts%20and%20Features/Notes/Note%20List.html">Note List</a>&nbsp;for
that particular note.</td>
</tr>
<tr>
<td><code>printLandscape</code>
@ -411,10 +330,34 @@
</td>
<td>When exporting to PDF, changes the size of the page. Supported values: <code>A0</code>, <code>A1</code>, <code>A2</code>, <code>A3</code>, <code>A4</code>, <code>A5</code>, <code>A6</code>, <code>Legal</code>, <code>Letter</code>, <code>Tabloid</code>, <code>Ledger</code>.</td>
</tr>
<tr>
<td><code>geolocation</code>
</td>
<td>Indicates the latitude and longitude of a note, to be displayed in a&nbsp;
<a
class="reference-link" href="../../Note%20Types/Geo%20Map.html">Geo Map</a>.</td>
</tr>
<tr>
<td><code>calendar:*</code>
</td>
<td>Defines specific options for the&nbsp;<a class="reference-link" href="../../Basic%20Concepts%20and%20Features/Notes/Note%20List/Calendar%20View.html">Calendar View</a>.</td>
</tr>
<tr>
<td><code>viewType</code>
</td>
<td>Sets the view of child notes (e.g. grid or list). See&nbsp;<a class="reference-link"
href="../../Basic%20Concepts%20and%20Features/Notes/Note%20List.html">Note List</a>&nbsp;for
more information.</td>
</tr>
</tbody>
</table>
</figure>
<h2>Relations</h2>
<aside class="admonition tip">
<p>Some relations presented here end with a <code>*</code>. That means that
there are multiple relations with the same prefix, consult the specific
page linked in the description of that relation for more information.</p>
</aside>
<figure class="table" style="width:100%;">
<table class="ck-table-resized">
<colgroup>
@ -429,69 +372,10 @@
</thead>
<tbody>
<tr>
<td><code>runOnNoteCreation</code>
<td><code>runOn*</code>
</td>
<td>executes when note is created on backend. Use this relation if you want
to run the script for all notes created under a specific subtree. In that
case, create it on the subtree root note and make it inheritable. A new
note created within the subtree (any depth) will trigger the script.</td>
</tr>
<tr>
<td><code>runOnChildNoteCreation</code>
<td>See&nbsp;<a class="reference-link" href="../../Scripting/Events.html">Events</a>
</td>
<td>executes when new note is created under the note where this relation is
defined</td>
</tr>
<tr>
<td><code>runOnNoteTitleChange</code>
</td>
<td>executes when note title is changed (includes note creation as well)</td>
</tr>
<tr>
<td><code>runOnNoteContentChange</code>
</td>
<td>executes when note content is changed (includes note creation as well).</td>
</tr>
<tr>
<td><code>runOnNoteChange</code>
</td>
<td>executes when note is changed (includes note creation as well). Does not
include content changes</td>
</tr>
<tr>
<td><code>runOnNoteDeletion</code>
</td>
<td>executes when note is being deleted</td>
</tr>
<tr>
<td><code>runOnBranchCreation</code>
</td>
<td>executes when a branch is created. Branch is a link between parent note
and child note and is created e.g. when cloning or moving note.</td>
</tr>
<tr>
<td><code>runOnBranchChange</code>
</td>
<td>executes when a branch is updated.</td>
</tr>
<tr>
<td><code>runOnBranchDeletion</code>
</td>
<td>executes when a branch is deleted. Branch is a link between parent note
and child note and is deleted e.g. when moving note (old branch/link is
deleted).</td>
</tr>
<tr>
<td><code>runOnAttributeCreation</code>
</td>
<td>executes when new attribute is created for the note which defines this
relation</td>
</tr>
<tr>
<td><code>runOnAttributeChange</code>
</td>
<td>executes when the attribute is changed of a note which defines this relation.
This is triggered also when the attribute is deleted</td>
</tr>
<tr>
<td><code>template</code>
@ -550,73 +434,6 @@
</tbody>
</table>
</figure>
<p>&nbsp;</p>
<ul>
<li><code>disableVersioning</code>: Disables automatic versioning, ideal for
large, unimportant notes like script libraries</li>
<li><code>versioningLimit</code>: Used to limit the number of revisions for
a single note</li>
<li><code>calendarRoot</code>: Marks the note as the root for&nbsp;<a class="reference-link"
href="../Advanced%20Showcases/Day%20Notes.html">Day Notes</a>. Only one
note should carry this label.</li>
<li><code>excludeFromExport</code>: Excludes notes and their subtrees from
export operations</li>
<li><code>run</code>: Specifies events to trigger scripts (e.g., <code>frontendStartup</code>, <code>hourly</code>)</li>
<li><code>runAtHour</code>: Defines specific hours for scripts to run, used
with <code>#run=hourly</code>
</li>
<li><code>disableInclusion</code>: Prevents a script from being included in
parent script executions</li>
<li><code>sorted</code>: Automatically sorts child notes alphabetically by
title</li>
<li><code>top</code>: Keeps the note at the top of its parent's list, useful
with <code>sorted</code>
</li>
<li><code>hidePromotedAttributes</code>: Hides certain attributes in the note's
display</li>
<li><code>readOnly</code>: Sets the note to read-only mode, applicable to
text and code notes</li>
<li><code>autoReadOnlyDisabled</code>: Disables automatic read-only mode for
large notes</li>
<li><code>appCss</code>: Marks CSS notes used to modify Triliums appearance</li>
<li><code>appTheme</code>: Marks full CSS themes available in Trilium's options</li>
<li><code>cssClass</code>: Adds a CSS class to the note's representation in
the tree</li>
<li><code>iconClass</code>: Adds a CSS class to the note's icon, useful for
distinguishing notes visually. See&nbsp;<a class="reference-link" href="../../Basic%20Concepts%20and%20Features/Notes/Note%20Icons.html">Note Icons</a>.</li>
<li><code>pageSize</code>: Specifies the number of items per page in note
listings</li>
<li><code>customRequestHandler</code> <strong>and</strong> <code>customResourceProvider</code>:
Refer to&nbsp;<a class="reference-link" href="../Custom%20Request%20Handler.html">Custom Request Handler</a>
</li>
<li><code>widget</code>: Marks a note as a custom widget, added to Trilium's
component tree</li>
<li><code>workspace</code> <strong>and related attributes</strong>: See&nbsp;
<a
class="reference-link" href="../../Basic%20Concepts%20and%20Features/Navigation/Workspace.html">Workspace</a>&nbsp;for more details</li>
<li><code>searchHome</code>: Specifies the parent for new search notes</li>
<li><code>inbox</code>: Designates a default location for new notes created
via the sidebar</li>
<li><code>sqlConsoleHome</code>: Default location for SQL console notes</li>
<li><code>bookmarked</code> <strong>and</strong> <code>bookmarkFolder</code>:
See&nbsp;<a class="reference-link" href="../../Basic%20Concepts%20and%20Features/Navigation/Bookmarks.html">Bookmarks</a>
</li>
<li><code>share:[…]</code>: See&nbsp;<a class="reference-link" href="../Sharing.html">Sharing</a>
</li>
<li><code>keyboardShortcut</code>: Assigns a keyboard shortcut to open the
note</li>
<li><code>displayRelations</code> <strong>and</strong> <code>hideRelations</code>:
Manages the display of note relations</li>
<li><code>titleTemplate</code>: See&nbsp;<a class="reference-link" href="../Default%20Note%20Title.html">Default Note Title</a>
</li>
<li><code>template</code>: Makes the note available as a template</li>
<li><code>toc</code>: Controls the visibility of the table of contents</li>
<li><code>color</code>: Defines the color of the note in the tree and links</li>
<li><code>hideChildrenOverview</code>: Hides child notes in the parent note's
editor</li>
<li><code>viewType</code>: Sets the view of child notes (grid or list)</li>
</ul>
<h2>Relations</h2>
</div>
</div>
</body>

View File

@ -0,0 +1,37 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../style.css">
<base target="_parent">
<title data-trilium-title>Trilium instance</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Trilium instance</h1>
<div class="ck-content">
<p>A Trilium instance represents a server. If&nbsp;<a class="reference-link"
href="../../Installation%20%26%20Setup/Synchronization.html">Synchronization</a>&nbsp;is
set up, since multiple servers are involved (the one from the desktop client
and the one the synchronisation is set up with), sometimes it can be useful
to distinguish the instance you are running on.</p>
<h2>Setting the instance name</h2>
<p>To set up a name for the instance, modify the <code>config.ini</code>:</p><pre><code class="language-text-x-trilium-auto">[General]
instanceName=Hello</code></pre>
<h2>Distinguishing the instance on back-end</h2>
<p>Use <code>api.getInstanceName()</code> to obtain the instance name of the
current server, as specified in the config file or in environment variables.</p>
<h2>Limiting script runs based on instance</h2>
<p>For a script that is run periodically or on a certain event, it's possible
to limit it to certain instances without having to change the code. Just
add <code>runOnInstance</code> and set as the value the instance name where
the script should run. To run on multiple named instances, simply add the
label multiple times.</p>
</div>
</div>
</body>
</html>

View File

@ -68,7 +68,7 @@ Content-Type: application/json
and you need to take care of this yourself.</p>
<p>Once we pass these checks we will just create the desired note using
<a
href="../Note%20Types/Code/Script%20API.html">Script API</a>.</p>
href="../Scripting/Script%20API.html">Script API</a>.</p>
<h2>Custom resource provider</h2>
<p>Another common use case is that you want to just expose a file note -
in such case you create label <code>customResourceProvider</code> (value

View File

@ -42,8 +42,14 @@
<p>The value of <code>#titleTemplate</code> is evaluated at the point of note's
creation as a JavaScript string, which means it can be enriched with the
help of JS string interpolation with dynamic data.</p>
<p>As an example, imagine you collect server outage incidents and write some
notes. It looks like this:</p>
<p>Second variable injected is <code>parentNote</code> which gives access to
the parent <a href="../Scripting/Script%20API/Frontend%20API/FNote.html"><code>FNote</code></a>.</p>
<p>See also&nbsp;<a class="reference-link" href="Templates.html">Templates</a>&nbsp;which
provides similar capabilities, including default note's content.</p>
<h3>Examples</h3>
<ul>
<li>Imagine you collect server outage incidents and write some notes. It looks
like this:
<ul>
<li>Incidents
<ul>
@ -51,14 +57,16 @@
<li>2022-05-15: Backup delay</li>
</ul>
</li>
</ul>
<p>You can automatize the date assignment by assigning a label <code>#titleTemplate="${now.format('YYYY-MM-DD')}: "</code> to
<li>You can automatize the date assignment by assigning a label <code>#titleTemplate="${now.format('YYYY-MM-DD')}: "</code> to
the parent note "Incidents". Whenever a new child note is created, the
title template is evaluated with the injected <a href="https://day.js.org/docs/en/display/format">now</a> object.</p>
<p>Second variable injected is <a href="https://triliumnext.github.io/Notes/backend_api/BNote.html">parentNote</a>,
an example could be <code>#titleTemplate="${parentNote.getLabelValue('authorName')}'s literary works"</code>.</p>
<p>See also [[<a href="Templates.html">template</a>]] which provides similar
capabilities, including default note's content.</p>
title template is evaluated with the injected <a href="https://day.js.org/docs/en/display/format">now</a> object.</li>
</ul>
</li>
<li>To use a parent's attribute in the title of new notes: <code>#titleTemplate="${parentNote.getLabelValue('authorName')}'s literary works"</code>
</li>
<li>To mirror the parent's note title: <code>${parentNote.title}</code>
</li>
</ul>
</div>
</div>
</body>

View File

@ -17,7 +17,8 @@
documents. This feature is particularly useful for publishing content directly
from your Trilium notes, making it accessible to others online.</p>
<h2>Prerequisites</h2>
<p>To use the sharing feature, you must have a <a href="../Installation%20%26%20Setup/Server%20Installation.html">server installation</a> of
<p>To use the sharing feature, you must have a&nbsp;<a class="reference-link"
href="../Installation%20%26%20Setup/Server%20Installation.html">Server Installation</a>&nbsp;of
Trilium. This is necessary because the notes will be hosted from the server.</p>
<h2>How to Share a Note</h2>
<ol>
@ -64,10 +65,11 @@
<p>The default shared page is basic in design, but you can customize it using
your own CSS:</p>
<ul>
<li><strong>Custom CSS</strong>: Link a CSS <a href="../Note%20Types/Code.html">code note</a> to
the shared page by adding a <code>~shareCss</code> relation to the note.
If you want this style to apply to the entire subtree, make the label inheritable.
You can hide the CSS code note from the tree navigation by adding the <code>#shareHiddenFromTree</code> label.</li>
<li><strong>Custom CSS</strong>: Link a CSS&nbsp;<a class="reference-link"
href="../Note%20Types/Code.html">Code</a>&nbsp;note to the shared page
by adding a <code>~shareCss</code> relation to the note. If you want this
style to apply to the entire subtree, make the label inheritable. You can
hide the CSS code note from the tree navigation by adding the <code>#shareHiddenFromTree</code> label.</li>
<li><strong>Omitting Default CSS</strong>: For extensive styling changes,
use the <code>#shareOmitDefaultCss</code> label to avoid conflicts with Trilium's
<a
@ -112,16 +114,6 @@ for (const attr of parentNote.attributes) {
making it easier to use Trilium as a fully-fledged website. Consider combining
this with the <code>#shareIndex</code> label, which will display a list of
all shared notes.</p>
<h2>Additional Options</h2>
<ul>
<li><strong>Raw Note Sharing</strong>: Use the <code>#shareRaw</code> label
to share a note without any HTML wrapper.</li>
<li><strong>Disallow Robot Indexing</strong>: Add the <code>#shareDisallowRobotIndexing</code> label
to prevent search engines from indexing the shared page by including a <code>noindex, follow</code> meta
tag and <code>X-Robots-Tag: noindex</code> header.</li>
<li><strong>Shared Notes Index</strong>: For text notes with the <code>#shareIndex</code> label,
the content will display a list of all shared note roots.</li>
</ul>
<h2>Limitations</h2>
<p>While the sharing feature is powerful, it has some limitations:</p>
<ul>
@ -135,6 +127,84 @@ for (const attr of parentNote.attributes) {
<li><strong>Include Notes</strong>: Not supported.</li>
</ul>
<p>Some of these limitations may be addressed in future updates.</p>
<h2>Attribute reference</h2>
<figure class="table">
<table>
<thead>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>shareHiddenFromTree</code>
</td>
<td>this note is hidden from left navigation tree, but still accessible with
its URL</td>
</tr>
<tr>
<td><code>shareExternalLink</code>
</td>
<td>note will act as a link to an external website in the share tree</td>
</tr>
<tr>
<td><code>shareAlias</code>
</td>
<td>define an alias using which the note will be available under <code>https://your_trilium_host/share/[your_alias]</code>
</td>
</tr>
<tr>
<td><code>shareOmitDefaultCss</code>
</td>
<td>default share page CSS will be omitted. Use when you make extensive styling
changes.</td>
</tr>
<tr>
<td><code>shareRoot</code>
</td>
<td>marks note which is served on /share root.</td>
</tr>
<tr>
<td><code>shareDescription</code>
</td>
<td>define text to be added to the HTML meta tag for description</td>
</tr>
<tr>
<td><code>shareRaw</code>
</td>
<td>Note will be served in its raw format, without HTML wrapper. See also&nbsp;
<a
class="reference-link" href="Sharing/Serving%20directly%20the%20content%20o.html">Serving directly the content of a note</a>&nbsp;for an alternative method
without setting an attribute.</td>
</tr>
<tr>
<td><code>shareDisallowRobotIndexing</code>
</td>
<td>
<p>Indicates to web crawlers that the page should not be indexed of this
note by:</p>
<ul>
<li>Setting the <code>X-Robots-Tag: noindex</code> HTTP header.</li>
<li>Setting the <code>noindex, follow</code> meta tag.</li>
</ul>
</td>
</tr>
<tr>
<td><code>shareCredentials</code>
</td>
<td>require credentials to access this shared note. Value is expected to be
in format <code>username:password</code>. Don't forget to make this inheritable
to apply to child-notes/images.</td>
</tr>
<tr>
<td><code>shareIndex</code>
</td>
<td>Note with this label will list all roots of shared notes.</td>
</tr>
</tbody>
</table>
</figure>
</div>
</div>
</body>

View File

@ -51,7 +51,7 @@
</p>
<p>For the template to appear in the menu, the template note must have the <code>#template</code> label.
Do not confuse this with the <code>~template</code> relation, which links
the instance note to the template note. If you use <a href="../Basic%20Concepts%20and%20Features/Navigation/Workspace.html">workspaces</a>,
the instance note to the template note. If you use <a href="../Basic%20Concepts%20and%20Features/Navigation/Workspaces.html">workspaces</a>,
you can also mark templates with <code>#workspaceTemplate</code> to display
them only in the workspace.</p>
<p>Templates can also be added or changed after note creation by creating

View File

@ -22,7 +22,7 @@
<p>In addition to showing only this subtree, this also narrows both full
text search and <a href="Note%20Navigation.html">“jump to note”</a> to just
notes present in hoisted subtree.</p>
<p>See also <a href="Workspace.html">Workspace</a> which extends this feature.</p>
<p>See also <a href="Workspaces.html">Workspace</a> which extends this feature.</p>
</div>
</div>
</body>

View File

@ -1,62 +0,0 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../style.css">
<base target="_parent">
<title data-trilium-title>Workspace</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Workspace</h1>
<div class="ck-content">
<p>Workspace is a concept built up on top of <a href="Note%20Hoisting.html">note hoisting</a>.
It is based on the idea that a user has several distinct spheres of interest.
An example might be "Personal" and "Work", these two spheres are quite
distinct and don't interact together. When I focus on Work, I don't really
care about personal notes.</p>
<p>So far workspace consists of these features:</p>
<ul>
<li>
<p><a href="Note%20Hoisting.html">note hoisting</a> - you can "zoom" into
a workspace subtree to focus only on the relevant notes</p>
</li>
<li>
<p>easy entering of workspace:&nbsp;</p>
<p>
<img src="1_Workspace_image.png">
</p>
</li>
<li>
<p>visual identification of workspace in tabs:
<br>
<img src="Workspace_image.png">
</p>
</li>
</ul>
<h3>How to use workspaces</h3>
<p>Let's say you have identified the workspaces and their subtrees. Define
on the root of this subtree following labels:</p>
<ul>
<li><code>#workspace</code> - Marks this note as a workspace, button to enter
the workspace is controlled by this</li>
<li><code>#workspaceIconClass</code> - controls the box icon to be displayed
in the tree and tabs, example <code>bx bx-home</code>. See <a href="https://boxicons.com/">https://boxicons.com/</a>
</li>
<li><code>#workspaceTabBackgroundColor</code> - Background color of the tab,
use any CSS color format, e.g. "lightblue" or "#ddd". See <a href="https://www.w3schools.com/cssref/css_colors.asp">https://www.w3schools.com/cssref/css_colors.asp</a>.</li>
<li><code>#workspaceCalendarRoot</code> - marking a note with this label will
define a new per-workspace calendar. If there's no such note, the global
calendar will be used.</li>
<li><code>#workspaceTemplate</code> - This note will appear in the selection
of available templates when creating a new note, but only when you are
currently hoisted into a workspace containing this template.</li>
</ul>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,96 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../style.css">
<base target="_parent">
<title data-trilium-title>Workspaces</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Workspaces</h1>
<div class="ck-content">
<p>Workspace is a concept built up on top of <a href="Note%20Hoisting.html">note hoisting</a>.
It is based on the idea that a user has several distinct spheres of interest.
An example might be "Personal" and "Work", these two spheres are quite
distinct and don't interact together. When I focus on Work, I don't really
care about personal notes.</p>
<p>So far workspace consists of these features:</p>
<ul>
<li><a href="Note%20Hoisting.html">note hoisting</a> - you can "zoom" into
a workspace subtree to focus only on the relevant notes</li>
<li>
<p>easy entering of workspace:&nbsp;</p>
<p>
<img src="1_Workspaces_image.png">
</p>
</li>
<li>visual identification of workspace in tabs:
<br>
<img src="Workspaces_image.png">
</li>
</ul>
<h3>Configuration</h3>
<figure class="table">
<table>
<thead>
<tr>
<th>Label</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>workspace</code>
</td>
<td>Marks this note as a workspace, button to enter the workspace is controlled
by this</td>
</tr>
<tr>
<td><code>workspaceIconClass</code>
</td>
<td>defines box icon CSS class which will be used in tab when hoisted to this
note</td>
</tr>
<tr>
<td><code>workspaceTabBackgroundColor</code>
</td>
<td>CSS color used in the note tab when hoisted to this note, use any CSS
color format, e.g. "lightblue" or "#ddd". See <a href="https://www.w3schools.com/cssref/css_colors.asp">https://www.w3schools.com/cssref/css_colors.asp</a>.</td>
</tr>
<tr>
<td><code>workspaceCalendarRoot</code>
</td>
<td>Marking a note with this label will define a new per-workspace calendar
for&nbsp;<a class="reference-link" href="../../Advanced%20Usage/Advanced%20Showcases/Day%20Notes.html">Day Notes</a>.
If there's no such note, the global calendar will be used.</td>
</tr>
<tr>
<td><code>workspaceTemplate</code>
</td>
<td>This note will appear in the selection of available template when creating
new note, but only when hoisted into a workspace containing this template</td>
</tr>
<tr>
<td><code>workspaceSearchHome</code>
</td>
<td>new search notes will be created as children of this note when hoisted
to some ancestor of this workspace note</td>
</tr>
<tr>
<td><code>workspaceInbox</code>
</td>
<td>default inbox location for new notes when hoisted to some ancestor of
this workspace note</td>
</tr>
</tbody>
</table>
</figure>
</div>
</div>
</body>
</html>

View File

@ -15,9 +15,16 @@
<div class="ck-content">
<p>When a note has one or more child notes, they will be listed at the end
of the note for easy navigation.</p>
<h2>Hide the note list for a given note</h2>
<p>If the note list is not desireable for a particular note, simply apply
the <code>hideChildrenOverview</code> <a href="../../Advanced%20Usage/Attributes.html">label</a>.</p>
<h2>Configuration</h2>
<ul>
<li>To hide the note list for a particular note, simply apply the <code>hideChildrenOverview</code>
<a
href="../../Advanced%20Usage/Attributes.html">label</a>.</li>
<li>For some view types, such as Grid view, only a subset of notes will be
displayed and pagination can be used to navigate through all of them for
performance reasons. To adjust the number of notes per page, set <code>pageSize</code> to
the desired number.</li>
</ul>
<h2>View types</h2>
<p>By default, the notes will be displayed in a grid, however there are also
some other view types available.</p>

View File

@ -95,7 +95,7 @@
</p>
<p>Allows defining a custom widget to be rendered inside the launcher. See&nbsp;
<a
href="../../Scripting/Widget%20Basics.html">Widget Basics</a>&nbsp;for more information.</p>
href="../../Scripting/Custom%20Widgets/Widget%20Basics.html">Widget Basics</a>&nbsp;for more information.</p>
</li>
<li>
<p><strong>Spacers</strong>

View File

@ -105,6 +105,9 @@
<h3>Edited notes</h3>
<p>This section pops automatically when entering a <a href="../../Advanced%20Usage/Advanced%20Showcases/Day%20Notes.html">day note</a> and
shows the notes that were edited that day.</p>
<p>It is possible to disable this behavior from settings, by going to&nbsp;
<a
class="reference-link" href="#root/_hidden/_options/_optionsAppearance">Appearance</a>&nbsp;settings and looking for the <em>Ribbon widgets</em> section.</p>
</div>
</div>
</body>

View File

@ -1,66 +0,0 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../style.css">
<base target="_parent">
<title data-trilium-title>Events</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Events</h1>
<div class="ck-content">
<p><a href="../../Scripting.html">Script</a> notes can be triggered by events.
Note that these are backend events and thus relation need to point to the
"JS backend" code note.</p>
<h2>Global events</h2>
<p>Global events are attached to the script note via label. Simply create
e.g. "run" label with some of these values and script note will be executed
once the event occurs.</p>
<ul>
<li><code>run</code>
<ul>
<li><code>frontendStartup</code> - executes on frontend upon startup</li>
<li><code>mobileStartup</code> - executes on mobile frontend upon startup</li>
<li><code>backendStartup</code> - executes on backend upon startup</li>
<li><code>hourly</code> - executes once an hour on backend</li>
<li><code>daily</code> - executes once a day on backend</li>
</ul>
</li>
</ul>
<h2>Entity events</h2>
<p>Other events are bound to some entity, these are defined as <a href="../../Advanced%20Usage/Attributes.html">relations</a> -
meaning that script is triggered only if note has this script attached
to it through relations (or it can inherit it).</p>
<ul>
<li><code>runOnNoteCreation</code> - executes when note is created on backend</li>
<li><code>runOnNoteTitleChange</code> - executes when note title is changed
(includes note creation as well)</li>
<li><code>runOnNoteContentChange</code> - executes when note content is changed
(includes note creation as well).</li>
<li><code>runOnNoteChange</code> - executes when note is changed (includes
note creation as well)</li>
<li><code>runOnNoteDeletion</code> - executes when note is being deleted</li>
<li><code>runOnBranchCreation</code> - executes when a branch is created. Branch
is a link between parent note and child note and is created e.g. when cloning
or moving note.</li>
<li><code>runOnBranchChange</code> (since v0.62) - executes when a branch is
changed - either expanded status or prefix are changed.</li>
<li><code>runOnBranchDeletion</code> - executes when a branch is delete. Branch
is a link between parent note and child note and is deleted e.g. when moving
note (old branch/link is deleted).</li>
<li><code>runOnChildNoteCreation</code> - executes when new note is created
under <em>this</em> note</li>
<li><code>runOnAttributeCreation</code> - executes when new attribute is created
under <em>this</em> note</li>
<li><code>runOnAttributeChange</code> - executes when attribute is changed
under <em>this</em> note</li>
</ul>
</div>
</div>
</body>
</html>

View File

@ -25,7 +25,7 @@
<h2>Location</h2>
<p>By default, saved searches are stored in the day note. However, you can
designate a different note to store saved searches by marking it with the <code>#searchHome</code> label.
Additionally, for <a href="../Basic%20Concepts%20and%20Features/Navigation/Workspace.html">workspaces</a>,
Additionally, for <a href="../Basic%20Concepts%20and%20Features/Navigation/Workspaces.html">workspaces</a>,
you can use the <code>#workspaceSearchHome</code> label to specify a storage
location for saved searches within that workspace.</p>
</div>

View File

@ -16,7 +16,7 @@
<p>Trilium supports creating&nbsp;<a class="reference-link" href="Note%20Types/Code.html">Code</a>&nbsp;notes,
i.e. notes which allow you to store some programming code and highlight
it. Special case is JavaScript code notes which can also be executed inside
Trilium which can in conjunction with&nbsp;<a class="reference-link" href="Note%20Types/Code/Script%20API.html">Script API</a>&nbsp;provide
Trilium which can in conjunction with&nbsp;<a class="reference-link" href="Scripting/Script%20API.html">Script API</a>&nbsp;provide
extra functionality.</p>
<h2>Scripting</h2>
<p>To go further I must explain basic architecture of Trilium - in its essence
@ -58,9 +58,9 @@
<p>You can see more scripting with explanation in&nbsp;<a class="reference-link"
href="Advanced%20Usage/Advanced%20Showcases.html">Advanced Showcases</a>.</p>
<h2>Events</h2>
<p>See&nbsp;<a class="reference-link" href="Note%20Types/Code/Events.html">Events</a>.</p>
<p>See&nbsp;<a class="reference-link" href="Scripting/Events.html">Events</a>.</p>
<h2>Script API</h2>
<p>See&nbsp;<a class="reference-link" href="Note%20Types/Code/Script%20API.html">Script API</a>.</p>
<p>See&nbsp;<a class="reference-link" href="Scripting/Script%20API.html">Script API</a>.</p>
</div>
</div>
</body>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../style.css">
<link rel="stylesheet" href="../../style.css">
<base target="_parent">
<title data-trilium-title>Custom Widgets</title>
</head>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../style.css">
<link rel="stylesheet" href="../../../style.css">
<base target="_parent">
<title data-trilium-title>Widget Basics</title>
</head>
@ -33,15 +33,15 @@ module.exports = new MyWidget();</code></pre>
<ol>
<li>Create a new <code>JS Frontend</code> note in Trilium and paste in the code
above.</li>
<li>Assign the <code>#widget</code> <a href="../Advanced%20Usage/Attributes.html">attribute</a> to
the <a href="../Basic%20Concepts%20and%20Features/Notes.html">note</a>.</li>
<li>Assign the <code>#widget</code> <a href="../../Advanced%20Usage/Attributes.html">attribute</a> to
the <a href="../../Basic%20Concepts%20and%20Features/Notes.html">note</a>.</li>
<li>Restart Trilium or reload the window.</li>
</ol>
<p>To verify that the widget is working, open the developer tools (<code>Cmd</code> + <code>Shift</code> + <code>I</code>)
and run <code>document.querySelector("#my-widget")</code>. If the element
is found, the widget is functioning correctly. If <code>undefined</code> is
returned, double-check that the <a href="../Basic%20Concepts%20and%20Features/Notes.html">note</a> has
the <code>#widget</code> <a href="../Advanced%20Usage/Attributes.html">attribute</a>.</p>
returned, double-check that the <a href="../../Basic%20Concepts%20and%20Features/Notes.html">note</a> has
the <code>#widget</code> <a href="../../Advanced%20Usage/Attributes.html">attribute</a>.</p>
<h3>Step 2: Adding an UI Element</h3>
<p>Next, let's improve the widget by adding a button to it.</p><pre><code class="language-text-x-trilium-auto">const template = ``;
@ -84,7 +84,7 @@ module.exports = new MyWidget();</code></pre>
of the left pane, alongside other action buttons.</p>
<h3>Step 4: Adding User Interaction</h3>
<p>Lets make the button interactive by showing a message when its clicked.
We'll use the <code>api.showMessage</code> method from the <a href="../Note%20Types/Code/Script%20API.html">Script API</a>.</p><pre><code class="language-text-x-trilium-auto">class MyWidget extends api.BasicWidget {
We'll use the <code>api.showMessage</code> method from the <a href="../Script%20API.html">Script API</a>.</p><pre><code class="language-text-x-trilium-auto">class MyWidget extends api.BasicWidget {
get position() { return 1; }
get parentWidget() { return "left-pane"; }

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../../style.css">
<link rel="stylesheet" href="../../../style.css">
<base target="_parent">
<title data-trilium-title>Word count widget</title>
</head>
@ -15,9 +15,9 @@
<div class="ck-content">
<aside class="admonition tip">
<p>This widget is also present in new installations in the&nbsp;<a class="reference-link"
href="../../../Advanced%20Usage/Database/Demo%20Notes.html">Demo Notes</a>.</p>
href="../../Advanced%20Usage/Database/Demo%20Notes.html">Demo Notes</a>.</p>
</aside>
<p>Create a&nbsp;<a class="reference-link" href="../../Code.html">Code</a>&nbsp;note
<p>Create a&nbsp;<a class="reference-link" href="../../Note%20Types/Code.html">Code</a>&nbsp;note
of type JS frontend and <strong>give it a</strong> <code>#widget</code> <strong>label</strong>.</p><pre><code class="language-text-x-trilium-auto">/*
* This defines a custom widget which displays number of words and characters in a current text note.
* To be activated for a given note, add label 'wordCount' to the note, you can also make it inheritable and thus activate it for the whole subtree.
@ -93,7 +93,7 @@ class WordCountWidget extends api.NoteContextAwareWidget {
}
module.exports = new WordCountWidget();</code></pre>
<p>After you make changes it is necessary to <a href="../../../Troubleshooting/Refreshing%20the%20application.html">restart Trilium</a> so
<p>After you make changes it is necessary to <a href="../../Troubleshooting/Refreshing%20the%20application.html">restart Trilium</a> so
that the layout can be rebuilt.</p>
<p>At the bottom of the note you can see the resulting widget:</p>
<figure

View File

@ -0,0 +1,149 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../style.css">
<base target="_parent">
<title data-trilium-title>Events</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Events</h1>
<div class="ck-content">
<p><a href="../Scripting.html">Script</a> notes can be triggered by events.
Note that these are backend events and thus relation need to point to the
"JS backend" code note.</p>
<h2>Global events</h2>
<p>Global events are attached to the script note via label. Simply create
e.g. "run" label with some of these values and script note will be executed
once the event occurs.</p>
<figure class="table">
<table>
<thead>
<tr>
<th>Label</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>run</code>
</td>
<td>
<p>Defines on which events script should run. Possible values are:</p>
<ul>
<li><code>frontendStartup</code> - when Trilium frontend starts up (or is refreshed),
but not on mobile.</li>
<li><code>mobileStartup</code> - when Trilium frontend starts up (or is refreshed),
on mobile.</li>
<li><code>backendStartup</code> - when Trilium backend starts up</li>
<li><code>hourly</code> - run once an hour. You can use additional label <code>runAtHour</code> to
specify at which hour, on the back-end.</li>
<li><code>daily</code> - run once a day, on the back-end</li>
</ul>
</td>
</tr>
<tr>
<td><code>runOnInstance</code>
</td>
<td>Specifies that the script should only run on a particular&nbsp;<a class="reference-link"
href="../Advanced%20Usage/Configuration%20(config.ini%20or%20environment%20variables)/Trilium%20instance.html">Trilium instance</a>.</td>
</tr>
<tr>
<td><code>runAtHour</code>
</td>
<td>On which hour should this run. Should be used together with <code>#run=hourly</code>.
Can be defined multiple times for more runs during the day.</td>
</tr>
</tbody>
</table>
</figure>
<h2>Entity events</h2>
<p>Other events are bound to some entity, these are defined as <a href="../Advanced%20Usage/Attributes.html">relations</a> -
meaning that script is triggered only if note has this script attached
to it through relations (or it can inherit it).</p>
<figure class="table">
<table>
<thead>
<tr>
<th>Relation</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>runOnNoteCreation</code>
</td>
<td>executes when note is created on backend. Use this relation if you want
to run the script for all notes created under a specific subtree. In that
case, create it on the subtree root note and make it inheritable. A new
note created within the subtree (any depth) will trigger the script.</td>
</tr>
<tr>
<td><code>runOnChildNoteCreation</code>
</td>
<td>executes when new note is created under the note where this relation is
defined</td>
</tr>
<tr>
<td><code>runOnNoteTitleChange</code>
</td>
<td>executes when note title is changed (includes note creation as well)</td>
</tr>
<tr>
<td><code>runOnNoteContentChange</code>
</td>
<td>executes when note content is changed (includes note creation as well).</td>
</tr>
<tr>
<td><code>runOnNoteChange</code>
</td>
<td>executes when note is changed (includes note creation as well). Does not
include content changes</td>
</tr>
<tr>
<td><code>runOnNoteDeletion</code>
</td>
<td>executes when note is being deleted</td>
</tr>
<tr>
<td><code>runOnBranchCreation</code>
</td>
<td>executes when a branch is created. Branch is a link between parent note
and child note and is created e.g. when cloning or moving note.</td>
</tr>
<tr>
<td><code>runOnBranchChange</code>
</td>
<td>executes when a branch is updated. (since v0.62)</td>
</tr>
<tr>
<td><code>runOnBranchDeletion</code>
</td>
<td>executes when a branch is deleted. Branch is a link between parent note
and child note and is deleted e.g. when moving note (old branch/link is
deleted).</td>
</tr>
<tr>
<td><code>runOnAttributeCreation</code>
</td>
<td>executes when new attribute is created for the note which defines this
relation</td>
</tr>
<tr>
<td><code>runOnAttributeChange</code>
</td>
<td>executes when the attribute is changed of a note which defines this relation.
This is triggered also when the attribute is deleted</td>
</tr>
</tbody>
</table>
</figure>
</div>
</div>
</body>
</html>

View File

@ -18,7 +18,7 @@
the current app and note context, and widgets that export an object to
Trilium to be used in the UI. In both cases, the frontend api of Trilium
is available to scripts running in the frontend context as global variable <code>api</code>.
The members and methods of the api can be seen on the <a href="../Note%20Types/Code/Script%20API.html">Script API</a> page.</p>
The members and methods of the api can be seen on the <a href="Script%20API.html">Script API</a> page.</p>
<h2>Scripts</h2>
<p>Scripts don't have any special requirements. They can be run at will using
the execute button in the UI or they can be configured to run at certain
@ -95,7 +95,7 @@
notes.</li>
</ul>
<h3>Tutorial</h3>
<p>For more information on building widgets, take a look at <a href="Widget%20Basics.html">Widget Basics</a>.</p>
<p>For more information on building widgets, take a look at <a href="Custom%20Widgets/Widget%20Basics.html">Widget Basics</a>.</p>
</div>
</div>
</body>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../style.css">
<link rel="stylesheet" href="../../style.css">
<base target="_parent">
<title data-trilium-title>Script API</title>
</head>

View File

@ -0,0 +1,19 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../style.css">
<base target="_parent">
<title data-trilium-title>Backend API</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Backend API</h1>
<div class="ck-content"></div>
</div>
</body>
</html>

View File

@ -0,0 +1,19 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../../style.css">
<base target="_parent">
<title data-trilium-title>FNote</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>FNote</h1>
<div class="ck-content"></div>
</div>
</body>
</html>

View File

@ -31,7 +31,7 @@
In Linux, you can set it as follows:</p><pre><code class="language-text-x-trilium-auto">TRILIUM_START_NOTE_ID=root ./trilium</code></pre>
<h2>Broken Script Prevents Application Startup</h2>
<p>If a custom script causes Triliumto crash, and it is set as a startup
script or in an active <a href="Note%20Types/Code/Custom%20Widgets.html">custom widget</a>,
script or in an active <a href="Scripting/Custom%20Widgets.html">custom widget</a>,
start Triliumin "safe mode" to prevent any custom scripts from executing:</p><pre><code class="language-text-x-trilium-auto">TRILIUM_SAFE_MODE=true ./trilium</code></pre>
<p>Depending on your Trilium distribution, you may have pre-made scripts
available: <code>trilium-safe-mode.bat</code> and <code>trilium-safe-mode.sh</code>.</p>

View File

@ -173,8 +173,8 @@
<li><a href="User%20Guide/Basic%20Concepts%20and%20Features/Navigation/Note%20Hoisting.html"
target="detail">Note Hoisting</a>
</li>
<li><a href="User%20Guide/Basic%20Concepts%20and%20Features/Navigation/Workspace.html"
target="detail">Workspace</a>
<li><a href="User%20Guide/Basic%20Concepts%20and%20Features/Navigation/Workspaces.html"
target="detail">Workspaces</a>
</li>
<li><a href="User%20Guide/Basic%20Concepts%20and%20Features/Navigation/Similar%20Notes.html"
target="detail">Similar Notes</a>
@ -254,19 +254,6 @@
</ul>
</li>
<li><a href="User%20Guide/Note%20Types/Code.html" target="detail">Code</a>
<ul>
<li><a href="User%20Guide/Note%20Types/Code/Script%20API.html" target="detail">Script API</a>
</li>
<li><a href="User%20Guide/Note%20Types/Code/Events.html" target="detail">Events</a>
</li>
<li><a href="User%20Guide/Note%20Types/Code/Custom%20Widgets.html" target="detail">Custom Widgets</a>
<ul>
<li><a href="User%20Guide/Note%20Types/Code/Custom%20Widgets/Word%20count%20widget.html"
target="detail">Word count widget</a>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="User%20Guide/Note%20Types/Saved%20Search.html" target="detail">Saved Search</a>
</li>
@ -399,6 +386,11 @@
</li>
<li><a href="User%20Guide/Advanced%20Usage/Configuration%20(config.ini%20or%20e.html"
target="detail">Configuration (config.ini or environment variables)</a>
<ul>
<li><a href="User%20Guide/Advanced%20Usage/Configuration%20(config.ini%20or%20environment%20variables)/Trilium%20instance.html"
target="detail">Trilium instance</a>
</li>
</ul>
</li>
<li><a href="User%20Guide/Advanced%20Usage/Bulk%20actions.html" target="detail">Bulk actions</a>
</li>
@ -435,8 +427,6 @@
<ul>
<li><a href="User%20Guide/Scripting/Frontend%20Basics.html" target="detail">Frontend Basics</a>
</li>
<li><a href="User%20Guide/Scripting/Widget%20Basics.html" target="detail">Widget Basics</a>
</li>
<li>Examples
<ul>
<li><a href="User%20Guide/Scripting/Examples/New%20Task%20launcher%20button.html"
@ -450,6 +440,31 @@
</li>
</ul>
</li>
<li><a href="User%20Guide/Scripting/Events.html" target="detail">Events</a>
</li>
<li><a href="User%20Guide/Scripting/Custom%20Widgets.html" target="detail">Custom Widgets</a>
<ul>
<li><a href="User%20Guide/Scripting/Custom%20Widgets/Word%20count%20widget.html"
target="detail">Word count widget</a>
</li>
<li><a href="User%20Guide/Scripting/Custom%20Widgets/Widget%20Basics.html"
target="detail">Widget Basics</a>
</li>
</ul>
</li>
<li><a href="User%20Guide/Scripting/Script%20API.html" target="detail">Script API</a>
<ul>
<li>Frontend API
<ul>
<li><a href="User%20Guide/Scripting/Script%20API/Frontend%20API/FNote.html"
target="detail">FNote</a>
</li>
</ul>
</li>
<li><a href="User%20Guide/Scripting/Script%20API/Backend%20API.html" target="detail">Backend API</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>