Skip to content

Commit 0ebe3a4

Browse files
authored
Merge pull request #171 from nextcloud/backport/168/stable16
[stable16] Bump pdf.js to 2.1.266
2 parents 1f41d5e + 8818ada commit 0ebe3a4

File tree

124 files changed

+93735
-57054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+93735
-57054
lines changed

js/workersrc.js

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,21 @@ function redirectIfNotDisplayedInFrame () {
1212
}
1313
redirectIfNotDisplayedInFrame();
1414

15-
// When "PDFViewerApplication.initialize" is executed it overwrites the value of
16-
// "PDFJS.workerSrc", so the custom initialization has to be executed after
17-
// that. As "PDFViewerApplication" does not provide any hookable point for
18-
// custom initialization in its initialization routine a dirty hack has to be
19-
// used.
20-
//
21-
// When "vendor/pdfjs/web/viewer.js" is parsed at the end it calls
22-
// "PDFViewerApplication.initialize" (either directly or as a "DOMContentLoaded"
23-
// event handler), and "PDFViewerApplication.initialize" sends an asynchronous
24-
// XHR request to initialize the locales, which causes the execution flow to
25-
// continue with the next script or the next "DOMContentLoaded" handler. Thanks
26-
// to this "initializeCustomPDFViewerApplication" can be executed at that point
27-
// by parsing "js/workersrc.js" after "vendor/pdfjs/web/viewer.js" and either
28-
// calling it directly or adding it as a "DOMContentLoaded" event handler (using
29-
// the same conditions as in "vendor/pdfjs/web/viewer.js").
15+
// When "PDFViewerApplication.webViewerInitialized" is executed (once
16+
// "PDFViewerApplication.initialize" is done) it opens the PDF file via URL,
17+
// which requires the PDFViewerApplication to be properly configured, so the
18+
// custom initialization has to be executed before that. This can be done by
19+
// listening to the "webviewerloaded" event, which is emitted after
20+
// "PDFViewerApplication" and "PDFViewerApplicationOptions" are globally set and
21+
// before "PDFViewerApplication.initialize" is executed.
3022
function initializeCustomPDFViewerApplication() {
31-
PDFJS.openExternalLinksInNewWindow = true;
32-
PDFJS.isEvalSupported = false;
33-
PDFJS.workerSrc = document.getElementsByTagName('head')[0].getAttribute('data-workersrc');
34-
PDFJS.cMapUrl = document.getElementsByTagName('head')[0].getAttribute('data-cmapurl');
23+
// Preferences override options, so they must be disabled for
24+
// "externalLinkTarget" to take effect.
25+
PDFViewerApplicationOptions.set('disablePreferences', true);
26+
PDFViewerApplicationOptions.set('externalLinkTarget', pdfjsLib.LinkTarget.BLANK);
27+
PDFViewerApplicationOptions.set('isEvalSupported', false);
28+
PDFViewerApplicationOptions.set('workerSrc', document.getElementsByTagName('head')[0].getAttribute('data-workersrc'));
29+
PDFViewerApplicationOptions.set('cMapUrl', document.getElementsByTagName('head')[0].getAttribute('data-cmapurl'));
3530

3631
// The download has to be forced to use the URL of the file; by default
3732
// "PDFViewerApplication.download" uses a blob, but this causes a CSP error
@@ -77,8 +72,4 @@ function initializeCustomPDFViewerApplication() {
7772
};
7873
}
7974

80-
if (document.readyState === 'interactive' || document.readyState === 'complete') {
81-
initializeCustomPDFViewerApplication();
82-
} else {
83-
document.addEventListener('DOMContentLoaded', initializeCustomPDFViewerApplication, true);
84-
}
75+
document.addEventListener('webviewerloaded', initializeCustomPDFViewerApplication, true);

templates/viewer.php

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
See https://github.com/adobe-type-tools/cmap-resources
2828
-->
29-
<html dir="ltr" mozdisallowselectionprint moznomarginboxes>
29+
<html dir="ltr" mozdisallowselectionprint>
3030
<head data-workersrc="<?php p($urlGenerator->linkTo('files_pdfviewer', 'vendor/pdfjs/build/pdf.worker.js')) ?>?v=<?php p($version) ?>"
3131
data-cmapurl="<?php p($urlGenerator->linkTo('files_pdfviewer', 'vendor/pdfjs/web/cmaps/')) ?>">
3232
<meta charset="utf-8">
@@ -74,6 +74,7 @@
7474
<div id="attachmentsView" class="hidden">
7575
</div>
7676
</div>
77+
<div id="sidebarResizer" class="hidden"></div>
7778
</div> <!-- sidebarContainer -->
7879

