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
small fixes
zadam8651e47118d0
diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.jsindex 34da729856..0a0ac58b23 100644--- a/src/public/javascripts/services/note_detail.js+++ b/src/public/javascripts/services/note_detail.js@@ -8,8 +8,6 @@ import treeUtils from "./tree_utils.js";import tabRow from "../widgets/tab_row.js";import appContext from "./app_context.js";-const $savedIndicator = $(".saved-indicator");-let detailLoadedListeners = [];async function reload() {@@ -32,10 +30,6 @@ async function switchToNote(notePath) {appContext.openTabsChanged();}-function onNoteChange(func) {- return appContext.getActiveTabContext().getComponent().onNoteChange(func);-}-function getActiveEditor() {const activeTabContext = appContext.getActiveTabContext();@@ -212,7 +206,6 @@ export default {loadNoteDetail,focusOnTitle,focusAndSelectTitle,- onNoteChange,addDetailLoadedListener,getActiveEditor,activateOrOpenNote,diff --git a/src/public/javascripts/widgets/type_widgets/book.js b/src/public/javascripts/widgets/type_widgets/book.jsindex 515f995e79..074a68cb03 100644--- a/src/public/javascripts/widgets/type_widgets/book.js+++ b/src/public/javascripts/widgets/type_widgets/book.js@@ -205,7 +205,7 @@ export default class BookTypeWidget extends TypeWidget {this.$content.append($('<div class="note-book-auto-message"></div>').append(`This note doesn't have any content so we display its children. Click `).append($addTextLink)- .append(' if you want to add some text.'))+ .append(' if you want to add some text.'));}const zoomLevel = parseInt(await note.getLabelValue('bookZoomLevel')) || this.getDefaultZoomLevel();diff --git a/src/public/javascripts/widgets/type_widgets/code.js b/src/public/javascripts/widgets/type_widgets/code.jsindex 99ab0fe530..ffb2c20790 100644--- a/src/public/javascripts/widgets/type_widgets/code.js+++ b/src/public/javascripts/widgets/type_widgets/code.js@@ -71,12 +71,12 @@ export default class CodeTypeWidget extends TypeWidget {//this.onNoteChange(() => this.tabContext.noteChanged());}- doRefresh() {+ doRefresh(note) {// CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check)// we provide fallback- this.codeEditor.setValue(this.tabContext.note.content || "");+ this.codeEditor.setValue(note.content || "");- const info = CodeMirror.findModeByMIME(this.tabContext.note.mime);+ const info = CodeMirror.findModeByMIME(note.mime);if (info) {this.codeEditor.setOption("mode", info.mime);diff --git a/src/public/javascripts/widgets/type_widgets/file.js b/src/public/javascripts/widgets/type_widgets/file.jsindex 02c445a819..0b74b3f7ac 100644--- a/src/public/javascripts/widgets/type_widgets/file.js+++ b/src/public/javascripts/widgets/type_widgets/file.js@@ -117,27 +117,27 @@ export default class FileTypeWidget extends TypeWidget {return this.$widget;}- async doRefresh() {- const attributes = await server.get('notes/' + this.tabContext.note.noteId + '/attributes');+ async doRefresh(note) {+ const attributes = await server.get('notes/' + note.noteId + '/attributes');const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);this.$widget.show();- this.$fileNoteId.text(this.tabContext.note.noteId);+ this.$fileNoteId.text(note.noteId);this.$fileName.text(attributeMap.originalFileName || "?");- this.$fileSize.text(this.tabContext.note.contentLength + " bytes");- this.$fileType.text(this.tabContext.note.mime);+ this.$fileSize.text(note.contentLength + " bytes");+ this.$fileType.text(note.mime);- if (this.tabContext.note.content) {+ if (note.content) {this.$previewContent.show();- this.$previewContent.text(this.tabContext.note.content);+ this.$previewContent.text(note.content);}else {this.$previewContent.empty().hide();}// open doesn't work for protected notes since it works through browser which isn't in protected session- this.$openButton.toggle(!this.tabContext.note.isProtected);+ this.$openButton.toggle(!note.isProtected);}getFileUrl() {diff --git a/src/public/javascripts/widgets/type_widgets/image.js b/src/public/javascripts/widgets/type_widgets/image.jsindex dbae149677..8298681739 100644--- a/src/public/javascripts/widgets/type_widgets/image.js+++ b/src/public/javascripts/widgets/type_widgets/image.js@@ -122,8 +122,7 @@ class NoteDetailImage extends TypeWidget {return this.$widget;}- async doRefresh() {- const note = this.tabContext.note;+ async doRefresh(note) {const attributes = await server.get('notes/' + note.noteId + '/attributes');const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);diff --git a/src/public/javascripts/widgets/type_widgets/protected_session.js b/src/public/javascripts/widgets/type_widgets/protected_session.jsindex 8844582fc2..195f0b9f20 100644--- a/src/public/javascripts/widgets/type_widgets/protected_session.js+++ b/src/public/javascripts/widgets/type_widgets/protected_session.js@@ -40,10 +40,6 @@ export default class ProtectedSessionTypeWidget extends TypeWidget {return this.$widget;}- render() {- this.$widget.show();- }-show() {}getContent() {}diff --git a/src/public/javascripts/widgets/type_widgets/relation_map.js b/src/public/javascripts/widgets/type_widgets/relation_map.jsindex 10c14b2f10..16354e6a89 100644--- a/src/public/javascripts/widgets/type_widgets/relation_map.js+++ b/src/public/javascripts/widgets/type_widgets/relation_map.js@@ -181,6 +181,12 @@ export default class RelationMapTypeWidget extends TypeWidget {this.$widget.on("drop", ev => this.dropNoteOntoRelationMapHandler(ev));this.$widget.on("dragover", ev => ev.preventDefault());+ this.initialized = new Promise(async res => {+ await libraryLoader.requireLibrary(libraryLoader.RELATION_MAP);++ jsPlumb.ready(res);+ });+return this.$widget;}@@ -264,24 +270,14 @@ export default class RelationMapTypeWidget extends TypeWidget {return id.substr(13);}- async doRefresh() {- this.$widget.show();-- await libraryLoader.requireLibrary(libraryLoader.RELATION_MAP);+ async doRefresh(note) {+ this.loadMapData();- jsPlumb.ready(() => {- // lazy loading above can take time and tab might have been already switched to another note- if (this.tabContext.note && this.tabContext.note.type === 'relation-map') {- this.loadMapData();+ this.initJsPlumbInstance();- this.initJsPlumbInstance();-- this.initPanZoom();-- this.loadNotesAndRelations();- }- });+ this.initPanZoom();+ this.loadNotesAndRelations();}clearMap() {diff --git a/src/public/javascripts/widgets/type_widgets/render.js b/src/public/javascripts/widgets/type_widgets/render.jsindex 19258f6738..44fad26642 100644--- a/src/public/javascripts/widgets/type_widgets/render.js+++ b/src/public/javascripts/widgets/type_widgets/render.js@@ -26,11 +26,12 @@ export default class RenderTypeWidget extends TypeWidget {return this.$widget;}- async doRefresh() {+ async doRefresh(note) {this.$widget.show();this.$noteDetailRenderHelp.hide();- const renderNotesFound = await renderService.render(this.ctx.note, this.$noteDetailRenderContent, this.ctx);+ // FIXME this.ctx+ const renderNotesFound = await renderService.render(note, this.$noteDetailRenderContent, this.ctx);if (!renderNotesFound) {this.$noteDetailRenderHelp.show();diff --git a/src/public/javascripts/widgets/type_widgets/search.js b/src/public/javascripts/widgets/type_widgets/search.jsindex b7bddda14d..d89ac418a2 100644--- a/src/public/javascripts/widgets/type_widgets/search.js+++ b/src/public/javascripts/widgets/type_widgets/search.js@@ -39,13 +39,13 @@ export default class SearchTypeWidget extends TypeWidget {return this.$widget;}- doRefresh() {+ doRefresh(note) {this.$help.html(searchNotesService.getHelpText());this.$component.show();try {- const json = JSON.parse(this.ctx.note.content);+ const json = JSON.parse(note.content);this.$searchString.val(json.searchString);}@@ -54,7 +54,7 @@ export default class SearchTypeWidget extends TypeWidget {this.$searchString.val('');}- this.$searchString.on('input', () => this.ctx.noteChanged());+ this.$searchString.on('input', () => this.noteChanged());}getContent() {diff --git a/src/public/javascripts/widgets/type_widgets/text.js b/src/public/javascripts/widgets/type_widgets/text.jsindex 0b382b48b3..189d982dc3 100644--- a/src/public/javascripts/widgets/type_widgets/text.js+++ b/src/public/javascripts/widgets/type_widgets/text.js@@ -134,12 +134,12 @@ export default class TextTypeWidget extends TypeWidget {}}- async doRefresh() {+ async doRefresh(note) {this.textEditor.isReadOnly = await this.isReadOnly();this.$widget.show();- this.textEditor.setData(this.tabContext.note.content);+ this.textEditor.setData(note.content);}getContent() {