Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/client/src/services/note_autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface Suggestion {
notePathTitle?: string;
notePath?: string;
highlightedNotePathTitle?: string;
highlightedNoteId?: string;
highlightedContentSnippet?: string;
action?: string | "create-note" | "search-notes" | "external-link" | "command";
parentNoteId?: string;
icon?: string;
Expand Down Expand Up @@ -344,6 +346,12 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
html += `<span class="text">`;
html += `<span class="search-result-title">${suggestion.highlightedNotePathTitle}</span>`;

// Highlighted noteId (if present)
if (suggestion.highlightedNoteId) {
html += `<div class="search-result-id">${suggestion.highlightedNoteId}</div>`;
}
html += `</div>`; // close .note-header

// Add attribute snippet inline if available
if (suggestion.highlightedAttributeSnippet) {
html += `<span class="search-result-attributes">${suggestion.highlightedAttributeSnippet}</span>`;
Expand Down
130 changes: 129 additions & 1 deletion apps/client/src/stylesheets/theme-next/dialogs.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ div.tn-tool-dialog {
backdrop-filter: var(--dropdown-backdrop-filter);
}

.jump-to-note-dialog .search-result-id {
display: block;
margin-top: 2px;
font-size: 0.8em;
color: var(--muted-text-color);
font-family: var(--monospace-font, monospace);
opacity: 0.8;
}

.jump-to-note-dialog .search-result-id b {
color: var(--accent-color);
font-weight: 600;
}

.jump-to-note-dialog .modal-content {
--bs-modal-header-padding-x: 0;

Expand Down Expand Up @@ -420,4 +434,118 @@ div.tn-tool-dialog {

.note-type-chooser-dialog div.note-type-dropdown .dropdown-item span.bx {
margin-right: .25em;
}
}

/* ============================================================
Quick Search Dropdown Styles
============================================================ */

.quick-search {
padding: 10px 10px 10px 0px;
height: 50px;
}

.quick-search button, .quick-search input {
border: 0;
font-size: 100% !important;
}

.quick-search .dropdown-menu {
--quick-search-item-delimiter-color: var(--dropdown-border-color);

max-height: 80vh;
min-width: 400px;
max-width: 720px;
overflow-y: auto;
overflow-x: hidden;
text-overflow: ellipsis;
box-shadow: -30px 50px 93px -50px black;
}

.quick-search .dropdown-item {
white-space: normal;
padding: 12px 16px;
line-height: 1.4;
position: relative;
}

.quick-search .dropdown-item + .dropdown-item::after {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 1px;
border-bottom: 1px solid var(--quick-search-item-delimiter-color);
}

.quick-search .dropdown-item:last-child::after {
display: none;
}

.quick-search .dropdown-item.disabled::after {
display: none;
}

.quick-search .dropdown-item.show-in-full-search::after {
display: none;
}

.quick-search-item.dropdown-item:hover {
background-color: #f8f9fa;
}

.quick-search .quick-search-item {
width: 100%;
}

.quick-search .quick-search-item-header {
padding: 0 8px;
}

.quick-search .quick-search-item-icon {
margin-inline-end: 2px;
}

.quick-search .search-result-title {
font-weight: 500;
}

.quick-search .search-result-attributes {
opacity: .5;
padding: 0 8px;
font-size: .75em;
}

.quick-search .search-result-id {
font-size: 0.75em;
color: var(--muted-text-color);
margin-top: 2px;
padding-left: 22px; /* aligns nicely with the icon */
}

.quick-search .search-result-content {
margin-top: 8px;
padding: 8px;
background-color: var(--accented-background-color);
color: var(--main-text-color);
font-size: .85em;
overflow: hidden;
text-overflow: ellipsis;
}

/* Search result highlighting */
.quick-search .search-result-title b,
.quick-search .search-result-content b,
.quick-search .search-result-attributes b {
color: var(--admonition-warning-accent-color);
text-decoration: underline;
}

.quick-search .dropdown-divider {
margin: 0;
}

.quick-search .bx-loader {
margin-inline-end: 4px;
}
8 changes: 8 additions & 0 deletions apps/server/src/becca/entities/battribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class BAttribute extends AbstractBeccaEntity<BAttribute> {
value!: string;
isInheritable!: boolean;

_normalizedKey?: string;
_normalizedValue?: string;

constructor(row?: AttributeRow) {
super();

Expand All @@ -59,6 +62,9 @@ class BAttribute extends AbstractBeccaEntity<BAttribute> {
this.isInheritable = !!isInheritable;
this.utcDateModified = utcDateModified;

this._normalizedKey = undefined;
this._normalizedValue = undefined;

return this;
}

Expand Down Expand Up @@ -172,6 +178,8 @@ class BAttribute extends AbstractBeccaEntity<BAttribute> {
}

this.name = sanitizeAttributeName(this.name);
this._normalizedKey = undefined;
this._normalizedValue = undefined;

if (!this.value) {
// null value isn't allowed
Expand Down
10 changes: 10 additions & 0 deletions apps/server/src/becca/entities/bnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class BNote extends AbstractBeccaEntity<BNote> {
return ["noteId", "title", "isProtected", "type", "mime", "blobId"];
}

_normalizedTitle?: string;
/** Cached trigrams for the note title */
_titleTrigrams?: Set<string>;

noteId!: string;
title!: string;
type!: NoteType;
Expand Down Expand Up @@ -149,6 +153,9 @@ class BNote extends AbstractBeccaEntity<BNote> {
this.utcDateModified = utcDateModified;
this.isBeingDeleted = false;

this._normalizedTitle = undefined;
this._titleTrigrams = undefined;

// ------ Derived attributes ------

this.isDecrypted = !this.noteId || !this.isProtected;
Expand Down Expand Up @@ -816,6 +823,9 @@ class BNote extends AbstractBeccaEntity<BNote> {
this.__attributeCache = null;
this.__inheritableAttributeCache = null;
this.__ancestorCache = null;

this._normalizedTitle = undefined;
this._titleTrigrams = undefined;
}

invalidateSubTree(path: string[] = []) {
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/routes/api/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function quickSearch(req: Request) {

// Use the same highlighting logic as autocomplete for consistency
const searchResults = searchService.searchNotesForAutocomplete(searchString, false);

// Extract note IDs for backward compatibility
const resultNoteIds = searchResults.map((result) => result.notePath.split("/").pop()).filter(Boolean) as string[];

Expand Down
Loading