`;
// Add attribute snippet (tags/attributes) below the title if available
if (result.highlightedAttributeSnippet) {
itemHtml += `
${result.highlightedAttributeSnippet}
`;
}
// Add content snippet below the attributes if available
if (result.highlightedContentSnippet) {
itemHtml += `
${result.highlightedContentSnippet}
`;
}
itemHtml += `
`;
$item.html(itemHtml);
$item.on("click", (e) => {
this.dropdown.hide();
e.preventDefault();
const activeContext = appContext.tabManager.getActiveContext();
if (activeContext) {
activeContext.setNote(noteId);
}
});
shortcutService.bindElShortcut($item, "return", () => {
this.dropdown.hide();
const activeContext = appContext.tabManager.getActiveContext();
if (activeContext) {
activeContext.setNote(noteId);
}
});
this.$dropdownMenu.append($item);
}
this.currentDisplayedCount = endIndex;
} else {
// Fallback to original behavior if no highlighted results
const startIndex = this.currentDisplayedCount;
const endIndex = Math.min(startIndex + batchSize, this.allSearchResultNoteIds.length);
const noteIdsToDisplay = this.allSearchResultNoteIds.slice(startIndex, endIndex);
for (const note of await froca.getNotes(noteIdsToDisplay)) {
const $link = await linkService.createLink(note.noteId, { showNotePath: true, showNoteIcon: true });
$link.addClass("dropdown-item");
$link.attr("tabIndex", "0");
$link.on("click", (e) => {
this.dropdown.hide();
if (!e.target || e.target.nodeName !== "A") {
// click on the link is handled by link handling, but we want the whole item clickable
const activeContext = appContext.tabManager.getActiveContext();
if (activeContext) {
activeContext.setNote(note.noteId);
}
}
});
shortcutService.bindElShortcut($link, "return", () => {
this.dropdown.hide();
const activeContext = appContext.tabManager.getActiveContext();
if (activeContext) {
activeContext.setNote(note.noteId);
}
});
this.$dropdownMenu.append($link);
}
this.currentDisplayedCount = endIndex;
}
this.isLoadingMore = false;
}
private handleScroll() {
if (this.isLoadingMore) return;
const dropdown = this.$dropdownMenu[0];
const scrollTop = dropdown.scrollTop;
const scrollHeight = dropdown.scrollHeight;
const clientHeight = dropdown.clientHeight;
// Trigger loading more when user scrolls near the bottom (within 50px)
if (scrollTop + clientHeight >= scrollHeight - 50) {
const totalResults = this.allSearchResults.length > 0 ? this.allSearchResults.length : this.allSearchResultNoteIds.length;
if (this.currentDisplayedCount < totalResults) {
this.displayMoreResults(LOAD_MORE_BATCH_SIZE).then(() => {
this.addShowInFullSearchButton();
});
}
}
}
private addShowInFullSearchButton() {
// Remove existing button if it exists
this.$dropdownMenu.find('.show-in-full-search').remove();
this.$dropdownMenu.find('.dropdown-divider').remove();
const $showInFullButton = $('