mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	fix showing/hiding of type widgets
This commit is contained in:
		@@ -71,7 +71,7 @@ window.onerror = function (msg, url, lineNo, columnNo, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
protectedSessionHolder.setProtectedSessionId(null);
 | 
					protectedSessionHolder.setProtectedSessionId(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for (const appCssNoteId of window.appCssNoteIds || []) {
 | 
					for (const appCssNoteId of glob.appCssNoteIds || []) {
 | 
				
			||||||
    libraryLoader.requireCss(`api/notes/download/${appCssNoteId}`);
 | 
					    libraryLoader.requireCss(`api/notes/download/${appCssNoteId}`);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -101,7 +101,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
 | 
				
			|||||||
        this.toggle(true);
 | 
					        this.toggle(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.type = await this.getWidgetType();
 | 
					        this.type = await this.getWidgetType();
 | 
				
			||||||
        this.mime = this.note.mime;
 | 
					        this.mime = this.note ? this.note.mime : null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!(this.type in this.typeWidgets)) {
 | 
					        if (!(this.type in this.typeWidgets)) {
 | 
				
			||||||
            const clazz = typeWidgetClasses[this.type];
 | 
					            const clazz = typeWidgetClasses[this.type];
 | 
				
			||||||
@@ -164,6 +164,8 @@ export default class NoteDetailWidget extends TabAwareWidget {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            const noteComplement = await this.tabContext.getNoteComplement();
 | 
					            const noteComplement = await this.tabContext.getNoteComplement();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            console.log(note, noteComplement);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (utils.isHtmlEmpty(noteComplement.content)) {
 | 
					            if (utils.isHtmlEmpty(noteComplement.content)) {
 | 
				
			||||||
                type = 'book';
 | 
					                type = 'book';
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,10 +36,6 @@ export default class EmptyTypeWidget extends TypeWidget {
 | 
				
			|||||||
        return this.$widget;
 | 
					        return this.$widget;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    refresh() {
 | 
					 | 
				
			||||||
        this.toggle(!this.tabContext.note);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    getContent() {}
 | 
					    getContent() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    focus() {}
 | 
					    focus() {}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,13 @@
 | 
				
			|||||||
import TabAwareWidget from "../tab_aware_widget.js";
 | 
					import TabAwareWidget from "../tab_aware_widget.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class TypeWidget extends TabAwareWidget {
 | 
					export default class TypeWidget extends TabAwareWidget {
 | 
				
			||||||
 | 
					    constructor(parent) {
 | 
				
			||||||
 | 
					        super(parent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /** @var {NoteDetailWidget} */
 | 
				
			||||||
 | 
					        this.noteDetailWidget = parent;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // for overriding
 | 
					    // for overriding
 | 
				
			||||||
    static getType() {}
 | 
					    static getType() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -10,13 +17,9 @@ export default class TypeWidget extends TabAwareWidget {
 | 
				
			|||||||
    doRefresh(note) {}
 | 
					    doRefresh(note) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    refresh() {
 | 
					    refresh() {
 | 
				
			||||||
        const note = this.tabContext.note;
 | 
					 | 
				
			||||||
        const widgetType = this.constructor.getType();
 | 
					        const widgetType = this.constructor.getType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!note
 | 
					        if (widgetType !== this.noteDetailWidget.type) {
 | 
				
			||||||
            || (note.type !== widgetType
 | 
					 | 
				
			||||||
                && (note.type !== 'text' || widgetType !== 'book') // text can be rendered as book if it does not have content
 | 
					 | 
				
			||||||
                && (widgetType !== 'protected-session' || !note.isProtected))) {
 | 
					 | 
				
			||||||
            this.toggle(false);
 | 
					            this.toggle(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            this.cleanup();
 | 
					            this.cleanup();
 | 
				
			||||||
@@ -24,7 +27,7 @@ export default class TypeWidget extends TabAwareWidget {
 | 
				
			|||||||
        else {
 | 
					        else {
 | 
				
			||||||
            this.toggle(true);
 | 
					            this.toggle(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            this.doRefresh(note);
 | 
					            this.doRefresh(this.note);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user