feat(note_tooltip): improve layout for empty notes

This commit is contained in:
Elian Doran
2025-02-07 21:36:22 +02:00
parent f77a29d7fe
commit 02d16d0125
2 changed files with 24 additions and 7 deletions

View File

@@ -140,10 +140,6 @@ async function renderTooltip(note: FNote | null) {
}
const noteTitleWithPathAsSuffix = await treeService.getNoteTitleWithPathAsSuffix(bestNotePath);
let content = "";
if (noteTitleWithPathAsSuffix) {
content = `<h5 class="note-tooltip-title">${noteTitleWithPathAsSuffix.prop("outerHTML")}</h5>`;
}
const { $renderedAttributes } = await attributeRenderer.renderNormalAttributes(note);
@@ -151,8 +147,21 @@ async function renderTooltip(note: FNote | null) {
tooltip: true,
trim: true
});
const isContentEmpty = ($renderedContent[0].innerHTML.length === 0);
content = `${content}<div class="note-tooltip-attributes">${$renderedAttributes[0].outerHTML}</div>${$renderedContent[0].outerHTML}`;
let content = "";
if (noteTitleWithPathAsSuffix) {
const classes = [ "note-tooltip-title" ];
if (isContentEmpty) {
classes.push("note-no-content");
}
content = `<h5 class="${classes.join(" ")}">${noteTitleWithPathAsSuffix.prop("outerHTML")}</h5>`;
}
content = `${content}<div class="note-tooltip-attributes">${$renderedAttributes[0].outerHTML}</div>`;
if (!isContentEmpty) {
content += $renderedContent[0].outerHTML;
}
return content;
}