mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 05:15:59 +01:00
chore(docs): sync developer guide
This commit is contained in:
@@ -11,7 +11,7 @@ The SVG export needs to be handled inside the note type implementation.
|
||||
|
||||
The first goal is to create a method to handle the <a class="reference-link" href="SVG%20rendering.md">SVG rendering</a>. Make sure to deduplicate the code if the SVG rendering is already handled.
|
||||
|
||||
```plain
|
||||
```
|
||||
async renderSvg() {
|
||||
return await this.mind.exportSvg().text();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ async renderSvg() {
|
||||
|
||||
Then create an event handler to manage the SVG export:
|
||||
|
||||
```plain
|
||||
```
|
||||
async exportSvgEvent({ntxId}) {
|
||||
if (!this.isNoteContext(ntxId) || this.note.type !== "mindMap") {
|
||||
return;
|
||||
|
||||
@@ -49,6 +49,6 @@ Go to `src/becca/entities/rows.ts` and add the new note type to `ALLOWED_NOTE_TY
|
||||
|
||||
Type widgets do a check whenever a note is selected to determine whether the widget needs to be displayed or not, based on the note type. Make sure `getType()` is well implemented in the newly added type widget (take great care that the value is returned but also that the note type ID matches the ones registered in the previous steps):
|
||||
|
||||
```plain
|
||||
```
|
||||
static getType() { return "foo"; }
|
||||
```
|
||||
@@ -1,7 +1,7 @@
|
||||
# Loading data
|
||||
Data loading can be done in `doRefresh()` since it gets a reference to the note:
|
||||
|
||||
```plain
|
||||
```
|
||||
const blob = await note.getBlob();
|
||||
const content = blob.getJsonContent();
|
||||
```
|
||||
|
||||
@@ -13,7 +13,7 @@ If the returned value is a `Blob`, then the underlying text can be obtained via
|
||||
|
||||
To save the SVG as an attachment alongside the content, simply modify `getData()`:
|
||||
|
||||
```plain
|
||||
```
|
||||
async getData() {
|
||||
const mind = this.mind;
|
||||
if (!mind) {
|
||||
@@ -47,7 +47,7 @@ Alter the `returnImageInt` method as follows:
|
||||
1. Add the image type to the guard condition which returns 400 for unsupported note types.
|
||||
2. Add an `if` statement to render the attachment using the correct name:
|
||||
|
||||
```plain
|
||||
```
|
||||
if (image.type === "mindMap") {
|
||||
renderSvgAttachment(image, res, 'mindmap-export.svg');
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ The data persistence is achieved via the spaced update mechanism which is alread
|
||||
|
||||
First, the class must implement `getData`, in order to retrieve the data from the custom widget in a serialized form. As an example from the mind map implementation:
|
||||
|
||||
```plain
|
||||
```
|
||||
async getData() {
|
||||
const mind = this.mind;
|
||||
if (!mind) {
|
||||
@@ -20,7 +20,7 @@ Here the content is a string containing a JSON. It is also possible to provide a
|
||||
|
||||
Then to trigger an update, register a listener within the custom widget that calls the spaced update, for example:
|
||||
|
||||
```plain
|
||||
```
|
||||
mind.bus.addListener("operation", (operation) => {
|
||||
this.spacedUpdate.scheduleUpdate();
|
||||
});
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# attachments
|
||||
<figure class="table" style="width:100%"><table class="ck-table-resized"><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Column Name</th><th>Data Type</th><th>Nullity</th><th>Default value</th><th>Description</th></tr></thead><tbody><tr><th><code>attachmentId</code></th><td>Text</td><td>Non-null</td><td> </td><td>Unique ID (e.g. <code>qhC1vzU4nwSE</code>)</td></tr><tr><th><code>ownerId</code></th><td>Text</td><td>Non-null</td><td> </td><td>The unique ID of a row in <a class="reference-link" href="notes.md">notes</a>.</td></tr><tr><th><code>role</code></th><td>Text</td><td>Non-null</td><td> </td><td>The role of the attachment: <code>image</code> for images that are attached to a note.</td></tr><tr><th><code>mime</code></th><td>Text</td><td>Non-null</td><td> </td><td>The MIME type of the attachment (e.g. <code>image/png</code>)</td></tr><tr><th><code>title</code></th><td>Text</td><td>Non-null</td><td> </td><td>The title of the attachment.</td></tr><tr><th><code>isProtected</code></th><td>Integer</td><td>Non-null</td><td>0</td><td><code>1</code> if the entity is <a href="../Protected%20entities.md">protected</a>, <code>0</code> otherwise.</td></tr><tr><th><code>position</code></th><td>Integer</td><td>Non-null</td><td>0</td><td>Not sure where the position is relevant for attachments (saw it with values of 10 and 0).</td></tr><tr><th><code>blobId</code></th><td>Text</td><td>Nullable</td><td><code>null</code></td><td>The corresponding <code>blobId</code> from the <a class="reference-link" href="blobs.md">blobs</a> table.</td></tr><tr><th><code>dateModified</code></th><td>Text</td><td>Non-null</td><td> </td><td>Localized modification date (e.g. <code>2023-11-08 18:43:44.204+0200</code>)</td></tr><tr><th><code>utcDateModified</code></th><td>Text</td><td>Non-null</td><td> </td><td>Modification date in UTC format (e.g. <code>2023-11-08 16:43:44.204Z</code>)</td></tr><tr><th><code>utcDateScheduledForErasure</code></th><td>Text</td><td>Nullable</td><td><code>null</code></td><td> </td></tr><tr><th><code>isDeleted</code></th><td>Integer</td><td>Non-null</td><td> </td><td><code>1</code> if the entity is <a href="../Deleted%20notes.md">deleted</a>, <code>0</code> otherwise.</td></tr><tr><th><code>deleteId</code></th><td>Text</td><td>Nullable</td><td><code>null</code></td><td> </td></tr></tbody></table></figure>
|
||||
<figure class="table" style="width:100%;"><table class="ck-table-resized"><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Column Name</th><th>Data Type</th><th>Nullity</th><th>Default value</th><th>Description</th></tr></thead><tbody><tr><th><code>attachmentId</code></th><td>Text</td><td>Non-null</td><td> </td><td>Unique ID (e.g. <code>qhC1vzU4nwSE</code>)</td></tr><tr><th><code>ownerId</code></th><td>Text</td><td>Non-null</td><td> </td><td>The unique ID of a row in <a class="reference-link" href="notes.md">notes</a>.</td></tr><tr><th><code>role</code></th><td>Text</td><td>Non-null</td><td> </td><td>The role of the attachment: <code>image</code> for images that are attached to a note.</td></tr><tr><th><code>mime</code></th><td>Text</td><td>Non-null</td><td> </td><td>The MIME type of the attachment (e.g. <code>image/png</code>)</td></tr><tr><th><code>title</code></th><td>Text</td><td>Non-null</td><td> </td><td>The title of the attachment.</td></tr><tr><th><code>isProtected</code></th><td>Integer</td><td>Non-null</td><td>0</td><td><code>1</code> if the entity is <a href="../Protected%20entities.md">protected</a>, <code>0</code> otherwise.</td></tr><tr><th><code>position</code></th><td>Integer</td><td>Non-null</td><td>0</td><td>Not sure where the position is relevant for attachments (saw it with values of 10 and 0).</td></tr><tr><th><code>blobId</code></th><td>Text</td><td>Nullable</td><td><code>null</code></td><td>The corresponding <code>blobId</code> from the <a class="reference-link" href="blobs.md">blobs</a> table.</td></tr><tr><th><code>dateModified</code></th><td>Text</td><td>Non-null</td><td> </td><td>Localized modification date (e.g. <code>2023-11-08 18:43:44.204+0200</code>)</td></tr><tr><th><code>utcDateModified</code></th><td>Text</td><td>Non-null</td><td> </td><td>Modification date in UTC format (e.g. <code>2023-11-08 16:43:44.204Z</code>)</td></tr><tr><th><code>utcDateScheduledForErasure</code></th><td>Text</td><td>Nullable</td><td><code>null</code></td><td> </td></tr><tr><th><code>isDeleted</code></th><td>Integer</td><td>Non-null</td><td> </td><td><code>1</code> if the entity is <a href="../Deleted%20notes.md">deleted</a>, <code>0</code> otherwise.</td></tr><tr><th><code>deleteId</code></th><td>Text</td><td>Nullable</td><td><code>null</code></td><td> </td></tr></tbody></table></figure>
|
||||
@@ -11,7 +11,7 @@ After making the necessary modifications, simply export the “Trilium Demo” n
|
||||
|
||||
## Testing the changes
|
||||
|
||||
```plain
|
||||
```
|
||||
rm -r data
|
||||
npm run start-server
|
||||
```
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
# Docker
|
||||
To run a Docker build:
|
||||
|
||||
```plain
|
||||
```
|
||||
./bin/builder-docker.sh
|
||||
```
|
||||
|
||||
To run the built Docker image:
|
||||
|
||||
```plain
|
||||
```
|
||||
sudo docker run -p 8081:8080 triliumnext/notes:v0.90.6-beta
|
||||
```
|
||||
|
||||
To enter a shell in the Docker container:
|
||||
|
||||
```plain
|
||||
```
|
||||
sudo docker run -it --entrypoint=/bin/sh zadam/trilium:0.63-latest
|
||||
```
|
||||
@@ -1,6 +1,6 @@
|
||||
# Adaptive icon
|
||||
<figure class="table" style="width:100%"><table class="ck-table-resized"><colgroup><col> <col></colgroup><tbody><tr><th>Before</th><td><figure class="image"><img src="1_Adaptive icon_image.png"></figure></td></tr><tr><th>After</th><td><figure class="image"><img src="6_Adaptive icon_image.png"></figure></td></tr><tr><th>With new scale</th><td><figure class="image"><img src="4_Adaptive icon_image.png"></figure></td></tr></tbody></table></figure>
|
||||
<figure class="table" style="width:100%;"><table class="ck-table-resized"><colgroup><col> <col></colgroup><tbody><tr><th>Before</th><td><figure class="image"><img src="1_Adaptive icon_image.png"></figure></td></tr><tr><th>After</th><td><figure class="image"><img src="6_Adaptive icon_image.png"></figure></td></tr><tr><th>With new scale</th><td><figure class="image"><img src="4_Adaptive icon_image.png"></figure></td></tr></tbody></table></figure>
|
||||
|
||||
## Scale
|
||||
|
||||
<figure class="table" style="width:300px"><table><tbody><tr><th>0.9</th><td style="background-color:hsl(0, 0%, 90%)"><figure class="image"><img src="2_Adaptive icon_image.png"></figure></td></tr><tr><th>0.85</th><td style="background-color:hsl(0, 0%, 90%)"><figure class="image"><img src="5_Adaptive icon_image.png"></figure></td></tr><tr><th>0.8</th><td style="background-color:hsl(0, 0%, 90%)"><figure class="image"><img src="Adaptive icon_image.png"></figure></td></tr><tr><th>0.75</th><td style="background-color:hsl(0, 0%, 90%)"><figure class="image"><img src="3_Adaptive icon_image.png"></figure></td></tr></tbody></table></figure>
|
||||
<figure class="table" style="width:300px;"><table><tbody><tr><th>0.9</th><td style="background-color:hsl(0, 0%, 90%)"><figure class="image"><img src="2_Adaptive icon_image.png"></figure></td></tr><tr><th>0.85</th><td style="background-color:hsl(0, 0%, 90%);"><figure class="image"><img src="5_Adaptive icon_image.png"></figure></td></tr><tr><th>0.8</th><td style="background-color:hsl(0, 0%, 90%);"><figure class="image"><img src="Adaptive icon_image.png"></figure></td></tr><tr><th>0.75</th><td style="background-color:hsl(0, 0%, 90%);"><figure class="image"><img src="3_Adaptive icon_image.png"></figure></td></tr></tbody></table></figure>
|
||||
@@ -7,14 +7,14 @@ In the screenshot, the icon is around 650px whereas the closest image we have is
|
||||
|
||||
Before:
|
||||
|
||||
```plain
|
||||
```
|
||||
File: ../images/app-icons/mac/icon.icns
|
||||
ic09: 62069 bytes, png: 512x512
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```plain
|
||||
```
|
||||
File: ../images/app-icons/mac/icon.icns
|
||||
icp4: 1140 bytes, png: 16x16
|
||||
icp5: 1868 bytes, png: 32x32
|
||||
|
||||
@@ -65,7 +65,7 @@ where `msgid` is the key of the message being translated.
|
||||
|
||||
In the translation, enclose the variables with `{{` and `}}`:
|
||||
|
||||
```plain
|
||||
```
|
||||
{
|
||||
"key": "{{what}} is {{how}}"
|
||||
}
|
||||
@@ -73,7 +73,7 @@ In the translation, enclose the variables with `{{` and `}}`:
|
||||
|
||||
Then pass the arguments when reading the translation:
|
||||
|
||||
```plain
|
||||
```
|
||||
t('key', { what: 'i18next', how: 'great' })
|
||||
```
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ However, a core difference is that Electron watches `dist/src/public` instead of
|
||||
|
||||
To ameliorate that, a separate watch script has been implemented which automatically copies files from `src/public` to `dist/src/public` whenever a change is detected. To run it:
|
||||
|
||||
```plain
|
||||
```
|
||||
npm run
|
||||
```
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ The note type is defined by the `type` column in <a class="reference-link" href
|
||||
|
||||
Possible types:
|
||||
|
||||
<figure class="table" style="width:100%"><table class="ck-table-resized"><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Note Type</th><th><code>type</code> value</th><th>Corresponding MIME type</th><th>Content of the note's blob</th><th>Relevant attributes</th></tr></thead><tbody><tr><th>Text</th><td><code>text</code></td><td> </td><td>The HTML of the note.</td><td> </td></tr><tr><th><a href="https://github.com/zadam/trilium/wiki/Relation-map">Relation Map </a></th><td><code>relationMap</code></td><td><code>application/json</code></td><td><p>A JSON describing the note:</p><pre><code class="language-text-plain">{
|
||||
<figure class="table" style="width:100%;"><table class="ck-table-resized"><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Note Type</th><th><code>type</code> value</th><th>Corresponding MIME type</th><th>Content of the note's blob</th><th>Relevant attributes</th></tr></thead><tbody><tr><th>Text</th><td><code>text</code></td><td> </td><td>The HTML of the note.</td><td> </td></tr><tr><th><a href="https://github.com/zadam/trilium/wiki/Relation-map">Relation Map </a></th><td><code>relationMap</code></td><td><code>application/json</code></td><td><p>A JSON describing the note:</p><pre><code class="language-text-plain">{
|
||||
"notes": [
|
||||
{
|
||||
"noteId": "gFQDL11KEm9G",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Check box option
|
||||
In the TPL:
|
||||
|
||||
```html
|
||||
```
|
||||
<div class="options-section">
|
||||
<h4>Background effects</h4>
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# Creating a new option
|
||||
1. Go to `options_interface.ts` and add the option to `OptionDefinitions`, specifying its intended data type (boolean, string, number). Note that in the end the option will still be stored as a string, but this aids in type safety across the application.
|
||||
|
||||
2. To add a new option with a set default, go to `options_init.ts` in the server and add a new entry in the `defaultOptions`.
|
||||
|
||||
3. **Make the option adjustable by the client**
|
||||
By default options are not adjustable or visible to the client. To do so, modify `routes/api/options.ts` to add the newly added option to `ALLOWED_OPTIONS`.
|
||||
@@ -5,7 +5,7 @@ For example, to create a select:
|
||||
|
||||
First, modify the template (`TPL`), to add the new widget:
|
||||
|
||||
```plain
|
||||
```
|
||||
<div class="col-6">
|
||||
<label>First day of the week</label>
|
||||
<select class="first-day-of-week-select form-control">
|
||||
@@ -17,19 +17,19 @@ First, modify the template (`TPL`), to add the new widget:
|
||||
|
||||
Secondly, create a reference to the new element in `doRender()`:
|
||||
|
||||
```plain
|
||||
```
|
||||
this.$firstDayOfWeek = this.$widget.find(".first-day-of-week-select");
|
||||
```
|
||||
|
||||
Then in `optionsLoaded` adjust the value to the one set in the database:
|
||||
|
||||
```plain
|
||||
```
|
||||
this.$firstDayOfWeek.val(options.firstDayOfWeek);
|
||||
```
|
||||
|
||||
To actually update the option, add a listener in `doRender`:
|
||||
|
||||
```plain
|
||||
```
|
||||
this.$firstDayOfWeek.on("change", () => {
|
||||
this.updateOption("firstDayOfWeek", this.$firstDayOfWeek.val());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user