diff --git a/apps/client/src/widgets/type_widgets/file/Pdf.tsx b/apps/client/src/widgets/type_widgets/file/Pdf.tsx index ee731448a9..cd010857a7 100644 --- a/apps/client/src/widgets/type_widgets/file/Pdf.tsx +++ b/apps/client/src/widgets/type_widgets/file/Pdf.tsx @@ -184,7 +184,7 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: { { const win = iframeRef.current?.contentWindow; if (win) { diff --git a/apps/client/src/widgets/type_widgets/file/PdfViewer.tsx b/apps/client/src/widgets/type_widgets/file/PdfViewer.tsx index 6415b89dd6..e00d0e9079 100644 --- a/apps/client/src/widgets/type_widgets/file/PdfViewer.tsx +++ b/apps/client/src/widgets/type_widgets/file/PdfViewer.tsx @@ -1,7 +1,8 @@ import type { HTMLAttributes, RefObject } from "preact"; import { useCallback, useEffect, useRef } from "preact/hooks"; -import Inter from "./../../../fonts/Inter/Inter-VariableFont_opsz,wght.ttf"; + import { useSyncedRef, useTriliumOption, useTriliumOptionBool } from "../../react/hooks"; +import Inter from "./../../../fonts/Inter/Inter-VariableFont_opsz,wght.ttf"; interface FontDefinition { name: string; @@ -10,11 +11,11 @@ interface FontDefinition { const FONTS: FontDefinition[] = [ {name: "Inter", url: Inter}, -] +]; interface PdfViewerProps extends Pick, "tabIndex"> { iframeRef?: RefObject; - /** Note: URLs are relative to /pdfjs/web. */ + /** Note: URLs are relative to /pdfjs/web, ideally use absolute paths (but without domain name) to avoid issues with some proxies. */ pdfUrl: string; onLoad?(): void; /** @@ -63,7 +64,7 @@ function useStyleInjection(iframeRef: RefObject) { const fontStyles = doc.createElement("style"); fontStyles.textContent = FONTS.map(injectFont).join("\n"); doc.head.appendChild(fontStyles); - + }, [ iframeRef ]); // React to changes. @@ -107,4 +108,4 @@ function injectFont(font: FontDefinition) { src: url('${font.url}'); } `; -} \ No newline at end of file +}