diff --git a/src/public/app/services/froca.js b/src/public/app/services/froca.js
index 91af4f1b2..e06386772 100644
--- a/src/public/app/services/froca.js
+++ b/src/public/app/services/froca.js
@@ -176,7 +176,7 @@ class Froca {
return;
}
- const searchResultNoteIds = await server.get('search-note/' + note.noteId);
+ const {searchResultNoteIds, highlightedTokens} = await server.get('search-note/' + note.noteId);
if (!Array.isArray(searchResultNoteIds)) {
throw new Error(`Search note '${note.noteId}' failed: ${searchResultNoteIds}`);
@@ -207,6 +207,7 @@ class Froca {
});
froca.notes[note.noteId].searchResultsLoaded = true;
+ froca.notes[note.noteId].highlightedTokens = highlightedTokens;
}
/** @returns {NoteShort[]} */
diff --git a/src/public/app/services/note_list_renderer.js b/src/public/app/services/note_list_renderer.js
index 1006374a5..2ed5b5ea3 100644
--- a/src/public/app/services/note_list_renderer.js
+++ b/src/public/app/services/note_list_renderer.js
@@ -2,6 +2,7 @@ import linkService from "./link.js";
import noteContentRenderer from "./note_content_renderer.js";
import froca from "./froca.js";
import attributeRenderer from "./attribute_renderer.js";
+import libraryLoader from "./library_loader.js";
const TPL = `
@@ -60,27 +61,27 @@ const TPL = `
padding-top: 10px;
}
- .note-book-title {
+ .note-book-header {
margin-bottom: 0;
word-break: break-all;
}
/* not-expanded title is limited to one line only */
- .note-book-card:not(.expanded) .note-book-title {
+ .note-book-card:not(.expanded) .note-book-header {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
- .note-book-title .rendered-note-attributes {
+ .note-book-header .rendered-note-attributes {
font-size: medium;
}
- .note-book-title .rendered-note-attributes:before {
+ .note-book-header .rendered-note-attributes:before {
content: "\\00a0\\00a0";
}
- .note-book-title .note-icon {
+ .note-book-header .note-icon {
font-size: 100%;
display: inline-block;
padding-right: 7px;
@@ -112,7 +113,7 @@ const TPL = `
max-height: 100%;
}
- .note-book-title {
+ .note-book-header {
flex-grow: 0;
}
@@ -198,6 +199,15 @@ class NoteListRenderer {
return;
}
+ const highlightedTokens = this.parentNote.highlightedTokens || [];
+ if (highlightedTokens.length > 0) {
+ await libraryLoader.requireLibrary(libraryLoader.MARKJS);
+
+ this.highlightRegex = new RegExp(highlightedTokens.join("|"), 'gi');
+ } else {
+ this.highlightRegex = null;
+ }
+
this.$noteList.show();
const $container = this.$noteList.find('.note-list-container').empty();
@@ -262,12 +272,13 @@ class NoteListRenderer {
const $card = $('
')
.attr('data-note-id', note.noteId)
.append(
- $('
')
+ $('