Skip to content

Build your personal knowledge base with Trilium Notes

fix loading of custom widgets

zadam141d4593caa5
diff --git a/src/public/javascripts/services/bundle.js b/src/public/javascripts/services/bundle.js
index 420bbafe02..8ee8246296 100644
--- a/src/public/javascripts/services/bundle.js
+++ b/src/public/javascripts/services/bundle.js
@@ -30,10 +30,30 @@ async function executeStartupBundles() {
}
}
+class WidgetsByParent {
+ constructor() {
+ this.byParent = {};
+ }
+
+ add(widget) {
+ if (!widget.parentWidget) {
+ console.log(`Custom widget does not have mandatory 'getParent()' method defined`);
+ return;
+ }
+
+ this.byParent[widget.parentWidget] = this.byParent[widget.parentWidget] || [];
+ this.byParent[widget.parentWidget].push(widget);
+ }
+
+ get(parentName) {
+ return this.byParent[parentName] || [];
+ }
+}
+
async function getWidgetBundlesByParent() {
const scriptBundles = await server.get("script/widgets");
- const byParent = {};
+ const widgetsByParent = new WidgetsByParent();
for (const bundle of scriptBundles) {
let widget;
@@ -46,16 +66,10 @@ async function getWidgetBundlesByParent() {
continue;
}
- if (!widget.parentWidget) {
- console.log(`Custom widget does not have mandatory 'getParent()' method defined`);
- continue;
- }
-
- byParent[widget.parentWidget] = byParent[widget.parentWidget] || [];
- byParent[widget.parentWidget].push(widget);
+ widgetsByParent.add(widget);
}
- return byParent;
+ return widgetsByParent;
}
export default {
diff --git a/src/public/javascripts/widgets/desktop_layout.js b/src/public/javascripts/widgets/desktop_layout.js
index 9d0f3fbf8f..73e7038126 100644
--- a/src/public/javascripts/widgets/desktop_layout.js
+++ b/src/public/javascripts/widgets/desktop_layout.js
@@ -148,7 +148,7 @@ export default class DesktopLayout {
.child(new TabCachingWidget(() => new NoteRevisionsWidget()))
.child(new TabCachingWidget(() => new SimilarNotesWidget()))
.child(new TabCachingWidget(() => new WhatLinksHereWidget()))
- .child(...this.customWidgets['right-pane'])
+ .child(...this.customWidgets.get('right-pane'))
)
.child(new SidePaneToggles().hideInZenMode())
);
diff --git a/src/public/javascripts/widgets/flex_container.js b/src/public/javascripts/widgets/flex_container.js
index c9f591c3bf..311071201b 100644
--- a/src/public/javascripts/widgets/flex_container.js
+++ b/src/public/javascripts/widgets/flex_container.js
@@ -16,6 +16,10 @@ export default class FlexContainer extends BasicWidget {
}
child(...components) {
+ if (!components) {
+ return this;
+ }
+
super.child(...components);
for (const component of components) {
diff --git a/src/services/window.js b/src/services/window.js
index f9cd530bab..098e1b8644 100644
--- a/src/services/window.js
+++ b/src/services/window.js
@@ -33,6 +33,7 @@ async function createMainWindow() {
height: mainWindowState.height,
title: 'Trilium Notes',
webPreferences: {
+ enableRemoteModule: true,
nodeIntegration: true,
spellcheck: spellcheckEnabled
},