diff --git a/package-lock.json b/package-lock.json index 586f3cc72..b3a30d031 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4122,9 +4122,9 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==" }, "helmet": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/helmet/-/helmet-4.3.1.tgz", - "integrity": "sha512-WsafDyKsIexB0+pUNkq3rL1rB5GVAghR68TP8ssM9DPEMzfBiluEQlVzJ/FEj6Vq2Ag3CNuxf7aYMjXrN0X49Q==" + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/helmet/-/helmet-4.4.1.tgz", + "integrity": "sha512-G8tp0wUMI7i8wkMk2xLcEvESg5PiCitFMYgGRc/PwULB0RVhTP5GFdxOwvJwp9XVha8CuS8mnhmE8I/8dx/pbw==" }, "hosted-git-info": { "version": "2.8.5", diff --git a/package.json b/package.json index 735632269..47dcdfc3b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "express": "4.17.1", "express-session": "1.17.1", "fs-extra": "9.0.1", - "helmet": "4.3.1", + "helmet": "4.4.1", "html": "1.0.0", "html2plaintext": "2.1.2", "http-proxy-agent": "4.0.1", diff --git a/src/public/app/services/date_notes.js b/src/public/app/services/date_notes.js index 42a9a46bd..7b46497c7 100644 --- a/src/public/app/services/date_notes.js +++ b/src/public/app/services/date_notes.js @@ -47,7 +47,7 @@ async function createSearchNote(opts = {}) { const note = await server.post('search-note'); const attrsToUpdate = [ - opts.subTreeNoteId ? { type: 'label', name: 'subTreeNoteId', value: opts.subTreeNoteId } : undefined, + opts.ancestor ? { type: 'relation', name: 'ancestor', value: opts.ancestorNoteId } : undefined, opts.searchString ? { type: 'label', name: 'searchString', value: opts.searchString } : undefined ].filter(attr => !!attr); diff --git a/src/public/app/services/dialog_command_executor.js b/src/public/app/services/dialog_command_executor.js index f422d8df3..2b149f5db 100644 --- a/src/public/app/services/dialog_command_executor.js +++ b/src/public/app/services/dialog_command_executor.js @@ -67,8 +67,8 @@ export default class DialogCommandExecutor extends Component { appContext.triggerCommand('focusOnDetail', {tabId: tabContext.tabId}); } - async searchNotesCommand({searchString, subTreeNoteId}) { - const searchNote = await dateNoteService.createSearchNote({searchString, subTreeNoteId}); + async searchNotesCommand({searchString, ancestorNoteId}) { + const searchNote = await dateNoteService.createSearchNote({searchString, ancestorNoteId}); const tabContext = await appContext.tabManager.openTabWithNote(searchNote.noteId, true); @@ -78,7 +78,7 @@ export default class DialogCommandExecutor extends Component { async searchInSubtreeCommand({notePath}) { const noteId = treeService.getNoteIdFromNotePath(notePath); - this.searchNotesCommand({subTreeNoteId: noteId}); + this.searchNotesCommand({ancestorNoteId: noteId}); } showBackendLogCommand() { diff --git a/src/public/app/services/note_autocomplete.js b/src/public/app/services/note_autocomplete.js index 6d847a1cd..4afcf07dd 100644 --- a/src/public/app/services/note_autocomplete.js +++ b/src/public/app/services/note_autocomplete.js @@ -23,6 +23,8 @@ async function autocompleteSourceForCKEditor(queryText) { highlightedNotePathTitle: row.highlightedNotePathTitle } })); + }, { + allowCreatingNotes: true }); }); } @@ -34,7 +36,7 @@ async function autocompleteSource(term, cb, options = {}) { + '?query=' + encodeURIComponent(term) + '&activeNoteId=' + activeNoteId); - if (term.trim().length >= 1) { + if (term.trim().length >= 1 && options.allowCreatingNotes) { results = [ { action: 'create-note', diff --git a/src/public/app/widgets/note_list.js b/src/public/app/widgets/note_list.js index 29eb17fdd..2a050bade 100644 --- a/src/public/app/widgets/note_list.js +++ b/src/public/app/widgets/note_list.js @@ -48,6 +48,10 @@ export default class NoteListWidget extends TabAwareWidget { } checkRenderStatus() { + // console.log("this.isIntersecting", this.isIntersecting); + // console.log(`${this.noteIdRefreshed} === ${this.noteId}`, this.noteIdRefreshed === this.noteId); + // console.log("this.shownNoteId !== this.noteId", this.shownNoteId !== this.noteId); + if (this.isIntersecting && this.noteIdRefreshed === this.noteId && this.shownNoteId !== this.noteId) { @@ -62,6 +66,11 @@ export default class NoteListWidget extends TabAwareWidget { await noteListRenderer.renderList(); } + /** + * We have this event so that we evaluate intersection only after note detail is loaded. + * If it's evaluated before note detail then it's clearly intersected (visible) although after note detail load + * it is not intersected (visible) anymore. + */ noteDetailRefreshedEvent({tabId}) { if (!this.isTab(tabId)) { return; @@ -72,6 +81,17 @@ export default class NoteListWidget extends TabAwareWidget { setTimeout(() => this.checkRenderStatus(), 100); } + searchRefreshedEvent({tabId}) { + if (!this.isTab(tabId)) { + return; + } + + this.noteIdRefreshed = this.noteId; + this.shownNoteId = null; + + this.checkRenderStatus(); + } + autoBookDisabledEvent({tabContext}) { if (this.isTab(tabContext.tabId)) { this.refresh(); diff --git a/src/public/app/widgets/search_definition.js b/src/public/app/widgets/search_definition.js index b85405ee4..e7db8f0c1 100644 --- a/src/public/app/widgets/search_definition.js +++ b/src/public/app/widgets/search_definition.js @@ -4,6 +4,7 @@ import server from "../services/server.js"; import TabAwareWidget from "./tab_aware_widget.js"; import treeCache from "../services/tree_cache.js"; import ws from "../services/ws.js"; +import utils from "../services/utils.js"; const TPL = `