Merge pull request #1393 from cryptpad/pdfjs-firefox
PDFjs rendering issue with Firefox 121
|
@ -150,7 +150,7 @@ define([
|
|||
video.src = url;
|
||||
};
|
||||
Thumb.fromPdfBlob = function (blob, cb) {
|
||||
require.config({paths: {'pdfjs-dist': '/lib/pdfjs'}});
|
||||
require.config({paths: {'pdfjs-dist': '/lib/pdfjs/legacy'}});
|
||||
require(['pdfjs-dist/build/pdf'], function (PDFJS) {
|
||||
var url = URL.createObjectURL(blob);
|
||||
var makeThumb = function (page) {
|
||||
|
|
|
@ -24,8 +24,29 @@ define([
|
|||
// Configure MediaTags to use our local viewer
|
||||
// This file is loaded by sframe-common so the following config is used in all the inner apps
|
||||
if (MediaTag) {
|
||||
// Firefox 121 introduces an issue with ligatures that requires an update to PDFjs
|
||||
// See: https://github.com/cryptpad/cryptpad/issues/1362
|
||||
// Unfortunately this updated PDFjs doesn't work with older browsers
|
||||
|
||||
let isModernFirefox = false;
|
||||
try {
|
||||
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
|
||||
if (isFirefox) {
|
||||
let version = +navigator.userAgent.match(/rv:([0-9.]+)/)[1];
|
||||
isModernFirefox = version >= 100;
|
||||
}
|
||||
} catch (e) {}
|
||||
let isModernChromium = false;
|
||||
try {
|
||||
isModernChromium = navigator.userAgentData.brands.some(data => {
|
||||
return data.brand === 'Chromium' && data.version >= 100;
|
||||
});
|
||||
} catch (e) {}
|
||||
|
||||
let path = 'legacy';
|
||||
if (isModernFirefox || isModernChromium) { path = 'modern'; }
|
||||
MediaTag.setDefaultConfig('pdf', {
|
||||
viewer: '/lib/pdfjs/web/viewer.html'
|
||||
viewer: `/lib/pdfjs/${path}/web/viewer.html`
|
||||
});
|
||||
MediaTag.setDefaultConfig('download', {
|
||||
text: Messages.mediatag_saveButton,
|
||||
|
|
|
@ -121,6 +121,12 @@ var factory = function () {
|
|||
if (cfg.pdf.viewer) { // PDFJS
|
||||
var viewerUrl = cfg.pdf.viewer + '?file=' + url;
|
||||
iframe.src = viewerUrl + '#' + window.encodeURIComponent(metadata.name);
|
||||
iframe.onload = function () {
|
||||
if (!metadata.name) { return; }
|
||||
try {
|
||||
iframe.contentWindow.PDFViewerApplication.setTitleUsingUrl(metadata.name)
|
||||
} catch (e) { console.warn(e); }
|
||||
};
|
||||
return void cb (void 0, iframe);
|
||||
}
|
||||
iframe.src = url + '#' + window.encodeURIComponent(metadata.name);
|
||||
|
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 196 B |
Before Width: | Height: | Size: 293 B After Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 193 B After Width: | Height: | Size: 193 B |
Before Width: | Height: | Size: 283 B After Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 193 B After Width: | Height: | Size: 193 B |
Before Width: | Height: | Size: 283 B After Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 196 B |
Before Width: | Height: | Size: 293 B After Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 326 B After Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 326 B After Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 603 B After Width: | Height: | Size: 603 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 402 B |
Before Width: | Height: | Size: 915 B After Width: | Height: | Size: 915 B |
Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 176 B |
Before Width: | Height: | Size: 254 B After Width: | Height: | Size: 254 B |
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 543 B After Width: | Height: | Size: 543 B |
Before Width: | Height: | Size: 174 B After Width: | Height: | Size: 174 B |
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 360 B After Width: | Height: | Size: 360 B |
Before Width: | Height: | Size: 702 B After Width: | Height: | Size: 702 B |
Before Width: | Height: | Size: 359 B After Width: | Height: | Size: 359 B |
Before Width: | Height: | Size: 711 B After Width: | Height: | Size: 711 B |
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 336 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 290 B After Width: | Height: | Size: 290 B |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 151 B |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 240 B |
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 252 B |
Before Width: | Height: | Size: 417 B After Width: | Height: | Size: 417 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 107 B |
Before Width: | Height: | Size: 145 B After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 536 B After Width: | Height: | Size: 536 B |
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 231 B |
Before Width: | Height: | Size: 392 B After Width: | Height: | Size: 392 B |
Before Width: | Height: | Size: 232 B After Width: | Height: | Size: 232 B |
Before Width: | Height: | Size: 388 B After Width: | Height: | Size: 388 B |
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 233 B |
Before Width: | Height: | Size: 385 B After Width: | Height: | Size: 385 B |
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 378 B After Width: | Height: | Size: 378 B |
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 321 B |
Before Width: | Height: | Size: 586 B After Width: | Height: | Size: 586 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 461 B After Width: | Height: | Size: 461 B |
Before Width: | Height: | Size: 309 B After Width: | Height: | Size: 309 B |
Before Width: | Height: | Size: 627 B After Width: | Height: | Size: 627 B |
Before Width: | Height: | Size: 230 B After Width: | Height: | Size: 230 B |
Before Width: | Height: | Size: 429 B After Width: | Height: | Size: 429 B |
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 228 B |
Before Width: | Height: | Size: 432 B After Width: | Height: | Size: 432 B |
Before Width: | Height: | Size: 219 B After Width: | Height: | Size: 219 B |
Before Width: | Height: | Size: 326 B After Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 217 B |
Before Width: | Height: | Size: 328 B After Width: | Height: | Size: 328 B |