Merge pull request #937 from zoehneto/pdf-new-options

Remember viewer spread and scroll modes and also make them configurable
This commit is contained in:
James Yu 2018-11-01 19:48:43 +08:00 committed by GitHub
commit 1803b7ecec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -649,6 +649,16 @@
"default": "auto",
"description": "The default zoom level of the PDF viewer.\nThis default value will be passed to the viewer upon opening. Possible values are `auto`, `page-actual`, `page-fit`, `page-width`, and one-based scale values (e.g., 0.5 for 50%, 2.0 for 200%)."
},
"latex-workshop.view.pdf.scrollMode": {
"type": "number",
"default": 0,
"description": "The default scroll mode of the PDF viewer.\nThis default value will be passed to the viewer upon opening. Possible values are `0` (vertical), `1`(horizontal) and `2` (wrapped)."
},
"latex-workshop.view.pdf.spreadMode": {
"type": "number",
"default": 0,
"description": "The default spread mode of the PDF viewer.\nThis default value will be passed to the viewer upon opening. Possible values are `0` (none), `1` (odd) and `2` (even)."
},
"latex-workshop.view.pdf.hand": {
"type": "boolean",
"default": false,

View File

@ -180,6 +180,8 @@ export class Viewer {
client.websocket.send(JSON.stringify({
type: 'params',
scale: configuration.get('view.pdf.zoom'),
scrollMode: configuration.get('view.pdf.scrollMode'),
spreadMode: configuration.get('view.pdf.spreadMode'),
hand: configuration.get('view.pdf.hand'),
invert: configuration.get('view.pdf.invert'),
}))

View File

@ -47,6 +47,8 @@ socket.addEventListener("message", (event) => {
// the user has clicked on any link in the past (pdf.js will automatically navigate to that link).
socket.send(JSON.stringify({type:"position",
scale:PDFViewerApplication.pdfViewer.currentScaleValue,
scrollMode:PDFViewerApplication.pdfViewer.scrollMode,
spreadMode:PDFViewerApplication.pdfViewer.spreadMode,
scrollTop:document.getElementById('viewerContainer').scrollTop,
scrollLeft:document.getElementById('viewerContainer').scrollLeft}))
PDFViewerApplicationOptions.set('showPreviousViewOnLoad', false);
@ -54,6 +56,8 @@ socket.addEventListener("message", (event) => {
break
case "position":
PDFViewerApplication.pdfViewer.currentScaleValue = data.scale
PDFViewerApplication.pdfViewer.scrollMode = data.scrollMode
PDFViewerApplication.pdfViewer.spreadMode = data.spreadMode
document.getElementById('viewerContainer').scrollTop = data.scrollTop
document.getElementById('viewerContainer').scrollLeft = data.scrollLeft
break
@ -61,6 +65,12 @@ socket.addEventListener("message", (event) => {
if (data.scale) {
PDFViewerApplication.pdfViewer.currentScaleValue = data.scale
}
if (data.scrollMode) {
PDFViewerApplication.pdfViewer.scrollMode = data.scrollMode
}
if (data.spreadMode) {
PDFViewerApplication.pdfViewer.spreadMode = data.spreadMode
}
if (data.hand) {
PDFViewerApplication.pdfCursorTools.handTool.activate()
} else {