mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-09 12:35:51 +00:00
Upgrade pdf.js to 3.6.172 (#13112)
GitOrigin-RevId: 030528343f271a1fc1e07c3bba358873173bec76
This commit is contained in:
parent
4670c698ee
commit
1f7d317db9
8 changed files with 62 additions and 34 deletions
56
package-lock.json
generated
56
package-lock.json
generated
|
@ -12281,9 +12281,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/canvas": {
|
||||
"version": "2.10.2",
|
||||
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.10.2.tgz",
|
||||
"integrity": "sha512-FSmlsip0nZ0U4Zcfht0qBJqDhlfGuevTZKE8h+dBOYrJjGvY3iqMGSzzbvkaFhvMXiVxfcMaPHS/kge++T5SKg==",
|
||||
"version": "2.11.2",
|
||||
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.11.2.tgz",
|
||||
"integrity": "sha512-ItanGBMrmRV7Py2Z+Xhs7cT+FNt5K0vPL4p9EZ/UX/Mu7hFbkxSjKF2KVtPwX7UYWp7dRKnrTvReflgrItJbdw==",
|
||||
"hasInstallScript": true,
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
|
@ -25916,6 +25916,14 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/path2d-polyfill": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path2d-polyfill/-/path2d-polyfill-2.0.1.tgz",
|
||||
"integrity": "sha512-ad/3bsalbbWhmBo0D6FZ4RNMwsLsPpL6gnvhuSaU5Vm7b06Kr5ubSltQQ0T7YKsiJQO+g22zJ4dJKNTXIyOXtA==",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/pathval": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
|
||||
|
@ -25947,19 +25955,23 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/pdfjs-dist31": {
|
||||
"node_modules/pdfjs-dist36": {
|
||||
"name": "pdfjs-dist",
|
||||
"version": "3.1.81",
|
||||
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-3.1.81.tgz",
|
||||
"integrity": "sha512-hZHVVbjU2Ac1VYyPFrg9fBcyS7EEdB8YFy5upk6LmnsXl10WxAavdiViGWi2C/xK0GZObEpSSJU1VnoF9t8n9w==",
|
||||
"version": "3.6.172",
|
||||
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-3.6.172.tgz",
|
||||
"integrity": "sha512-bfOhCg+S9DXh/ImWhWYTOiq3aVMFSCvzGiBzsIJtdMC71kVWDBw7UXr32xh0y56qc5wMVylIeqV3hBaRsu+e+w==",
|
||||
"dependencies": {
|
||||
"path2d-polyfill": "^2.0.1",
|
||||
"web-streams-polyfill": "^3.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"canvas": "^2.10.2"
|
||||
"canvas": "^2.11.2"
|
||||
}
|
||||
},
|
||||
"node_modules/pdfjs-dist31/node_modules/web-streams-polyfill": {
|
||||
"node_modules/pdfjs-dist36/node_modules/web-streams-polyfill": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
|
||||
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
|
||||
|
@ -35260,7 +35272,7 @@
|
|||
"passport-saml": "^3.2.4",
|
||||
"passport-twitter": "^1.0.4",
|
||||
"pdfjs-dist213": "npm:pdfjs-dist@2.13.216",
|
||||
"pdfjs-dist31": "npm:pdfjs-dist@3.1.81",
|
||||
"pdfjs-dist36": "npm:pdfjs-dist@3.6.172",
|
||||
"prop-types": "^15.7.2",
|
||||
"pug": "^3.0.1",
|
||||
"pug-runtime": "^3.0.1",
|
||||
|
@ -45086,7 +45098,7 @@
|
|||
"passport-saml": "^3.2.4",
|
||||
"passport-twitter": "^1.0.4",
|
||||
"pdfjs-dist213": "npm:pdfjs-dist@2.13.216",
|
||||
"pdfjs-dist31": "npm:pdfjs-dist@3.1.81",
|
||||
"pdfjs-dist36": "npm:pdfjs-dist@3.6.172",
|
||||
"pirates": "^4.0.1",
|
||||
"postcss-loader": "^6.2.1",
|
||||
"prop-types": "^15.7.2",
|
||||
|
@ -50486,9 +50498,9 @@
|
|||
"integrity": "sha512-bdsfZd6K6ap87AGqSHJP/s1V+U6Z5lyrcbBu3ovbCCf8cSYpwTtGrCBObMpJqwxfTbLW6YTIdbb1jEeTelcpYQ=="
|
||||
},
|
||||
"canvas": {
|
||||
"version": "2.10.2",
|
||||
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.10.2.tgz",
|
||||
"integrity": "sha512-FSmlsip0nZ0U4Zcfht0qBJqDhlfGuevTZKE8h+dBOYrJjGvY3iqMGSzzbvkaFhvMXiVxfcMaPHS/kge++T5SKg==",
|
||||
"version": "2.11.2",
|
||||
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.11.2.tgz",
|
||||
"integrity": "sha512-ItanGBMrmRV7Py2Z+Xhs7cT+FNt5K0vPL4p9EZ/UX/Mu7hFbkxSjKF2KVtPwX7UYWp7dRKnrTvReflgrItJbdw==",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"@mapbox/node-pre-gyp": "^1.0.0",
|
||||
|
@ -61411,6 +61423,11 @@
|
|||
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
|
||||
"devOptional": true
|
||||
},
|
||||
"path2d-polyfill": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path2d-polyfill/-/path2d-polyfill-2.0.1.tgz",
|
||||
"integrity": "sha512-ad/3bsalbbWhmBo0D6FZ4RNMwsLsPpL6gnvhuSaU5Vm7b06Kr5ubSltQQ0T7YKsiJQO+g22zJ4dJKNTXIyOXtA=="
|
||||
},
|
||||
"pathval": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
|
||||
|
@ -61430,12 +61447,13 @@
|
|||
"web-streams-polyfill": "^3.2.0"
|
||||
}
|
||||
},
|
||||
"pdfjs-dist31": {
|
||||
"version": "npm:pdfjs-dist@3.1.81",
|
||||
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-3.1.81.tgz",
|
||||
"integrity": "sha512-hZHVVbjU2Ac1VYyPFrg9fBcyS7EEdB8YFy5upk6LmnsXl10WxAavdiViGWi2C/xK0GZObEpSSJU1VnoF9t8n9w==",
|
||||
"pdfjs-dist36": {
|
||||
"version": "npm:pdfjs-dist@3.6.172",
|
||||
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-3.6.172.tgz",
|
||||
"integrity": "sha512-bfOhCg+S9DXh/ImWhWYTOiq3aVMFSCvzGiBzsIJtdMC71kVWDBw7UXr32xh0y56qc5wMVylIeqV3hBaRsu+e+w==",
|
||||
"requires": {
|
||||
"canvas": "^2.10.2",
|
||||
"canvas": "^2.11.2",
|
||||
"path2d-polyfill": "^2.0.1",
|
||||
"web-streams-polyfill": "^3.2.1"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -968,7 +968,7 @@ const ProjectController = {
|
|||
SplitTestHandler.getAssignment(
|
||||
req,
|
||||
res,
|
||||
'pdfjs-31',
|
||||
'pdfjs-36',
|
||||
{},
|
||||
(error, assignment) => {
|
||||
// do not fail editor load if assignment fails
|
||||
|
|
|
@ -35,7 +35,7 @@ const buildConfig = () => {
|
|||
)
|
||||
|
||||
// add entrypoints under '/' for pdfjs workers
|
||||
const pdfjsVersions = ['pdfjs-dist213', 'pdfjs-dist31']
|
||||
const pdfjsVersions = ['pdfjs-dist213', 'pdfjs-dist36']
|
||||
for (const name of pdfjsVersions) {
|
||||
addWorker(name, `${name}/legacy/build/pdf.worker.js`)
|
||||
}
|
||||
|
|
|
@ -215,7 +215,11 @@ function PdfJsViewer({ url, pdfFile }) {
|
|||
useEffect(() => {
|
||||
if (pdfJsWrapper) {
|
||||
const handleTextlayerrendered = textLayer => {
|
||||
const pageElement = textLayer.source.textLayerDiv.closest('.page')
|
||||
// handle both versions for backwards-compatibility
|
||||
const textLayerDiv =
|
||||
textLayer.source.textLayerDiv ?? textLayer.source.textLayer.div
|
||||
|
||||
const pageElement = textLayerDiv.closest('.page')
|
||||
|
||||
if (!pageElement.dataset.listeningForDoubleClick) {
|
||||
pageElement.dataset.listeningForDoubleClick = true
|
||||
|
|
|
@ -6,20 +6,20 @@ import 'core-js/stable/promise/all-settled' // polyfill for Promise.allSettled (
|
|||
import getMeta from '../../../utils/meta'
|
||||
import { createWorker } from '../../../utils/worker'
|
||||
|
||||
async function importPDFJS31() {
|
||||
const cMapUrl = '/js/pdfjs-dist31/cmaps/'
|
||||
const standardFontDataUrl = '/fonts/pdfjs-dist31/'
|
||||
const imageResourcesPath = '/images/pdfjs-dist31/'
|
||||
async function importPDFJS36() {
|
||||
const cMapUrl = '/js/pdfjs-dist36/cmaps/'
|
||||
const standardFontDataUrl = '/fonts/pdfjs-dist36/'
|
||||
const imageResourcesPath = '/images/pdfjs-dist36/'
|
||||
|
||||
const [PDFJS, PDFJSViewer] = await Promise.all([
|
||||
import('pdfjs-dist31/legacy/build/pdf'),
|
||||
import('pdfjs-dist31/legacy/web/pdf_viewer'),
|
||||
import('pdfjs-dist31/legacy/web/pdf_viewer.css'),
|
||||
import('pdfjs-dist36/legacy/build/pdf'),
|
||||
import('pdfjs-dist36/legacy/web/pdf_viewer'),
|
||||
import('pdfjs-dist36/legacy/web/pdf_viewer.css'),
|
||||
])
|
||||
|
||||
createWorker(() => {
|
||||
PDFJS.GlobalWorkerOptions.workerPort = new Worker(
|
||||
new URL('pdfjs-dist31/legacy/build/pdf.worker.js', import.meta.url)
|
||||
new URL('pdfjs-dist36/legacy/build/pdf.worker.js', import.meta.url)
|
||||
)
|
||||
})
|
||||
|
||||
|
@ -61,13 +61,14 @@ async function importPDFJS213() {
|
|||
async function importPDFJS() {
|
||||
const variant = getMeta('ol-pdfjsVariant', 'default')
|
||||
|
||||
// NOTE: split test variants must have at least 3 characters
|
||||
switch (variant) {
|
||||
case '213':
|
||||
case 'default':
|
||||
return importPDFJS213()
|
||||
|
||||
case '318':
|
||||
return importPDFJS31()
|
||||
case '36172':
|
||||
return importPDFJS36()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,10 @@
|
|||
box-sizing: content-box;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
box-shadow: 0 0 8px #bbb;
|
||||
border: none;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.pdfjs-viewer-inner {
|
||||
position: absolute;
|
||||
|
@ -209,6 +213,7 @@
|
|||
top: 0;
|
||||
left: 0;
|
||||
display: inline-block;
|
||||
z-index: 2;
|
||||
.btn-group {
|
||||
transition: opacity 0.5s ease, visibility 0 linear 0.5s;
|
||||
visibility: hidden;
|
||||
|
|
|
@ -215,7 +215,7 @@
|
|||
"passport-saml": "^3.2.4",
|
||||
"passport-twitter": "^1.0.4",
|
||||
"pdfjs-dist213": "npm:pdfjs-dist@2.13.216",
|
||||
"pdfjs-dist31": "npm:pdfjs-dist@3.1.81",
|
||||
"pdfjs-dist36": "npm:pdfjs-dist@3.6.172",
|
||||
"prop-types": "^15.7.2",
|
||||
"pug": "^3.0.1",
|
||||
"pug-runtime": "^3.0.1",
|
||||
|
|
|
@ -61,7 +61,7 @@ const mathjaxDir = getModuleDirectory('mathjax')
|
|||
const mathjax3Dir = getModuleDirectory('mathjax-3')
|
||||
const aceDir = getModuleDirectory('ace-builds')
|
||||
|
||||
const pdfjsVersions = ['pdfjs-dist213', 'pdfjs-dist31']
|
||||
const pdfjsVersions = ['pdfjs-dist213', 'pdfjs-dist36']
|
||||
|
||||
const vendorDir = path.join(__dirname, 'frontend/js/vendor')
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue