fix(edit-docs): convert to Markdown

This commit is contained in:
Elian Doran 2025-03-10 21:15:33 +02:00
parent d134ee0552
commit e79f18f001
No known key found for this signature in database
318 changed files with 6528 additions and 10998 deletions

View File

@ -100,7 +100,7 @@ async function exportData() {
// First export as zip.
const { exportToZipFile } = (await import("./src/services/export/zip.js")).default;
await exportToZipFile(NOTE_ID_USER_GUIDE, "html", zipFilePath);
await exportToZipFile(NOTE_ID_USER_GUIDE, "markdown", zipFilePath);
const promise = deferred<void>()
setTimeout(async () => {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
# User Guide
The sub-children of this note are automatically synced.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 77 KiB

View File

@ -1,37 +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>Advanced Showcases</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Advanced Showcases</h1>
<div class="ck-content">
<p>Trilium offers advanced functionality through <a href="Code%20Notes/Scripts.html">Scripts</a> and
<a
href="Attributes/Promoted%20Attributes.html">Promoted Attributes</a>. To illustrate these features, we've prepared
several showcases available in the <a href="Database.html">demo notes</a>:</p>
<ul>
<li><a href="Relation%20Map.html">Relation Map</a>
</li>
<li><a href="Advanced%20Showcases/Day%20Notes.html">Day Notes</a>
</li>
<li><a href="Advanced%20Showcases/Weight%20Tracker.html">Weight Tracker</a>
</li>
<li><a href="Advanced%20Showcases/Task%20Manager.html">Task Manager</a>
</li>
</ul>
<p>It's important to note that these examples are not natively supported
by Trilium out of the box; instead, they demonstrate what you can build
within Trilium.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,9 @@
# Advanced Showcases
Trilium offers advanced functionality through [Scripts](Code%20Notes/Scripts.md) and [Promoted Attributes](Attributes/Promoted%20Attributes.md). To illustrate these features, we've prepared several showcases available in the [demo notes](Database.md):
* [Relation Map](Relation%20Map.md)
* [Day Notes](Advanced%20Showcases/Day%20Notes.md)
* [Weight Tracker](Advanced%20Showcases/Weight%20Tracker.md)
* [Task Manager](Advanced%20Showcases/Task%20Manager.md)
It's important to note that these examples are not natively supported by Trilium out of the box; instead, they demonstrate what you can build within Trilium.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -1,102 +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>Day Notes</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Day Notes</h1>
<div class="ck-content">
<p>A common pattern in note-taking is that a lot of notes will be centered
around a certain date - e.g. you have some tasks which needs to be done
on a certain date, you have meeting minutes from a certain date, you have
your thoughts etc. and it all revolves around a date on which they occurred.
For this reason, it makes sense to create a certain "day workspace" which
will centralize all those notes relevant for a certain date.</p>
<p>For this, Trilium provides a concept of "day note". Trilium semi-automatically
generates a single note for each day. Under this note you can save all
those relevant notes.</p>
<p>Select an existing day note, and the menubar contains a calendar widget.
Select any day to create a note for that day.&nbsp;</p>
<p>
<img src="Day Notes_image.png" width="533" height="364">
</p>
<p>This pattern works well also because of <a href="../../Basic%20Concepts/Note/Cloning%20Notes.html">Cloning Notes</a> functionality
- note can appear in multiple places in the note tree, so besides appearing
under day note, it can also be categorized into other notes.</p>
<h2>Demo</h2>
<figure class="image">
<img style="aspect-ratio:1060/758;" src="1_Day Notes_image.png" width="1060"
height="758">
</figure>
<p>You can see the structure of day notes appearing under "Journal" note
- there's a note for the whole year 2017, under it, you have "12 - December"
which then contains "18 - Monday". This is our "day note" which contains
some text in its content and also has some child notes (some of them are
from <a href="Task%20Manager.html">Task manager</a>).</p>
<p>You can also notice how this day note has <a href="../Attributes/Promoted%20Attributes.html">promoted attribute</a> "weight"
where you can track your daily weight. This data is then used in <a href="Weight%20Tracker.html">Weight tracker</a>.</p>
<h2>Templates</h2>
<p>Trilium provides <a href="../Attributes/Template.html">template</a> functionality,
and it could be used together with day notes.</p>
<p>You can define one of the following relations on the root of the journal
(identified by <code>#calendarRoot</code> label):</p>
<ul>
<li>yearTemplate</li>
<li>monthTemplate</li>
<li>dateTemplate</li>
</ul>
<p>All of these are relations. When Trilium creates a new note for year or
month or date, it will take a look at the root and attach a corresponding <code>~template</code> relation
to the newly created role. Using this, you can e.g. create your daily template
with e.g. checkboxes for daily routine etc.</p>
<h2>Date pattern</h2>
<p>It's possible to customize the title of generated date notes by defining
a <code>#datePattern</code> label on a root calendar note (identified by <code>#calendarRoot</code> label).
Following are possible values:</p>
<ul>
<li><code>{dayInMonthPadded} - {weekDay}</code> day notes are named e.g. "24
- Monday"</li>
<li><code>{dayInMonthPadded}: {weekDay3}</code> day notes are named e.g. "24:
Mon"</li>
<li><code>{dayInMonthPadded}: {weekDay2}</code> day notes are named e.g. "24:
Mo"</li>
<li><code>{isoDate} - {weekDay}</code> day notes are named e.g. "2020-12-24
- Monday"</li>
<li><code>{ordinal}</code> is replaced with the ordinal date (e.g. 1st, 2nd,
3rd) etc.</li>
</ul>
<h2>Month pattern</h2>
<p>It is also possible to customize the title of generated month notes through
the <code>#monthPattern</code> attribute, much like <code>#datePattern</code>.
The options are:</p>
<ul>
<li><code>{monthNumberPadded}</code> results in a number like <code>09</code> for
September, and <code>11</code> for November</li>
<li><code>{month}</code> results in the full month name (e.g. <code>September</code> or <code>October</code>)</li>
<li><code>{shortMonth3}</code> is replaced with the first 3 letters of the
month, e.g. Jan, Feb, etc.</li>
<li><code>{shortMonth4}</code> is replaced with the first 4 letters of the
month, e.g. Sept, Octo, etc.</li>
</ul>
<p>The default is <code>{monthNumberPadded} - {month}</code>
</p>
<h2>Implementation</h2>
<p>Trilium has some special support for day notes in the form of <a href="https://triliumnext.github.io/Notes/backend_api/BackendScriptApi.html">backend Script API</a> -
see e.g. getDayNote() function.</p>
<p>Day (and year, month) notes are created with a label - e.g. <code>#dateNote="2018-08-16"</code> this
can then be used by other scripts to add new notes to day note etc.</p>
<p>Journal also has relation <code>child:child:child:template=Day template</code> (see
[[attribute inheritance]]) which effectively adds [[template]] to day notes
(grand-grand-grand children of Journal).</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,59 @@
# Day Notes
A common pattern in note-taking is that a lot of notes will be centered around a certain date - e.g. you have some tasks which needs to be done on a certain date, you have meeting minutes from a certain date, you have your thoughts etc. and it all revolves around a date on which they occurred. For this reason, it makes sense to create a certain "day workspace" which will centralize all those notes relevant for a certain date.
For this, Trilium provides a concept of "day note". Trilium semi-automatically generates a single note for each day. Under this note you can save all those relevant notes.
Select an existing day note, and the menubar contains a calendar widget. Select any day to create a note for that day. 
![](1_Day Notes_image.png)
This pattern works well also because of [Cloning Notes](../../Basic%20Concepts/Note/Cloning%20Notes.md) functionality - note can appear in multiple places in the note tree, so besides appearing under day note, it can also be categorized into other notes.
## Demo
![](Day Notes_image.png)
You can see the structure of day notes appearing under "Journal" note - there's a note for the whole year 2017, under it, you have "12 - December" which then contains "18 - Monday". This is our "day note" which contains some text in its content and also has some child notes (some of them are from [Task manager](Task%20Manager.md)).
You can also notice how this day note has [promoted attribute](../Attributes/Promoted%20Attributes.md) "weight" where you can track your daily weight. This data is then used in [Weight tracker](Weight%20Tracker.md).
## Templates
Trilium provides [template](../Attributes/Template.md) functionality, and it could be used together with day notes.
You can define one of the following relations on the root of the journal (identified by `#calendarRoot` label):
* yearTemplate
* monthTemplate
* dateTemplate
All of these are relations. When Trilium creates a new note for year or month or date, it will take a look at the root and attach a corresponding `~template` relation to the newly created role. Using this, you can e.g. create your daily template with e.g. checkboxes for daily routine etc.
## Date pattern
It's possible to customize the title of generated date notes by defining a `#datePattern` label on a root calendar note (identified by `#calendarRoot` label). Following are possible values:
* `{dayInMonthPadded} - {weekDay}` day notes are named e.g. "24 - Monday"
* `{dayInMonthPadded}: {weekDay3}` day notes are named e.g. "24: Mon"
* `{dayInMonthPadded}: {weekDay2}` day notes are named e.g. "24: Mo"
* `{isoDate} - {weekDay}` day notes are named e.g. "2020-12-24 - Monday"
* `{ordinal}` is replaced with the ordinal date (e.g. 1st, 2nd, 3rd) etc.
## Month pattern
It is also possible to customize the title of generated month notes through the `#monthPattern` attribute, much like `#datePattern`. The options are:
* `{monthNumberPadded}` results in a number like `09` for September, and `11` for November
* `{month}` results in the full month name (e.g. `September` or `October`)
* `{shortMonth3}` is replaced with the first 3 letters of the month, e.g. Jan, Feb, etc.
* `{shortMonth4}` is replaced with the first 4 letters of the month, e.g. Sept, Octo, etc.
The default is `{monthNumberPadded} - {month}`
## Implementation
Trilium has some special support for day notes in the form of [backend Script API](https://triliumnext.github.io/Notes/backend_api/BackendScriptApi.html) - see e.g. getDayNote() function.
Day (and year, month) notes are created with a label - e.g. `#dateNote="2018-08-16"` this can then be used by other scripts to add new notes to day note etc.
Journal also has relation `child:child:child:template=Day template` (see \[\[attribute inheritance\]\]) which effectively adds \[\[template\]\] to day notes (grand-grand-grand children of Journal).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 82 KiB

View File

@ -1,86 +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>Task Manager</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Task Manager</h1>
<div class="ck-content">
<p>Task Manager is a <a href="../Attributes/Promoted%20Attributes.html">promoted attributes</a> and
<a
href="../Code%20Notes/Scripts.html">scripts</a>showcase present in the <a href="../Database.html">demo notes</a>.</p>
<h2>Demo</h2>
<p>
<img src="../../Attachments/task-manager.png" alt="">
</p>
<p>Task Manager manages outstanding (TODO) tasks and finished tasks (non-empty
doneDate attribute). Outstanding tasks are further categorized by location
and arbitrary tags - whenever you change tag attribute in the task note,
this task is then automatically moved to appropriate location.</p>
<p>Task Manager also integrates with <a href="Day%20Notes.html">day notes</a> -
notes are <a href="../../Basic%20Concepts/Note/Cloning%20Notes.html">cloned</a> into
day note to both todoDate note and doneDate note (with <a href="../../Basic%20Concepts/Navigation/Tree%20Concepts.html">prefix</a> of
either "TODO" or "DONE").</p>
<h2>Implementation</h2>
<p>New tasks are created in the TODO note which has <code>~child:template</code>
<a
href="../Attributes.html">relation</a>(see <a href="../Attributes/Attribute%20Inheritance.html">attribute inheritance</a>)
pointing to the task template.</p>
<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="../Code%20Notes/Events.html">event</a> handler which is run on
attribute change. This <a href="../Code%20Notes/Scripts.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>
<h3>New task button</h3>
<p>There's also "button" note which contains simple script which adds a button
to create new note (task) in the TODO note.</p><pre><code class="language-text-x-trilium-auto">api.addButtonToToolbar({
title: 'New task',
icon: 'check',
shortcut: 'alt+n',
action: async () =&gt; {
// creating notes is backend (server) responsibility so we need to pass
// the control there
const taskNoteId = await api.runOnBackend(async () =&gt; {
const todoRootNote = await api.getNoteWithLabel('taskTodoRoot');
const {note} = await api.createNote(todoRootNote.noteId, 'new task', '');
return note.noteId;
});
// we got an ID of newly created note and we want to immediatelly display it
await api.activateNewNote(taskNoteId);
}
});</code></pre>
<h3>CSS</h3>
<p>In the demo screenshot above you may notice that TODO tasks are in red
color and DONE tasks are green.</p>
<p>This is done by having this CSS <a href="../Code%20Notes.html">code note</a> which
defines extra CSS classes:</p><pre><code class="language-text-x-trilium-auto">span.fancytree-node.todo .fancytree-title {
color: red !important;
}
span.fancytree-node.done .fancytree-title {
color: green !important;
}</code></pre>
<p>This <a href="../Code%20Notes.html">code note</a> has <code>#appCss</code>
<a
href="../Attributes.html">label</a>which is recognized by Trilium on startup and loaded as CSS into
the application.</p>
<p>Second part of this functionality is based in event handler described
above which assigns <code>#cssClass</code> label to the task to either "done"
or "todo" based on the task status.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,63 @@
# Task Manager
Task Manager is a [promoted attributes](../Attributes/Promoted%20Attributes.md) and [scripts](../Code%20Notes/Scripts.md)showcase present in the [demo notes](../Database.md).
## Demo
![](../../Attachments/task-manager.png)
Task Manager manages outstanding (TODO) tasks and finished tasks (non-empty doneDate attribute). Outstanding tasks are further categorized by location and arbitrary tags - whenever you change tag attribute in the task note, this task is then automatically moved to appropriate location.
Task Manager also integrates with [day notes](Day%20Notes.md) - notes are [cloned](../../Basic%20Concepts/Note/Cloning%20Notes.md) into day note to both todoDate note and doneDate note (with [prefix](../../Basic%20Concepts/Navigation/Tree%20Concepts.md) of either "TODO" or "DONE").
## Implementation
New tasks are created in the TODO note which has `~child:template` [relation](../Attributes.md)(see [attribute inheritance](../Attributes/Attribute%20Inheritance.md)) pointing to the task template.
### Attributes
Task template defines several [promoted attributes](../Attributes/Promoted%20Attributes.md) - todoDate, doneDate, tags, location. Importantly it also defines `~runOnAttributeChange` relation - [event](../Code%20Notes/Events.md) handler which is run on attribute change. This [script](../Code%20Notes/Scripts.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
There's also "button" note which contains simple script which adds a button to create new note (task) in the TODO note.
```
api.addButtonToToolbar({
title: 'New task',
icon: 'check',
shortcut: 'alt+n',
action: async () => {
// creating notes is backend (server) responsibility so we need to pass
// the control there
const taskNoteId = await api.runOnBackend(async () => {
const todoRootNote = await api.getNoteWithLabel('taskTodoRoot');
const {note} = await api.createNote(todoRootNote.noteId, 'new task', '');
return note.noteId;
});
// we got an ID of newly created note and we want to immediatelly display it
await api.activateNewNote(taskNoteId);
}
});
```
### CSS
In the demo screenshot above you may notice that TODO tasks are in red color and DONE tasks are green.
This is done by having this CSS [code note](../Code%20Notes.md) which defines extra CSS classes:
```
span.fancytree-node.todo .fancytree-title {
color: red !important;
}
span.fancytree-node.done .fancytree-title {
color: green !important;
}
```
This [code note](../Code%20Notes.md) has `#appCss` [label](../Attributes.md)which is recognized by Trilium on startup and loaded as CSS into the application.
Second part of this functionality is based in event handler described above which assigns `#cssClass` label to the task to either "done" or "todo" based on the task status.

View File

@ -1,94 +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>Weight Tracker</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Weight Tracker</h1>
<div class="ck-content">
<figure class="image">
<img style="aspect-ratio:1003/683;" src="Weight Tracker_image.png" width="1003"
height="683">
</figure>
<p>The <code>Weight Tracker</code> is a <a href="../Code%20Notes/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="../Attributes/Template.html">template</a> from which <a href="Day%20Notes.html">day notes</a> are
created, you can aggregate the data and plot weight change over time.</p>
<h2>Implementation</h2>
<p>The <code>Weight Tracker</code> note in the screenshot above is of the type <code>Render Note</code>.
That type of note doesn't have any useful content itself. Instead it is
a placeholder where a <a href="../Code%20Notes/Scripts.html">script</a> can
render its output.</p>
<p>Scripts for <code>Render Notes</code> are defined in a <a href="../Attributes.html">relation</a> called <code>~renderNote</code>.
In this example, it's the <code>Weight Tracker</code>'s child <code>Implementation</code>.
The Implementation consists of two <a href="../Code%20Notes.html">code notes</a> that
contain some HTML and JavaScript respectively, which load all the notes
with a <code>weight</code> attribute and display their values in a chart.</p>
<p>To actually render the chart, we're using a third party library called
<a
href="https://www.chartjs.org/">chart.js</a>which is imported as an attachment, since it's not built into
Trilium.</p>
<h3>Code</h3>
<p>Here's the content of the script which is placed in a <a href="../Code%20Notes.html">code note</a> of
type <code>JS Frontend</code>:</p><pre><code class="language-text-x-trilium-auto">async function getChartData() {
const days = await api.runOnBackend(async () =&gt; {
const notes = api.getNotesWithLabel('weight');
const days = [];
for (const note of notes) {
const date = note.getLabelValue('dateNote');
const weight = parseFloat(note.getLabelValue('weight'));
if (date &amp;&amp; weight) {
days.push({ date, weight });
}
}
days.sort((a, b) =&gt; a.date &gt; b.date ? 1 : -1);
return days;
});
const datasets = [
{
label: "Weight (kg)",
backgroundColor: 'red',
borderColor: 'red',
data: days.map(day =&gt; day.weight),
fill: false,
spanGaps: true,
datalabels: {
display: false
}
}
];
return {
datasets: datasets,
labels: days.map(day =&gt; day.date)
};
}
const ctx = $("#canvas")[0].getContext("2d");
new chartjs.Chart(ctx, {
type: 'line',
data: await getChartData()
});</code></pre>
<h2>How to remove the Weight Tracker button from the top bar</h2>
<p>In the link map of the <code>Weight Tracker</code>, there is a note called <code>Button</code>.
Open it and delete or comment out its contents. The <code>Weight Tracker</code> button
will disappear after you restart Trilium.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,70 @@
# Weight Tracker
![](Weight Tracker_image.png)
The `Weight Tracker` is a [Script API](../Code%20Notes/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](../Attributes/Template.md) from which [day notes](Day%20Notes.md) are created, you can aggregate the data and plot weight change over time.
## Implementation
The `Weight Tracker` note in the screenshot above is of the type `Render Note`. That type of note doesn't have any useful content itself. Instead it is a placeholder where a [script](../Code%20Notes/Scripts.md) can render its output.
Scripts for `Render Notes` are defined in a [relation](../Attributes.md) called `~renderNote`. In this example, it's the `Weight Tracker`'s child `Implementation`. The Implementation consists of two [code notes](../Code%20Notes.md) that contain some HTML and JavaScript respectively, which load all the notes with a `weight` attribute and display their values in a chart.
To actually render the chart, we're using a third party library called [chart.js](https://www.chartjs.org/)which is imported as an attachment, since it's not built into Trilium.
### Code
Here's the content of the script which is placed in a [code note](../Code%20Notes.md) of type `JS Frontend`:
```
async function getChartData() {
const days = await api.runOnBackend(async () => {
const notes = api.getNotesWithLabel('weight');
const days = [];
for (const note of notes) {
const date = note.getLabelValue('dateNote');
const weight = parseFloat(note.getLabelValue('weight'));
if (date && weight) {
days.push({ date, weight });
}
}
days.sort((a, b) => a.date > b.date ? 1 : -1);
return days;
});
const datasets = [
{
label: "Weight (kg)",
backgroundColor: 'red',
borderColor: 'red',
data: days.map(day => day.weight),
fill: false,
spanGaps: true,
datalabels: {
display: false
}
}
];
return {
datasets: datasets,
labels: days.map(day => day.date)
};
}
const ctx = $("#canvas")[0].getContext("2d");
new chartjs.Chart(ctx, {
type: 'line',
data: await getChartData()
});
```
## How to remove the Weight Tracker button from the top bar
In the link map of the `Weight Tracker`, there is a note called `Button`. Open it and delete or comment out its contents. The `Weight Tracker` button will disappear after you restart Trilium.

View File

@ -1,148 +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>Attributes</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Attributes</h1>
<div class="ck-content">
<p>In Trilium, attributes are key-value pairs assigned to notes, providing
additional metadata or functionality. There are two primary types of attributes:</p>
<ol>
<li><strong>Labels</strong>: Simple key-value text records</li>
<li><strong>Relations</strong>: Named links to other notes</li>
</ol>
<p>These attributes play a crucial role in organizing, categorising, and
enhancing the functionality of notes.</p>
<figure class="image">
<img style="aspect-ratio:669/266;" src="1_Attributes_image.png" width="669"
height="266">
</figure>
<h2>Labels</h2>
<p>Labels in Trilium can be used for a variety of purposes:</p>
<ul>
<li><strong>Metadata</strong>: Assign labels with optional values for categorization,
such as <code>#year=1999</code>, <code>#genre="sci-fi"</code>, or <code>#author="Neal Stephenson"</code>
</li>
<li><strong>Configuration</strong>: Labels can configure advanced features
or settings</li>
<li><strong>Scripts and Plugins</strong>: Used to tag notes with special metadata,
such as the "weight" attribute in the <a href="Advanced%20Showcases/Weight%20Tracker.html">Weight Tracker</a>
</li>
</ul>
<p>Labels are also searchable, enhancing note retrieval.</p>
<h3>Common Labels for Advanced Configuration</h3>
<ul>
<li><code><strong>disableVersioning</strong></code>: Disables automatic versioning,
ideal for large, unimportant notes like script libraries</li>
<li><code><strong>versioningLimit</strong></code>: Used to limit the number
of revisions for a single note</li>
<li><code><strong>calendarRoot</strong></code>: Marks the note as the root
for <a href="Advanced%20Showcases/Day%20Notes.html">day notes</a>. Only
one note should carry this label</li>
<li><code><strong>archived</strong></code>: Hides notes from default search
results and dialogs</li>
<li><code><strong>excludeFromExport</strong></code>: Excludes notes and their
subtrees from export operations</li>
<li><code><strong>run</strong></code>: Specifies events to trigger scripts
(e.g., <code>frontendStartup</code>, <code>hourly</code>)</li>
<li><code><strong>runAtHour</strong></code>: Defines specific hours for scripts
to run, used with <code>#run=hourly</code>
</li>
<li><code><strong>disableInclusion</strong></code>: Prevents a script from
being included in parent script executions</li>
<li><code><strong>sorted</strong></code>: Automatically sorts child notes
alphabetically by title</li>
<li><code><strong>top</strong></code>: Keeps the note at the top of its parent's
list, useful with <code>sorted</code>
</li>
<li><code><strong>hidePromotedAttributes</strong></code>: Hides certain attributes
in the note's display</li>
<li><code><strong>readOnly</strong></code>: Sets the note to read-only mode,
applicable to text and code notes</li>
<li><code><strong>autoReadOnlyDisabled</strong></code>: Disables automatic
read-only mode for large notes</li>
<li><code><strong>appCss</strong></code>: Marks CSS notes used to modify Triliums
appearance</li>
<li><code><strong>appTheme</strong></code>: Marks full CSS themes available
in Trilium's options</li>
<li><code><strong>cssClass</strong></code>: Adds a CSS class to the note's
representation in the tree</li>
<li><code><strong>iconClass</strong></code>: Adds a CSS class to the note's
icon, useful for distinguishing notes visually. See <a href="../Basic%20Concepts/Note/Note%20Icons.html">note icons</a>
</li>
<li><code><strong>pageSize</strong></code>: Specifies the number of items
per page in note listings</li>
<li><code><strong>customRequestHandler</strong></code><strong> and </strong><code><strong>customResourceProvider</strong></code>:
Refer to <a href="Custom%20Request%20Handler.html">Custom request handler</a>
</li>
<li><code><strong>widget</strong></code>: Marks a note as a custom widget,
added to Trilium's component tree</li>
<li><code><strong>workspace</strong></code><strong> and related attributes</strong>:
See <a href="../Basic%20Concepts/Navigation/Workspace.html">Workspace</a> for
more details</li>
<li><code><strong>searchHome</strong></code>: Specifies the parent for new
search notes</li>
<li><code><strong>inbox</strong></code>: Designates a default location for
new notes created via the sidebar</li>
<li><code><strong>sqlConsoleHome</strong></code>: Default location for SQL
console notes</li>
<li><code><strong>bookmarked</strong></code><strong> and </strong><code><strong>bookmarkFolder</strong></code>:
See <a href="../Basic%20Concepts/Navigation/Bookmarks.html">Bookmarks</a>
</li>
<li><code><strong>shareXXX</strong></code>: See <a href="Sharing.html">Sharing</a>
</li>
<li><code><strong>keyboardShortcut</strong></code>: Assigns a keyboard shortcut
to open the note</li>
<li><code><strong>displayRelations</strong></code><strong> and </strong><code><strong>hideRelations</strong></code>:
Manages the display of note relations</li>
<li><code><strong>titleTemplate</strong></code>: See <a href="Default%20Note%20Title.html">Default note title</a>
</li>
<li><code><strong>template</strong></code>: Makes the note available as a
template</li>
<li><code><strong>toc</strong></code>: Controls the visibility of the table
of contents</li>
<li><code><strong>color</strong></code>: Defines the color of the note in
the tree and links</li>
<li><code><strong>hideChildrenOverview</strong></code>: Hides child notes
in the parent note's editor</li>
<li><code><strong>viewType</strong></code>: Sets the view of child notes (grid
or list)</li>
</ul>
<h2>Relations</h2>
<p>Relations define connections between notes, similar to links.</p>
<h3>Uses</h3>
<ul>
<li><strong>Metadata Relationships</strong>: For example, linking a book note
to an author note</li>
<li><strong>Scripting</strong>: Attaching scripts to events or conditions
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>
<h2>Multiplicity</h2>
<p>Attributes in Trilium can be "multivalued", meaning multiple attributes
with the same name can coexist.</p>
<h2>Attribute Definitions and Promoted Attributes</h2>
<p>Special labels create "label/attribute" definitions, enhancing the organization
and management of attributes. For more details, see <a href="Attributes/Promoted%20Attributes.html">Promoted attributes</a>.</p>
<h2>Attribute Inheritance</h2>
<p>Trilium supports attribute inheritance, allowing child notes to inherit
attributes from their parents. For more information, see <a href="Attributes/Attribute%20Inheritance.html">Attribute inheritance</a>.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,82 @@
# Attributes
In Trilium, attributes are key-value pairs assigned to notes, providing additional metadata or functionality. There are two primary types of attributes:
1. **Labels**: Simple key-value text records
2. **Relations**: Named links to other notes
These attributes play a crucial role in organizing, categorising, and enhancing the functionality of notes.
![](Attributes_image.png)
## Labels
Labels in Trilium can be used for a variety of purposes:
* **Metadata**: Assign labels with optional values for categorization, such as `#year=1999`, `#genre="sci-fi"`, or `#author="Neal Stephenson"`
* **Configuration**: Labels can configure advanced features or settings
* **Scripts and Plugins**: Used to tag notes with special metadata, such as the "weight" attribute in the [Weight Tracker](Advanced%20Showcases/Weight%20Tracker.md)
Labels are also searchable, enhancing note retrieval.
### Common Labels for Advanced Configuration
* `**disableVersioning**`: Disables automatic versioning, ideal for large, unimportant notes like script libraries
* `**versioningLimit**`: Used to limit the number of revisions for a single note
* `**calendarRoot**`: Marks the note as the root for [day notes](Advanced%20Showcases/Day%20Notes.md). Only one note should carry this label
* `**archived**`: Hides notes from default search results and dialogs
* `**excludeFromExport**`: Excludes notes and their subtrees from export operations
* `**run**`: Specifies events to trigger scripts (e.g., `frontendStartup`, `hourly`)
* `**runAtHour**`: Defines specific hours for scripts to run, used with `#run=hourly`
* `**disableInclusion**`: Prevents a script from being included in parent script executions
* `**sorted**`: Automatically sorts child notes alphabetically by title
* `**top**`: Keeps the note at the top of its parent's list, useful with `sorted`
* `**hidePromotedAttributes**`: Hides certain attributes in the note's display
* `**readOnly**`: Sets the note to read-only mode, applicable to text and code notes
* `**autoReadOnlyDisabled**`: Disables automatic read-only mode for large notes
* `**appCss**`: Marks CSS notes used to modify Triliums appearance
* `**appTheme**`: Marks full CSS themes available in Trilium's options
* `**cssClass**`: Adds a CSS class to the note's representation in the tree
* `**iconClass**`: Adds a CSS class to the note's icon, useful for distinguishing notes visually. See [note icons](../Basic%20Concepts/Note/Note%20Icons.md)
* `**pageSize**`: Specifies the number of items per page in note listings
* `**customRequestHandler**` **and** `**customResourceProvider**`: Refer to [Custom request handler](Custom%20Request%20Handler.md)
* `**widget**`: Marks a note as a custom widget, added to Trilium's component tree
* `**workspace**` **and related attributes**: See [Workspace](../Basic%20Concepts/Navigation/Workspace.md) for more details
* `**searchHome**`: Specifies the parent for new search notes
* `**inbox**`: Designates a default location for new notes created via the sidebar
* `**sqlConsoleHome**`: Default location for SQL console notes
* `**bookmarked**` **and** `**bookmarkFolder**`: See [Bookmarks](../Basic%20Concepts/Navigation/Bookmarks.md)
* `**shareXXX**`: See [Sharing](Sharing.md)
* `**keyboardShortcut**`: Assigns a keyboard shortcut to open the note
* `**displayRelations**` **and** `**hideRelations**`: Manages the display of note relations
* `**titleTemplate**`: See [Default note title](Default%20Note%20Title.md)
* `**template**`: Makes the note available as a template
* `**toc**`: Controls the visibility of the table of contents
* `**color**`: Defines the color of the note in the tree and links
* `**hideChildrenOverview**`: Hides child notes in the parent note's editor
* `**viewType**`: Sets the view of child notes (grid or list)
## Relations
Relations define connections between notes, similar to links.
### Uses
* **Metadata Relationships**: For example, linking a book note to an author note
* **Scripting**: Attaching scripts to events or conditions related to the note
### 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
## Multiplicity
Attributes in Trilium can be "multivalued", meaning multiple attributes with the same name can coexist.
## Attribute Definitions and Promoted Attributes
Special labels create "label/attribute" definitions, enhancing the organization and management of attributes. For more details, see [Promoted attributes](Attributes/Promoted%20Attributes.md).
## Attribute Inheritance
Trilium supports attribute inheritance, allowing child notes to inherit attributes from their parents. For more information, see [Attribute inheritance](Attributes/Attribute%20Inheritance.md).

View File

@ -1,52 +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>Attribute Inheritance</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Attribute Inheritance</h1>
<div class="ck-content">
<h2>1. Standard Inheritance</h2>
<p>In Trilium, attributes can be automatically inherited by child notes if
they have the <code>isInheritable</code> flag set to <code>true</code>. This
means the attribute (a key-value pair) is applied to the note and all its
descendants.</p>
<h3>Example Use Case</h3>
<p>The <code>archived</code> label can be set to be inheritable, allowing you
to hide a whole subtree of notes from searches and other dialogs by applying
this label at the top level.</p>
<h2>2. Copying Inheritance</h2>
<p>Copying inheritance differs from standard inheritance by using a <code>child:</code> prefix
in the attribute name. This prefix causes new child notes to automatically
receive specific attributes from the parent note. These attributes are
independent of the parent and will persist even if the note is moved elsewhere.</p>
<h3>How to Use</h3>
<ul>
<li><strong>Syntax:</strong> <code>#child:attributeName</code>
</li>
<li><strong>Chained Inheritance:</strong> You can chain this inheritance, such
as <code>#child:child:attributeName</code>, where each child down the hierarchy
receives the appropriate attribute.</li>
</ul>
<h3>Example</h3>
<p>If a parent note has the label <code>#child:exampleAttribute</code>, all
newly created child notes will inherit the <code>#exampleAttribute</code> label.
This can be useful for setting default properties for notes in a specific
section.</p>
<h2>3. Template Inheritance</h2>
<p>Attributes can also be inherited from <a href="Template.html">templates</a>.
When a new note is created using a template, it inherits the attributes
defined in that template. This is particularly useful for maintaining consistency
across notes that follow a similar structure or function.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,25 @@
# Attribute Inheritance
## 1\. Standard Inheritance
In Trilium, attributes can be automatically inherited by child notes if they have the `isInheritable` flag set to `true`. This means the attribute (a key-value pair) is applied to the note and all its descendants.
### Example Use Case
The `archived` label can be set to be inheritable, allowing you to hide a whole subtree of notes from searches and other dialogs by applying this label at the top level.
## 2\. Copying Inheritance
Copying inheritance differs from standard inheritance by using a `child:` prefix in the attribute name. This prefix causes new child notes to automatically receive specific attributes from the parent note. These attributes are independent of the parent and will persist even if the note is moved elsewhere.
### How to Use
* **Syntax:** `#child:attributeName`
* **Chained Inheritance:** You can chain this inheritance, such as `#child:child:attributeName`, where each child down the hierarchy receives the appropriate attribute.
### Example
If a parent note has the label `#child:exampleAttribute`, all newly created child notes will inherit the `#exampleAttribute` label. This can be useful for setting default properties for notes in a specific section.
## 3\. Template Inheritance
Attributes can also be inherited from [templates](Template.md). When a new note is created using a template, it inherits the attributes defined in that template. This is particularly useful for maintaining consistency across notes that follow a similar structure or function.

View File

@ -1,71 +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>Promoted Attributes</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Promoted Attributes</h1>
<div class="ck-content">
<p>Promoted attributes are <a href="../Attributes.html">attributes</a> which
are considered important and thus are "promoted" onto the main note UI.
See example below:</p>
<p>
<img src="../../Attachments/promoted-attributes.png" alt="">
</p>
<p>You can see the note having kind of form with several fields. Each of
these is just regular attribute, the only difference is that they appear
on the note itself.</p>
<p>Attributes can be pretty useful since they allow for querying and script
automation etc. but they are also inconveniently hidden. This allows you
to select few of the important ones and push them to the front of the user.</p>
<p>Now, how do we make attribute to appear on the UI?</p>
<h2>Attribute definition</h2>
<p>Attribute is always name-value pair where both name and value are strings.</p>
<p><i>Attribute definition</i> specifies how should this value be interpreted
- is it just string, or is it a date? Should we allow multiple values or
note? And importantly, should we <i>promote</i> the attribute or not?</p>
<figure
class="image">
<img style="aspect-ratio:932/749;" src="Promoted Attributes_image.png"
width="932" height="749">
</figure>
<p>You can notice tag attribute definition. These "definition" attributes
define how the "value" attributes should behave.</p>
<p>So there's one attribute for value and one for definition. But notice
how definition attribute is <a href="Attribute%20Inheritance.html">Inheritable</a>,
meaning that it's also applied to all descendant note. So in a way, this
definition is used for the whole subtree while "value" attributes are applied
only for this note.</p>
<h3>Inverse relation</h3>
<p>Some relations always occur in pairs - my favorite example is on the family.
If you have a note representing husband and note representing wife, then
there might be a relation between those two of <code>isPartnerOf</code>.
This is bidirectional relationship - meaning that if a relation is pointing
from husband to wife then there should be always another relation pointing
from wife to husband.</p>
<p>Another example is with parent - child relationship. Again these always
occur in pairs, but in this case it's not exact same relation - the one
going from parent to child might be called <code>isParentOf</code> and the
other one going from child to parent might be called <code>isChildOf</code>.</p>
<p>Relation definition allows you to specify such "inverse relation" - for
the relation you just define you specify which is the inverse relation.
Note that in the second example we should have two relation definitions
- one for <code>isParentOf</code> which defines <code>isChildOf</code> as inverse
relation and then second relation definition for <code>isChildOf</code> which
defines <code>isParentOf</code> as inverse relation.</p>
<p>What this does internally is that whenever we save a relation which has
defined inverse relation, we check that this inverse relation exists on
the relation target note. Similarly, when we delete relation, we also delete
inverse relation on the target note.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,32 @@
# Promoted Attributes
Promoted attributes are [attributes](../Attributes.md) which are considered important and thus are "promoted" onto the main note UI. See example below:
![](../../Attachments/promoted-attributes.png)
You can see the note having kind of form with several fields. Each of these is just regular attribute, the only difference is that they appear on the note itself.
Attributes can be pretty useful since they allow for querying and script automation etc. but they are also inconveniently hidden. This allows you to select few of the important ones and push them to the front of the user.
Now, how do we make attribute to appear on the UI?
## Attribute definition
Attribute is always name-value pair where both name and value are strings.
_Attribute definition_ specifies how should this value be interpreted - is it just string, or is it a date? Should we allow multiple values or note? And importantly, should we _promote_ the attribute or not?
![](Promoted Attributes_image.png)
You can notice tag attribute definition. These "definition" attributes define how the "value" attributes should behave.
So there's one attribute for value and one for definition. But notice how definition attribute is [Inheritable](Attribute%20Inheritance.md), meaning that it's also applied to all descendant note. So in a way, this definition is used for the whole subtree while "value" attributes are applied only for this note.
### Inverse relation
Some relations always occur in pairs - my favorite example is on the family. If you have a note representing husband and note representing wife, then there might be a relation between those two of `isPartnerOf`. This is bidirectional relationship - meaning that if a relation is pointing from husband to wife then there should be always another relation pointing from wife to husband.
Another example is with parent - child relationship. Again these always occur in pairs, but in this case it's not exact same relation - the one going from parent to child might be called `isParentOf` and the other one going from child to parent might be called `isChildOf`.
Relation definition allows you to specify such "inverse relation" - for the relation you just define you specify which is the inverse relation. Note that in the second example we should have two relation definitions - one for `isParentOf` which defines `isChildOf` as inverse relation and then second relation definition for `isChildOf` which defines `isParentOf` as inverse relation.
What this does internally is that whenever we save a relation which has defined inverse relation, we check that this inverse relation exists on the relation target note. Similarly, when we delete relation, we also delete inverse relation on the target note.

View File

@ -1,74 +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>Template</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Template</h1>
<div class="ck-content">
<p>A template in Trilium serves as a predefined structure for other notes,
referred to as instance notes. Assigning a template to a note brings three
main effects:</p>
<ol>
<li><strong>Attribute Inheritance</strong>: All attributes from the template
note are <a href="Attribute%20Inheritance.html">inherited</a> by the instance
notes. Even attributes with <code>#isInheritable=false</code> are inherited
by the instance notes, although only inheritable attributes are further
inherited by the children of the instance notes.</li>
<li><strong>Content Duplication</strong>: The content of the template note
is copied to the instance note, provided the instance note is empty at
the time of template assignment.</li>
<li><strong>Child Note Duplication</strong>: All child notes of the template
are deep-duplicated to the instance note.</li>
</ol>
<h2>Example</h2>
<p>A typical example would be a "Book" template note, which might include:</p>
<ul>
<li><strong>Promoted Attributes</strong>: Such as publication year, author,
etc. (see <a href="Promoted%20Attributes.html">promoted attributes</a>).</li>
<li><strong>Outline</strong>: An outline for a book review, including sections
like themes, conclusion, etc.</li>
<li><strong>Child Notes</strong>: Additional notes for highlights, summary,
etc.</li>
</ul>
<p>
<img src="../../Attachments/template.png" alt="Template Example">
</p>
<h2>Instance Note</h2>
<p>An instance note is a note related to a template note. This relationship
means the instance note's content is initialized from the template, and
all attributes from the template are inherited.</p>
<p>To create an instance note through the UI:</p>
<p>
<img src="../../Attachments/template-create-instance-n.png" alt="show child note templates">
</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/Navigation/Workspace.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
a <code>~template</code> relation pointing to the desired template note.</p>
<h2>Additional Notes</h2>
<p>From a visual perspective, templates can define <code>#iconClass</code> and <code>#cssClass</code> attributes,
allowing all instance notes (e.g., books) to display a specific icon and
CSS style.</p>
<p>Explore the concept further in the <a href="../Database.html">demo notes</a>,
including examples like the <a href="../Relation%20Map.html">Relation Map</a>,
<a
href="../Advanced%20Showcases/Task%20Manager.html">Task Manager</a>, and <a href="../Advanced%20Showcases/Day%20Notes.html">Day Notes</a>.</p>
<p>Additionally, see <a href="../Default%20Note%20Title.html">default note title</a> for
creating title templates. Note templates and title templates can be combined
by creating a <code>#titleTemplate</code> for a template note.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,36 @@
# Template
A template in Trilium serves as a predefined structure for other notes, referred to as instance notes. Assigning a template to a note brings three main effects:
1. **Attribute Inheritance**: All attributes from the template note are [inherited](Attribute%20Inheritance.md) by the instance notes. Even attributes with `#isInheritable=false` are inherited by the instance notes, although only inheritable attributes are further inherited by the children of the instance notes.
2. **Content Duplication**: The content of the template note is copied to the instance note, provided the instance note is empty at the time of template assignment.
3. **Child Note Duplication**: All child notes of the template are deep-duplicated to the instance note.
## Example
A typical example would be a "Book" template note, which might include:
* **Promoted Attributes**: Such as publication year, author, etc. (see [promoted attributes](Promoted%20Attributes.md)).
* **Outline**: An outline for a book review, including sections like themes, conclusion, etc.
* **Child Notes**: Additional notes for highlights, summary, etc.
![Template Example](../../Attachments/template.png)
## Instance Note
An instance note is a note related to a template note. This relationship means the instance note's content is initialized from the template, and all attributes from the template are inherited.
To create an instance note through the UI:
![show child note templates](../../Attachments/template-create-instance-n.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/Navigation/Workspace.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.
## Additional Notes
From a visual perspective, templates can define `#iconClass` and `#cssClass` attributes, allowing all instance notes (e.g., books) to display a specific icon and CSS style.
Explore the concept further in the [demo notes](../Database.md), including examples like the [Relation Map](../Relation%20Map.md), [Task Manager](../Advanced%20Showcases/Task%20Manager.md), and [Day Notes](../Advanced%20Showcases/Day%20Notes.md).
Additionally, see [default note title](../Default%20Note%20Title.md) for creating title templates. Note templates and title templates can be combined by creating a `#titleTemplate` for a template note.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -1,27 +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>Bulk actions</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Bulk actions</h1>
<div class="ck-content">
<h3>Execute script</h3>
<p>For more complex scenarios, it is possible to type in a JavaScript expression
in order to apply the necessary changes.</p>
<p>To apply a suffix (<code>- suffix</code> in this example), to the note
title:</p><pre><code class="language-application-javascript-env-backend">note.title = note.title + " - suffix";</code></pre>
<p>To alter attributes of a note in a bulk action, such as setting the <code>#shareAlias</code> label
to the title of the note:</p><pre><code class="language-application-javascript-env-backend">note.setLabel("shareAlias", note.title)</code></pre>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,16 @@
# Bulk actions
### Execute script
For more complex scenarios, it is possible to type in a JavaScript expression in order to apply the necessary changes.
To apply a suffix (`- suffix` in this example), to the note title:
```javascript
note.title = note.title + " - suffix";
```
To alter attributes of a note in a bulk action, such as setting the `#shareAlias` label to the title of the note:
```javascript
note.setLabel("shareAlias", note.title)
```

View File

@ -1,52 +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>Code Notes</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Code Notes</h1>
<div class="ck-content">
<p>Trilium supports creating "code" notes, i.e. notes which contain some
sort of formal code - be it programming language (C++, JavaScript), structured
data (JSON, XML) or other types of codes (CSS etc.).</p>
<p>This can be useful for a few things:</p>
<ul>
<li>computer programmers can store code snippets as notes with syntax highlighting</li>
<li>JavaScript code notes can be executed inside Trilium for some extra functionality
<ul>
<li>we call such JavaScript code notes "scripts" - see <a href="Code%20Notes/Scripts.html">Scripts</a>
</li>
</ul>
</li>
<li>JSON, XML etc. can be used as storage for structured data (typically used
in conjunction with scripting)</li>
</ul>
<figure class="image">
<img style="aspect-ratio:910/703;" src="1_Code Notes_image.png" width="910"
height="703">
</figure>
<h2>Extra languages</h2>
<p>Trilium supports syntax highlighting for many languages, but by default
displays only some of them (to reduce the number of items). You can add
extra languages in Options -&gt; Code notes.</p>
<h2>Code blocks</h2>
<p>An alternative to the code note is a "code block" - feature of a text
note which can add short snippets of code to the text editor. Starting
with TriliumNext v0.90.12, the code blocks also support syntax highlighting.</p>
<figure
class="image">
<img style="aspect-ratio:912/705;" src="Code Notes_image.png" width="912"
height="705">
</figure>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,21 @@
# Code Notes
Trilium supports creating "code" notes, i.e. notes which contain some sort of formal code - be it programming language (C++, JavaScript), structured data (JSON, XML) or other types of codes (CSS etc.).
This can be useful for a few things:
* computer programmers can store code snippets as notes with syntax highlighting
* JavaScript code notes can be executed inside Trilium for some extra functionality
* we call such JavaScript code notes "scripts" - see [Scripts](Code%20Notes/Scripts.md)
* JSON, XML etc. can be used as storage for structured data (typically used in conjunction with scripting)
![](Code Notes_image.png)
## Extra languages
Trilium supports syntax highlighting for many languages, but by default displays only some of them (to reduce the number of items). You can add extra languages in Options -> Code notes.
## Code blocks
An alternative to the code note is a "code block" - feature of a text note which can add short snippets of code to the text editor. Starting with TriliumNext v0.90.12, the code blocks also support syntax highlighting.
![](1_Code Notes_image.png)

View File

@ -1,113 +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>Custom Widgets</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Custom Widgets</h1>
<div class="ck-content">
<p>It's possible to create custom widget in three possible locations where
you can display your custom content.</p>
<p>Positions are:</p>
<ul>
<li><code>left-pane</code>
</li>
<li><code>center-pane</code>
</li>
<li><code>note-detail-pane</code> - located within <code>center-pane</code>,
but specific to note (split)</li>
<li><code>right-pane</code>
</li>
</ul>
<h2>Example - word count widget</h2>
<p>Create a code 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.
*
* See it in action in "Books" and its subtree.
*/
const TPL = `
Word count:
&nbsp;
Character count:
`;
class WordCountWidget extends api.NoteContextAwareWidget {
static get parentWidget() { return 'center-pane'; }
get position() { return 100; } // higher value means position towards the bottom/right
isEnabled() {
return super.isEnabled()
&amp;&amp; this.note.type === 'text'
&amp;&amp; this.note.hasLabel('wordCount');
}
doRender() {
this.$widget = $(TPL);
this.$wordCount = this.$widget.find('.word-count');
this.$characterCount = this.$widget.find('.character-count');
return this.$widget;
}
async refreshWithNote(note) {
const {content} = await note.getNoteComplement();
const text = $(content).text(); // get plain text only
const counts = this.getCounts(text);
this.$wordCount.text(counts.words);
this.$characterCount.text(counts.characters);
}
getCounts(text) {
const chunks = text
.split(/[\s-+:,/\\]+/)
.filter(chunk =&gt; chunk !== '');
let words;
if (chunks.length === 1 &amp;&amp; chunks[0] === '') {
words = 0;
}
else {
words = chunks.length;
}
const characters = chunks.join('').length;
return {words, characters};
}
async entitiesReloadedEvent({loadResults}) {
if (loadResults.isNoteContentReloaded(this.noteId)) {
this.refresh();
}
}
}
module.exports = WordCountWidget;</code></pre>
<p>After you make changes it is necessary to restart Trilium so that the
layout can be rebuilt.</p>
<h3>Example screenshot</h3>
<p>On the bottom you can see the resulting widget:</p>
<p>
<img src="../../Attachments/Custom-widget%20image.png" alt="">
</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,96 @@
# Custom Widgets
It's possible to create custom widget in three possible locations where you can display your custom content.
Positions are:
* `left-pane`
* `center-pane`
* `note-detail-pane` - located within `center-pane`, but specific to note (split)
* `right-pane`
## Example - word count widget
Create a code note of type JS frontend and **give it a** `**#widget**` **label**.
```
/*
* 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.
*
* See it in action in "Books" and its subtree.
*/
const TPL = `
Word count:
 
Character count:
`;
class WordCountWidget extends api.NoteContextAwareWidget {
static get parentWidget() { return 'center-pane'; }
get position() { return 100; } // higher value means position towards the bottom/right
isEnabled() {
return super.isEnabled()
&& this.note.type === 'text'
&& this.note.hasLabel('wordCount');
}
doRender() {
this.$widget = $(TPL);
this.$wordCount = this.$widget.find('.word-count');
this.$characterCount = this.$widget.find('.character-count');
return this.$widget;
}
async refreshWithNote(note) {
const {content} = await note.getNoteComplement();
const text = $(content).text(); // get plain text only
const counts = this.getCounts(text);
this.$wordCount.text(counts.words);
this.$characterCount.text(counts.characters);
}
getCounts(text) {
const chunks = text
.split(/[\s-+:,/\\]+/)
.filter(chunk => chunk !== '');
let words;
if (chunks.length === 1 && chunks[0] === '') {
words = 0;
}
else {
words = chunks.length;
}
const characters = chunks.join('').length;
return {words, characters};
}
async entitiesReloadedEvent({loadResults}) {
if (loadResults.isNoteContentReloaded(this.noteId)) {
this.refresh();
}
}
}
module.exports = WordCountWidget;
```
After you make changes it is necessary to restart Trilium so that the layout can be rebuilt.
### Example screenshot
On the bottom you can see the resulting widget:
![](../../Attachments/Custom-widget%20image.png)

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="Scripts.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="../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 <i>this</i> note</li>
<li><code>runOnAttributeCreation</code> - executes when new attribute is created
under <i>this</i> note</li>
<li><code>runOnAttributeChange</code> - executes when attribute is changed
under <i>this</i> note</li>
</ul>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,29 @@
# Events
[Script](Scripts.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](../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

@ -1,30 +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>Script API</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Script API</h1>
<div class="ck-content">
<p>Trilium offers a "Script API" that enables scripts to perform various
useful functions. There are two main APIs available:</p>
<ul>
<li><a href="https://triliumnext.github.io/Notes/frontend_api/FrontendScriptApi.html">Frontend API</a>
</li>
<li><a href="https://triliumnext.github.io/Notes/backend_api/BackendScriptApi.html">Backend API</a>
</li>
</ul>
<p>Please note that the Script API is currently experimental and may undergo
changes in future updates.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,7 @@
# Script API
Trilium offers a "Script API" that enables scripts to perform various useful functions. There are two main APIs available:
* [Frontend API](https://triliumnext.github.io/Notes/frontend_api/FrontendScriptApi.html)
* [Backend API](https://triliumnext.github.io/Notes/backend_api/BackendScriptApi.html)
Please note that the Script API is currently experimental and may undergo changes in future updates.

View File

@ -1,86 +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>Scripts</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Scripts</h1>
<div class="ck-content">
<p>Trilium supports creating <a href="../Code%20Notes.html">code notes</a>,
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 href="Script%20API.html">Script API</a> provide
extra functionality.</p>
<h2>Scripting</h2>
<p>To go further I must explain basic architecture of Trilium - in its essence
it is a classic web application - it has these two main components:</p>
<ul>
<li>frontend running in the browser (using HTML, CSS, JavaScript) - this is
mainly used to interact with the user, display notes etc.</li>
<li>backend running JavaScript code in node.js runtime - this is responsible
for e.g. storing notes, encrypting them etc.</li>
</ul>
<p>So we have frontend and backend, each with their own set of responsibilities,
but their common feature is that they both run JavaScript code. Add to
this the fact, that we're able to create JavaScript [[code notes]] and
we're onto something.</p>
<h2>Button use case</h2>
<p>Let's take a look at our demo script (shipped with default Trilium <a href="../Database.html">database</a>)
- Task manager. One of the things this script does is adding a button to
the Trilium interface which will allow user to easily add new Task (TODO
item).</p>
<p>
<img src="../../Attachments/button-script.png" alt="">
</p>
<p>First take a look at the red circle all the way on the top - this what
we want to achieve - new button in UI which will create new note representing
a task/todo item.</p>
<p>Red point below the first one marks the note type we have created for
this script - it's "JavaScript frontend". It's frontend because adding
button to UI is clearly frontend responsibility.</p>
<p>In the note content you can see the code which calls one of the API methods,
this one is specifically meant to add new buttons. Code needs to set few
button properties:</p>
<ul>
<li>button title</li>
<li>icon which should appear on the button</li>
<li>optional shortcut under which you can trigger the button</li>
<li>most importantly "action" - what must happen when button is clicked</li>
</ul>
<h3>Action handler</h3>
<p>Saving the note to the database is backend's responsibility, so we immediately
pass control to the backend and ask it to create a note. Once this is done,
we show the newly created note so that the user can set the task title
and maybe some attributes.</p>
<h3>Script execution</h3>
<p>So we have a script which will add the button to the toolbar. But how
can we execute it? One possibility is to click on "play" icon (marked by
red circle). The problem with this is that this UI change is time bound
by Trilium runtime so when we restart Trilium, button won't be there.</p>
<p>We need to execute it every time Trilium starts up, but we probably don't
want to have to manually click on play button on every start up.</p>
<p>The solution is marked by red circle at the bottom - this note has <a href="../Attributes.html">label</a> <code>#run=frontendStartup</code> -
this is one of the "system" labels which Trilium understands. As you might
guess, this will cause all such labeled script notes to be executed once
Trilium frontend starts up.</p>
<p>(<code>#run=frontendStartup</code> does not work for <a href="../../Installation%20%26%20Setup/Mobile%20Frontend.html">Mobile frontend</a> -
if you want to have scripts running there, give the script <code>#run=mobileStartup</code> label)</p>
<h3>More showcases</h3>
<p>You can see more scripting with explanation in <a href="../Advanced%20Showcases.html">Advanced showcases</a>
</p>
<h2>Events</h2>
<p>See <a href="Events.html">Events</a>.</p>
<h2>Script API</h2>
<p>See <a href="Script%20API.html">Script API</a>.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,54 @@
# Scripts
Trilium supports creating [code notes](../Code%20Notes.md), 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 [Script API](Script%20API.md) provide extra functionality.
## Scripting
To go further I must explain basic architecture of Trilium - in its essence it is a classic web application - it has these two main components:
* frontend running in the browser (using HTML, CSS, JavaScript) - this is mainly used to interact with the user, display notes etc.
* backend running JavaScript code in node.js runtime - this is responsible for e.g. storing notes, encrypting them etc.
So we have frontend and backend, each with their own set of responsibilities, but their common feature is that they both run JavaScript code. Add to this the fact, that we're able to create JavaScript \[\[code notes\]\] and we're onto something.
## Button use case
Let's take a look at our demo script (shipped with default Trilium [database](../Database.md)) - Task manager. One of the things this script does is adding a button to the Trilium interface which will allow user to easily add new Task (TODO item).
![](../../Attachments/button-script.png)
First take a look at the red circle all the way on the top - this what we want to achieve - new button in UI which will create new note representing a task/todo item.
Red point below the first one marks the note type we have created for this script - it's "JavaScript frontend". It's frontend because adding button to UI is clearly frontend responsibility.
In the note content you can see the code which calls one of the API methods, this one is specifically meant to add new buttons. Code needs to set few button properties:
* button title
* icon which should appear on the button
* optional shortcut under which you can trigger the button
* most importantly "action" - what must happen when button is clicked
### Action handler
Saving the note to the database is backend's responsibility, so we immediately pass control to the backend and ask it to create a note. Once this is done, we show the newly created note so that the user can set the task title and maybe some attributes.
### Script execution
So we have a script which will add the button to the toolbar. But how can we execute it? One possibility is to click on "play" icon (marked by red circle). The problem with this is that this UI change is time bound by Trilium runtime so when we restart Trilium, button won't be there.
We need to execute it every time Trilium starts up, but we probably don't want to have to manually click on play button on every start up.
The solution is marked by red circle at the bottom - this note has [label](../Attributes.md) `#run=frontendStartup` - this is one of the "system" labels which Trilium understands. As you might guess, this will cause all such labeled script notes to be executed once Trilium frontend starts up.
(`#run=frontendStartup` does not work for [Mobile frontend](../../Installation%20%26%20Setup/Mobile%20Frontend.md) - if you want to have scripts running there, give the script `#run=mobileStartup` label)
### More showcases
You can see more scripting with explanation in [Advanced showcases](../Advanced%20Showcases.md)
## Events
See [Events](Events.md).
## Script API
See [Script API](Script%20API.md).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 99 KiB

View File

@ -1,47 +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>Configuration (config.ini or environment variables)</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Configuration (config.ini or environment variables)</h1>
<div class="ck-content">
<p>Trilium supports configuration via a file named <code>config.ini</code> and
environment variables. Please review the file named <a href="https://github.com/TriliumNext/Notes/blob/develop/config-sample.ini">config-sample.ini</a> in
the <a href="https://github.com/TriliumNext/Notes">Notes</a> repository to
see what values are supported.</p>
<p>You can provide the same values via environment variables instead of the <code>config.ini</code> file,
and these environment variables use the following format:</p>
<ol>
<li>Environment variables should be prefixed with <code>TRILIUM_</code> and
use underscores to represent the INI section structure.</li>
<li>The format is: <code>TRILIUM_&lt;SECTION&gt;_&lt;KEY&gt;=&lt;VALUE&gt;</code>
</li>
<li>The environment variables will override any matching values from config.ini</li>
</ol>
<p>For example, if you have this in your config.ini:</p><pre><code class="language-text-x-trilium-auto">[Network]
host=localhost
port=8080</code></pre>
<p>You can override these values using environment variables:</p><pre><code class="language-text-x-sh">TRILIUM_NETWORK_HOST=0.0.0.0
TRILIUM_NETWORK_PORT=9000</code></pre>
<p>The code will:</p>
<ol>
<li>First load the <code>config.ini</code> file as before</li>
<li>Then scan all environment variables for ones starting with <code>TRILIUM_</code>
</li>
<li>Parse these variables into section/key pairs</li>
<li>Merge them with the config from the file, with environment variables taking
precedence</li>
</ol>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,30 @@
# Configuration (config.ini or environment variables)
Trilium supports configuration via a file named `config.ini` and environment variables. Please review the file named [config-sample.ini](https://github.com/TriliumNext/Notes/blob/develop/config-sample.ini) in the [Notes](https://github.com/TriliumNext/Notes) repository to see what values are supported.
You can provide the same values via environment variables instead of the `config.ini` file, and these environment variables use the following format:
1. Environment variables should be prefixed with `TRILIUM_` and use underscores to represent the INI section structure.
2. The format is: `TRILIUM_<SECTION>_<KEY>=<VALUE>`
3. The environment variables will override any matching values from config.ini
For example, if you have this in your config.ini:
```
[Network]
host=localhost
port=8080
```
You can override these values using environment variables:
```sh
TRILIUM_NETWORK_HOST=0.0.0.0
TRILIUM_NETWORK_PORT=9000
```
The code will:
1. First load the `config.ini` file as before
2. Then scan all environment variables for ones starting with `TRILIUM_`
3. Parse these variables into section/key pairs
4. Merge them with the config from the file, with environment variables taking precedence

View File

@ -1,95 +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>Custom Request Handler</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Custom Request Handler</h1>
<div class="ck-content">
<p>Trilium provides a mechanism for <a href="Code%20Notes/Scripts.html">scripts</a> to
open a public REST endpoint. This opens a way for various integrations
with other services - a simple example would be creating new note from
Slack by issuing a slash command (e.g. <code>/trilium buy milk</code>).</p>
<h2>Create note from outside Trilium</h2>
<p>Let's take a look at an example. The goal is to provide a REST endpoint
to which we can send title and content and Trilium will create a note.</p>
<p>We'll start with creating a JavaScript backend <a href="Code%20Notes.html">code note</a> containing:</p><pre><code class="language-text-x-trilium-auto">const {req, res} = api;
const {secret, title, content} = req.body;
if (req.method == 'POST' &amp;&amp; secret === 'secret-password') {
// notes must be saved somewhere in the tree hierarchy specified by a parent note.
// This is defined by a relation from this code note to the "target" parent note
// alternetively you can just use constant noteId for simplicity (get that from "Note Info" dialog of the desired parent note)
const targetParentNoteId = api.currentNote.getRelationValue('targetNote');
const {note} = api.createTextNote(targetParentNoteId, title, content);
const notePojo = note.getPojo();
res.status(201).json(notePojo);
}
else {
res.send(400);
}</code></pre>
<p>This script note has also following two attributes:</p>
<ul>
<li>label <code>#customRequestHandler</code> with value <code>create-note</code>
</li>
<li>relation <code>~targetNote</code> pointing to a note where new notes should
be saved</li>
</ul>
<h3>Explanation</h3>
<p>Let's test this by using an HTTP client to send a request:</p><pre><code class="language-text-x-trilium-auto">POST http://my.trilium.org/custom/create-note
Content-Type: application/json
{
"secret": "secret-password",
"title": "hello",
"content": "world"
}+++++++++++++++++++++++++++++++++++++++++++++++</code></pre>
<p>Notice the <code>/custom</code> part in the request path - Trilium considers
any request with this prefix as "custom" and tries to find a matching handler
by looking at all notes which have <code>customRequestHandler</code> <a href="Attributes.html">label</a>.
Value of this label then contains a regular expression which will match
the request path (in our case trivial regex "create-note").</p>
<p>Trilium will then find our code note created above and execute it. <code>api.req</code>, <code>api.res</code> are
set to <a href="https://expressjs.com/en/api.html#req">request</a> and
<a
href="https://expressjs.com/en/api.html#res">response</a>objects from which we can get details of the request and also
respond.</p>
<p>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.</p>
<p>Once we pass these checks we will just create the desired note using
<a
href="Code%20Notes/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
is again path regex).</p>
<p>For more information, see&nbsp;<a class="reference-link" href="Custom%20Resource%20Providers.html">Custom Resource Providers</a>.</p>
<h2>Advanced concepts</h2>
<p><code>api.req</code> and <code>api.res</code> are Express.js objects - you
can always look into its <a href="https://expressjs.com/en/api.html">documentation</a> for
details.</p>
<h3>Parameters</h3>
<p>REST request paths often contain parameters in the URL, e.g.:</p><pre><code class="language-text-x-trilium-auto">http://my.trilium.org/custom/notes/123</code></pre>
<p>The last part is dynamic so the matching of the URL must also be dynamic
- for this reason the matching is done with regular expressions. Following <code>customRequestHandler</code> value
would match it:</p><pre><code class="language-text-x-trilium-auto">notes/([0-9]+)</code></pre>
<p>Additionally, this also defines a matching group with the use of parenthesis
which then makes it easier to extract the value. The matched groups are
available in <code>api.pathParams</code>:</p><pre><code class="language-text-x-trilium-auto">const noteId = api.pathParams[0];</code></pre>
<p>Often you also need query params (as in e.g. <code>http://my.trilium.org/custom/notes?noteId=123</code>),
you can get those with standard express <code>req.query.noteId</code>.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,88 @@
# Custom Request Handler
Trilium provides a mechanism for [scripts](Code%20Notes/Scripts.md) to open a public REST endpoint. This opens a way for various integrations with other services - a simple example would be creating new note from Slack by issuing a slash command (e.g. `/trilium buy milk`).
## Create note from outside Trilium
Let's take a look at an example. The goal is to provide a REST endpoint to which we can send title and content and Trilium will create a note.
We'll start with creating a JavaScript backend [code note](Code%20Notes.md) containing:
```
const {req, res} = api;
const {secret, title, content} = req.body;
if (req.method == 'POST' && secret === 'secret-password') {
// notes must be saved somewhere in the tree hierarchy specified by a parent note.
// This is defined by a relation from this code note to the "target" parent note
// alternetively you can just use constant noteId for simplicity (get that from "Note Info" dialog of the desired parent note)
const targetParentNoteId = api.currentNote.getRelationValue('targetNote');
const {note} = api.createTextNote(targetParentNoteId, title, content);
const notePojo = note.getPojo();
res.status(201).json(notePojo);
}
else {
res.send(400);
}
```
This script note has also following two attributes:
* label `#customRequestHandler` with value `create-note`
* relation `~targetNote` pointing to a note where new notes should be saved
### Explanation
Let's test this by using an HTTP client to send a request:
```
POST http://my.trilium.org/custom/create-note
Content-Type: application/json
{
"secret": "secret-password",
"title": "hello",
"content": "world"
}+++++++++++++++++++++++++++++++++++++++++++++++
```
Notice the `/custom` part in the request path - Trilium considers any request with this prefix as "custom" and tries to find a matching handler by looking at all notes which have `customRequestHandler` [label](Attributes.md). Value of this label then contains a regular expression which will match the request path (in our case trivial regex "create-note").
Trilium will then find our code note created above and execute it. `api.req`, `api.res` are set to [request](https://expressjs.com/en/api.html#req) and [response](https://expressjs.com/en/api.html#res)objects from which we can get details of the request and also respond.
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](Code%20Notes/Script%20API.md).
## Custom resource provider
Another common use case is that you want to just expose a file note - in such case you create label `customResourceProvider` (value is again path regex).
For more information, see [Custom Resource Providers](Custom%20Resource%20Providers.md).
## Advanced concepts
`api.req` and `api.res` are Express.js objects - you can always look into its [documentation](https://expressjs.com/en/api.html) for details.
### Parameters
REST request paths often contain parameters in the URL, e.g.:
```
http://my.trilium.org/custom/notes/123
```
The last part is dynamic so the matching of the URL must also be dynamic - for this reason the matching is done with regular expressions. Following `customRequestHandler` value would match it:
```
notes/([0-9]+)
```
Additionally, this also defines a matching group with the use of parenthesis which then makes it easier to extract the value. The matched groups are available in `api.pathParams`:
```
const noteId = api.pathParams[0];
```
Often you also need query params (as in e.g. `http://my.trilium.org/custom/notes?noteId=123`), you can get those with standard express `req.query.noteId`.

View File

@ -1,63 +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>Custom Resource Providers</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Custom Resource Providers</h1>
<div class="ck-content">
<div class="content">
<div class="ck-content">
<p>A custom resource provider allows any file imported into Trilium (images,
fonts, stylesheets) to be publicly accessible via a URL.</p>
<p>A potential use case for this is to add embed a custom font alongside
a theme.</p>
<h2>Steps for creating a custom resource provider</h2>
<ol>
<li>Import a file such as an image or a font into Trilium by drag &amp; drop.</li>
<li>Select the file and go to the <i>Owned Attributes</i> section.</li>
<li>Add the label <code>#customResourceProvider=hello</code>.</li>
<li>To test if it is working, use a browser to navigate to <code>&lt;protocol&gt;://&lt;host&gt;/custom/hello</code> (where <code>&lt;protocol&gt;</code> is
either <code>http</code> or <code>https</code> based on your setup, and <code>&lt;host&gt;</code> is
the host or IP to your Trilium server instance). If you are running the
TriliumNext application without a server, use <code>http://localhost:37840</code> as
the base URL.</li>
<li>If everything went well, at the previous step the browser should have
downloaded the file uploaded in the first step.</li>
</ol>
<p>Instead of <code>hello</code>, the name can be:</p>
<ul>
<li>A path, such as <code>fonts/Roboto.ttf</code>, which would be accessible
via <code>&lt;host&gt;/custom/fonts/Roboto.ttf</code>.</li>
<li>As a more advanced use case, a regular expression to match multiple routes,
such as <code>hello/.*</code> which will be accessible via <code>/custom/hello/1</code>, <code>/custom/hello/2</code>, <code>/custom/hello/world</code>,
etc.</li>
</ul>
<h2>Using it in a theme</h2>
<p>For example, if you have a custom font to be imported by the theme, first
upload a font file into Trilium and assign it the <code>#customResourceProvider=fonts/myfont.ttf</code> attribute.</p>
<p>Then modify the theme CSS to point to:</p><pre><code class="language-text-css">@font-face {
font-family: customFont;
src: url("/custom/fonts/myfont.ttf");
}
div {
font-family: customFont;
}</code></pre>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,34 @@
# Custom Resource Providers
A custom resource provider allows any file imported into Trilium (images, fonts, stylesheets) to be publicly accessible via a URL.
A potential use case for this is to add embed a custom font alongside a theme.
## Steps for creating a custom resource provider
1. Import a file such as an image or a font into Trilium by drag & drop.
2. Select the file and go to the _Owned Attributes_ section.
3. Add the label `#customResourceProvider=hello`.
4. To test if it is working, use a browser to navigate to `<protocol>://<host>/custom/hello` (where `<protocol>` is either `http` or `https` based on your setup, and `<host>` is the host or IP to your Trilium server instance). If you are running the TriliumNext application without a server, use `http://localhost:37840` as the base URL.
5. If everything went well, at the previous step the browser should have downloaded the file uploaded in the first step.
Instead of `hello`, the name can be:
* A path, such as `fonts/Roboto.ttf`, which would be accessible via `<host>/custom/fonts/Roboto.ttf`.
* As a more advanced use case, a regular expression to match multiple routes, such as `hello/.*` which will be accessible via `/custom/hello/1`, `/custom/hello/2`, `/custom/hello/world`, etc.
## Using it in a theme
For example, if you have a custom font to be imported by the theme, first upload a font file into Trilium and assign it the `#customResourceProvider=fonts/myfont.ttf` attribute.
Then modify the theme CSS to point to:
```css
@font-face {
font-family: customFont;
src: url("/custom/fonts/myfont.ttf");
}
div {
font-family: customFont;
}
```

View File

@ -1,74 +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>Database</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Database</h1>
<div class="ck-content">
<p>Your Trilium data is stored in a <a href="https://www.sqlite.org">SQLite</a> database
which contains all notes, tree structure, metadata, and most of the configuration.
The database file is named <code>document.db</code> and is stored in the
application's default&nbsp;<a class="reference-link" href="../Installation%20%26%20Setup/Data%20directory.html">Data directory</a>.</p>
<h2>Demo Notes</h2>
<p>When you run Trilium for the first time, it will generate a new database
containing demo notes. These notes showcase its many features, such as:</p>
<ul>
<li><a href="Relation%20Map.html">Relation Map</a>
</li>
<li><a href="Advanced%20Showcases/Day%20Notes.html">Day Notes</a>
</li>
<li><a href="Advanced%20Showcases/Weight%20Tracker.html">Weight Tracker</a>
</li>
<li><a href="Advanced%20Showcases/Task%20Manager.html">Task Manager</a>
</li>
<li><a href="../Basic%20Concepts/Themes.html">Custom CSS Themes</a>
</li>
</ul>
<h3>Restoring Demo Notes</h3>
<p>There are some cases in which you may want to restore the original demo
notes. For example, if you experimented with some of the more advanced
features and want to see the original reference, or if you simply want
to explore the latest version of the demo notes, which might showcase new
features.</p>
<p>You can easily restore the demo notes by using Trilium's built-in import
feature by importing them:</p>
<ul>
<li>Download <a href="https://github.com/TriliumNext/Notes/raw/develop/db/demo.zip">this .zip archive</a> with
the latest version of the demo notes</li>
<li>Right click on any note in your tree under which you would like the demo
notes to be imported</li>
<li>Click "Import into note"</li>
<li>Select the .zip archive to import it</li>
</ul>
<h2>Manually Modifying the Database</h2>
<p>Trilium provides a lot of flexibility, and with it, opportunities for
advanced users to tweak it. If you need to explore or modify the database
directly, you can use a tool such as <a href="https://sqlitebrowser.org/">SQLite Browser</a> to
work directly on the database file.</p>
<p>See&nbsp;<a class="reference-link" href="Database/Manually%20altering%20the%20database.html">Manually altering the database</a>&nbsp;for
more information.</p>
<h2>How to Reset the Database</h2>
<p>If you are experimenting with Trilium and want to return it to its original
state, you can do that by deleting the current database. When you restart
the application, it will generate a new database containing the original
demo notes.</p>
<p>To delete the database, simply go to the <a href="../Installation%20%26%20Setup/Data%20directory.html">data directory</a> and
delete the <code>document.db</code> file (and any other files starting with <code>document.db</code>).</p>
<p>If you do not need to preserve any configurations that might be stored
in the <code>config.ini</code> file, you can just delete all of the <a href="../Installation%20%26%20Setup/Data%20directory.html">data directory's</a> contents
to fully restore the application to its original state. You can also review
the <a href="Configuration%20(config.ini%20or%20e.html">configuration</a> file
to provide all <code>config.ini</code> values as environment variables instead.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,37 @@
# Database
Your Trilium data is stored in a [SQLite](https://www.sqlite.org) database which contains all notes, tree structure, metadata, and most of the configuration. The database file is named `document.db` and is stored in the application's default [Data directory](../Installation%20%26%20Setup/Data%20directory.md).
## Demo Notes
When you run Trilium for the first time, it will generate a new database containing demo notes. These notes showcase its many features, such as:
* [Relation Map](Relation%20Map.md)
* [Day Notes](Advanced%20Showcases/Day%20Notes.md)
* [Weight Tracker](Advanced%20Showcases/Weight%20Tracker.md)
* [Task Manager](Advanced%20Showcases/Task%20Manager.md)
* [Custom CSS Themes](../Basic%20Concepts/Themes.md)
### Restoring Demo Notes
There are some cases in which you may want to restore the original demo notes. For example, if you experimented with some of the more advanced features and want to see the original reference, or if you simply want to explore the latest version of the demo notes, which might showcase new features.
You can easily restore the demo notes by using Trilium's built-in import feature by importing them:
* Download [this .zip archive](https://github.com/TriliumNext/Notes/raw/develop/db/demo.zip) with the latest version of the demo notes
* Right click on any note in your tree under which you would like the demo notes to be imported
* Click "Import into note"
* Select the .zip archive to import it
## Manually Modifying the Database
Trilium provides a lot of flexibility, and with it, opportunities for advanced users to tweak it. If you need to explore or modify the database directly, you can use a tool such as [SQLite Browser](https://sqlitebrowser.org/) to work directly on the database file.
See [Manually altering the database](Database/Manually%20altering%20the%20database.md) for more information.
## How to Reset the Database
If you are experimenting with Trilium and want to return it to its original state, you can do that by deleting the current database. When you restart the application, it will generate a new database containing the original demo notes.
To delete the database, simply go to the [data directory](../Installation%20%26%20Setup/Data%20directory.md) and delete the `document.db` file (and any other files starting with `document.db`).
If you do not need to preserve any configurations that might be stored in the `config.ini` file, you can just delete all of the [data directory's](../Installation%20%26%20Setup/Data%20directory.md) contents to fully restore the application to its original state. You can also review the [configuration](Configuration%20\(config.ini%20or%20e.md) file to provide all `config.ini` values as environment variables instead.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 668 B

After

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 635 B

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 B

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -1,57 +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>Manually altering the database</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Manually altering the database</h1>
<div class="ck-content">
<p>There are some situations where modifying the SQLite database that Trilium
uses is desirable.</p>
<p>If you are doing any advanced development or troubleshooting where you
manually modify the database, you might want to consider creating backups
of your <code>document.db</code> file.</p>
<h2>Modifying it internally using the SQL Console</h2>
<p>The SQL Console is Trilium's built-in database editor.</p>
<p>See&nbsp;<a class="reference-link" href="Manually%20altering%20the%20database/SQL%20Console.html">SQL Console</a>.</p>
<h2>Externally modifying the database</h2>
<p>Sometimes the SQL Console cannot be used (for example if the application
cannot start).</p>
<p>When making external modifications, consider closing the desktop application.
If modifying the server database, then stop the service or Docker container.</p>
<h3>Using DB Browser for SQLite</h3>
<p>DB Browser for SQLite is a cross-platform editor that can be used to alter
the database using a graphical user interface.</p>
<p>To do so:</p>
<ol>
<li>In the main menu, select File → Open database… and navigate to the database
in the&nbsp;<a class="reference-link" href="../../Installation%20%26%20Setup/Data%20directory.html">Data directory</a>.</li>
<li>Select the <i>Execute SQL</i> tab.</li>
<li>Type in the desired SQL statement.</li>
<li>Press the "Play" button in the toolbar underneath the "Execute SQL" tab
(or F5 key).</li>
<li>Press "Write Changes" in the main toolbar.</li>
<li>Close the application or close the database.</li>
</ol>
<figure class="image">
<img style="aspect-ratio:1186/1130;" src="Manually altering the data.png"
width="1186" height="1130">
</figure>
<h3>Using the SQLite CLI</h3>
<p>First, start the SQLite 3 CLI by specifying the path to the database:</p><pre><code class="language-text-x-sh">sqlite3 ~/.local/share/trilium-data/document.db</code></pre>
<ul>
<li>In the prompt simply type the statement and make sure it ends with a <code>;</code> character.</li>
<li>To exit, simply type <code>.quit</code> and enter.</li>
</ul>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,42 @@
# Manually altering the database
There are some situations where modifying the SQLite database that Trilium uses is desirable.
If you are doing any advanced development or troubleshooting where you manually modify the database, you might want to consider creating backups of your `document.db` file.
## Modifying it internally using the SQL Console
The SQL Console is Trilium's built-in database editor.
See [SQL Console](Manually%20altering%20the%20database/SQL%20Console.md).
## Externally modifying the database
Sometimes the SQL Console cannot be used (for example if the application cannot start).
When making external modifications, consider closing the desktop application. If modifying the server database, then stop the service or Docker container.
### Using DB Browser for SQLite
DB Browser for SQLite is a cross-platform editor that can be used to alter the database using a graphical user interface.
To do so:
1. In the main menu, select File → Open database… and navigate to the database in the [Data directory](../../Installation%20%26%20Setup/Data%20directory.md).
2. Select the _Execute SQL_ tab.
3. Type in the desired SQL statement.
4. Press the "Play" button in the toolbar underneath the "Execute SQL" tab (or F5 key).
5. Press "Write Changes" in the main toolbar.
6. Close the application or close the database.
![](6_Manually altering the data.png)
### Using the SQLite CLI
First, start the SQLite 3 CLI by specifying the path to the database:
```sh
sqlite3 ~/.local/share/trilium-data/document.db
```
* In the prompt simply type the statement and make sure it ends with a `;` character.
* To exit, simply type `.quit` and enter.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 B

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -1,54 +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>SQL Console</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>SQL Console</h1>
<div class="ck-content">
<p>The SQL Console is Trilium's built-in database editor.</p>
<p>It can be accessed by going to the <a href="../../../Basic%20Concepts/UI%20Elements">global menu</a>
Advanced → Open SQL Console.</p>
<figure class="image">
<img style="aspect-ratio:1301/287;" src="SQL Console_image.png" width="1301"
height="287">
</figure>
<h3>Interaction</h3>
<ul>
<li>Hovering the mouse over one of the tables listed at the top of the document
will show the columns and their data type.</li>
<li>Only one SQL statement can be run at once.</li>
<li>To run the statement, press the
<img src="2_SQL Console_image.png" width="17"
height="18">icon.</li>
<li>
<p>For queries that return a result, the data will displayed in a table.</p>
<p>
<img src="1_SQL Console_image.png" width="968" height="272">
</p>
</li>
</ul>
<h3>Saved SQL console</h3>
<p>SQL queries or commands can be saved into a dedicated note.</p>
<p>To do so, simply write the query and press the
<img src="3_SQL Console_image.png"
width="19" height="19">button. Once saved, the note will appear in&nbsp;<a class="reference-link"
href="../../Advanced%20Showcases/Day%20Notes.html">Day Notes</a>.</p>
<ul>
<li>The SQL expression will not be displayed by default, but it can still
be viewed by going to the note context menu and selecting <i>Note source</i>.</li>
<li>The expression cannot be modified. If needed, recreate it by copying the
statement back into the SQL console and then saving it again.</li>
</ul>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,25 @@
# SQL Console
The SQL Console is Trilium's built-in database editor.
It can be accessed by going to the [global menu](../../../Basic%20Concepts/UI%20Elements) → Advanced → Open SQL Console.
![](3_SQL Console_image.png)
### Interaction
* Hovering the mouse over one of the tables listed at the top of the document will show the columns and their data type.
* Only one SQL statement can be run at once.
* To run the statement, press the ![](1_SQL Console_image.png)icon.
* For queries that return a result, the data will displayed in a table.
![](SQL Console_image.png)
### Saved SQL console
SQL queries or commands can be saved into a dedicated note.
To do so, simply write the query and press the ![](2_SQL Console_image.png)button. Once saved, the note will appear in [Day Notes](../../Advanced%20Showcases/Day%20Notes.md).
* The SQL expression will not be displayed by default, but it can still be viewed by going to the note context menu and selecting _Note source_.
* The expression cannot be modified. If needed, recreate it by copying the statement back into the SQL console and then saving it again.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 30 KiB

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>Default Note Title</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Default Note Title</h1>
<div class="ck-content">
<p>When a new note is created, its name is by default "new note". In some
cases, it can be desirable to have a different or even a dynamic default
note title.</p>
<p>For this use case, Trilium (since v0.52) supports <code>#titleTemplate</code>
<a
href="Attributes.html">label</a>. You can create such a label for a given note, assign it a value,
and this value will be used as a default title when creating child notes.
As with other labels, you can make it inheritable to apply recursively,
and you can even place it on the root note to have it applied globally
everywhere.</p>
<p>As an example use case, imagine you collect books you've read in a given
year like this:</p>
<ul>
<li>2022 Books
<ul>
<li>Neal Stephenson: Anathem, 2008</li>
<li>Franz Kafka: Die Verwandlung, 1915</li>
</ul>
</li>
</ul>
<p>Now, to the parent note "2022 Books" you can assign label <code>#titleTemplate="[Author name]: [Book title], [Publication year]"</code>.</p>
<p>And all children of "2022 Books" will be created with initial title "[Author
name]: [Book title], [Publication year]". There's no artificial intelligence
here, the idea is to just prompt you to manually fill in the pieces of
information into the note title by yourself.</p>
<h2>Dynamic value</h2>
<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>
<ul>
<li>Incidents
<ul>
<li>2022-05-09: System crash</li>
<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
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="Attributes/Template.html">template</a>]] which provides
similar capabilities, including default note's content.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,30 @@
# Default Note Title
When a new note is created, its name is by default "new note". In some cases, it can be desirable to have a different or even a dynamic default note title.
For this use case, Trilium (since v0.52) supports `#titleTemplate` [label](Attributes.md). You can create such a label for a given note, assign it a value, and this value will be used as a default title when creating child notes. As with other labels, you can make it inheritable to apply recursively, and you can even place it on the root note to have it applied globally everywhere.
As an example use case, imagine you collect books you've read in a given year like this:
* 2022 Books
* Neal Stephenson: Anathem, 2008
* Franz Kafka: Die Verwandlung, 1915
Now, to the parent note "2022 Books" you can assign label `#titleTemplate="[Author name]: [Book title], [Publication year]"`.
And all children of "2022 Books" will be created with initial title "\[Author name\]: \[Book title\], \[Publication year\]". There's no artificial intelligence here, the idea is to just prompt you to manually fill in the pieces of information into the note title by yourself.
## Dynamic value
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:
* 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](Attributes/Template.md)\]\] which provides similar capabilities, including default note's content.

View File

@ -1,40 +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>ETAPI (REST API)</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>ETAPI (REST API)</h1>
<div class="ck-content">
<p>ETAPI is Trilium's public/external REST API. It is available since Trilium
v0.50.</p>
<p>The documentation is in OpenAPI format, available <a href="https://github.com/TriliumNext/Notes/blob/master/src/etapi/etapi.openapi.yaml">here</a>.</p>
<p><a href="https://github.com/Nriver/trilium-py">trilium-py</a> is a third-party
Python implementation for ETAPI client, you can use Python to communicate
with Trilium.</p>
<h2>Authentication</h2>
<p>All operations have to be authenticated using a token. You can get this
token either from Options -&gt; ETAPI or programmatically using the <code>/auth/login</code> REST
call (see the <a href="https://github.com/TriliumNext/Notes/blob/master/src/etapi/etapi.openapi.yaml">spec</a>):</p><pre><code class="language-text-x-trilium-auto">GET https://myserver.com/etapi/app-info
Authorization: ETAPITOKEN</code></pre>
<p>Alternatively, since 0.56 you can also use basic auth format:</p><pre><code class="language-text-x-trilium-auto">GET https://myserver.com/etapi/app-info
Authorization: Basic BATOKEN</code></pre>
<ul>
<li>Where <code>BATOKEN = BASE64(username + ':' + password)</code> - this is
a standard Basic Auth serialization</li>
<li>Where <code>username</code> is "etapi"</li>
<li>And <code>password</code> is the generated ETAPI token described above.</li>
</ul>
<p>Basic Auth is meant to be used with tools which support only basic auth.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,28 @@
# ETAPI (REST API)
ETAPI is Trilium's public/external REST API. It is available since Trilium v0.50.
The documentation is in OpenAPI format, available [here](https://github.com/TriliumNext/Notes/blob/master/src/etapi/etapi.openapi.yaml).
[trilium-py](https://github.com/Nriver/trilium-py) is a third-party Python implementation for ETAPI client, you can use Python to communicate with Trilium.
## Authentication
All operations have to be authenticated using a token. You can get this token either from Options -> ETAPI or programmatically using the `/auth/login` REST call (see the [spec](https://github.com/TriliumNext/Notes/blob/master/src/etapi/etapi.openapi.yaml)):
```
GET https://myserver.com/etapi/app-info
Authorization: ETAPITOKEN
```
Alternatively, since 0.56 you can also use basic auth format:
```
GET https://myserver.com/etapi/app-info
Authorization: Basic BATOKEN
```
* Where `BATOKEN = BASE64(username + ':' + password)` - this is a standard Basic Auth serialization
* Where `username` is "etapi"
* And `password` is the generated ETAPI token described above.
Basic Auth is meant to be used with tools which support only basic auth.

View File

@ -1,44 +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>Note Map</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Note Map</h1>
<div class="ck-content">
<p>Note map is a visualisation of connections between notes.</p>
<p>This provides an insight into a structure ("web") of notes.</p>
<p>There are two types of note map:</p>
<h2>Link Map</h2>
<p>Shows <a href="Attributes.html">relations</a> between notes:</p>
<figure
class="image">
<img style="aspect-ratio:1059/757;" src="1_Note Map_image.png" width="1059"
height="757">
</figure>
<h2>Tree Map</h2>
<p>Shows hierarchical map of notes:</p>
<figure class="image">
<img style="aspect-ratio:1068/814;" src="Note Map_image.png" width="1068"
height="814">
</figure>
<h2>See also</h2>
<p><a href="Relation%20Map.html">Relation map</a> is a similar concept, with
some differences:</p>
<ul>
<li>note map is automatically generated while relation map must be created
manually</li>
<li>relation map is a type of note while a link map is just virtual visualization</li>
</ul>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,25 @@
# Note Map
Note map is a visualisation of connections between notes.
This provides an insight into a structure ("web") of notes.
There are two types of note map:
## Link Map
Shows [relations](Attributes.md) between notes:
![](Note Map_image.png)
## Tree Map
Shows hierarchical map of notes:
![](1_Note Map_image.png)
## See also
[Relation map](Relation%20Map.md) is a similar concept, with some differences:
* note map is automatically generated while relation map must be created manually
* relation map is a type of note while a link map is just virtual visualization

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -1,95 +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>Relation Map</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Relation Map</h1>
<div class="ck-content">
<p>Relation map is a type of <a href="../Basic%20Concepts/Navigation/Tree%20Concepts.html">note</a> which
visualizes notes and their <a href="Attributes.html">relations</a>. See
an example:</p>
<h2>Development process demo</h2>
<p>This is a basic example how you can create simple diagram using relation
maps:</p>
<p>
<img src="../Attachments/relation-map-dev-process.png" alt="">
</p>
<p>And this is how you can create it:</p>
<p>
<img src="api/images/SC6fYfv2NV3q/relation-map-dev-process-demo." alt="">
</p>
<p>We start completely from scratch by first creating new note called "Development
process" and changing its type to "Relation map". After that we create
new notes one by one and place them by clicking into the map. We also drag
<a
href="Attributes.html">relations</a>between notes and name them. That's all!</p>
<p>Items on the map - "Specification", "Development", "Testing" and "Demo"
are actually notes which have been created under "Development process"
note - you can click on them and write some content. Connections between
notes are called "<a href="Attributes.html">relations</a>".</p>
<h2>Family demo</h2>
<p>This is more complicated demo using some advanced concepts. Resulting
diagram is here:</p>
<p>
<img src="../Attachments/relation-map-family.png" alt="">
</p>
<p>This is how you get to it:</p>
<p>
<img src="../Attachments/relation-map-family-demo.gif" alt="">
</p>
<p>There are several steps here:</p>
<ul>
<li>we start with empty relation map and two existing notes representing Prince
Philip and Queen Elizabeth II. These two notes already have "isPartnerOf"
<a
href="Attributes.html">relations</a>defined.
<ul>
<li>There are actually two "inverse" relations (one from Philip to Elizabeth
and one from Elizabeth to Philip)</li>
</ul>
</li>
<li>we drag both notes to relation map and place to suitable position. Notice
how the existing "isPartnerOf" relations are displayed.</li>
<li>now we create new note - we name it "Prince Charles" and place it on the
relation map by clicking on the desired position. The note is by default
created under the relation map note (visible in the note tree on the left).</li>
<li>we create two new relations "isChildOf" targeting both Philip and Elizabeth
<ul>
<li>now there's something unexpected - we can also see the relation to display
another "hasChild" relation. This is because there's a <a href="Attributes/Promoted%20Attributes.html">relation definition</a> which
puts "isChildOf" as an "<a href="Attributes/Promoted%20Attributes.html">inverse</a>"
relation of "hasChildOf" (and vice versa) and thus it is created automatically.</li>
</ul>
</li>
<li>we create another note for Princess Diana and create "isPartnerOf" relation
from Charles. Again notice how the relation has arrows both ways - this
is because "isPartnerOf" definition specifies its inverse relation as again
"isPartnerOf" so the opposite relation is created automatically.</li>
<li>as the last step we pan &amp; zoom the map to fit better to window dimensions.</li>
</ul>
<p>Relation definitions mentioned above come from "Person template" note
which is assigned to any child of "My Family Tree" relation note. You can
play with the whole thing in the <a href="Database.html">demo notes</a>.</p>
<h2>Details</h2>
<p>You can specify which relations should be displayed with comma delimited
names of relations in <code>displayRelations</code> label.</p>
<p>Alternatively, you can specify comma delimited list of relation names
in <code>hideRelations</code> which will display all relations, except for
the ones defined in the label.</p>
<h2>See also</h2>
<ul>
<li><a href="Note%20Map.html">Note map</a> is a similar concept</li>
</ul>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,49 @@
# Relation Map
Relation map is a type of [note](../Basic%20Concepts/Navigation/Tree%20Concepts.md) which visualizes notes and their [relations](Attributes.md). See an example:
## Development process demo
This is a basic example how you can create simple diagram using relation maps:
![](../Attachments/relation-map-dev-process.png)
And this is how you can create it:
![](api/images/PDGOsZt0D5iu/relation-map-dev-process-demo.)
We start completely from scratch by first creating new note called "Development process" and changing its type to "Relation map". After that we create new notes one by one and place them by clicking into the map. We also drag [relations](Attributes.md)between notes and name them. That's all!
Items on the map - "Specification", "Development", "Testing" and "Demo" are actually notes which have been created under "Development process" note - you can click on them and write some content. Connections between notes are called "[relations](Attributes.md)".
## Family demo
This is more complicated demo using some advanced concepts. Resulting diagram is here:
![](../Attachments/relation-map-family.png)
This is how you get to it:
![](../Attachments/relation-map-family-demo.gif)
There are several steps here:
* we start with empty relation map and two existing notes representing Prince Philip and Queen Elizabeth II. These two notes already have "isPartnerOf" [relations](Attributes.md)defined.
* There are actually two "inverse" relations (one from Philip to Elizabeth and one from Elizabeth to Philip)
* we drag both notes to relation map and place to suitable position. Notice how the existing "isPartnerOf" relations are displayed.
* now we create new note - we name it "Prince Charles" and place it on the relation map by clicking on the desired position. The note is by default created under the relation map note (visible in the note tree on the left).
* we create two new relations "isChildOf" targeting both Philip and Elizabeth
* now there's something unexpected - we can also see the relation to display another "hasChild" relation. This is because there's a [relation definition](Attributes/Promoted%20Attributes.md) which puts "isChildOf" as an "[inverse](Attributes/Promoted%20Attributes.md)" relation of "hasChildOf" (and vice versa) and thus it is created automatically.
* we create another note for Princess Diana and create "isPartnerOf" relation from Charles. Again notice how the relation has arrows both ways - this is because "isPartnerOf" definition specifies its inverse relation as again "isPartnerOf" so the opposite relation is created automatically.
* as the last step we pan & zoom the map to fit better to window dimensions.
Relation definitions mentioned above come from "Person template" note which is assigned to any child of "My Family Tree" relation note. You can play with the whole thing in the [demo notes](Database.md).
## Details
You can specify which relations should be displayed with comma delimited names of relations in `displayRelations` label.
Alternatively, you can specify comma delimited list of relation names in `hideRelations` which will display all relations, except for the ones defined in the label.
## See also
* [Note map](Note%20Map.md) is a similar concept

View File

@ -1,142 +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>Sharing</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Sharing</h1>
<div class="ck-content">
<p>Trilium allows you to share selected notes as <strong>publicly accessible</strong> read-only
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
Trilium. This is necessary because the notes will be hosted from the server.</p>
<h2>How to Share a Note</h2>
<ol>
<li>
<p><strong>Enable Sharing</strong>: To share a note, toggle the <code>Shared</code> switch
within the note's interface. Once sharing is enabled, an URL will appear,
which you can click to access the shared note.</p>
<p>
<img src="../Attachments/share-single-note.png" alt="Share Note">
</p>
</li>
<li>
<p><strong>Access the Shared Note</strong>: The link provided will open the
note in your browser. If your server is not configured with a public IP,
the URL will refer to <code>localhost (127.0.0.1)</code>.</p>
<p>
<img src="../Attachments/share-single-note-web.png" alt="Shared Note Example">
</p>
</li>
</ol>
<h2>Sharing a Note Subtree</h2>
<p>When you share a note, you actually share the entire subtree of notes
beneath it. If the note has child notes, they will also be included in
the shared content. For example, sharing the "Formatting" subtree will
display a page with basic navigation for exploring all the notes within
that subtree.</p>
<p>
<img src="../Attachments/share-multiple-notes-web.png" alt="Shared Subtree Example">
</p>
<h2>Viewing All Shared Notes</h2>
<p>You can view a list of all shared notes by clicking on "Show Shared Notes
Subtree." This allows you to manage and navigate through all the notes
you have made public.</p>
<h2>Security Considerations</h2>
<p>Shared notes are published on the open internet and can be accessed by
anyone with the URL. The URL's randomness does not provide security, so
it is crucial not to share sensitive information through this feature.</p>
<h3>Password Protection</h3>
<p>To protect shared notes with a username and password, you can use the <code>#shareCredentials</code> attribute.
Add this label to the note with the format <code>#shareCredentials="username:password"</code>.
To protect an entire subtree, make sure the label is <a href="Attributes/Attribute%20Inheritance.html">inheritable</a>.</p>
<h2>Advanced Sharing Options</h2>
<h3>Customizing the Appearance of Shared Notes</h3>
<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="Code%20Notes.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>Omitting Default CSS</strong>: For extensive styling changes,
use the <code>#shareOmitDefaultCss</code> label to avoid conflicts with Trilium's
<a
href="../Basic%20Concepts/Themes.html">default stylesheet</a>.</li>
</ul>
<h3>Adding JavaScript</h3>
<p>You can inject custom JavaScript into the shared note using the <code>~shareJs</code> relation.
This allows you to access note attributes or traverse the note tree using
the <code>fetchNote()</code> API, which retrieves note data based on its
ID.</p>
<p>Example:</p><pre><code class="language-application-javascript-env-backend">const currentNote = await fetchNote();
const parentNote = await fetchNote(currentNote.parentNoteIds[0]);
for (const attr of parentNote.attributes) {
console.log(attr.type, attr.name, attr.value);
}</code></pre>
<h3>Creating Human-Readable URL Aliases</h3>
<p>Shared notes typically have URLs like <code>http://domain.tld/share/knvU8aJy4dJ7</code>,
where the last part is the note's ID. You can make these URLs more user-friendly
by adding the <code>#shareAlias</code> label to individual notes (e.g., <code>#shareAlias=highlighting</code>).
This will change the URL to <code>http://domain.tld/share/highlighting</code>.</p>
<p><strong>Important</strong>:</p>
<ol>
<li>Ensure that aliases are unique.</li>
<li>Using slashes (<code>/</code>) within aliases to create subpaths is not
supported.</li>
</ol>
<h3>Viewing and Managing Shared Notes</h3>
<p>All shared notes are grouped under an automatically managed "Shared Notes"
section. From here, you can view, share, or unshare notes by moving or
cloning them within this section.</p>
<p>
<img src="../Attachments/shared-list.png" alt="Shared Notes List">
</p>
<h3>Setting a Custom Favicon</h3>
<p>To customize the favicon for your shared pages, create a relation <code>~shareFavicon</code> pointing
to a file note containing the favicon (e.g., in <code>.ico</code> format).</p>
<h3>Sharing a Note as the Root</h3>
<p>You can designate a specific note or folder as the root of your shared
content by adding the <code>#shareRoot</code> label. This note will be linked
when visiting <code>[http://domain.tld/share](http://domain/share)</code>,
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>
<li><strong>No Relation Map Support</strong>
</li>
<li><strong>Book Notes</strong>: Only show a list of child notes.</li>
<li><strong>Code Notes</strong>: No syntax highlighting.</li>
<li><strong>Static Note Tree</strong>
</li>
<li><strong>Protected Notes</strong>: Cannot be shared.</li>
<li><strong>Include Notes</strong>: Not supported.</li>
</ul>
<p>Some of these limitations may be addressed in future updates.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,101 @@
# Sharing
Trilium allows you to share selected notes as **publicly accessible** read-only documents. This feature is particularly useful for publishing content directly from your Trilium notes, making it accessible to others online.
## 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.
## How to Share a Note
1. **Enable Sharing**: To share a note, toggle the `Shared` switch within the note's interface. Once sharing is enabled, an URL will appear, which you can click to access the shared note.
![Share Note](../Attachments/share-single-note.png)
2. **Access the Shared Note**: The link provided will open the note in your browser. If your server is not configured with a public IP, the URL will refer to `localhost (127.0.0.1)`.
![Shared Note Example](../Attachments/share-single-note-web.png)
## Sharing a Note Subtree
When you share a note, you actually share the entire subtree of notes beneath it. If the note has child notes, they will also be included in the shared content. For example, sharing the "Formatting" subtree will display a page with basic navigation for exploring all the notes within that subtree.
![Shared Subtree Example](../Attachments/share-multiple-notes-web.png)
## Viewing All Shared Notes
You can view a list of all shared notes by clicking on "Show Shared Notes Subtree." This allows you to manage and navigate through all the notes you have made public.
## Security Considerations
Shared notes are published on the open internet and can be accessed by anyone with the URL. The URL's randomness does not provide security, so it is crucial not to share sensitive information through this feature.
### Password Protection
To protect shared notes with a username and password, you can use the `#shareCredentials` attribute. Add this label to the note with the format `#shareCredentials="username:password"`. To protect an entire subtree, make sure the label is [inheritable](Attributes/Attribute%20Inheritance.md).
## Advanced Sharing Options
### Customizing the Appearance of Shared Notes
The default shared page is basic in design, but you can customize it using your own CSS:
* **Custom CSS**: Link a CSS [code note](Code%20Notes.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.
* **Omitting Default CSS**: For extensive styling changes, use the `#shareOmitDefaultCss` label to avoid conflicts with Trilium's [default stylesheet](../Basic%20Concepts/Themes.md).
### Adding JavaScript
You can inject custom JavaScript into the shared note using the `~shareJs` relation. This allows you to access note attributes or traverse the note tree using the `fetchNote()` API, which retrieves note data based on its ID.
Example:
```javascript
const currentNote = await fetchNote();
const parentNote = await fetchNote(currentNote.parentNoteIds[0]);
for (const attr of parentNote.attributes) {
console.log(attr.type, attr.name, attr.value);
}
```
### Creating Human-Readable URL Aliases
Shared notes typically have URLs like `http://domain.tld/share/knvU8aJy4dJ7`, where the last part is the note's ID. You can make these URLs more user-friendly by adding the `#shareAlias` label to individual notes (e.g., `#shareAlias=highlighting`). This will change the URL to `http://domain.tld/share/highlighting`.
**Important**:
1. Ensure that aliases are unique.
2. Using slashes (`/`) within aliases to create subpaths is not supported.
### Viewing and Managing Shared Notes
All shared notes are grouped under an automatically managed "Shared Notes" section. From here, you can view, share, or unshare notes by moving or cloning them within this section.
![Shared Notes List](../Attachments/shared-list.png)
### Setting a Custom Favicon
To customize the favicon for your shared pages, create a relation `~shareFavicon` pointing to a file note containing the favicon (e.g., in `.ico` format).
### Sharing a Note as the Root
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:
* **No Relation Map Support**
* **Book Notes**: Only show a list of child notes.
* **Code Notes**: No syntax highlighting.
* **Static Note Tree**
* **Protected Notes**: Cannot be shared.
* **Include Notes**: Not supported.
Some of these limitations may be addressed in future updates.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

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>Serving directly the content of a note</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Serving directly the content of a note</h1>
<div class="ck-content">
<div class="content">
<div class="ck-content">
<p>When accessing a shared note, Trilium will render it as a web page. Sometimes
it's desirable to serve the content directly so that it can be used in
a script or downloaded by the user.</p>
<figure class="table" style="width:100%;">
<table class="ck-table-resized">
<colgroup>
<col style="width:48.52%;">
<col style="width:51.48%;">
</colgroup>
<tbody>
<tr>
<td>
<figure class="image">
<img style="aspect-ratio:378/231;" src="Serving directly the conte.png"
width="378" height="231">
<figcaption>A note displayed as a web page (HTML)</figcaption>
</figure>
</td>
<td style="vertical-align:top;">
<figure class="image">
<img style="aspect-ratio:402/129;" src="1_Serving directly the conte.png"
width="402" height="129">
<figcaption>A note displayed as a raw format</figcaption>
</figure>
</td>
</tr>
</tbody>
</table>
</figure>
<h2>By adding an attribute to the note</h2>
<p>Simply add the <code>#shareRaw</code> attribute and the note will always
be rendered <i>raw</i> when accessed from the share URL.</p>
<h2>By altering the URL</h2>
<p>Append <code>?raw</code> to the URL to display a note in its raw format
regardless of whether the <code>#shareRaw</code> attribute is added on the
note.</p>
<p>
<img src="1_Serving directly the conte.png" width="402" height="129">
</p>
<p>&nbsp;</p>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,16 @@
# Serving directly the content of a note
When accessing a shared note, Trilium will render it as a web page. Sometimes it's desirable to serve the content directly so that it can be used in a script or downloaded by the user.
| | |
| --- | --- |
| ![](1_Serving directly the conte.png)<br><br>A note displayed as a web page (HTML) | ![](Serving directly the conte.png)<br><br>A note displayed as a raw format |
## By adding an attribute to the note
Simply add the `#shareRaw` attribute and the note will always be rendered _raw_ when accessed from the share URL.
## By altering the URL
Append `?raw` to the URL to display a note in its raw format regardless of whether the `#shareRaw` attribute is added on the note.
![](Serving directly the conte.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -1,37 +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>Evernote</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Evernote</h1>
<div class="ck-content">
<p>Trilium can import ENEX files which are used by Evernote for backup/export.
One ENEX file represents content (notes and resources) of one notebook.</p>
<h2>Export ENEX from Evernote</h2>
<p>To export ENEX file, you need to have a <i>legacy</i> desktop version of
Evernote (i.e. not web/mobile). Right click on notebook and select export
and follow the wizard.</p>
<h2>Import ENEX in Trilium</h2>
<p>Once you have ENEX file, you can import it to Trilium. Right click on
some note (to which you want to import the file), click on "Import" and
select the ENEX file.</p>
<p>After importing the ENEX file, go over the imported notes and resources
to be sure the import went well, and you didn't lose any data.</p>
<h2>Limitations</h2>
<p>All resources (except for images) are created as note's attachments.</p>
<p>HTML inside ENEX files is not exactly valid so some formatting maybe broken
or lost. You can report major problems into <a href="https://github.com/TriliumNext/Notes/issues">Trilium issue tracker</a>.
%%{WARNING}%%</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,18 @@
# Evernote
Trilium can import ENEX files which are used by Evernote for backup/export. One ENEX file represents content (notes and resources) of one notebook.
## Export ENEX from Evernote
To export ENEX file, you need to have a _legacy_ desktop version of Evernote (i.e. not web/mobile). Right click on notebook and select export and follow the wizard.
## Import ENEX in Trilium
Once you have ENEX file, you can import it to Trilium. Right click on some note (to which you want to import the file), click on "Import" and select the ENEX file.
After importing the ENEX file, go over the imported notes and resources to be sure the import went well, and you didn't lose any data.
## Limitations
All resources (except for images) are created as note's attachments.
HTML inside ENEX files is not exactly valid so some formatting maybe broken or lost. You can report major problems into [Trilium issue tracker](https://github.com/TriliumNext/Notes/issues). %%{WARNING}%%

View File

@ -1,64 +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>Markdown</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Markdown</h1>
<div class="ck-content">
<p>Trilium Notes supports importing Markdown restricted to the <a href="https://spec.commonmark.org/current/">CommonMark specification</a> (where
<a
href="https://github.com/TriliumNext/Notes/issues/2026">tables are not supported</a>)</p>
<h2>Import</h2>
<h3>Clipboard import</h3>
<p>If you want to import just a chunk of markdown from clipboard, you can
do it from editor block menu:</p>
<p>
<img src="../../Attachments/markdown-inline-import.gif" alt="">
</p>
<h3>File import</h3>
<p>You can also import Markdown files from files:</p>
<ul>
<li>single markdown file (with .md extension)</li>
<li>whole tree of markdown files (packaged into <a href="https://en.wikipedia.org/wiki/Tar_(computing)">.zip</a> archive)
<ul>
<li>Markdown files need to be packaged into ZIP archive because browser can't
read directories, only single files.</li>
<li>You can use e.g. <a href="https://www.7-zip.org">7-zip</a> to package directory
of markdown files into the ZIP file</li>
</ul>
</li>
</ul>
<p>[[gifs/markdown-file-import.gif]]</p>
<p>
<img src="../../Attachments/markdown-file-import.gif" alt="">
</p>
<h2>Export</h2>
<h3>Subtree export</h3>
<p>You can export whole subtree to ZIP archive which will have directory
structured modelled after subtree structure:</p>
<p>
<img src="../../Attachments/markdown-export-subtree.gif" alt="">
</p>
<h3>Single note export</h3>
<p>If you want to export just single note without its subtree, you can do
it from Note actions menu:</p>
<p>
<img src="../../Attachments/markdown-export-note.gif" alt="">
</p>
<h3>Exporting protected notes</h3>
<p>If you want to export protected notes, enter a protected session first!
This will export the notes in an unencrypted form, so if you reimport into
Trilium, make sure to re-protect these notes.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,41 @@
# Markdown
Trilium Notes supports importing Markdown restricted to the [CommonMark specification](https://spec.commonmark.org/current/) (where [tables are not supported](https://github.com/TriliumNext/Notes/issues/2026))
## Import
### Clipboard import
If you want to import just a chunk of markdown from clipboard, you can do it from editor block menu:
![](../../Attachments/markdown-inline-import.gif)
### File import
You can also import Markdown files from files:
* single markdown file (with .md extension)
* whole tree of markdown files (packaged into [.zip](https://en.wikipedia.org/wiki/Tar_\(computing\)) archive)
* Markdown files need to be packaged into ZIP archive because browser can't read directories, only single files.
* You can use e.g. [7-zip](https://www.7-zip.org) to package directory of markdown files into the ZIP file
\[\[gifs/markdown-file-import.gif\]\]
![](../../Attachments/markdown-file-import.gif)
## Export
### Subtree export
You can export whole subtree to ZIP archive which will have directory structured modelled after subtree structure:
![](../../Attachments/markdown-export-subtree.gif)
### Single note export
If you want to export just single note without its subtree, you can do it from Note actions menu:
![](../../Attachments/markdown-export-note.gif)
### Exporting protected notes
If you want to export protected notes, enter a protected session first! This will export the notes in an unencrypted form, so if you reimport into Trilium, make sure to re-protect these notes.

View File

@ -1,99 +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>OneNote</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>OneNote</h1>
<div class="ck-content">
<p><strong>This page describes a method to migrate via EverNote Legacy, but this app is no longer available/working.</strong>
</p>
<h2>Prep Onenote notes for best compatibility</h2>
<ul>
<li>Remove Onenote Tags and replace with Emoji if possible (Onenote Tags will
get imported into trilium as an image which clutters the Trilium tree somewhat)</li>
<li>Make sure to use Onenote headings where applicable (These will be carried
over correctly into Trilium)</li>
<li>Remove extra whitespace in Onenote (Whitespace seems to be more noticible
in Trilium, so removing it now will make it look nicer in trilium)</li>
<li>If possible, try to avoid very long Onenote pages. Trilium works best
with shorter concise pages with any number of sub or (sub-sub...) pages.</li>
<li>Make sure numbered lists don't have unusual spaces between items in the
list (Sometimes the numbered list will start at 1 again in Trilum if there
is an extra space in the list in OneNote).</li>
</ul>
<h2>Migration Procedure</h2>
<h3>Import into Evernote from OneNote:</h3>
<ul>
<li>Install <a href="https://web.archive.org/web/20230327110646/https://help.evernote.com/hc/en-us/articles/360052560314">Evernote Legacy</a>.
Current versions of Evernote do not have this functionality. (Requires
Evernote account, but import works without internet connection - be sure
to NOT sync notes to Evernote!).</li>
<li>In evernote navigate to File &gt; Import &gt; Onenote &gt; Notebook &gt;
Section &gt; OK</li>
</ul>
<p>If exporting all sections at a time, they will not be grouped in folders
- they will all be added to a single folder, but the order will be kept,
so you can re-group into folders after importing to Trilium</p>
<h3>Export from Evernote</h3>
<ul>
<li>Right click on the created notebook in Evernote and choose "Export Notes…"</li>
<li>Use the default export format of .enex</li>
</ul>
<h3>Cleanup enex file (optional)</h3>
<ul>
<li>
<p>If the Onenote header (that is at the top of each Onenote page) is not
desired, you can use the following regex to remove them in a text editor
like VsCode:</p>
<p>Find (using regex): <code>.&lt;div.*&gt;&lt;h1</code> Replace with: <code>&lt;h1</code>
</p>
</li>
</ul>
<h3>Import into Trilium</h3>
<ul>
<li>In Trilium, right click on the root node and choose Import (all default
options should be fine).</li>
<li>Select the .enex file exported from Evernote</li>
<li>Be patient. Large .enex files may take a few minutes to process</li>
<li>Repeat import for each .enex file</li>
</ul>
<h2>Other importing notes:</h2>
<ul>
<li>Centered text in Onenote will be left-justified after importing into Trilium</li>
<li>Internal onenote links will obviously be broken, but the link still exists
so you can do a search in Trilium to find all onenote:// links and then
re-link to the proper Trilium page (there is no way to link to a paragraph
in trilium, so it's good to keep trilium pages short so links point to
a small chunk of information instead of a massive note)</li>
<li>Text colors, highlights, and formatting generally carries over well</li>
<li>Revision history will be lost, but any new revisions will be tracked in
Trilium</li>
<li>The structure of notes are not maintained exactly, so if you had sub-notes
in Onenote, you may have to re-arrange the notes accordingly (This is easy
since the order of the notes is preserved).</li>
<li>Evernote tags are created for each "section" in OneNote and these tags
are carried over to Trilium as attributes
<ul>
<li>If the tags are not desired, you can turn them off in the Evernote export
options.</li>
</ul>
</li>
<li>If the "Created with OneNote" text is not desired, do a find/replace in
the enex files before importing to Trilium</li>
<li>Some links will be disabled (not clickable) when importing from enex.</li>
<li>Files, screenshots, and attachments are all preserved (This is the only
one-note export option that seems to preserve all of these).</li>
</ul>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,51 @@
# OneNote
**This page describes a method to migrate via EverNote Legacy, but this app is no longer available/working.**
## Prep Onenote notes for best compatibility
* Remove Onenote Tags and replace with Emoji if possible (Onenote Tags will get imported into trilium as an image which clutters the Trilium tree somewhat)
* Make sure to use Onenote headings where applicable (These will be carried over correctly into Trilium)
* Remove extra whitespace in Onenote (Whitespace seems to be more noticible in Trilium, so removing it now will make it look nicer in trilium)
* If possible, try to avoid very long Onenote pages. Trilium works best with shorter concise pages with any number of sub or (sub-sub...) pages.
* Make sure numbered lists don't have unusual spaces between items in the list (Sometimes the numbered list will start at 1 again in Trilum if there is an extra space in the list in OneNote).
## Migration Procedure
### Import into Evernote from OneNote:
* Install [Evernote Legacy](https://web.archive.org/web/20230327110646/https://help.evernote.com/hc/en-us/articles/360052560314). Current versions of Evernote do not have this functionality. (Requires Evernote account, but import works without internet connection - be sure to NOT sync notes to Evernote!).
* In evernote navigate to File > Import > Onenote > Notebook > Section > OK
If exporting all sections at a time, they will not be grouped in folders - they will all be added to a single folder, but the order will be kept, so you can re-group into folders after importing to Trilium
### Export from Evernote
* Right click on the created notebook in Evernote and choose "Export Notes…"
* Use the default export format of .enex
### Cleanup enex file (optional)
* If the Onenote header (that is at the top of each Onenote page) is not desired, you can use the following regex to remove them in a text editor like VsCode:
Find (using regex): `.<div.*><h1` Replace with: `<h1`
### Import into Trilium
* In Trilium, right click on the root node and choose Import (all default options should be fine).
* Select the .enex file exported from Evernote
* Be patient. Large .enex files may take a few minutes to process
* Repeat import for each .enex file
## Other importing notes:
* Centered text in Onenote will be left-justified after importing into Trilium
* Internal onenote links will obviously be broken, but the link still exists so you can do a search in Trilium to find all onenote:// links and then re-link to the proper Trilium page (there is no way to link to a paragraph in trilium, so it's good to keep trilium pages short so links point to a small chunk of information instead of a massive note)
* Text colors, highlights, and formatting generally carries over well
* Revision history will be lost, but any new revisions will be tracked in Trilium
* The structure of notes are not maintained exactly, so if you had sub-notes in Onenote, you may have to re-arrange the notes accordingly (This is easy since the order of the notes is preserved).
* Evernote tags are created for each "section" in OneNote and these tags are carried over to Trilium as attributes
* If the tags are not desired, you can turn them off in the Evernote export options.
* If the "Created with OneNote" text is not desired, do a find/replace in the enex files before importing to Trilium
* Some links will be disabled (not clickable) when importing from enex.
* Files, screenshots, and attachments are all preserved (This is the only one-note export option that seems to preserve all of these).

View File

@ -1,127 +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>Keyboard Shortcuts</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Keyboard Shortcuts</h1>
<div class="ck-content">
<p>This is supposed to be a complete list of keyboard shortcuts. Note that
some of these may work only in certain contexts (e.g. in tree pane or note
editor).</p>
<p>It is also possible to configure most keyboard shortcuts in Options -&gt;
Keyboard shortcuts. Using <code>global:</code> prefix, you can assign a shortcut
which will work even without Trilium being in focus (requires app restart
to take effect).</p>
<h2>Note navigation</h2>
<ul>
<li><code>UP</code>, <code>DOWN</code> - go up/down in the list of notes, <code>CTRL-SHIFT-UP</code> and <code>CTRL-SHIFT-DOWN</code> work
also from editor</li>
<li><code>LEFT</code>, <code>RIGHT</code> - collapse/expand node</li>
<li><code>ALT+LEFT</code>, <code>ALT+RIGHT</code> - go back / forwards in the
history</li>
<li><code>CTRL+J</code> - show <a href="Navigation/Note%20Navigation.html">"Jump to" dialog</a>
</li>
<li><code>CTRL+.</code> - scroll to current note (useful when you scroll away
from your note or your focus is currently in the editor)</li>
<li><code>BACKSPACE</code> - jumps to parent note</li>
<li><code>ALT+C</code> - collapse whole note tree</li>
<li><code>ALT+-</code> (alt with minus sign) - collapse subtree (if some subtree
takes too much space on tree pane you can collapse it)</li>
<li>you can define a <a href="../Advanced%20Usage/Attributes.html">label</a> <code>#keyboardShortcut</code> with
e.g. value <code>Ctrl+I</code>. Pressing this keyboard combination will
then bring you to the note on which it is defined. Note that Trilium must
be reloaded/restarted (Ctrl+R) for changes to be in effect.</li>
</ul>
<p>See demo of some of these features in <a href="Navigation/Note%20Navigation.html">note navigation</a>.</p>
<h2>Tabs</h2>
<ul>
<li><code>CTRL+click</code> - (or middle mouse click) on note link opens note
in a new tab</li>
</ul>
<p>Only in desktop (electron build):</p>
<ul>
<li><code>CTRL+T</code> - opens empty tab</li>
<li><code>CTRL+W</code> - closes active tab</li>
<li><code>CTRL+Tab</code> - activates next tab</li>
<li><code>CTRL+Shift+Tab</code> - activates previous tab</li>
</ul>
<h2>Creating notes</h2>
<ul>
<li><code>CTRL+O</code> - creates new note after the current note</li>
<li><code>CTRL+P</code> - creates new sub-note into current note</li>
<li><code>F2</code> - edit <a href="Navigation/Note%20Navigation.html">prefix</a> of
current note clone</li>
</ul>
<h2>Moving / cloning notes</h2>
<ul>
<li><code>CTRL+UP</code>, <code>CTRL+DOWN</code> - move note up/down in the
note list</li>
<li><code>CTRL+LEFT</code> - move note up in the note tree</li>
<li><code>CTRL+RIGHT</code> - move note down in the note tree</li>
<li><code>SHIFT+UP</code>, <code>SHIFT+DOWN</code> - multi-select note above/below</li>
<li><code>CTRL+A</code> - select all notes in the current level</li>
<li><code>SHIFT+click</code> - multi select note which you clicked on</li>
<li><code>CTRL+C</code> - copies current note (or current selection) into clipboard
(used for <a href="Note/Cloning%20Notes.html">cloning</a>
</li>
<li><code>CTRL+X</code> - cuts current (or current selection) note into clipboard
(used for moving notes)</li>
<li><code>CTRL+V</code> - pastes note(s) as sub-note into current note (which
is either move or clone depending on whether it was copied or cut into
clipboard)</li>
<li><code>DEL</code> - delete note / sub-tree</li>
</ul>
<h2>Editing notes</h2>
<p>Trilium uses CKEditor 5 for the <a href="../Note%20Types/Text.html">text notes</a> and
CodeMirror 5 for <a href="../Advanced%20Usage/Code%20Notes.html">code notes</a>.
Check the documentation of these projects to see all their built-in keyboard
shortcuts.</p>
<ul>
<li><code>ALT-F10</code> - bring up inline formatting toolbar (arrow keys <code>&lt;-</code>,<code>-&gt;</code> to
navigate, <code>ENTER</code> to apply)</li>
<li><code>ALT-F10</code> - again to bring up block formatting toolbar</li>
<li><code>ENTER</code> in tree pane switches from tree pane into note title.
Enter from note title switches focus to text editor. <code>CTRL+.</code> switches
back from editor to tree pane.</li>
<li><code>CTRL+K</code> - create / edit <a href="Note/Links.html">external link</a>
</li>
<li><code>CTRL+L</code> - create <a href="Note/Links.html">internal (note) link</a>
</li>
<li><code>ALT+T</code> - inserts current date and time at caret position</li>
<li><code>CTRL+.</code> - jump away from the editor to tree pane and scroll
to current note</li>
</ul>
<h2>Runtime shortcuts</h2>
<p>These are hooked in Electron to be similar to native browser keyboard
shortcuts.</p>
<ul>
<li><code>F5</code>, <code>CTRL-R</code> - reloads trilium frontend</li>
<li><code>CTRL+SHIFT+I</code> - show developer tools</li>
<li><code>CTRL+F</code> - show search dialog</li>
<li><code>CTRL+-</code> - zoom out</li>
<li><code>CTRL+=</code> - zoom in</li>
</ul>
<h2>Other</h2>
<ul>
<li><code>ALT+O</code> - show SQL console (use only if you know what you're
doing)</li>
<li><code>ALT+M</code> - distraction-free mode - display only note editor,
everything else is hidden</li>
<li><code>F11</code> - toggle full screen</li>
<li><code>CTRL+S</code> - toggle <a href="Navigation/Search.html">search</a> form
in tree pane</li>
<li><code>ALT+A</code> - show note <a href="../Advanced%20Usage/Attributes.html">attributes</a> dialog</li>
</ul>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,78 @@
# Keyboard Shortcuts
This is supposed to be a complete list of keyboard shortcuts. Note that some of these may work only in certain contexts (e.g. in tree pane or note editor).
It is also possible to configure most keyboard shortcuts in Options -> Keyboard shortcuts. Using `global:` prefix, you can assign a shortcut which will work even without Trilium being in focus (requires app restart to take effect).
## Note navigation
* `UP`, `DOWN` - go up/down in the list of notes, `CTRL-SHIFT-UP` and `CTRL-SHIFT-DOWN` work also from editor
* `LEFT`, `RIGHT` - collapse/expand node
* `ALT+LEFT`, `ALT+RIGHT` - go back / forwards in the history
* `CTRL+J` - show ["Jump to" dialog](Navigation/Note%20Navigation.md)
* `CTRL+.` - scroll to current note (useful when you scroll away from your note or your focus is currently in the editor)
* `BACKSPACE` - jumps to parent note
* `ALT+C` - collapse whole note tree
* `ALT+-` (alt with minus sign) - collapse subtree (if some subtree takes too much space on tree pane you can collapse it)
* you can define a [label](../Advanced%20Usage/Attributes.md) `#keyboardShortcut` with e.g. value `Ctrl+I`. Pressing this keyboard combination will then bring you to the note on which it is defined. Note that Trilium must be reloaded/restarted (Ctrl+R) for changes to be in effect.
See demo of some of these features in [note navigation](Navigation/Note%20Navigation.md).
## Tabs
* `CTRL+click` - (or middle mouse click) on note link opens note in a new tab
Only in desktop (electron build):
* `CTRL+T` - opens empty tab
* `CTRL+W` - closes active tab
* `CTRL+Tab` - activates next tab
* `CTRL+Shift+Tab` - activates previous tab
## Creating notes
* `CTRL+O` - creates new note after the current note
* `CTRL+P` - creates new sub-note into current note
* `F2` - edit [prefix](Navigation/Note%20Navigation.md) of current note clone
## Moving / cloning notes
* `CTRL+UP`, `CTRL+DOWN` - move note up/down in the note list
* `CTRL+LEFT` - move note up in the note tree
* `CTRL+RIGHT` - move note down in the note tree
* `SHIFT+UP`, `SHIFT+DOWN` - multi-select note above/below
* `CTRL+A` - select all notes in the current level
* `SHIFT+click` - multi select note which you clicked on
* `CTRL+C` - copies current note (or current selection) into clipboard (used for [cloning](Note/Cloning%20Notes.md)
* `CTRL+X` - cuts current (or current selection) note into clipboard (used for moving notes)
* `CTRL+V` - pastes note(s) as sub-note into current note (which is either move or clone depending on whether it was copied or cut into clipboard)
* `DEL` - delete note / sub-tree
## Editing notes
Trilium uses CKEditor 5 for the [text notes](../Note%20Types/Text.md) and CodeMirror 5 for [code notes](../Advanced%20Usage/Code%20Notes.md). Check the documentation of these projects to see all their built-in keyboard shortcuts.
* `ALT-F10` - bring up inline formatting toolbar (arrow keys `<-`,`->` to navigate, `ENTER` to apply)
* `ALT-F10` - again to bring up block formatting toolbar
* `ENTER` in tree pane switches from tree pane into note title. Enter from note title switches focus to text editor. `CTRL+.` switches back from editor to tree pane.
* `CTRL+K` - create / edit [external link](Note/Links.md)
* `CTRL+L` - create [internal (note) link](Note/Links.md)
* `ALT+T` - inserts current date and time at caret position
* `CTRL+.` - jump away from the editor to tree pane and scroll to current note
## Runtime shortcuts
These are hooked in Electron to be similar to native browser keyboard shortcuts.
* `F5`, `CTRL-R` - reloads trilium frontend
* `CTRL+SHIFT+I` - show developer tools
* `CTRL+F` - show search dialog
* `CTRL+-` - zoom out
* `CTRL+=` - zoom in
## Other
* `ALT+O` - show SQL console (use only if you know what you're doing)
* `ALT+M` - distraction-free mode - display only note editor, everything else is hidden
* `F11` - toggle full screen
* `CTRL+S` - toggle [search](Navigation/Search.md) form in tree pane
* `ALT+A` - show note [attributes](../Advanced%20Usage/Attributes.md) dialog

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,32 +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>Bookmarks</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Bookmarks</h1>
<div class="ck-content">
<p>To easily access selected notes, you can bookmark them. See demo:</p>
<p>
<img src="../../Attachments/bookmarks.gif" alt="">
</p>
<h2>Bookmark folder</h2>
<p>Space in the left panel is limited, and you might want to bookmark many
items. One possible solution is to bookmark a folder, so it shows its children:</p>
<p>
<img src="../../Attachments/bookmark-folder.png" alt="">
</p>
<p>To do this, you need to add a <code>#bookmarkFolder</code> label to the
note.</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,12 @@
# Bookmarks
To easily access selected notes, you can bookmark them. See demo:
![](../../Attachments/bookmarks.gif)
## Bookmark folder
Space in the left panel is limited, and you might want to bookmark many items. One possible solution is to bookmark a folder, so it shows its children:
![](../../Attachments/bookmark-folder.png)
To do this, you need to add a `#bookmarkFolder` label to the note.

View File

@ -1,30 +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>Note Hoisting</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Note Hoisting</h1>
<div class="ck-content">
<p>Hoisting is a standard outliner feature which allows you to focus on (or
"zoom into") a specific note and its subtree by hiding all parent and sibling
notes. Demo:</p>
<p>
<img src="../../Attachments/note-hoisting.gif" alt="">
</p>
<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>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,8 @@
# Note Hoisting
Hoisting is a standard outliner feature which allows you to focus on (or "zoom into") a specific note and its subtree by hiding all parent and sibling notes. Demo:
![](../../Attachments/note-hoisting.gif)
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.

View File

@ -1,48 +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>Note Navigation</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Note Navigation</h1>
<div class="ck-content">
<p>One of the Trilium's goals is to provide fast and comfortable navigation
between notes.</p>
<h2>Backwards and forward</h2>
<p>You can use alt-left and alt-right to move back and forward in history
of viewed pages.</p>
<p>This works identically to browser backwards / forwards, it's actually
using built-in browser support for this.</p>
<figure class="image">
<img style="aspect-ratio:669/266;" src="1_Note Navigation_image.png" width="669"
height="266">
</figure>
<h2>Jump to note</h2>
<p>This is useful to quickly find and view arbitrary note - click on <code>Jump to</code> button
on the top or press <code>CTRL-J</code>. Then type part of the note name
and autocomplete will help you pick the desired note.</p>
<p>
<img src="../../Attachments/jump-to.gif" alt="">
</p>
<h3>Recent notes</h3>
<p>Jump to note also has the ability to show the list of recently viewed
/ edited notes and quickly jump to it.</p>
<p>To access this functionality, click on <code>Jump to</code> button on the
top. By default, (when nothing is entered into autocomplete), this dialog
will show the list of recent notes.</p>
<p>Alternatively you can click on the "time" icon on the right.</p>
<p>
<img src="../../Attachments/recent-notes.gif" alt="">
</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,26 @@
# Note Navigation
One of the Trilium's goals is to provide fast and comfortable navigation between notes.
## Backwards and forward
You can use alt-left and alt-right to move back and forward in history of viewed pages.
This works identically to browser backwards / forwards, it's actually using built-in browser support for this.
![](Note Navigation_image.png)
## Jump to note
This is useful to quickly find and view arbitrary note - click on `Jump to` button on the top or press `CTRL-J`. Then type part of the note name and autocomplete will help you pick the desired note.
![](../../Attachments/jump-to.gif)
### Recent notes
Jump to note also has the ability to show the list of recently viewed / edited notes and quickly jump to it.
To access this functionality, click on `Jump to` button on the top. By default, (when nothing is entered into autocomplete), this dialog will show the list of recent notes.
Alternatively you can click on the "time" icon on the right.
![](../../Attachments/recent-notes.gif)

View File

@ -1,158 +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>Search</title>
</head>
<body>
<div class="content">
<h1 data-trilium-h1>Search</h1>
<div class="ck-content">
<h2>Local Search</h2>
<p>Local search allows you to search within the currently displayed note.
To initiate a local search, press CTRL-F. If using a web browser, this
will be handled by the browser's native search functionality. In the desktop
(electron) version, a separate dialog will apear.</p>
<h2>Note Search</h2>
<p>Note search enables you to find notes by searching for text in the title,
content, or <a href="../../Advanced%20Usage/Attributes.html">attributes</a> of
the notes. You also have the option to save your searches, which will create
a special search note which is visible on your navigation tree and contains
the search results as sub-items.</p>
<p>To search for notes, click on the magnifying glass icon on the toolbar
or press the <code>CTRL-S</code> keyboard <a href="../Keyboard%20Shortcuts.html">shortcut</a>.</p>
<h3>Simple Note Search Examples</h3>
<ul>
<li><code>rings tolkien</code>: Full-text search to find notes containing
both "rings" and "tolkien".</li>
<li><code>"The Lord of the Rings" Tolkien</code>: Full-text search where "The
Lord of the Rings" must match exactly.</li>
<li><code>note.content *=* rings OR note.content *=* tolkien</code>: Find
notes containing "rings" or "tolkien" in their content.</li>
<li><code>towers #book</code>: Combine full-text and attribute search to find
notes containing "towers" and having the "book" label.</li>
<li><code>towers #book or #author</code>: Search for notes containing "towers"
and having either the "book" or "author" label.</li>
<li><code>towers #!book</code>: Search for notes containing "towers" and not
having the "book" label.</li>
<li><code>#book #publicationYear = 1954</code>: Find notes with the "book"
label and "publicationYear" set to 1954.</li>
<li><code>#genre *=* fan</code>: Find notes with the "genre" label containing
the substring "fan". Additional operators include <code>*=*</code> for "contains", <code>=*</code> for
"starts with", <code>*=</code> for "ends with", and <code>!=</code> for "is
not equal to".</li>
<li><code>#book #publicationYear &gt;= 1950 #publicationYear &lt; 1960</code>:
Use numeric operators to find all books published in the 1950s.</li>
<li><code>#dateNote &gt;= TODAY-30</code>: A "smart search" to find notes
with the "dateNote" label within the last 30 days. Supported smart values
include NOW +- seconds, TODAY +- days, MONTH +- months, YEAR +- years.</li>
<li><code>~author.title *=* Tolkien</code>: Find notes related to an author
whose title contains "Tolkien".</li>
<li><code>#publicationYear %= '19[0-9]{2}'</code>: Use the '%=' operator to
match a regular expression (regex). This feature has been available since
Trilium 0.52.</li>
</ul>
<h3>Advanced Use Cases</h3>
<ul>
<li><code>~author.relations.son.title = 'Christopher Tolkien'</code>: Search
for notes with an "author" relation to a note that has a "son" relation
to "Christopher Tolkien". This can be modeled with the following note structure:
<ul>
<li>Books
<ul>
<li>Lord of the Rings
<ul>
<li>label: “book”</li>
<li>relation: “author” points to “J. R. R. Tolkien” note</li>
</ul>
</li>
</ul>
</li>
<li>People
<ul>
<li>J. R. R. Tolkien
<ul>
<li>relation: “son” points to "Christopher Tolkien" note</li>
<li>Christopher Tolkien</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><code>~author.title *= Tolkien OR (#publicationDate &gt;= 1954 AND #publicationDate &lt;= 1960)</code>:
Use boolean expressions and parentheses to group expressions. Note that
expressions starting with a parenthesis need an "expression separator sign"
(# or ~) prepended.</li>
<li><code>note.parents.title = 'Books'</code>: Find notes with a parent named
"Books".</li>
<li><code>note.parents.parents.title = 'Books'</code>: Find notes with a grandparent
named "Books".</li>
<li><code>note.ancestors.title = 'Books'</code>: Find notes with an ancestor
named "Books".</li>
<li><code>note.children.title = 'sub-note'</code>: Find notes with a child
named "sub-note".</li>
</ul>
<h3>Search with Note Properties</h3>
<p>Notes have properties that can be used in searches, such as <code>noteId</code>, <code>dateModified</code>, <code>dateCreated</code>, <code>isProtected</code>, <code>type</code>, <code>title</code>, <code>text</code>, <code>content</code>, <code>rawContent</code>, <code>ownedLabelCount</code>, <code>labelCount</code>, <code>ownedRelationCount</code>, <code>relationCount</code>, <code>ownedRelationCountIncludingLinks</code>, <code>relationCountIncludingLinks</code>, <code>ownedAttributeCount</code>, <code>attributeCount</code>, <code>targetRelationCount</code>, <code>targetRelationCountIncludingLinks</code>, <code>parentCount</code>, <code>childrenCount</code>, <code>isArchived</code>, <code>contentSize</code>, <code>noteSize</code>,
and <code>revisionCount</code>.</p>
<p>These properties can be accessed via the <code>note.</code> prefix, e.g., <code>note.type = code AND note.mime = 'application/json'</code>.</p>
<h3>Order by and Limit</h3><pre><code class="language-text-x-trilium-auto">#author=Tolkien orderBy #publicationDate desc, note.title limit 10</code></pre>
<p>This example will:</p>
<ol>
<li>Find notes with the author label "Tolkien".</li>
<li>Order the results by <code>publicationDate</code> in descending order.</li>
<li>Use <code>note.title</code> as a secondary ordering if publication dates
are equal.</li>
<li>Limit the results to the first 10 notes.</li>
</ol>
<h3>Negation</h3>
<p>Some queries can only be expressed with negation:</p><pre><code class="language-text-x-trilium-auto">#book AND not(note.ancestor.title = 'Tolkien')</code></pre>
<p>This query finds all book notes not in the "Tolkien" subtree.</p>
<h2>Under the Hood</h2>
<h3>Label and Relation Shortcuts</h3>
<p>The "full" syntax for searching by labels is:</p><pre><code class="language-text-x-trilium-auto">note.labels.publicationYear = 1954</code></pre>
<p>For relations:</p><pre><code class="language-text-x-trilium-auto">note.relations.author.title *=* Tolkien</code></pre>
<p>However, common label and relation searches have shortcut syntax:</p><pre><code class="language-text-x-trilium-auto">#publicationYear = 1954
#author.title *=* Tolkien</code></pre>
<h3>Separating Full-Text and Attribute Parts</h3>
<p>Search syntax allows combining full-text search with attribute-based search
seamlessly. For example, <code>tolkien #book</code> contains:</p>
<ol>
<li>Full-text tokens - <code>tolkien</code>
</li>
<li>Attribute expressions - <code>#book</code>
</li>
</ol>
<p>Trilium detects the separation between full text search and attribute/property
search by looking for certain special characters or words that denote attributes
and properties (e.g., #, ~, note.). If you need to include these in full-text
search, escape them with a backslash so they are processed as regular text:</p><pre><code class="language-text-x-trilium-auto">"note.txt"
\#hash
#myLabel = 'Say "Hello World"'</code></pre>
<h3>Escaping Special Characters</h3>
<p>Special characters can be enclosed in quotes or escaped with a backslash
to be used in full-text search:</p><pre><code class="language-text-x-trilium-auto">"note.txt"
\#hash
#myLabel = 'Say "Hello World"'</code></pre>
<p>Three types of quotes are supported: single, double, and backtick.</p>
<h3>Type Coercion</h3>
<p>Label values are technically strings but can be coerced for numeric comparisons:</p><pre><code class="language-text-x-trilium-auto">note.dateCreated =* '2019-05'</code></pre>
<p>This finds notes created in May 2019. Numeric operators like <code>#publicationYear &gt;= 1960</code> convert
string values to numbers for comparison.</p>
<h2>Auto-Trigger Search from URL</h2>
<p>You can open Trilium and automatically trigger a search by including the
search <a href="https://meyerweb.com/eric/tools/dencoder/">url encoded</a> string
in the URL:</p>
<p><code>http://localhost:8080/#?searchString=abc</code>
</p>
</div>
</div>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More