mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2552 from overleaf/jel-update-pdfjs
Update PDF.js GitOrigin-RevId: 231ab11eccc32e4eddc87fc8829dd28843e41a51
This commit is contained in:
parent
353625be51
commit
222ba263ff
4 changed files with 24 additions and 23 deletions
|
@ -22,7 +22,6 @@ define(['base', './pdfJsLoader'], (App, PDFJS) =>
|
||||||
// App = angular.module 'PDFRenderer', ['pdfAnnotations', 'pdfTextLayer']
|
// App = angular.module 'PDFRenderer', ['pdfAnnotations', 'pdfTextLayer']
|
||||||
|
|
||||||
App.factory('PDFRenderer', function(
|
App.factory('PDFRenderer', function(
|
||||||
$q,
|
|
||||||
$timeout,
|
$timeout,
|
||||||
pdfAnnotations,
|
pdfAnnotations,
|
||||||
pdfTextLayer,
|
pdfTextLayer,
|
||||||
|
@ -76,11 +75,11 @@ define(['base', './pdfJsLoader'], (App, PDFJS) =>
|
||||||
disableStream: !!this.options.disableAutoFetch
|
disableStream: !!this.options.disableAutoFetch
|
||||||
})
|
})
|
||||||
this.pdfjs.onProgress = this.options.progressCallback
|
this.pdfjs.onProgress = this.options.progressCallback
|
||||||
this.document = $q.when(this.pdfjs)
|
this.document = this.pdfjs
|
||||||
this.navigateFn = this.options.navigateFn
|
this.navigateFn = this.options.navigateFn
|
||||||
this.spinner = new pdfSpinner()
|
this.spinner = new pdfSpinner()
|
||||||
this.resetState()
|
this.resetState()
|
||||||
this.document.then(pdfDocument => {
|
this.document.promise.then(pdfDocument => {
|
||||||
return pdfDocument.getDownloadInfo().then(() => {
|
return pdfDocument.getDownloadInfo().then(() => {
|
||||||
return this.options.loadedCallback()
|
return this.options.loadedCallback()
|
||||||
})
|
})
|
||||||
|
@ -116,22 +115,24 @@ define(['base', './pdfJsLoader'], (App, PDFJS) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
getNumPages() {
|
getNumPages() {
|
||||||
return this.document.then(pdfDocument => pdfDocument.numPages)
|
return this.document.promise.then(pdfDocument => pdfDocument.numPages)
|
||||||
}
|
}
|
||||||
|
|
||||||
getPage(pageNum) {
|
getPage(pageNum) {
|
||||||
return this.document.then(pdfDocument => pdfDocument.getPage(pageNum))
|
return this.document.promise.then(pdfDocument =>
|
||||||
|
pdfDocument.getPage(pageNum)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getPdfViewport(pageNum, scale) {
|
getPdfViewport(pageNum, scale) {
|
||||||
if (scale == null) {
|
if (scale == null) {
|
||||||
;({ scale } = this)
|
;({ scale } = this)
|
||||||
}
|
}
|
||||||
return this.document.then(pdfDocument => {
|
return this.document.promise.then(pdfDocument => {
|
||||||
return pdfDocument.getPage(pageNum).then(
|
return pdfDocument.getPage(pageNum).then(
|
||||||
function(page) {
|
function(page) {
|
||||||
let viewport
|
let viewport
|
||||||
return (viewport = page.getViewport(scale))
|
return (viewport = page.getViewport({ scale: scale }))
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
return typeof this.errorCallback === 'function'
|
return typeof this.errorCallback === 'function'
|
||||||
|
@ -143,13 +144,13 @@ define(['base', './pdfJsLoader'], (App, PDFJS) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
getDestinations() {
|
getDestinations() {
|
||||||
return this.document.then(pdfDocument =>
|
return this.document.promise.then(pdfDocument =>
|
||||||
pdfDocument.getDestinations()
|
pdfDocument.getDestinations()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getDestination(dest) {
|
getDestination(dest) {
|
||||||
return this.document.then(
|
return this.document.promise.then(
|
||||||
pdfDocument => pdfDocument.getDestination(dest),
|
pdfDocument => pdfDocument.getDestination(dest),
|
||||||
error => {
|
error => {
|
||||||
return typeof this.errorCallback === 'function'
|
return typeof this.errorCallback === 'function'
|
||||||
|
@ -160,7 +161,7 @@ define(['base', './pdfJsLoader'], (App, PDFJS) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
getPageIndex(ref) {
|
getPageIndex(ref) {
|
||||||
return this.document.then(pdfDocument => {
|
return this.document.promise.then(pdfDocument => {
|
||||||
return pdfDocument.getPageIndex(ref).then(
|
return pdfDocument.getPageIndex(ref).then(
|
||||||
idx => idx,
|
idx => idx,
|
||||||
error => {
|
error => {
|
||||||
|
@ -366,7 +367,7 @@ define(['base', './pdfJsLoader'], (App, PDFJS) =>
|
||||||
return
|
return
|
||||||
} // return from cancelled page load
|
} // return from cancelled page load
|
||||||
pageState.renderTask = this.doRender(element, pagenum, pageObject)
|
pageState.renderTask = this.doRender(element, pagenum, pageObject)
|
||||||
return pageState.renderTask.then(
|
return pageState.renderTask.promise.then(
|
||||||
() => {
|
() => {
|
||||||
// render task success
|
// render task success
|
||||||
this.clearIndicator(page)
|
this.clearIndicator(page)
|
||||||
|
@ -409,7 +410,7 @@ define(['base', './pdfJsLoader'], (App, PDFJS) =>
|
||||||
// when rendering was complete.
|
// when rendering was complete.
|
||||||
element.canvas.replaceWith(canvas)
|
element.canvas.replaceWith(canvas)
|
||||||
|
|
||||||
const viewport = page.getViewport(scale)
|
const viewport = page.getViewport({ scale: scale })
|
||||||
|
|
||||||
const devicePixelRatio = window.devicePixelRatio || 1
|
const devicePixelRatio = window.devicePixelRatio || 1
|
||||||
|
|
||||||
|
@ -467,7 +468,7 @@ define(['base', './pdfJsLoader'], (App, PDFJS) =>
|
||||||
|
|
||||||
const textLayerTimeout = this.TEXTLAYER_TIMEOUT
|
const textLayerTimeout = this.TEXTLAYER_TIMEOUT
|
||||||
|
|
||||||
result
|
result.promise
|
||||||
.then(function() {
|
.then(function() {
|
||||||
// page render success
|
// page render success
|
||||||
canvas.removeClass('pdfng-rendering')
|
canvas.removeClass('pdfng-rendering')
|
||||||
|
@ -508,7 +509,7 @@ define(['base', './pdfJsLoader'], (App, PDFJS) =>
|
||||||
destroy() {
|
destroy() {
|
||||||
this.shuttingDown = true
|
this.shuttingDown = true
|
||||||
this.resetState()
|
this.resetState()
|
||||||
return this.pdfjs.then(function(document) {
|
return this.pdfjs.promise.then(function(document) {
|
||||||
document.cleanup()
|
document.cleanup()
|
||||||
return document.destroy()
|
return document.destroy()
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
.plv-text-layer > div {
|
.plv-text-layer > span {
|
||||||
color: transparent;
|
color: transparent;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
@ -25,9 +25,9 @@
|
||||||
-ms-transform-origin: 0% 0%;
|
-ms-transform-origin: 0% 0%;
|
||||||
transform-origin: 0% 0%;
|
transform-origin: 0% 0%;
|
||||||
}
|
}
|
||||||
.plv-text-layer > div::selection {
|
.plv-text-layer > span::selection {
|
||||||
background: rgba(0, 0, 255, 0.3);
|
background: rgba(0, 0, 255, 0.3);
|
||||||
}
|
}
|
||||||
.plv-text-layer > div::-moz-selection {
|
.plv-text-layer > span::-moz-selection {
|
||||||
background: rgba(0, 0, 255, 0.3);
|
background: rgba(0, 0, 255, 0.3);
|
||||||
}
|
}
|
||||||
|
|
6
services/web/package-lock.json
generated
6
services/web/package-lock.json
generated
|
@ -16716,9 +16716,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pdfjs-dist": {
|
"pdfjs-dist": {
|
||||||
"version": "2.0.943",
|
"version": "2.2.228",
|
||||||
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.0.943.tgz",
|
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.2.228.tgz",
|
||||||
"integrity": "sha512-iLhNcm4XceTHRaSU5o22ZGCm4YpuW5+rf4+BJFH/feBhMQLbCGBry+Jet8Q419QDI4qgARaIQzXuiNrsNWS8Yw==",
|
"integrity": "sha512-W5LhYPMS2UKX0ELIa4u+CFCMoox5qQNQElt0bAK2mwz1V8jZL0rvLao+0tBujce84PK6PvWG36Nwr7agCCWFGQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"node-ensure": "^0.0.0",
|
"node-ensure": "^0.0.0",
|
||||||
"worker-loader": "^2.0.0"
|
"worker-loader": "^2.0.0"
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
"passport-orcid": "0.0.3",
|
"passport-orcid": "0.0.3",
|
||||||
"passport-saml": "^1.1.0",
|
"passport-saml": "^1.1.0",
|
||||||
"passport-twitter": "^1.0.4",
|
"passport-twitter": "^1.0.4",
|
||||||
"pdfjs-dist": "^2.0.943",
|
"pdfjs-dist": "^2.2.228",
|
||||||
"pug": "^2.0.0-beta6",
|
"pug": "^2.0.0-beta6",
|
||||||
"react": "^15.4.2",
|
"react": "^15.4.2",
|
||||||
"react-dom": "^15.4.2",
|
"react-dom": "^15.4.2",
|
||||||
|
|
Loading…
Reference in a new issue