Skip to content

Build your personal knowledge base with Trilium Notes

added "show results in full text"

azivneraee60c444f0a
diff --git a/src/public/javascripts/dialogs/jump_to_note.js b/src/public/javascripts/dialogs/jump_to_note.js
index 5059426f15..421724ded3 100644
--- a/src/public/javascripts/dialogs/jump_to_note.js
+++ b/src/public/javascripts/dialogs/jump_to_note.js
@@ -1,10 +1,13 @@
import treeService from '../services/tree.js';
import linkService from '../services/link.js';
import server from '../services/server.js';
+import searchNotesService from '../services/search_notes.js';
const $dialog = $("#jump-to-note-dialog");
const $autoComplete = $("#jump-to-note-autocomplete");
const $form = $("#jump-to-note-form");
+const $jumpToNoteButton = $("#jump-to-note-button");
+const $showInFullTextButton = $("#show-in-full-text-button");
async function showDialog() {
glob.activeDialog = $dialog;
@@ -24,12 +27,6 @@ async function showDialog() {
},
minLength: 2
});
-
- $autoComplete.autocomplete("instance")._renderItem = function(ul, item) {
- return $("<li>")
- .append("<div>" + item.label + "</div>")
- .appendTo(ul);
- };
}
function getSelectedNotePath() {
@@ -47,12 +44,32 @@ function goToNote() {
}
}
+function showInFullText(e) {
+ // stop from propagating upwards (dangerous especially with ctrl+enter executable javascript notes)
+ e.preventDefault();
+ e.stopPropagation();
+
+ const searchText = $autoComplete.val();
+
+ searchNotesService.resetSearch();
+ searchNotesService.showSearch();
+ searchNotesService.doSearch(searchText);
+
+ $dialog.dialog('close');
+}
+
$form.submit(() => {
goToNote();
return false;
});
+$jumpToNoteButton.click(goToNote);
+
+$showInFullTextButton.click(showInFullText);
+
+$dialog.bind('keydown', 'ctrl+return', showInFullText);
+
export default {
showDialog
};
\ No newline at end of file
diff --git a/src/public/javascripts/services/entrypoints.js b/src/public/javascripts/services/entrypoints.js
index 36a51b7872..1e67a840c9 100644
--- a/src/public/javascripts/services/entrypoints.js
+++ b/src/public/javascripts/services/entrypoints.js
@@ -23,7 +23,7 @@ function registerEntrypoints() {
utils.bindShortcut('ctrl+l', addLinkDialog.showDialog);
- $("#jump-to-note-button").click(jumpToNoteDialog.showDialog);
+ $("#jump-to-note-dialog-button").click(jumpToNoteDialog.showDialog);
utils.bindShortcut('ctrl+j', jumpToNoteDialog.showDialog);
$("#show-note-revisions-button").click(noteRevisionsDialog.showCurrentNoteRevisions);
diff --git a/src/public/javascripts/services/search_notes.js b/src/public/javascripts/services/search_notes.js
index 24521efa6c..b8b90d88cf 100644
--- a/src/public/javascripts/services/search_notes.js
+++ b/src/public/javascripts/services/search_notes.js
@@ -11,10 +11,14 @@ const $searchBox = $("#search-box");
const $searchResults = $("#search-results");
const $searchResultsInner = $("#search-results-inner");
+function showSearch() {
+ $searchBox.show();
+ $searchInput.focus();
+}
+
function toggleSearch() {
if ($searchBox.is(":hidden")) {
- $searchBox.show();
- $searchInput.focus();
+ showSearch();
}
else {
resetSearch();
@@ -32,8 +36,13 @@ function getTree() {
return $tree.fancytree('getTree');
}
-async function doSearch() {
- const searchText = $searchInput.val();
+async function doSearch(searchText) {
+ if (searchText) {
+ $searchInput.val(searchText);
+ }
+ else {
+ searchText = $searchInput.val();
+ }
const results = await server.get('search/' + encodeURIComponent(searchText));
@@ -81,5 +90,8 @@ $resetSearchButton.click(resetSearch);
$saveSearchButton.click(saveSearch);
export default {
- toggleSearch
+ toggleSearch,
+ resetSearch,
+ showSearch,
+ doSearch
};
\ No newline at end of file
diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css
index fa14759f8b..85a36340ae 100644
--- a/src/public/stylesheets/style.css
+++ b/src/public/stylesheets/style.css
@@ -371,12 +371,12 @@ div.ui-tooltip {
display: flex;
}
-.btn {
+.btn:not(.btn-primary) {
border-color: #ddd;
background-color: #eee;
}
-.btn.active {
+.btn.active:not(.btn-primary) {
background-color: #ccc;
}
diff --git a/src/views/index.ejs b/src/views/index.ejs
index 8ca85ea7bf..17222a4662 100644
--- a/src/views/index.ejs
+++ b/src/views/index.ejs
@@ -24,7 +24,7 @@
</div>
<div style="flex-grow: 100; display: flex;">
- <button class="btn btn-xs" id="jump-to-note-button" title="CTRL+J">Jump to note</button>
+ <button class="btn btn-xs" id="jump-to-note-dialog-button" title="CTRL+J">Jump to note</button>
<button class="btn btn-xs" id="recent-notes-button" title="CTRL+E">Recent notes</button>
<button class="btn btn-xs" id="recent-changes-button">Recent changes</button>
<div>
@@ -303,7 +303,11 @@
<input id="jump-to-note-autocomplete" style="width: 100%;">
</div>
- <button name="action" value="jump" class="btn btn-sm">Jump <kbd>enter</kbd></button>
+ <div style="display: flex; justify-content: space-between;">
+ <button id="jump-to-note-button" class="btn btn-sm btn-primary">Jump <kbd>enter</kbd></button>
+
+ <button id="show-in-full-text-button" class="btn btn-sm">&lt;&lt; Show results in full text <kbd>ctrl+enter</kbd></button>
+ </div>
</form>
</div>