From f68a481edcfb7267c95b9ff41fa4923dc4f9d84a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 15 Apr 2026 17:14:44 +0300 Subject: [PATCH] feat(print/pdf): disable selection in preview --- .../client/src/widgets/dialogs/print_preview.tsx | 2 +- .../src/widgets/type_widgets/file/PdfViewer.tsx | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/client/src/widgets/dialogs/print_preview.tsx b/apps/client/src/widgets/dialogs/print_preview.tsx index bcc329b9d7..5862802204 100644 --- a/apps/client/src/widgets/dialogs/print_preview.tsx +++ b/apps/client/src/widgets/dialogs/print_preview.tsx @@ -310,7 +310,7 @@ export default function PrintPreviewDialog() { )} - {pdfUrl && } + {pdfUrl && } ); diff --git a/apps/client/src/widgets/type_widgets/file/PdfViewer.tsx b/apps/client/src/widgets/type_widgets/file/PdfViewer.tsx index 0780a75d72..c072cb328c 100644 --- a/apps/client/src/widgets/type_widgets/file/PdfViewer.tsx +++ b/apps/client/src/widgets/type_widgets/file/PdfViewer.tsx @@ -22,16 +22,18 @@ interface PdfViewerProps extends Pick, "tabInd * If set, enables editable mode which includes persistence of user settings, annotations as well as specific features such as sending table of contents data for the sidebar. */ editable?: boolean; + /** If set, disables text selection in the rendered PDF. */ + disableSelection?: boolean; } /** * Reusable component displaying a PDF. The PDF needs to be provided via a URL. */ -export default function PdfViewer({ iframeRef: externalIframeRef, pdfUrl, onLoad, editable }: PdfViewerProps) { +export default function PdfViewer({ iframeRef: externalIframeRef, pdfUrl, onLoad, editable, disableSelection }: PdfViewerProps) { const iframeRef = useSyncedRef(externalIframeRef, null); const [ locale ] = useTriliumOption("locale"); const [ newLayout ] = useTriliumOptionBool("newLayout"); - const injectStyles = useStyleInjection(iframeRef); + const injectStyles = useStyleInjection(iframeRef, disableSelection); return (