mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
added "show results in full text"
This commit is contained in:
parent
e7a504c66b
commit
aee60c444f
@ -1,10 +1,13 @@
|
|||||||
import treeService from '../services/tree.js';
|
import treeService from '../services/tree.js';
|
||||||
import linkService from '../services/link.js';
|
import linkService from '../services/link.js';
|
||||||
import server from '../services/server.js';
|
import server from '../services/server.js';
|
||||||
|
import searchNotesService from '../services/search_notes.js';
|
||||||
|
|
||||||
const $dialog = $("#jump-to-note-dialog");
|
const $dialog = $("#jump-to-note-dialog");
|
||||||
const $autoComplete = $("#jump-to-note-autocomplete");
|
const $autoComplete = $("#jump-to-note-autocomplete");
|
||||||
const $form = $("#jump-to-note-form");
|
const $form = $("#jump-to-note-form");
|
||||||
|
const $jumpToNoteButton = $("#jump-to-note-button");
|
||||||
|
const $showInFullTextButton = $("#show-in-full-text-button");
|
||||||
|
|
||||||
async function showDialog() {
|
async function showDialog() {
|
||||||
glob.activeDialog = $dialog;
|
glob.activeDialog = $dialog;
|
||||||
@ -24,12 +27,6 @@ async function showDialog() {
|
|||||||
},
|
},
|
||||||
minLength: 2
|
minLength: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
$autoComplete.autocomplete("instance")._renderItem = function(ul, item) {
|
|
||||||
return $("<li>")
|
|
||||||
.append("<div>" + item.label + "</div>")
|
|
||||||
.appendTo(ul);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedNotePath() {
|
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(() => {
|
$form.submit(() => {
|
||||||
goToNote();
|
goToNote();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$jumpToNoteButton.click(goToNote);
|
||||||
|
|
||||||
|
$showInFullTextButton.click(showInFullText);
|
||||||
|
|
||||||
|
$dialog.bind('keydown', 'ctrl+return', showInFullText);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
showDialog
|
showDialog
|
||||||
};
|
};
|
@ -23,7 +23,7 @@ function registerEntrypoints() {
|
|||||||
|
|
||||||
utils.bindShortcut('ctrl+l', addLinkDialog.showDialog);
|
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);
|
utils.bindShortcut('ctrl+j', jumpToNoteDialog.showDialog);
|
||||||
|
|
||||||
$("#show-note-revisions-button").click(noteRevisionsDialog.showCurrentNoteRevisions);
|
$("#show-note-revisions-button").click(noteRevisionsDialog.showCurrentNoteRevisions);
|
||||||
|
@ -11,10 +11,14 @@ const $searchBox = $("#search-box");
|
|||||||
const $searchResults = $("#search-results");
|
const $searchResults = $("#search-results");
|
||||||
const $searchResultsInner = $("#search-results-inner");
|
const $searchResultsInner = $("#search-results-inner");
|
||||||
|
|
||||||
|
function showSearch() {
|
||||||
|
$searchBox.show();
|
||||||
|
$searchInput.focus();
|
||||||
|
}
|
||||||
|
|
||||||
function toggleSearch() {
|
function toggleSearch() {
|
||||||
if ($searchBox.is(":hidden")) {
|
if ($searchBox.is(":hidden")) {
|
||||||
$searchBox.show();
|
showSearch();
|
||||||
$searchInput.focus();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
resetSearch();
|
resetSearch();
|
||||||
@ -32,8 +36,13 @@ function getTree() {
|
|||||||
return $tree.fancytree('getTree');
|
return $tree.fancytree('getTree');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function doSearch() {
|
async function doSearch(searchText) {
|
||||||
const searchText = $searchInput.val();
|
if (searchText) {
|
||||||
|
$searchInput.val(searchText);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
searchText = $searchInput.val();
|
||||||
|
}
|
||||||
|
|
||||||
const results = await server.get('search/' + encodeURIComponent(searchText));
|
const results = await server.get('search/' + encodeURIComponent(searchText));
|
||||||
|
|
||||||
@ -81,5 +90,8 @@ $resetSearchButton.click(resetSearch);
|
|||||||
$saveSearchButton.click(saveSearch);
|
$saveSearchButton.click(saveSearch);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
toggleSearch
|
toggleSearch,
|
||||||
|
resetSearch,
|
||||||
|
showSearch,
|
||||||
|
doSearch
|
||||||
};
|
};
|
@ -371,12 +371,12 @@ div.ui-tooltip {
|
|||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn:not(.btn-primary) {
|
||||||
border-color: #ddd;
|
border-color: #ddd;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn.active {
|
.btn.active:not(.btn-primary) {
|
||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="flex-grow: 100; display: flex;">
|
<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-notes-button" title="CTRL+E">Recent notes</button>
|
||||||
<button class="btn btn-xs" id="recent-changes-button">Recent changes</button>
|
<button class="btn btn-xs" id="recent-changes-button">Recent changes</button>
|
||||||
<div>
|
<div>
|
||||||
@ -303,7 +303,11 @@
|
|||||||
<input id="jump-to-note-autocomplete" style="width: 100%;">
|
<input id="jump-to-note-autocomplete" style="width: 100%;">
|
||||||
</div>
|
</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"><< Show results in full text <kbd>ctrl+enter</kbd></button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user