From 222ba263ffbfb5885a8933a9eb32bdec4240420e Mon Sep 17 00:00:00 2001 From: Jessica Lawshe Date: Tue, 11 Feb 2020 08:50:39 -0600 Subject: [PATCH] Merge pull request #2552 from overleaf/jel-update-pdfjs Update PDF.js GitOrigin-RevId: 231ab11eccc32e4eddc87fc8829dd28843e41a51 --- .../js/ide/pdfng/directives/pdfRenderer.js | 29 ++++++++++--------- .../vendor/pdfListView/TextLayer.css | 10 +++---- services/web/package-lock.json | 6 ++-- services/web/package.json | 2 +- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/services/web/frontend/js/ide/pdfng/directives/pdfRenderer.js b/services/web/frontend/js/ide/pdfng/directives/pdfRenderer.js index eb7be5d440..221b837cbf 100644 --- a/services/web/frontend/js/ide/pdfng/directives/pdfRenderer.js +++ b/services/web/frontend/js/ide/pdfng/directives/pdfRenderer.js @@ -22,7 +22,6 @@ define(['base', './pdfJsLoader'], (App, PDFJS) => // App = angular.module 'PDFRenderer', ['pdfAnnotations', 'pdfTextLayer'] App.factory('PDFRenderer', function( - $q, $timeout, pdfAnnotations, pdfTextLayer, @@ -76,11 +75,11 @@ define(['base', './pdfJsLoader'], (App, PDFJS) => disableStream: !!this.options.disableAutoFetch }) this.pdfjs.onProgress = this.options.progressCallback - this.document = $q.when(this.pdfjs) + this.document = this.pdfjs this.navigateFn = this.options.navigateFn this.spinner = new pdfSpinner() this.resetState() - this.document.then(pdfDocument => { + this.document.promise.then(pdfDocument => { return pdfDocument.getDownloadInfo().then(() => { return this.options.loadedCallback() }) @@ -116,22 +115,24 @@ define(['base', './pdfJsLoader'], (App, PDFJS) => } getNumPages() { - return this.document.then(pdfDocument => pdfDocument.numPages) + return this.document.promise.then(pdfDocument => pdfDocument.numPages) } getPage(pageNum) { - return this.document.then(pdfDocument => pdfDocument.getPage(pageNum)) + return this.document.promise.then(pdfDocument => + pdfDocument.getPage(pageNum) + ) } getPdfViewport(pageNum, scale) { if (scale == null) { ;({ scale } = this) } - return this.document.then(pdfDocument => { + return this.document.promise.then(pdfDocument => { return pdfDocument.getPage(pageNum).then( function(page) { let viewport - return (viewport = page.getViewport(scale)) + return (viewport = page.getViewport({ scale: scale })) }, error => { return typeof this.errorCallback === 'function' @@ -143,13 +144,13 @@ define(['base', './pdfJsLoader'], (App, PDFJS) => } getDestinations() { - return this.document.then(pdfDocument => + return this.document.promise.then(pdfDocument => pdfDocument.getDestinations() ) } getDestination(dest) { - return this.document.then( + return this.document.promise.then( pdfDocument => pdfDocument.getDestination(dest), error => { return typeof this.errorCallback === 'function' @@ -160,7 +161,7 @@ define(['base', './pdfJsLoader'], (App, PDFJS) => } getPageIndex(ref) { - return this.document.then(pdfDocument => { + return this.document.promise.then(pdfDocument => { return pdfDocument.getPageIndex(ref).then( idx => idx, error => { @@ -366,7 +367,7 @@ define(['base', './pdfJsLoader'], (App, PDFJS) => return } // return from cancelled page load pageState.renderTask = this.doRender(element, pagenum, pageObject) - return pageState.renderTask.then( + return pageState.renderTask.promise.then( () => { // render task success this.clearIndicator(page) @@ -409,7 +410,7 @@ define(['base', './pdfJsLoader'], (App, PDFJS) => // when rendering was complete. element.canvas.replaceWith(canvas) - const viewport = page.getViewport(scale) + const viewport = page.getViewport({ scale: scale }) const devicePixelRatio = window.devicePixelRatio || 1 @@ -467,7 +468,7 @@ define(['base', './pdfJsLoader'], (App, PDFJS) => const textLayerTimeout = this.TEXTLAYER_TIMEOUT - result + result.promise .then(function() { // page render success canvas.removeClass('pdfng-rendering') @@ -508,7 +509,7 @@ define(['base', './pdfJsLoader'], (App, PDFJS) => destroy() { this.shuttingDown = true this.resetState() - return this.pdfjs.then(function(document) { + return this.pdfjs.promise.then(function(document) { document.cleanup() return document.destroy() }) diff --git a/services/web/frontend/stylesheets/vendor/pdfListView/TextLayer.css b/services/web/frontend/stylesheets/vendor/pdfListView/TextLayer.css index 7fe818f658..fa3a627cc9 100644 --- a/services/web/frontend/stylesheets/vendor/pdfListView/TextLayer.css +++ b/services/web/frontend/stylesheets/vendor/pdfListView/TextLayer.css @@ -12,7 +12,7 @@ overflow: hidden; pointer-events: none; } -.plv-text-layer > div { +.plv-text-layer > span { color: transparent; position: absolute; line-height: 1; @@ -25,9 +25,9 @@ -ms-transform-origin: 0% 0%; transform-origin: 0% 0%; } -.plv-text-layer > div::selection { - background:rgba(0,0,255,0.3); +.plv-text-layer > span::selection { + background: rgba(0, 0, 255, 0.3); } -.plv-text-layer > div::-moz-selection { - background:rgba(0,0,255,0.3); +.plv-text-layer > span::-moz-selection { + background: rgba(0, 0, 255, 0.3); } diff --git a/services/web/package-lock.json b/services/web/package-lock.json index f02c7df593..91b2190552 100644 --- a/services/web/package-lock.json +++ b/services/web/package-lock.json @@ -16716,9 +16716,9 @@ } }, "pdfjs-dist": { - "version": "2.0.943", - "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.0.943.tgz", - "integrity": "sha512-iLhNcm4XceTHRaSU5o22ZGCm4YpuW5+rf4+BJFH/feBhMQLbCGBry+Jet8Q419QDI4qgARaIQzXuiNrsNWS8Yw==", + "version": "2.2.228", + "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.2.228.tgz", + "integrity": "sha512-W5LhYPMS2UKX0ELIa4u+CFCMoox5qQNQElt0bAK2mwz1V8jZL0rvLao+0tBujce84PK6PvWG36Nwr7agCCWFGQ==", "requires": { "node-ensure": "^0.0.0", "worker-loader": "^2.0.0" diff --git a/services/web/package.json b/services/web/package.json index ad94bcb9b6..e323d9ce9d 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -100,7 +100,7 @@ "passport-orcid": "0.0.3", "passport-saml": "^1.1.0", "passport-twitter": "^1.0.4", - "pdfjs-dist": "^2.0.943", + "pdfjs-dist": "^2.2.228", "pug": "^2.0.0-beta6", "react": "^15.4.2", "react-dom": "^15.4.2",