From 528d94a8fb1712e5cd2fcd42eef54d703b3f86f3 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 25 Sep 2023 23:05:54 +0200 Subject: [PATCH] accept custom widgets as classes instead of instances, #4274 --- src/public/app/services/bundle.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/public/app/services/bundle.js b/src/public/app/services/bundle.js index a55abfe4a4..51348111a2 100644 --- a/src/public/app/services/bundle.js +++ b/src/public/app/services/bundle.js @@ -53,7 +53,15 @@ class WidgetsByParent { } get(parentName) { - return this.byParent[parentName] || []; + if (!this.byParent[parentName]) { + return []; + } + + return this.byParent[parentName] + // previously, custom widgets were provided as a single instance, but that has the disadvantage + // for splits where we actually need multiple instaces and thus having a class to instantiate is better + // https://github.com/zadam/trilium/issues/4274 + .map(w => w.prototype ? new w() : w); } }