Merge pull request #2552 from overleaf/jel-update-pdfjs
Update PDF.js GitOrigin-RevId: 231ab11eccc32e4eddc87fc8829dd28843e41a51
This commit is contained in:
@@ -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()
|
||||
})
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user