fix(scripting): RightPanelWidget requiring async doRenderBody (closes #7778)

This commit is contained in:
Elian Doran 2025-11-19 22:10:42 +02:00
parent 5da4762f40
commit 0d0448d86b
No known key found for this signature in database
6 changed files with 28 additions and 10 deletions

View File

@ -66,9 +66,14 @@ class RightPanelWidget extends NoteContextAwareWidget {
this.$buttons.append((buttonWidget as BasicWidget).render()); this.$buttons.append((buttonWidget as BasicWidget).render());
} }
this.initialized = this.doRenderBody().catch((e) => { const renderResult = this.doRenderBody();
this.logRenderingError(e); if (typeof renderResult === "object" && "catch" in renderResult) {
}); this.initialized = renderResult.catch((e) => {
this.logRenderingError(e);
});
} else {
this.initialized = Promise.resolve();
}
} }
/** /**
@ -77,7 +82,7 @@ class RightPanelWidget extends NoteContextAwareWidget {
* Your class should override this method. * Your class should override this method.
* @returns {Promise|undefined} if widget needs async operation to initialize, it can return a Promise * @returns {Promise|undefined} if widget needs async operation to initialize, it can return a Promise
*/ */
async doRenderBody() {} doRenderBody(): Promise<void> | void {}
} }
export default RightPanelWidget; export default RightPanelWidget;

View File

@ -16,7 +16,7 @@
- traefik.http.middlewares.trilium-headers.headers.customrequestheaders.X-Forwarded-Proto=https</code></pre> - traefik.http.middlewares.trilium-headers.headers.customrequestheaders.X-Forwarded-Proto=https</code></pre>
<h3>Setup needed environment variables</h3> <h3>Setup needed environment variables</h3>
<p>After setting up a reverse proxy, make sure to configure the&nbsp;<a class="reference-link" <p>After setting up a reverse proxy, make sure to configure the&nbsp;<a class="reference-link"
href="Trusted%20proxy.md">[missing note]</a>.</p> href="#root/_help_LLzSMXACKhUs">[missing note]</a>.</p>
<h3>Example <code>docker-compose.yaml</code></h3><pre><code class="language-text-x-yaml">services: <h3>Example <code>docker-compose.yaml</code></h3><pre><code class="language-text-x-yaml">services:
trilium: trilium:
image: triliumnext/trilium image: triliumnext/trilium

View File

@ -1,8 +1,13 @@
<ul> <ul>
<li><code>doRender</code> must not be overridden, instead <code>doRenderBody()</code> has <li data-list-item-id="ef125f092e6b27dc2c8486d195be8be39"><code>doRender</code> must not be overridden, instead <code>doRenderBody()</code> has
to be overridden.</li> to be overridden.
<li><code>parentWidget()</code> must be set to <code>“rightPane”</code>.</li> <ul>
<li><code>widgetTitle()</code> getter can optionally be overriden, otherwise <li data-list-item-id="e632e4415d4439f862124dc2e024093db"><code>doRenderBody</code> can optionally be <code>async</code>.</li>
</ul>
</li>
<li data-list-item-id="eef79d03bdc04d4869f6ee69f9086931f"><code>parentWidget()</code> must be set to <code>“rightPane”</code>.</li>
<li
data-list-item-id="e1bbd084dfcfdea1a8061159b8dcffd44"><code>widgetTitle()</code> getter can optionally be overriden, otherwise
the widget will be displayed as “Untitled widget”.</li> the widget will be displayed as “Untitled widget”.</li>
</ul><pre><code class="language-text-x-trilium-auto">const template = `&lt;div&gt;Hi&lt;/div&gt;`; </ul><pre><code class="language-text-x-trilium-auto">const template = `&lt;div&gt;Hi&lt;/div&gt;`;

View File

@ -1,5 +1,5 @@
# Documentation # Documentation
There are multiple types of documentation for Trilium:<img class="image-style-align-right" src="api/images/eyrnitqBQ2w6/Documentation_image.png" width="205" height="162"> There are multiple types of documentation for Trilium:<img class="image-style-align-right" src="api/images/veLUtimyaTkr/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 _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. * The _Developer's Guide_ represents a set of Markdown documents that present the internals of Trilium, for developers.

View File

@ -1069,6 +1069,13 @@
"type": "text", "type": "text",
"mime": "text/html", "mime": "text/html",
"attributes": [ "attributes": [
{
"type": "relation",
"name": "internalLink",
"value": "LLzSMXACKhUs",
"isInheritable": false,
"position": 10
},
{ {
"type": "label", "type": "label",
"name": "shareAlias", "name": "shareAlias",

View File

@ -1,5 +1,6 @@
# Right pane widget # Right pane widget
* `doRender` must not be overridden, instead `doRenderBody()` has to be overridden. * `doRender` must not be overridden, instead `doRenderBody()` has to be overridden.
* `doRenderBody` can optionally be `async`.
* `parentWidget()` must be set to `“rightPane”`. * `parentWidget()` must be set to `“rightPane”`.
* `widgetTitle()` getter can optionally be overriden, otherwise the widget will be displayed as “Untitled widget”. * `widgetTitle()` getter can optionally be overriden, otherwise the widget will be displayed as “Untitled widget”.