mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	fix loading of custom widgets
This commit is contained in:
		@@ -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() {
 | 
					async function getWidgetBundlesByParent() {
 | 
				
			||||||
    const scriptBundles = await server.get("script/widgets");
 | 
					    const scriptBundles = await server.get("script/widgets");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const byParent = {};
 | 
					    const widgetsByParent = new WidgetsByParent();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (const bundle of scriptBundles) {
 | 
					    for (const bundle of scriptBundles) {
 | 
				
			||||||
        let widget;
 | 
					        let widget;
 | 
				
			||||||
@@ -46,16 +66,10 @@ async function getWidgetBundlesByParent() {
 | 
				
			|||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!widget.parentWidget) {
 | 
					        widgetsByParent.add(widget);
 | 
				
			||||||
            console.log(`Custom widget does not have mandatory 'getParent()' method defined`);
 | 
					 | 
				
			||||||
            continue;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        byParent[widget.parentWidget] = byParent[widget.parentWidget] || [];
 | 
					    return widgetsByParent;
 | 
				
			||||||
        byParent[widget.parentWidget].push(widget);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return byParent;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -148,7 +148,7 @@ export default class DesktopLayout {
 | 
				
			|||||||
                    .child(new TabCachingWidget(() => new NoteRevisionsWidget()))
 | 
					                    .child(new TabCachingWidget(() => new NoteRevisionsWidget()))
 | 
				
			||||||
                    .child(new TabCachingWidget(() => new SimilarNotesWidget()))
 | 
					                    .child(new TabCachingWidget(() => new SimilarNotesWidget()))
 | 
				
			||||||
                    .child(new TabCachingWidget(() => new WhatLinksHereWidget()))
 | 
					                    .child(new TabCachingWidget(() => new WhatLinksHereWidget()))
 | 
				
			||||||
                    .child(...this.customWidgets['right-pane'])
 | 
					                    .child(...this.customWidgets.get('right-pane'))
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
                .child(new SidePaneToggles().hideInZenMode())
 | 
					                .child(new SidePaneToggles().hideInZenMode())
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,10 @@ export default class FlexContainer extends BasicWidget {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    child(...components) {
 | 
					    child(...components) {
 | 
				
			||||||
 | 
					        if (!components) {
 | 
				
			||||||
 | 
					            return this;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        super.child(...components);
 | 
					        super.child(...components);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (const component of components) {
 | 
					        for (const component of components) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,6 +33,7 @@ async function createMainWindow() {
 | 
				
			|||||||
        height: mainWindowState.height,
 | 
					        height: mainWindowState.height,
 | 
				
			||||||
        title: 'Trilium Notes',
 | 
					        title: 'Trilium Notes',
 | 
				
			||||||
        webPreferences: {
 | 
					        webPreferences: {
 | 
				
			||||||
 | 
					            enableRemoteModule: true,
 | 
				
			||||||
            nodeIntegration: true,
 | 
					            nodeIntegration: true,
 | 
				
			||||||
            spellcheck: spellcheckEnabled
 | 
					            spellcheck: spellcheckEnabled
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user