docs(technical): dayjs intro & supported plugins

This commit is contained in:
Elian Doran 2025-12-03 22:01:06 +02:00
parent 8c324cd185
commit 6f85d3370c
No known key found for this signature in database
6 changed files with 126 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -4,28 +4,29 @@ class="image image-style-align-center">
<img style="aspect-ratio:1398/1015;" src="Split View_2_Split View_im.png"
width="1398" height="1015">
</figure>
<h2><strong>Interactions</strong></h2>
<h2><strong>Interactions</strong></h2>
<ul>
<li data-list-item-id="eb22263532280510ca0efeb2c2e757629">Press the
<li>Press the
<img src="Split View_Split View_imag.png">button to the right of a note's title to open a new split to the right
of it.
<ul>
<li data-list-item-id="eda17492ea2d8da7c4bf2fb3e2f7bfbe9">It is possible to have as many splits as desired, simply press again the
<li>It is possible to have as many splits as desired, simply press again the
button.</li>
<li data-list-item-id="ea0223c947ea17534d577c9cfef4d5c6e">Only horizontal splits are possible, vertical or drag &amp; dropping is
<li>Only horizontal splits are possible, vertical or drag &amp; dropping is
not supported.</li>
</ul>
</li>
<li data-list-item-id="e77d99fdc9a0846903de57d1b710fdd56">When at least one split is open, press the
<li>When at least one split is open, press the
<img src="Split View_3_Split View_im.png">button next to it to close it.</li>
<li data-list-item-id="ec9d11f5bcfd10795f282e275938b2f4a">Use the
<li>Use the
<img src="Split View_4_Split View_im.png">or the
<img src="Split View_1_Split View_im.png">button to move around the splits.</li>
<li data-list-item-id="e8384a579c3d6ee8df4d7dbf9b07c3436">Each <a href="#root/_help_3seOhtN8uLIY">tab</a> has its own split view configuration
<li>Each <a href="#root/_help_3seOhtN8uLIY">tab</a> has its own split view configuration
(e.g. one tab can have two notes in a split view, whereas the others are
one-note views).
<ul>
<li data-list-item-id="e298299f6b2f1b9d8b5f26a5f8a0c9092">The tab will indicate only the title of the main note (the first one in
<li>The tab will indicate only the title of the main note (the first one in
the list).</li>
</ul>
</li>
@ -48,35 +49,34 @@ class="image image-style-align-center">
as well, with the following differences from the desktop version of the
split:</p>
<ul>
<li data-list-item-id="efc0bb8eb81ea1617b73188613f2ede5d">On smartphones, the split views are laid out vertically (one on the top
<li>On smartphones, the split views are laid out vertically (one on the top
and one on the bottom), instead of horizontally as on the desktop.</li>
<li
data-list-item-id="e7659da22c36db39ae8e3dc5424afba1e">There can be only one split open per tab.</li>
<li data-list-item-id="eb848af9837a484a9de9117922c6d7186">It's not possible to resize the two split panes.</li>
<li data-list-item-id="e869c240066f602fbc1c0e55259ba62e5">When the keyboard is opened, the active note will be “maximized”, thus
allowing for more space even when a split is open. When the keyboard is
closed, the splits become equal in size again.</li>
<li>There can be only one split open per tab.</li>
<li>It's not possible to resize the two split panes.</li>
<li>When the keyboard is opened, the active note will be “maximized”, thus
allowing for more space even when a split is open. When the keyboard is
closed, the splits become equal in size again.</li>
</ul>
<p>Interaction:</p>
<ul>
<li data-list-item-id="edbf5c644758db5aca9867c516f97542b">To create a new split, click the three dots button on the right of the
<li>To create a new split, click the three dots button on the right of the
note title and select <em>Create new split</em>.
<ul>
<li data-list-item-id="eed272873b629f70418c3e7074a829369">This option will only be available if there is no split already open in
<li>This option will only be available if there is no split already open in
the current tab.</li>
</ul>
</li>
<li data-list-item-id="e733863e6058336ebfcf27042f56be312">To close a split, click the three dots button on the right of the note
<li>To close a split, click the three dots button on the right of the note
title and select <em>Close this pane</em>.
<ul>
<li data-list-item-id="e9e6c191873dcd658242c64553343e0c7">Note that this option will only be available on the second note in the
<li>Note that this option will only be available on the second note in the
split (the one at the bottom on smartphones, the one on the right on tablets).</li>
</ul>
</li>
<li data-list-item-id="e780e5e7736b4d26705102545c5626a6a">When long-pressing a link, a contextual menu will show up with an option
<li>When long-pressing a link, a contextual menu will show up with an option
to <em>Open note in a new split</em>.
<ul>
<li data-list-item-id="e264277ee51f6d266a4088e2545f6648d">If there's already a split, the option will replace the existing split
<li>If there's already a split, the option will replace the existing split
instead.</li>
</ul>
</li>

View File

@ -0,0 +1,37 @@
<p>Day.js is a date manipulation library that's used by Trilium, but it's
also shared with both front-end and back-end scripts. For more information
about the library itself, consult the <a href="https://day.js.org/en/">official documentation</a>.</p>
<h2>How to use</h2>
<p>The <code>dayjs</code> method is provided directly in the <code>api</code> global:</p><pre><code class="language-application-javascript-env-backend">const date = api.dayjs();
api.log(date.format("YYYY-MM-DD"));</code></pre>
<h2>Plugins</h2>
<p>Day.js uses a modular, plugin-based architecture. Generally these plugins
must be imported, but this process doesn't work inside Trilium scripts
due to the use of a bundler.</p>
<p>Since v0.100.0, the same set of plugins is available for both front-end
and back-end scripts.</p>
<p>The following Day.js plugins are directly integrated into Trilium:</p>
<ul>
<li data-list-item-id="ee48062bdf09fc0c616bb530989292b21"><a href="https://day.js.org/docs/en/plugin/advanced-format">AdvancedFormat</a>
</li>
<li data-list-item-id="ed6e0cbd3a519a8720d1c9e9cc400bb04"><a href="https://day.js.org/docs/en/plugin/duration">Duration</a>, since
v0.100.0.</li>
<li data-list-item-id="e94f06e705bf337dd83b07f86d3f7adb7"><a href="https://day.js.org/docs/en/plugin/is-between">IsBetween</a>
</li>
<li data-list-item-id="e15e52376df80e3452567a47df67f41bd"><a href="https://day.js.org/docs/en/plugin/iso-week">IsoWeek</a>
</li>
<li data-list-item-id="e5c807c71a6b02320901809cc94dcca25"><a href="https://day.js.org/docs/en/plugin/is-same-or-after">IsSameOrAfter</a>
</li>
<li data-list-item-id="e1536f1bb4d9b9a40789ebe18a183e5d4"><a href="https://day.js.org/docs/en/plugin/is-same-or-before">IsSameOrBefore</a>
</li>
<li data-list-item-id="ec1f021ff7cf2edec5f8548843a1d5a0c"><a href="https://day.js.org/docs/en/plugin/quarter-of-year">QuarterOfYear</a>
</li>
<li data-list-item-id="e7cf8af04f2a71d8e380627cd6d3f6d04"><a href="https://day.js.org/docs/en/plugin/utc">UTC</a>
</li>
</ul>
<aside class="admonition note">
<p>If another Day.js plugin might be needed for scripting purposes, feel
free to open a feature request for it. Depending on the size of the plugin
and the potential use of it inside the Trilium code base, it has a chance
of being integrated.</p>
</aside>

View File

@ -1,5 +1,5 @@
# Documentation
There are multiple types of documentation for Trilium:<img class="image-style-align-right" src="api/images/KJUp1g3csedB/Documentation_image.png" width="205" height="162">
There are multiple types of documentation for Trilium:<img class="image-style-align-right" src="api/images/rE2kRecw5n8A/Documentation_image.png" width="205" height="162">
* The _User Guide_ represents the user-facing documentation. This documentation can be browsed by users directly from within Trilium, by pressing <kbd>F1</kbd>.
* The _Developer's Guide_ represents a set of Markdown documents that present the internals of Trilium, for developers.

View File

@ -15928,6 +15928,41 @@
],
"dataFileName": "Backend API.dat",
"attachments": []
},
{
"isClone": false,
"noteId": "ApVHZ8JY5ofC",
"notePath": [
"pOsGYCXsbNQG",
"CdNpE2pqjmI6",
"GLks18SNjxmC",
"ApVHZ8JY5ofC"
],
"title": "Day.js",
"notePosition": 30,
"prefix": null,
"isExpanded": false,
"type": "text",
"mime": "text/html",
"attributes": [
{
"type": "label",
"name": "shareAlias",
"value": "day.js",
"isInheritable": false,
"position": 30
},
{
"type": "label",
"name": "iconClass",
"value": "bx bx-calendar",
"isInheritable": false,
"position": 40
}
],
"format": "markdown",
"dataFileName": "Day.js.md",
"attachments": []
}
]
},

