docs(user): use webviews for frontend & backend APIs

This commit is contained in:
Elian Doran 2025-04-13 19:09:14 +03:00
parent 002140c998
commit 31fb7c1404
No known key found for this signature in database
10 changed files with 105 additions and 41 deletions

View File

@ -9636,13 +9636,6 @@
"isInheritable": false,
"position": 10
},
{
"type": "relation",
"name": "internalLink",
"value": "habiZ3HU8Kw8",
"isInheritable": false,
"position": 20
},
{
"type": "relation",
"name": "internalLink",
@ -9656,6 +9649,13 @@
"value": "default-note-title",
"isInheritable": false,
"position": 30
},
{
"type": "relation",
"name": "internalLink",
"value": "habiZ3HU8Kw8",
"isInheritable": false,
"position": 20
}
],
"format": "markdown",
@ -10014,13 +10014,6 @@
"isInheritable": false,
"position": 40
},
{
"type": "relation",
"name": "internalLink",
"value": "habiZ3HU8Kw8",
"isInheritable": false,
"position": 50
},
{
"type": "relation",
"name": "internalLink",
@ -10034,6 +10027,13 @@
"value": "bx bx-list-plus",
"isInheritable": false,
"position": 10
},
{
"type": "relation",
"name": "internalLink",
"value": "habiZ3HU8Kw8",
"isInheritable": false,
"position": 50
}
],
"format": "markdown",
@ -11071,6 +11071,27 @@
"value": "script-api",
"isInheritable": false,
"position": 10
},
{
"type": "relation",
"name": "internalLink",
"value": "CdNpE2pqjmI6",
"isInheritable": false,
"position": 20
},
{
"type": "relation",
"name": "internalLink",
"value": "Q2z6av6JZVWm",
"isInheritable": false,
"position": 30
},
{
"type": "relation",
"name": "internalLink",
"value": "MEtfsqa5VwNi",
"isInheritable": false,
"position": 40
}
],
"format": "markdown",
@ -11091,10 +11112,17 @@
"notePosition": 10,
"prefix": null,
"isExpanded": false,
"type": "text",
"mime": "text/html",
"attributes": [],
"format": "markdown",
"type": "webView",
"mime": "",
"attributes": [
{
"type": "label",
"name": "webViewSrc",
"value": "https://triliumnext.github.io/Notes/Script%20API/interfaces/Frontend_Script_API.Api.html",
"isInheritable": false,
"position": 10
}
],
"attachments": [],
"dirFileName": "Frontend API",
"children": [
@ -11112,11 +11140,18 @@
"notePosition": 10,
"prefix": null,
"isExpanded": false,
"type": "text",
"mime": "text/html",
"attributes": [],
"format": "markdown",
"dataFileName": "FNote.md",
"type": "webView",
"mime": "",
"attributes": [
{
"type": "label",
"name": "webViewSrc",
"value": "https://triliumnext.github.io/Notes/Script%20API/classes/Frontend_Script_API.FNote.html",
"isInheritable": false,
"position": 10
}
],
"dataFileName": "FNote.dat",
"attachments": []
}
]
@ -11134,11 +11169,18 @@
"notePosition": 20,
"prefix": null,
"isExpanded": false,
"type": "text",
"mime": "text/html",
"attributes": [],
"format": "markdown",
"dataFileName": "Backend API.md",
"type": "webView",
"mime": "",
"attributes": [
{
"type": "label",
"name": "webViewSrc",
"value": "https://triliumnext.github.io/Notes/Script%20API/interfaces/Backend_Script_API.Api.html",
"isInheritable": false,
"position": 10
}
],
"dataFileName": "Backend API.dat",
"attachments": []
}
]

View File

