mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
widgets are respecting positions
This commit is contained in:
parent
3e3d111d76
commit
d039a5f24e
@ -79,14 +79,23 @@ class Sidebar {
|
||||
const widget = new widgetClass(this.ctx, options, state);
|
||||
|
||||
if (await widget.isEnabled()) {
|
||||
const $el = await widget.render();
|
||||
|
||||
this.widgets.push(widget);
|
||||
this.$widgetContainer.append($el);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
messagingService.logError(`Error while loading widget ${widgetClass.name}: ${e.message}`);
|
||||
messagingService.logError(`Error while creating widget ${widgetClass.name}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
this.widgets.sort((a, b) => a.getPosition() < b.getPosition() ? -1 : 1);
|
||||
|
||||
for (const widget of this.widgets) {
|
||||
try {
|
||||
const $el = await widget.render();
|
||||
this.$widgetContainer.append($el);
|
||||
}
|
||||
catch (e) {
|
||||
messagingService.logError(`Error while loading widget ${widget.widgetName}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ class StandardWidget {
|
||||
|
||||
getMaxHeight() { return null; }
|
||||
|
||||
getPosition() { return this.widgetOptions.position; }
|
||||
|
||||
async render() {
|
||||
const widgetId = `tab-${this.ctx.tabId}-widget-${this.widgetName}`;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user