mirror of
https://github.com/zadam/trilium.git
synced 2025-12-21 15:49:56 +01:00
feat(share): disable search if single note
This commit is contained in:
@@ -23,7 +23,10 @@ function buildResultItem(result: SearchResult) {
|
||||
|
||||
|
||||
export default function setupSearch() {
|
||||
const searchInput: HTMLInputElement = document.querySelector(".search-input")!;
|
||||
const searchInput: HTMLInputElement | null = document.querySelector(".search-input");
|
||||
if (!searchInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
searchInput.addEventListener("keyup", debounce(async () => {
|
||||
// console.log("CHANGE EVENT");
|
||||
@@ -38,14 +41,14 @@ export default function setupSearch() {
|
||||
lines.push(buildResultItem(result));
|
||||
}
|
||||
lines.push("</div>");
|
||||
|
||||
|
||||
const container = parseHTML(lines.join("")) as HTMLDivElement;
|
||||
// console.log(container, lines);
|
||||
const rect = searchInput.getBoundingClientRect();
|
||||
container.style.top = `${rect.bottom}px`;
|
||||
container.style.left = `${rect.left}px`;
|
||||
container.style.minWidth = `${rect.width}px`;
|
||||
|
||||
|
||||
const existing = document.querySelector(".search-results");
|
||||
if (existing) existing.replaceWith(container);
|
||||
else document.body.append(container);
|
||||
@@ -58,4 +61,4 @@ export default function setupSearch() {
|
||||
if (parents(e.target as HTMLElement, ".search-results,.search-item").length) return;
|
||||
if (existing) existing.remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user