@ -57,7 +57,7 @@ These actions operate the <a class="reference-link" href="Attributes/Relations.
* **Rename note**
* For each note, it will change the title of the note to the given one.
* As a more advanced use case, the note can be a “template string” which allows for dynamic values with access to the note information via <a class="reference-link" href="../Scripting/Script%20API/Frontend%20API/FNote.md">FNote</a>, for example:
* As a more advanced use case, the note can be a “template string” which allows for dynamic values with access to the note information via <a class="reference-link" href="../Scripting/Script%20API/Frontend%20API/FNote.dat">FNote</a>, for example:
* `NEW: ${note.title}` will prefix all notes with `NEW:` .
* `${note.dateCreatedObj.format('MM-DD:')}: ${note.title}` will prefix the note titles with each note's creation date (in month-day format).
* **Move note**

View File

@ -17,7 +17,7 @@ And all children of "2022 Books" will be created with initial title "\[Author na
The value of `#titleTemplate` is evaluated at the point of note's creation as a JavaScript string, which means it can be enriched with the help of JS string interpolation with dynamic data.
Second variable injected is `parentNote` which gives access to the parent [`FNote`](../Scripting/Script%20API/Frontend%20API/FNote.md).
Second variable injected is `parentNote` which gives access to the parent [`FNote`](../Scripting/Script%20API/Frontend%20API/FNote.dat).
See also <a class="reference-link" href="Templates.md">Templates</a> which provides similar capabilities, including default note's content.

View File

@ -1,7 +1,19 @@
# Script API
Trilium offers a "Script API" that enables scripts to perform various useful functions. There are two main APIs available:
For [script code notes](../Scripting.md), Trilium offers an API that gives them access to various features of the application.
* [Frontend API](https://triliumnext.github.io/Notes/frontend_api/FrontendScriptApi.html)
* [Backend API](https://triliumnext.github.io/Notes/backend_api/BackendScriptApi.html)
There are two APIs:
Please note that the Script API is currently experimental and may undergo changes in future updates.
* One for the front-end scripts: <a class="reference-link" href="Script%20API/Frontend%20API">Frontend API</a>
* One for the back-end scripts: <a class="reference-link" href="Script%20API/Backend%20API.dat">Backend API</a>
In both cases, the API resides in a global variable, `api`, that can be used anywhere in the script.
For example, to display a message to the user the following front-end script can be used:
```
api.showMessage("Hello world.");
```
> [!NOTE]
> **Note**
> The Script API is currently experimental and may undergo changes in future updates.

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,20 @@
<p>Trilium offers a "Script API" that enables scripts to perform various
useful functions. There are two main APIs available:</p>
<p>For <a href="#root/pOsGYCXsbNQG/_help_CdNpE2pqjmI6">script code notes</a>,
Trilium offers an API that gives them access to various features of the
application.</p>
<p>There are two APIs:</p>
<ul>
<li><a href="https://triliumnext.github.io/Notes/frontend_api/FrontendScriptApi.html">Frontend API</a>
<li>One for the front-end scripts:&nbsp;<a class="reference-link" href="#root/pOsGYCXsbNQG/CdNpE2pqjmI6/GLks18SNjxmC/_help_Q2z6av6JZVWm">Frontend API</a>
</li>
<li><a href="https://triliumnext.github.io/Notes/backend_api/BackendScriptApi.html">Backend API</a>
<li>One for the back-end scripts:&nbsp;<a class="reference-link" href="#root/pOsGYCXsbNQG/CdNpE2pqjmI6/GLks18SNjxmC/_help_MEtfsqa5VwNi">Backend API</a>
</li>
</ul>
<p>Please note that the Script API is currently experimental and may undergo
changes in future updates.</p>
<p>In both cases, the API resides in a global variable, <code>api</code>,
that can be used anywhere in the script.</p>
<p>For example, to display a message to the user the following front-end
script can be used:</p><pre><code class="language-text-x-trilium-auto">api.showMessage("Hello world.");</code></pre>
<aside
class="admonition note">
<p><strong>Note</strong>
<br>The Script API is currently experimental and may undergo changes in future
updates.</p>
</aside>