Skip to content

Build your personal knowledge base with Trilium Notes

feat(web-clipper): show the preview's title as Trilium shows a note's

Elian Dorana7dd30bbe6f2
diff --git a/apps/web-clipper/assets/theme.css b/apps/web-clipper/assets/theme.css
index 0bad8e5445..eb0247cc5c 100644
--- a/apps/web-clipper/assets/theme.css
+++ b/apps/web-clipper/assets/theme.css
@@ -53,6 +53,9 @@
--hover-item-background-color: #0000001a;
--hover-item-text-color: black;
+ --note-icon-background-color: #4f4f4f;
+ --note-icon-color: white;
+
--button-text-color: currentColor;
--icon-button-size: 32px;
--icon-button-icon-ratio: 0.65;
@@ -107,6 +110,9 @@
--hover-item-background-color: #ffffff16;
--hover-item-text-color: #efefef;
+ --note-icon-background-color: #444444;
+ --note-icon-color: #d4d4d4;
+
--status-ok-color: #74d369;
--status-warning-color: #d3c769;
--status-error-color: #d36969;
diff --git a/apps/web-clipper/entrypoints/popup/main.tsx b/apps/web-clipper/entrypoints/popup/main.tsx
index effd8ce59e..0681168641 100644
--- a/apps/web-clipper/entrypoints/popup/main.tsx
+++ b/apps/web-clipper/entrypoints/popup/main.tsx
@@ -6,6 +6,7 @@ import ArrowLeft from "@boxicons/js/icons/ArrowLeft";
import Article from "@boxicons/js/icons/Article";
import Cog from "@boxicons/js/icons/Cog";
import Crop from "@boxicons/js/icons/Crop";
+import Globe from "@boxicons/js/icons/Globe";
import HelpCircle from "@boxicons/js/icons/HelpCircle";
import Link from "@boxicons/js/icons/Link";
import RefreshCw from "@boxicons/js/icons/RefreshCw";
@@ -241,16 +242,21 @@ function PagePreview({ disabled, shortcut }: { disabled: boolean, shortcut: stri
{page === null && <div className="page-preview-placeholder">This page cannot be saved as an article.</div>}
{page && (
<>
- <input
- type="text"
- className="page-title"
- aria-label="Note title"
- placeholder="Note title"
- value={title}
- onInput={(e) => setTitle(e.currentTarget.value)}
- />
- <div className="page-meta">
- {new URL(page.pageUrl).hostname}{published && ` · Published ${published}`}
+ <div className="page-heading">
+ <span className="page-icon"><Icon icon={Globe} /></span>
+ <div className="page-heading-text">
+ <input
+ type="text"
+ className="page-title"
+ aria-label="Note title"
+ placeholder="Note title"
+ value={title}
+ onInput={(e) => setTitle(e.currentTarget.value)}
+ />
+ <div className="page-meta">
+ {new URL(page.pageUrl).hostname}{published && ` · Published ${published}`}
+ </div>
+ </div>
</div>
<iframe
className="page-content"
diff --git a/apps/web-clipper/entrypoints/popup/popup.css b/apps/web-clipper/entrypoints/popup/popup.css
index a5b044c367..198d51fab6 100644
--- a/apps/web-clipper/entrypoints/popup/popup.css
+++ b/apps/web-clipper/entrypoints/popup/popup.css
@@ -82,15 +82,52 @@ body {
flex-direction: column;
gap: 6px;
+ .page-heading {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+
+ .page-icon {
+ display: flex;
+ flex-shrink: 0;
+ align-items: center;
+ justify-content: center;
+ width: 40px;
+ height: 40px;
+ border-radius: 50%;
+ background: var(--note-icon-background-color);
+ color: var(--note-icon-color);
+
+ svg.icon {
+ width: 22px;
+ height: 22px;
+ }
+ }
+
+ .page-heading-text {
+ display: flex;
+ flex-direction: column;
+ flex-grow: 1;
+ min-width: 0;
+ }
+
.page-title {
+ --input-background-color: transparent;
+
width: 100%;
+ padding: 0 6px;
+ border: 0;
+ border-radius: 6px;
+ font-size: 1.35em;
font-weight: 500;
}
.page-meta {
overflow: hidden;
+ padding-inline: 6px;
color: var(--muted-text-color);
- font-size: 0.9em;
+ font-size: 0.85em;
white-space: nowrap;
text-overflow: ellipsis;
}
diff --git a/apps/web-clipper/entrypoints/popup/popup.spec.tsx b/apps/web-clipper/entrypoints/popup/popup.spec.tsx
index e8405a644a..1356bd865f 100644
--- a/apps/web-clipper/entrypoints/popup/popup.spec.tsx
+++ b/apps/web-clipper/entrypoints/popup/popup.spec.tsx
@@ -170,8 +170,11 @@ describe("popup", () => {
expect(tabsQuery).toHaveBeenCalledWith({ active: true, currentWindow: true });
expect(tabsSendMessage).toHaveBeenCalledWith(7, { name: "trilium-save-page" });
- expect(container.querySelector<HTMLInputElement>(".page-title")?.value).toBe("An article");
- expect(container.querySelector(".page-meta")?.textContent).toBe("example.com · Published 2024-05-01");
+ const heading = container.querySelector(".page-heading");
+ expect(heading).not.toBeNull();
+ expect(heading?.querySelector(".page-icon svg path")).not.toBeNull();
+ expect(heading?.querySelector<HTMLInputElement>(".page-title")?.value).toBe("An article");
+ expect(heading?.querySelector(".page-meta")?.textContent).toBe("example.com · Published 2024-05-01");
const frame = container.querySelector<HTMLIFrameElement>("iframe.page-content");
expect(frame?.getAttribute("sandbox")).toBe("");
expect(frame?.getAttribute("srcdoc")).toBe(previewDocument(PAGE));