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 extracted description when the content script is silent
Elian Doran1cd06a981d88
diff --git a/apps/web-clipper/entrypoints/popup/main.tsx b/apps/web-clipper/entrypoints/popup/main.tsxindex 57b85537c5..46bd4bd711 100644--- a/apps/web-clipper/entrypoints/popup/main.tsx+++ b/apps/web-clipper/entrypoints/popup/main.tsx@@ -366,7 +366,8 @@ function PagePreview({ tab, disabled, shortcuts, draft, onDraftChange }: {const mode = chosenMode && modes.includes(chosenMode) ? chosenMode : modes[0];const clip = mode === "selection" ? selection : mode === "page" ? pageClip : undefined;const shownTitle = title ?? (pageReading ?? selection)?.title ?? tab?.title ?? "";- const shownDescription = description ?? tab?.description ?? "";+ const shownDescription =+ description ?? tab?.description ?? pageReading?.labels.pageDescription ?? "";const savedDescription = shownDescription.replace(/\s+/g, " ").trim();const shownAuthor = author ?? pageReading?.labels.pageAuthor ?? "";const savedAuthor = shownAuthor.replace(/\s+/g, " ").trim();diff --git a/apps/web-clipper/entrypoints/popup/popup.spec.tsx b/apps/web-clipper/entrypoints/popup/popup.spec.tsxindex 51f9e7bde8..5a82e59e03 100644--- a/apps/web-clipper/entrypoints/popup/popup.spec.tsx+++ b/apps/web-clipper/entrypoints/popup/popup.spec.tsx@@ -539,6 +539,21 @@ describe("popup", () => {expect(container.querySelector(".page-body .note-text")).not.toBeNull();});+ it("takes the description from the page reading when the content script cannot be asked", async () => {+ const labels = { ...PAGE.labels, pageDescription: "All about the post" };+ pageReadings = { article: { ...PAGE, labels }, wholePage: WHOLE_PAGE };+ metadata = new Error("Could not establish connection.");+ await rerender();++ expect(container.querySelector<HTMLTextAreaElement>(".page-description")?.value)+ .toBe("All about the post");+ await click("Save page to Trilium");+ expect(sendMessage).toHaveBeenLastCalledWith({+ name: "save-whole-page",+ page: { ...PAGE, labels }+ });+ });+it("offers the page's author in Page mode, and saves it as edited", async () => {const author = () => container.querySelector<HTMLInputElement>(".page-fields .page-author");expect(author()?.value).toBe("Jane Doe");