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
refactor(client): hide pdf.js' own sidebar on both layouts
Elian Dorane56f23881973
diff --git a/apps/client/src/widgets/type_widgets/file/PdfViewer.spec.tsx b/apps/client/src/widgets/type_widgets/file/PdfViewer.spec.tsxindex 43b1910e42..55f6638abe 100644--- a/apps/client/src/widgets/type_widgets/file/PdfViewer.spec.tsx+++ b/apps/client/src/widgets/type_widgets/file/PdfViewer.spec.tsx@@ -25,6 +25,10 @@ describe("PdfViewer", () => {expect(viewerUrl({}).has("noteId")).toBe(false);expect(viewerUrl({ noteId: "abc123", ntxId: null }).has("ntxId")).toBe(false);});++ it("hides pdf.js' own sidebar, since the right panel lists the document's contents", () => {+ expect(viewerUrl({}).get("sidebar")).toBe("0");+ });});describe("getPdfUrl", () => {diff --git a/apps/client/src/widgets/type_widgets/file/PdfViewer.tsx b/apps/client/src/widgets/type_widgets/file/PdfViewer.tsxindex 697ad4273a..9224fb0897 100644--- a/apps/client/src/widgets/type_widgets/file/PdfViewer.tsx+++ b/apps/client/src/widgets/type_widgets/file/PdfViewer.tsx@@ -2,7 +2,7 @@ import type { HTMLAttributes, RefObject } from "preact";import { useCallback, useEffect, useRef } from "preact/hooks";import { onEffectiveThemeStyleChange } from "../../../services/theme";-import { useSyncedRef, useTriliumOption, useTriliumOptionBool } from "../../react/hooks";+import { useSyncedRef, useTriliumOption } from "../../react/hooks";interface FontDefinition {name: string;@@ -48,7 +48,6 @@ interface PdfViewerProps extends Pick<HTMLAttributes<HTMLIFrameElement>, "tabIndexport default function PdfViewer({ iframeRef: externalIframeRef, pdfUrl, onLoad, editable, toolbar = true, disableSelection, minPixelRatio, noteId, ntxId }: PdfViewerProps) {const iframeRef = useSyncedRef(externalIframeRef, null);const [ locale ] = useTriliumOption("locale");- const [ newLayout ] = useTriliumOptionBool("newLayout");const injectStyles = useStyleInjection(iframeRef, disableSelection);return (@@ -56,7 +55,7 @@ export default function PdfViewer({ iframeRef: externalIframeRef, pdfUrl, onLoadref={iframeRef}class="pdf-preview"style={{width: "100%", height: "100%"}}- src={`pdfjs/web/viewer.html?v=${glob.triliumVersion}&file=${pdfUrl}&locale=${locale}&sidebar=${newLayout ? "0" : "1"}&editable=${editable ? "1" : "0"}&toolbar=${toolbar ? "1" : "0"}${minPixelRatio ? `&minPixelRatio=${minPixelRatio}` : ""}${noteId ? getAddressParams(noteId, ntxId) : ""}`}+ src={`pdfjs/web/viewer.html?v=${glob.triliumVersion}&file=${pdfUrl}&locale=${locale}&sidebar=0&editable=${editable ? "1" : "0"}&toolbar=${toolbar ? "1" : "0"}${minPixelRatio ? `&minPixelRatio=${minPixelRatio}` : ""}${noteId ? getAddressParams(noteId, ntxId) : ""}`}onLoad={() => {injectStyles();onLoad?.();