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(web-clipper): draw the preview's links in the theme's link color
Elian Doran8600b0e24221
diff --git a/apps/web-clipper/entrypoints/popup/main.tsx b/apps/web-clipper/entrypoints/popup/main.tsxindex 3f853895d0..9705e6d90b 100644--- a/apps/web-clipper/entrypoints/popup/main.tsx+++ b/apps/web-clipper/entrypoints/popup/main.tsx@@ -46,7 +46,7 @@ const PREVIEW_STYLE = `h1 { font-size: 1.3em; } h2 { font-size: 1.15em; } h3, h4, h5, h6 { font-size: 1em; }img, video, svg, iframe { max-width: 100%; height: auto; }pre { white-space: pre-wrap; }- a { pointer-events: none; }+ a { color: light-dark(#0076af, #95c3d9); text-decoration: none; pointer-events: none; }`;const root = document.getElementById("root");diff --git a/apps/web-clipper/entrypoints/popup/popup.spec.tsx b/apps/web-clipper/entrypoints/popup/popup.spec.tsxindex 74f792c468..5a8587ffc5 100644--- a/apps/web-clipper/entrypoints/popup/popup.spec.tsx+++ b/apps/web-clipper/entrypoints/popup/popup.spec.tsx@@ -1,4 +1,6 @@import Crop from "@boxicons/js/icons/Crop";+import { readFileSync } from "fs";+import { join } from "path";import { render } from "preact";import { act } from "preact/test-utils";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";@@ -314,6 +316,14 @@ describe("previewDocument", () => {expect(doc.querySelector("p")?.textContent).toBe("Body");expect(doc.querySelector("style")?.textContent).toContain("max-width: 100%");});++ it("colors links with the theme's link colors, which the frame cannot read from the popup", () => {+ const theme = readFileSync(join(import.meta.dirname, "../../assets/theme.css"), "utf8");+ const [ light, dark ] = [ ...theme.matchAll(/--link-color: (#[0-9a-f]+);/g) ].map((match) => match[1]);+ expect(light).toBeDefined();+ expect(dark).toBeDefined();+ expect(previewDocument(PAGE)).toContain(`color: light-dark(${light}, ${dark})`);+ });});describe("shortcutsByCommand", () => {