Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix showing/hiding of type widgets
zadam41d1d83dc20e
diff --git a/src/public/javascripts/services/glob.js b/src/public/javascripts/services/glob.jsindex 4567f12056..0730a41318 100644--- a/src/public/javascripts/services/glob.js+++ b/src/public/javascripts/services/glob.js@@ -71,7 +71,7 @@ window.onerror = function (msg, url, lineNo, columnNo, error) {protectedSessionHolder.setProtectedSessionId(null);-for (const appCssNoteId of window.appCssNoteIds || []) {+for (const appCssNoteId of glob.appCssNoteIds || []) {libraryLoader.requireCss(`api/notes/download/${appCssNoteId}`);}diff --git a/src/public/javascripts/widgets/note_detail.js b/src/public/javascripts/widgets/note_detail.jsindex d19e20d9ba..076fc6c17c 100644--- a/src/public/javascripts/widgets/note_detail.js+++ b/src/public/javascripts/widgets/note_detail.js@@ -101,7 +101,7 @@ export default class NoteDetailWidget extends TabAwareWidget {this.toggle(true);this.type = await this.getWidgetType();- this.mime = this.note.mime;+ this.mime = this.note ? this.note.mime : null;if (!(this.type in this.typeWidgets)) {const clazz = typeWidgetClasses[this.type];@@ -164,6 +164,8 @@ export default class NoteDetailWidget extends TabAwareWidget {const noteComplement = await this.tabContext.getNoteComplement();+ console.log(note, noteComplement);+if (utils.isHtmlEmpty(noteComplement.content)) {type = 'book';}diff --git a/src/public/javascripts/widgets/type_widgets/empty.js b/src/public/javascripts/widgets/type_widgets/empty.jsindex 5316040b93..b166b0527b 100644--- a/src/public/javascripts/widgets/type_widgets/empty.js+++ b/src/public/javascripts/widgets/type_widgets/empty.js@@ -36,10 +36,6 @@ export default class EmptyTypeWidget extends TypeWidget {return this.$widget;}- refresh() {- this.toggle(!this.tabContext.note);- }-getContent() {}focus() {}diff --git a/src/public/javascripts/widgets/type_widgets/type_widget.js b/src/public/javascripts/widgets/type_widgets/type_widget.jsindex c5edd622dc..e423292861 100644--- a/src/public/javascripts/widgets/type_widgets/type_widget.js+++ b/src/public/javascripts/widgets/type_widgets/type_widget.js@@ -1,6 +1,13 @@import TabAwareWidget from "../tab_aware_widget.js";export default class TypeWidget extends TabAwareWidget {+ constructor(parent) {+ super(parent);++ /** @var {NoteDetailWidget} */+ this.noteDetailWidget = parent;+ }+// for overridingstatic getType() {}@@ -10,13 +17,9 @@ export default class TypeWidget extends TabAwareWidget {doRefresh(note) {}refresh() {- const note = this.tabContext.note;const widgetType = this.constructor.getType();- if (!note- || (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))) {+ if (widgetType !== this.noteDetailWidget.type) {this.toggle(false);this.cleanup();@@ -24,7 +27,7 @@ export default class TypeWidget extends TabAwareWidget {else {this.toggle(true);- this.doRefresh(note);+ this.doRefresh(this.note);}}