View File

@ -0,0 +1,31 @@
# Day.js
Day.js is a date manipulation library that's used by Trilium, but it's also shared with both front-end and back-end scripts. For more information about the library itself, consult the [official documentation](https://day.js.org/en/).
## How to use
The `dayjs` method is provided directly in the `api` global:
```javascript
const date = api.dayjs();
api.log(date.format("YYYY-MM-DD"));
```
## Plugins
Day.js uses a modular, plugin-based architecture. Generally these plugins must be imported, but this process doesn't work inside Trilium scripts due to the use of a bundler.
Since v0.100.0, the same set of plugins is available for both front-end and back-end scripts.
The following Day.js plugins are directly integrated into Trilium:
* [AdvancedFormat](https://day.js.org/docs/en/plugin/advanced-format)
* [Duration](https://day.js.org/docs/en/plugin/duration), since v0.100.0.
* [IsBetween](https://day.js.org/docs/en/plugin/is-between)
* [IsoWeek](https://day.js.org/docs/en/plugin/iso-week)
* [IsSameOrAfter](https://day.js.org/docs/en/plugin/is-same-or-after)
* [IsSameOrBefore](https://day.js.org/docs/en/plugin/is-same-or-before)
* [QuarterOfYear](https://day.js.org/docs/en/plugin/quarter-of-year)
* [UTC](https://day.js.org/docs/en/plugin/utc)
> [!NOTE]
> If another Day.js plugin might be needed for scripting purposes, feel free to open a feature request for it. Depending on the size of the plugin and the potential use of it inside the Trilium code base, it has a chance of being integrated.