diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 5e4c3e3fd..1d3c7231c 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -851,6 +851,10 @@ export default class NoteTreeWidget extends TabAwareWidget { if (!foundChildNode) { if (logErrors) { + // besides real errors this can be also caused by hiding of e.g. included images + // these are real notes with real notePath, user can display them in a detail + // but they don't have a node in the tree + ws.logError(`Can't find node for child node of noteId=${childNoteId} for parent of noteId=${parentNode.data.noteId} and hoistedNoteId=${hoistedNoteId}, requested path is ${notePath}`); } diff --git a/src/services/note_cache/entities/note.js b/src/services/note_cache/entities/note.js index a00682b29..6fa8ca937 100644 --- a/src/services/note_cache/entities/note.js +++ b/src/services/note_cache/entities/note.js @@ -160,7 +160,7 @@ class Note { return this.flatTextCache; } - this.flatTextCache = this.noteId + ' '; + this.flatTextCache = this.noteId + ' ' + this.type + ' ' + this.mime; for (const branch of this.parentBranches) { if (branch.prefix) { diff --git a/src/services/search/expressions/note_cache_flat_text.js b/src/services/search/expressions/note_cache_flat_text.js index c503d7653..944316140 100644 --- a/src/services/search/expressions/note_cache_flat_text.js +++ b/src/services/search/expressions/note_cache_flat_text.js @@ -36,6 +36,12 @@ class NoteCacheFlatTextExp extends Expression { const foundAttrTokens = []; + for (const token of tokens) { + if (note.type.includes(token) || note.mime.includes(token)) { + foundAttrTokens.push(token); + } + } + for (const attribute of note.ownedAttributes) { for (const token of tokens) { if (attribute.name.toLowerCase().includes(token) @@ -77,10 +83,18 @@ class NoteCacheFlatTextExp extends Expression { const foundAttrTokens = []; + for (const token of this.tokens) { + if (note.type.includes(token) || note.mime.includes(token)) { + foundAttrTokens.push(token); + } + } + for (const attribute of note.ownedAttributes) { + const lcName = attribute.name.toLowerCase(); + const lcValue = attribute.value.toLowerCase(); + for (const token of this.tokens) { - if (attribute.name.toLowerCase().includes(token) - || attribute.value.toLowerCase().includes(token)) { + if (lcName.includes(token) || lcValue.includes(token)) { foundAttrTokens.push(token); } } diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js index 1b2b27e71..51b45bedd 100644 --- a/src/services/search/services/search.js +++ b/src/services/search/services/search.js @@ -146,6 +146,14 @@ function highlightSearchResults(searchResults, highlightedTokens) { result.highlightedNotePathTitle = result.notePathTitle; + if (highlightedTokens.find(token => note.type.includes(token))) { + result.highlightedNotePathTitle += ` type: ${note.type}`; + } + + if (highlightedTokens.find(token => note.mime.includes(token))) { + result.highlightedNotePathTitle += ` mime: ${note.mime}`; + } + for (const attr of note.attributes) { if (highlightedTokens.find(token => attr.name.includes(token) || attr.value.includes(token))) { result.highlightedNotePathTitle += ` ${formatAttribute(attr)}`;