mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 15:49:00 +02:00
feat(command_palette): hide search in full text
This commit is contained in:
parent
d59d544c0f
commit
ace166a925
@ -36,6 +36,7 @@ export default class JumpToNoteDialog extends BasicWidget {
|
|||||||
private $autoComplete!: JQuery<HTMLElement>;
|
private $autoComplete!: JQuery<HTMLElement>;
|
||||||
private $results!: JQuery<HTMLElement>;
|
private $results!: JQuery<HTMLElement>;
|
||||||
private $showInFullTextButton!: JQuery<HTMLElement>;
|
private $showInFullTextButton!: JQuery<HTMLElement>;
|
||||||
|
private isCommandMode: boolean = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -53,6 +54,29 @@ export default class JumpToNoteDialog extends BasicWidget {
|
|||||||
this.$showInFullTextButton.on("click", (e) => this.showInFullText(e));
|
this.$showInFullTextButton.on("click", (e) => this.showInFullText(e));
|
||||||
|
|
||||||
shortcutService.bindElShortcut(this.$widget, "ctrl+return", (e) => this.showInFullText(e));
|
shortcutService.bindElShortcut(this.$widget, "ctrl+return", (e) => this.showInFullText(e));
|
||||||
|
|
||||||
|
// Monitor input changes to detect command mode switches
|
||||||
|
this.$autoComplete.on("input", () => {
|
||||||
|
this.updateCommandModeState();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateCommandModeState() {
|
||||||
|
const currentValue = String(this.$autoComplete.val() || "");
|
||||||
|
const newCommandMode = currentValue.startsWith(">");
|
||||||
|
|
||||||
|
if (newCommandMode !== this.isCommandMode) {
|
||||||
|
this.isCommandMode = newCommandMode;
|
||||||
|
this.updateButtonVisibility();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateButtonVisibility() {
|
||||||
|
if (this.isCommandMode) {
|
||||||
|
this.$showInFullTextButton.hide();
|
||||||
|
} else {
|
||||||
|
this.$showInFullTextButton.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async jumpToNoteEvent() {
|
async jumpToNoteEvent() {
|
||||||
@ -126,6 +150,8 @@ export default class JumpToNoteDialog extends BasicWidget {
|
|||||||
if (commandMode) {
|
if (commandMode) {
|
||||||
// Start in command mode - manually trigger command search
|
// Start in command mode - manually trigger command search
|
||||||
this.$autoComplete.autocomplete("val", ">");
|
this.$autoComplete.autocomplete("val", ">");
|
||||||
|
this.isCommandMode = true;
|
||||||
|
this.updateButtonVisibility();
|
||||||
|
|
||||||
// Manually populate with all commands immediately
|
// Manually populate with all commands immediately
|
||||||
noteAutocompleteService.showAllCommands(this.$autoComplete);
|
noteAutocompleteService.showAllCommands(this.$autoComplete);
|
||||||
@ -137,6 +163,8 @@ export default class JumpToNoteDialog extends BasicWidget {
|
|||||||
// so we'll keep the content.
|
// so we'll keep the content.
|
||||||
// if it's outside of this time limit, then we assume it's a completely new search and show recent notes instead.
|
// if it's outside of this time limit, then we assume it's a completely new search and show recent notes instead.
|
||||||
if (Date.now() - this.lastOpenedTs > KEEP_LAST_SEARCH_FOR_X_SECONDS * 1000) {
|
if (Date.now() - this.lastOpenedTs > KEEP_LAST_SEARCH_FOR_X_SECONDS * 1000) {
|
||||||
|
this.isCommandMode = false;
|
||||||
|
this.updateButtonVisibility();
|
||||||
noteAutocompleteService.showRecentNotes(this.$autoComplete);
|
noteAutocompleteService.showRecentNotes(this.$autoComplete);
|
||||||
} else {
|
} else {
|
||||||
this.$autoComplete
|
this.$autoComplete
|
||||||
@ -145,6 +173,9 @@ export default class JumpToNoteDialog extends BasicWidget {
|
|||||||
.autocomplete("val", this.$autoComplete.next().text())
|
.autocomplete("val", this.$autoComplete.next().text())
|
||||||
.trigger("focus")
|
.trigger("focus")
|
||||||
.trigger("select");
|
.trigger("select");
|
||||||
|
|
||||||
|
// Update command mode state based on the restored value
|
||||||
|
this.updateCommandModeState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,6 +185,11 @@ export default class JumpToNoteDialog extends BasicWidget {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
|
// Don't perform full text search in command mode
|
||||||
|
if (this.isCommandMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const searchString = String(this.$autoComplete.val());
|
const searchString = String(this.$autoComplete.val());
|
||||||
|
|
||||||
this.triggerCommand("searchNotes", { searchString });
|
this.triggerCommand("searchNotes", { searchString });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user