mirror of
https://github.com/zadam/trilium.git
synced 2024-11-11 01:23:57 +08:00
reimplemented triggering search from URL, fixes #385
This commit is contained in:
parent
ac0d61e9b4
commit
b3381a3b53
3 changed files with 10 additions and 2 deletions
|
@ -117,6 +117,10 @@ export default class TabManager extends Component {
|
|||
parsedFromUrl.viewScope,
|
||||
parsedFromUrl.hoistedNoteId
|
||||
);
|
||||
} else if (parsedFromUrl.searchString) {
|
||||
await appContext.triggerCommand('searchNotes', {
|
||||
searchString: parsedFromUrl.searchString
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
|
|
|
@ -153,6 +153,7 @@ function parseNavigationStateFromUrl(url) {
|
|||
};
|
||||
let ntxId = null;
|
||||
let hoistedNoteId = null;
|
||||
let searchString = null;
|
||||
|
||||
if (paramString) {
|
||||
for (const pair of paramString.split("&")) {
|
||||
|
@ -164,6 +165,8 @@ function parseNavigationStateFromUrl(url) {
|
|||
ntxId = value;
|
||||
} else if (name === 'hoistedNoteId') {
|
||||
hoistedNoteId = value;
|
||||
} else if (name === 'searchString') {
|
||||
searchString = value; // supports triggering search from URL, e.g. #?searchString=blabla
|
||||
} else if (['viewMode', 'attachmentId'].includes(name)) {
|
||||
viewScope[name] = value;
|
||||
} else {
|
||||
|
@ -177,7 +180,8 @@ function parseNavigationStateFromUrl(url) {
|
|||
noteId: treeService.getNoteIdFromUrl(notePath),
|
||||
ntxId,
|
||||
hoistedNoteId,
|
||||
viewScope
|
||||
viewScope,
|
||||
searchString
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ export default class SearchString extends AbstractSearchOption {
|
|||
}
|
||||
|
||||
focusOnSearchDefinitionEvent() {
|
||||
this.$searchString.val(appContext.lastSearchString).focus().select();
|
||||
this.$searchString.val(this.$searchString.val().trim() || appContext.lastSearchString).focus().select();
|
||||
this.spacedUpdate.scheduleUpdate();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue