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(pdf): keep a text box's font colour out of the sidebar's row tint
Elian Doranf3c6b1a1761a
diff --git a/packages/pdfjs-viewer/src/annotations.spec.ts b/packages/pdfjs-viewer/src/annotations.spec.tsindex a461cc6653..de4bbce413 100644--- a/packages/pdfjs-viewer/src/annotations.spec.ts+++ b/packages/pdfjs-viewer/src/annotations.spec.ts@@ -218,6 +218,21 @@ describe("extraction from a real document", () => {expect(highlight).toMatchObject({ id: "5R", color: "#00ff00", contents: "Edited in the viewer" });});+ it("keeps a text box's font colour out of the sidebar's tint", async () => {+ viewer = await installViewerApp(allFeaturesPdf());+ // Every stored annotation becomes an editor once a tool is active, so this state is+ // reached just by pressing a toolbar button. A FreeTextEditor's `color` is the colour of+ // its *text*, not a fill — taking it would paint the row in the text's colour, and only+ // while a tool happened to be selected.+ vi.spyOn(viewer.pdfDocument.annotationStorage, "getEditor").mockImplementation((id: string) =>+ (id === "19R" ? { color: "#000000" } : null));++ await setupPdfAnnotations();++ const { annotations } = viewer.lastMessageOfType("pdfjs-viewer-annotations");+ expect(annotations.find((annotation: any) => annotation.id === "19R").color).toBeNull();+ });+it("removes deleted annotations even when they are adjacent", async () => {viewer = await installViewerApp(allFeaturesPdf());vi.spyOn(viewer.pdfDocument.annotationStorage, "getEditor").mockReturnValue({ deleted: true });diff --git a/packages/pdfjs-viewer/src/annotations.ts b/packages/pdfjs-viewer/src/annotations.tsindex 8a4a1cccaa..f8457855d1 100644--- a/packages/pdfjs-viewer/src/annotations.ts+++ b/packages/pdfjs-viewer/src/annotations.ts@@ -176,7 +176,7 @@ function applyEditorOverrides(annotations: PdfAnnotationInfo[], storage: any): Pif (editor?.deleted) {continue;}- if (editor?.color) {+ if (editor?.color && ann.type !== "freetext") {ann.color = editor.color;}if (editor?.comment?.text) {