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(clipper): keep the card compact on a page with nothing to save
Elian Doran507b3c1edc01
diff --git a/apps/web-clipper/entrypoints/popup/main.tsx b/apps/web-clipper/entrypoints/popup/main.tsxindex de66673890..a326ea082d 100644--- a/apps/web-clipper/entrypoints/popup/main.tsx+++ b/apps/web-clipper/entrypoints/popup/main.tsx@@ -535,6 +535,9 @@ function PagePreview({ tab, disabled, shortcuts, draft, onDraftChange, saveStateconst published = pageLabels?.publishedDate;const modified = pageLabels?.modifiedDate;const button = SAVE_BUTTONS[mode ?? "page"];+ const bookmarkOnly = mode === "note" && modes.length === 1;+ /** The body fits its fields where there is no preview to give room to. */+ const compact = tab?.pdf || bookmarkOnly;return (<div className="page-preview">@@ -566,12 +569,12 @@ function PagePreview({ tab, disabled, shortcuts, draft, onDraftChange, saveState</div>)}- {mode === "note" && modes.length === 1 && (+ {bookmarkOnly && (<div className="clip-hint">This page has nothing to save; save it as a bookmark.</div>)}{mode === "pdf" && <div className="clip-hint">The PDF is saved as a file in Trilium.</div>}- <div className={tab?.pdf ? "page-body pdf" : "page-body"}>+ <div className={compact ? "page-body compact" : "page-body"}>{mode && (<div className={mode === "note" ? "page-fields bookmark" : "page-fields"}>{mode !== "pdf" && (diff --git a/apps/web-clipper/entrypoints/popup/popup.css b/apps/web-clipper/entrypoints/popup/popup.cssindex 0cc6b4d592..bcaeb04147 100644--- a/apps/web-clipper/entrypoints/popup/popup.css+++ b/apps/web-clipper/entrypoints/popup/popup.css@@ -186,7 +186,7 @@ body {border-radius: 6px;background: var(--main-background-color);- &.pdf {+ &.compact {height: auto;.page-fields {diff --git a/apps/web-clipper/entrypoints/popup/popup.spec.tsx b/apps/web-clipper/entrypoints/popup/popup.spec.tsxindex 613aa42c9e..a3957d1404 100644--- a/apps/web-clipper/entrypoints/popup/popup.spec.tsx+++ b/apps/web-clipper/entrypoints/popup/popup.spec.tsx@@ -367,6 +367,7 @@ describe("popup", () => {expect(container.querySelector(".no-items")).toBeNull();expect(container.querySelector(".clip-mode")).toBeNull();expect(container.querySelector(".clip-hint")?.textContent).toBe("This page has nothing to save; save it as a bookmark.");+ expect(container.querySelector(".page-body")?.className).toBe("page-body compact");expect(document.activeElement).toBe(container.querySelector(".page-body .note-text"));expect(container.querySelector(".page-meta")).toBeNull();expect(button("Save bookmark")?.disabled).toBe(false);@@ -770,7 +771,7 @@ describe("popup", () => {expect(container.querySelector(".note-text")).toBeNull();expect(container.querySelector(".page-author")).toBeNull();expect(container.querySelector(".page-content")).toBeNull();- expect(container.querySelector(".page-body")?.className).toBe("page-body pdf");+ expect(container.querySelector(".page-body")?.className).toBe("page-body compact");expect(placeholder()).toBeUndefined();expect(shortcutOf("Save PDF to Trilium").text).toBe("Alt+Shift+S");@@ -797,7 +798,7 @@ describe("popup", () => {await click("Bookmark");expect(button("Save bookmark")?.disabled).toBe(false);- expect(container.querySelector(".page-body")?.className).toBe("page-body pdf");+ expect(container.querySelector(".page-body")?.className).toBe("page-body compact");expect(container.querySelector(".note-text")).not.toBeNull();expect(container.querySelector(".clip-hint")).toBeNull();});