diff --git a/CHANGELOG.md b/CHANGELOG.md index 355aa4a..89c54b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ instead of version numbers. [[#346](https://github.com/edemaine/coauthor/issues/346)] * PDFs remember your previous page when you click on a link, adding back/forward navigation buttons similar to browser back/forward. +* + and - keys now advance pages in the current PDF. + (Click or mouse over a PDF to make it the current PDF.) ## 2023-12-17 diff --git a/client/MessagePDF.coffee b/client/MessagePDF.coffee index 0dc94cc..b439973 100644 --- a/client/MessagePDF.coffee +++ b/client/MessagePDF.coffee @@ -11,6 +11,8 @@ import {themeDocument} from '/lib/settings' #pdf2svg = false # controls pdf.js rendering mode pdfjs = null # will become import of 'pdfjs-dist' +export currentPDF = null + export messageTheme = new ReactiveDict export getMessageTheme = (fileId) -> @@ -53,6 +55,7 @@ WrappedMessagePDF = React.memo ({file}) -> [page, setPage] = useState() [annotations, setAnnotations] = useState [] [annotationsTransform, setAnnotationsTransform] = useState() + thisPDF = useRef() useTracker -> ## Reset @@ -109,6 +112,8 @@ WrappedMessagePDF = React.memo ({file}) -> unless inView replaceCanvas canvasRef, nullCanvas() if canvasRef.current.width return + ## Keep track of latest rendered PDF + currentPDF = thisPDF ## Secondary canvas for double-buffered rendering canvas = document.createElement 'canvas' context = canvas.getContext '2d' @@ -170,6 +175,8 @@ WrappedMessagePDF = React.memo ({file}) -> onChangePage = (delta) => (e) => e.currentTarget.blur() setPageNum clipPage pageNum + delta + thisPDF.current = (delta) => + setPageNum clipPage pageNum + delta onInputPage = (e) => setPageInput e.currentTarget.value p = Math.round e.currentTarget.valueAsNumber @@ -188,8 +195,10 @@ WrappedMessagePDF = React.memo ({file}) -> setFit newFit onTheme = (e) => messageTheme.set file, oppositeTheme theme + onFocus = (e) => + currentPDF = thisPDF -
+
{if progress?
@@ -233,12 +242,12 @@ WrappedMessagePDF = React.memo ({file}) ->