Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(geomap): stop laying out the marker preview's wrapper as markup
Elian Dorand489555c52d6
diff --git a/apps/client/src/widgets/collections/geomap/Tooltips.spec.tsx b/apps/client/src/widgets/collections/geomap/Tooltips.spec.tsxindex 5959b6f77d..a6ffa8d8cf 100644--- a/apps/client/src/widgets/collections/geomap/Tooltips.spec.tsx+++ b/apps/client/src/widgets/collections/geomap/Tooltips.spec.tsx@@ -162,6 +162,10 @@ describe("Tooltips", () => {// Drawn in the shape the app's tooltip styles are written against.expect(FakePopup.open[0]?.html).toContain(`class="tooltip note-tooltip show"`);expect(FakePopup.open[0]?.html).toContain(`class="note-tooltip-content"`);+ // `.tooltip-inner` is `pre-line`, so a line break laid out between the tags is a blank line+ // drawn in the preview — one above it and one below, 43px of nothing. The rendered note+ // brings no newline of its own here, so the wrapper is where any of them would come from.+ expect(FakePopup.open[0]?.html).not.toContain("\n");});/**diff --git a/apps/client/src/widgets/collections/geomap/Tooltips.tsx b/apps/client/src/widgets/collections/geomap/Tooltips.tsxindex a0e35e25b3..ac381c46fe 100644--- a/apps/client/src/widgets/collections/geomap/Tooltips.tsx+++ b/apps/client/src/widgets/collections/geomap/Tooltips.tsx@@ -165,12 +165,15 @@ export default function Tooltips() {** The content is sanitized because a note's HTML reaches the client through paths CKEditor never* saw — the internal API, ETAPI and sync — exactly as the tooltip service sanitizes it.+ *+ * Written without a line break anywhere between the tags, because `.tooltip-inner` is `pre-line`:+ * every newline inside it is a newline the preview is drawn with, and laying this out as one would+ * lay out markup put a blank line above the preview and another below it.*/function buildTooltipHtml(content: string) {- return `\-<div class="tooltip note-tooltip show" role="tooltip">- <div class="tooltip-inner">- <div class="note-tooltip-content">${sanitizeNoteContentHtml(content)}</div>- </div>-</div>`;+ return `<div class="tooltip note-tooltip show" role="tooltip">`+ + `<div class="tooltip-inner">`+ + `<div class="note-tooltip-content">${sanitizeNoteContentHtml(content)}</div>`+ + `</div>`+ + `</div>`;}