7980
<div id="mainContainer">
@@ -91,11 +92,15 @@
9192
</div>
9293
</div>
9394

94-
<div id="findbarOptionsContainer">
95+
<div id="findbarOptionsOneContainer">
9596
<input type="checkbox" id="findHighlightAll" class="toolbarField" tabindex="94">
9697
<label for="findHighlightAll" class="toolbarLabel" data-l10n-id="find_highlight">Highlight all</label>
9798
<input type="checkbox" id="findMatchCase" class="toolbarField" tabindex="95">
9899
<label for="findMatchCase" class="toolbarLabel" data-l10n-id="find_match_case_label">Match case</label>
100+
</div>
101+
<div id="findbarOptionsTwoContainer">
102+
<input type="checkbox" id="findEntireWord" class="toolbarField" tabindex="96">
103+
<label for="findEntireWord" class="toolbarLabel" data-l10n-id="find_entire_word_label">Whole words</label>
99104
<span id="findResultsCount" class="toolbarLabel hidden"></span>
100105
</div>
101106

@@ -155,7 +160,31 @@
155160

156161
<div class="horizontalToolbarSeparator"></div>
157162

158-
<button id="documentProperties" class="secondaryToolbarButton documentProperties" title="Document Properties…" tabindex="62" data-l10n-id="document_properties">
163+
<button id="scrollVertical" class="secondaryToolbarButton scrollModeButtons scrollVertical toggled" title="Use Vertical Scrolling" tabindex="62" data-l10n-id="scroll_vertical">
164+
<span data-l10n-id="scroll_vertical_label">Vertical Scrolling</span>
165+
</button>
166+
<button id="scrollHorizontal" class="secondaryToolbarButton scrollModeButtons scrollHorizontal" title="Use Horizontal Scrolling" tabindex="63" data-l10n-id="scroll_horizontal">
167+
<span data-l10n-id="scroll_horizontal_label">Horizontal Scrolling</span>
168+
</button>
169+
<button id="scrollWrapped" class="secondaryToolbarButton scrollModeButtons scrollWrapped" title="Use Wrapped Scrolling" tabindex="64" data-l10n-id="scroll_wrapped">
170+
<span data-l10n-id="scroll_wrapped_label">Wrapped Scrolling</span>
171+
</button>
172+
173+
<div class="horizontalToolbarSeparator scrollModeButtons"></div>
174+
175+
<button id="spreadNone" class="secondaryToolbarButton spreadModeButtons spreadNone toggled" title="Do not join page spreads" tabindex="65" data-l10n-id="spread_none">
176+
<span data-l10n-id="spread_none_label">No Spreads</span>
177+
</button>
178+
<button id="spreadOdd" class="secondaryToolbarButton spreadModeButtons spreadOdd" title="Join page spreads starting with odd-numbered pages" tabindex="66" data-l10n-id="spread_odd">
179+
<span data-l10n-id="spread_odd_label">Odd Spreads</span>
180+
</button>
181+
<button id="spreadEven" class="secondaryToolbarButton spreadModeButtons spreadEven" title="Join page spreads starting with even-numbered pages" tabindex="67" data-l10n-id="spread_even">
182+
<span data-l10n-id="spread_even_label">Even Spreads</span>
183+
</button>
184+
185+
<div class="horizontalToolbarSeparator spreadModeButtons"></div>
186+
187+
<button id="documentProperties" class="secondaryToolbarButton documentProperties" title="Document Properties…" tabindex="68" data-l10n-id="document_properties">
159188
<span data-l10n-id="document_properties_label">Document Properties…</span>
160189
</button>
161190
</div>
@@ -342,6 +371,13 @@
342371
<div class="row">
343372
<span data-l10n-id="document_properties_page_count">Page Count:</span> <p id="pageCountField">-</p>
344373
</div>
374+
<div class="row">
375+
<span data-l10n-id="document_properties_page_size">Page Size:</span> <p id="pageSizeField">-</p>
376+
</div>
377+
<div class="separator"></div>
378+
<div class="row">
379+
<span data-l10n-id="document_properties_linearized">Fast Web View:</span> <p id="linearizedField">-</p>
380+
</div>
345381
<div class="buttonRow">
346382
<button id="documentPropertiesClose" class="overlayButton"><span data-l10n-id="document_properties_close">Close</span></button>
347383
</div>

0 commit comments

Comments
 (0)