pdfjs-dist 2.6.347 → 2.7.570
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/README.md +3 -3
- package/bower.json +1 -1
- package/build/pdf.js +2050 -1087
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +18219 -10436
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/es5/build/pdf.d.ts +1 -0
- package/es5/build/pdf.js +6623 -6654
- package/es5/build/pdf.js.map +1 -1
- package/es5/build/pdf.min.js +1 -1
- package/es5/build/pdf.worker.js +20815 -13888
- package/es5/build/pdf.worker.js.map +1 -1
- package/es5/build/pdf.worker.min.js +1 -1
- package/es5/image_decoders/pdf.image_decoders.js +3817 -4946
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -1
- package/es5/image_decoders/pdf.image_decoders.min.js +1 -1
- package/es5/web/pdf_viewer.css +18 -15
- package/es5/web/pdf_viewer.js +1094 -514
- package/es5/web/pdf_viewer.js.map +1 -1
- package/image_decoders/pdf.image_decoders.js +774 -168
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/core/annotation.js +556 -108
- package/lib/core/cff_parser.js +7 -1
- package/lib/core/charsets.js +1 -1
- package/lib/core/cmap.js +20 -1
- package/lib/core/core_utils.js +162 -3
- package/lib/core/crypto.js +1 -1
- package/lib/core/default_appearance.js +132 -0
- package/lib/core/document.js +115 -9
- package/lib/core/encodings.js +1 -1
- package/lib/core/evaluator.js +168 -74
- package/lib/core/fonts.js +97 -11
- package/lib/core/function.js +5 -10
- package/lib/core/glyphlist.js +11 -4529
- package/lib/core/image_utils.js +30 -1
- package/lib/core/jpg.js +1 -1
- package/lib/core/jpx.js +5 -5
- package/lib/core/murmurhash3.js +1 -1
- package/lib/core/obj.js +123 -39
- package/lib/core/pattern.js +4 -4
- package/lib/core/primitives.js +24 -5
- package/lib/core/standard_fonts.js +1 -1
- package/lib/core/stream.js +5 -1
- package/lib/core/unicode.js +15 -1387
- package/lib/core/worker.js +58 -17
- package/lib/core/writer.js +68 -4
- package/lib/display/annotation_layer.js +712 -119
- package/lib/display/annotation_storage.js +21 -4
- package/lib/display/api.js +88 -18
- package/lib/display/canvas.js +414 -375
- package/lib/display/display_utils.js +11 -4
- package/lib/display/fetch_stream.js +3 -3
- package/lib/display/font_loader.js +2 -3
- package/lib/display/metadata.js +54 -20
- package/lib/display/node_stream.js +1 -1
- package/lib/display/optional_content_config.js +1 -1
- package/lib/display/pattern_helper.js +109 -113
- package/lib/display/svg.js +5 -5
- package/lib/display/text_layer.js +54 -54
- package/lib/display/transport_stream.js +4 -4
- package/lib/display/webgl.js +65 -68
- package/lib/examples/node/domstubs.js +9 -4
- package/lib/pdf.js +2 -2
- package/lib/pdf.sandbox.js +311 -0
- package/lib/pdf.worker.js +2 -2
- package/lib/shared/scripting_utils.js +84 -0
- package/lib/shared/util.js +129 -14
- package/lib/{display → shared}/xml_parser.js +112 -4
- package/lib/test/unit/annotation_spec.js +831 -109
- package/lib/test/unit/annotation_storage_spec.js +28 -10
- package/lib/test/unit/api_spec.js +190 -160
- package/lib/test/unit/bidi_spec.js +6 -6
- package/lib/test/unit/cff_parser_spec.js +73 -73
- package/lib/test/unit/clitests_helper.js +2 -0
- package/lib/test/unit/cmap_spec.js +48 -74
- package/lib/test/unit/core_utils_spec.js +34 -0
- package/lib/test/unit/crypto_spec.js +162 -199
- package/lib/test/unit/custom_spec.js +7 -18
- package/lib/test/unit/default_appearance_spec.js +54 -0
- package/lib/test/unit/display_svg_spec.js +24 -19
- package/lib/test/unit/display_utils_spec.js +1 -1
- package/lib/test/unit/document_spec.js +187 -20
- package/lib/test/unit/evaluator_spec.js +30 -30
- package/lib/test/unit/function_spec.js +165 -165
- package/lib/test/unit/jasmine-boot.js +52 -53
- package/lib/test/unit/metadata_spec.js +2 -2
- package/lib/test/unit/murmurhash3_spec.js +29 -16
- package/lib/test/unit/network_spec.js +21 -21
- package/lib/test/unit/pdf_find_controller_spec.js +131 -69
- package/lib/test/unit/pdf_find_utils_spec.js +10 -10
- package/lib/test/unit/scripting_spec.js +1104 -0
- package/lib/test/unit/stream_spec.js +8 -8
- package/lib/test/unit/test_utils.js +16 -19
- package/lib/test/unit/testreporter.js +11 -4
- package/lib/test/unit/type1_parser_spec.js +23 -23
- package/lib/test/unit/ui_utils_spec.js +78 -35
- package/lib/test/unit/unicode_spec.js +7 -7
- package/lib/test/unit/util_spec.js +26 -3
- package/lib/test/unit/writer_spec.js +16 -1
- package/lib/test/unit/xml_spec.js +117 -0
- package/lib/web/annotation_layer_builder.js +18 -6
- package/lib/web/app.js +579 -161
- package/lib/web/app_options.js +14 -0
- package/lib/web/base_tree_viewer.js +50 -0
- package/lib/web/base_viewer.js +350 -14
- package/lib/web/chromecom.js +9 -1
- package/lib/web/debugger.js +1 -2
- package/lib/web/download_manager.js +0 -15
- package/lib/web/firefox_print_service.js +6 -4
- package/lib/web/firefoxcom.js +84 -69
- package/lib/web/generic_scripting.js +55 -0
- package/lib/web/genericcom.js +9 -1
- package/lib/web/grab_to_pan.js +1 -1
- package/lib/web/interfaces.js +9 -3
- package/lib/web/pdf_attachment_viewer.js +1 -3
- package/lib/web/pdf_cursor_tools.js +20 -13
- package/lib/web/pdf_document_properties.js +48 -61
- package/lib/web/pdf_find_bar.js +1 -3
- package/lib/web/pdf_find_controller.js +58 -12
- package/lib/web/pdf_history.js +43 -21
- package/lib/web/pdf_layer_viewer.js +1 -9
- package/lib/web/pdf_link_service.js +108 -78
- package/lib/web/pdf_outline_viewer.js +166 -10
- package/lib/web/pdf_page_view.js +14 -14
- package/lib/web/pdf_presentation_mode.js +21 -31
- package/lib/web/pdf_rendering_queue.js +8 -1
- package/lib/web/pdf_sidebar.js +62 -107
- package/lib/web/pdf_sidebar_resizer.js +11 -21
- package/lib/web/pdf_single_page_viewer.js +8 -0
- package/lib/web/pdf_thumbnail_view.js +26 -26
- package/lib/web/pdf_thumbnail_viewer.js +13 -2
- package/lib/web/pdf_viewer.component.js +2 -2
- package/lib/web/pdf_viewer.js +3 -1
- package/lib/web/preferences.js +33 -44
- package/lib/web/text_layer_builder.js +2 -9
- package/lib/web/ui_utils.js +78 -46
- package/lib/web/viewer_compatibility.js +1 -2
- package/package.json +4 -1
- package/types/display/annotation_layer.d.ts +18 -3
- package/types/display/api.d.ts +110 -54
- package/types/display/canvas.d.ts +1 -1
- package/types/display/display_utils.d.ts +96 -95
- package/types/display/fetch_stream.d.ts +2 -2
- package/types/display/metadata.d.ts +4 -0
- package/types/display/pattern_helper.d.ts +1 -1
- package/types/display/text_layer.d.ts +7 -7
- package/types/display/transport_stream.d.ts +1 -1
- package/types/shared/scripting_utils.d.ts +12 -0
- package/types/shared/util.d.ts +281 -250
- package/types/shared/xml_parser.d.ts +64 -0
- package/web/pdf_viewer.css +18 -15
- package/web/pdf_viewer.js +809 -408
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +1 -1
- package/types/display/xml_parser.d.ts +0 -35
package/lib/web/pdf_sidebar.js
CHANGED
@@ -24,22 +24,13 @@
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.PDFSidebar =
|
27
|
+
exports.PDFSidebar = void 0;
|
28
28
|
|
29
29
|
var _ui_utils = require("./ui_utils.js");
|
30
30
|
|
31
31
|
var _pdf_rendering_queue = require("./pdf_rendering_queue.js");
|
32
32
|
|
33
33
|
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
34
|
-
const SidebarView = {
|
35
|
-
UNKNOWN: -1,
|
36
|
-
NONE: 0,
|
37
|
-
THUMBS: 1,
|
38
|
-
OUTLINE: 2,
|
39
|
-
ATTACHMENTS: 3,
|
40
|
-
LAYERS: 4
|
41
|
-
};
|
42
|
-
exports.SidebarView = SidebarView;
|
43
34
|
|
44
35
|
class PDFSidebar {
|
45
36
|
constructor({
|
@@ -47,11 +38,10 @@ class PDFSidebar {
|
|
47
38
|
pdfViewer,
|
48
39
|
pdfThumbnailViewer,
|
49
40
|
eventBus,
|
50
|
-
l10n = _ui_utils.NullL10n
|
51
|
-
disableNotification = false
|
41
|
+
l10n = _ui_utils.NullL10n
|
52
42
|
}) {
|
53
43
|
this.isOpen = false;
|
54
|
-
this.active = SidebarView.THUMBS;
|
44
|
+
this.active = _ui_utils.SidebarView.THUMBS;
|
55
45
|
this.isInitialViewSet = false;
|
56
46
|
this.onToggled = null;
|
57
47
|
this.pdfViewer = pdfViewer;
|
@@ -67,9 +57,10 @@ class PDFSidebar {
|
|
67
57
|
this.outlineView = elements.outlineView;
|
68
58
|
this.attachmentsView = elements.attachmentsView;
|
69
59
|
this.layersView = elements.layersView;
|
60
|
+
this._outlineOptionsContainer = elements.outlineOptionsContainer;
|
61
|
+
this._currentOutlineItemButton = elements.currentOutlineItemButton;
|
70
62
|
this.eventBus = eventBus;
|
71
63
|
this.l10n = l10n;
|
72
|
-
this._disableNotification = disableNotification;
|
73
64
|
|
74
65
|
this._addEventListeners();
|
75
66
|
}
|
@@ -77,42 +68,43 @@ class PDFSidebar {
|
|
77
68
|
reset() {
|
78
69
|
this.isInitialViewSet = false;
|
79
70
|
|
80
|
-
this._hideUINotification(
|
71
|
+
this._hideUINotification(true);
|
81
72
|
|
82
|
-
this.switchView(SidebarView.THUMBS);
|
73
|
+
this.switchView(_ui_utils.SidebarView.THUMBS);
|
83
74
|
this.outlineButton.disabled = false;
|
84
75
|
this.attachmentsButton.disabled = false;
|
85
76
|
this.layersButton.disabled = false;
|
77
|
+
this._currentOutlineItemButton.disabled = true;
|
86
78
|
}
|
87
79
|
|
88
80
|
get visibleView() {
|
89
|
-
return this.isOpen ? this.active : SidebarView.NONE;
|
81
|
+
return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
|
90
82
|
}
|
91
83
|
|
92
84
|
get isThumbnailViewVisible() {
|
93
|
-
return this.isOpen && this.active === SidebarView.THUMBS;
|
85
|
+
return this.isOpen && this.active === _ui_utils.SidebarView.THUMBS;
|
94
86
|
}
|
95
87
|
|
96
88
|
get isOutlineViewVisible() {
|
97
|
-
return this.isOpen && this.active === SidebarView.OUTLINE;
|
89
|
+
return this.isOpen && this.active === _ui_utils.SidebarView.OUTLINE;
|
98
90
|
}
|
99
91
|
|
100
92
|
get isAttachmentsViewVisible() {
|
101
|
-
return this.isOpen && this.active === SidebarView.ATTACHMENTS;
|
93
|
+
return this.isOpen && this.active === _ui_utils.SidebarView.ATTACHMENTS;
|
102
94
|
}
|
103
95
|
|
104
96
|
get isLayersViewVisible() {
|
105
|
-
return this.isOpen && this.active === SidebarView.LAYERS;
|
97
|
+
return this.isOpen && this.active === _ui_utils.SidebarView.LAYERS;
|
106
98
|
}
|
107
99
|
|
108
|
-
setInitialView(view = SidebarView.NONE) {
|
100
|
+
setInitialView(view = _ui_utils.SidebarView.NONE) {
|
109
101
|
if (this.isInitialViewSet) {
|
110
102
|
return;
|
111
103
|
}
|
112
104
|
|
113
105
|
this.isInitialViewSet = true;
|
114
106
|
|
115
|
-
if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
|
107
|
+
if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
|
116
108
|
this._dispatchEvent();
|
117
109
|
|
118
110
|
return;
|
@@ -132,7 +124,7 @@ class PDFSidebar {
|
|
132
124
|
let shouldForceRendering = false;
|
133
125
|
|
134
126
|
switch (view) {
|
135
|
-
case SidebarView.NONE:
|
127
|
+
case _ui_utils.SidebarView.NONE:
|
136
128
|
if (this.isOpen) {
|
137
129
|
this.close();
|
138
130
|
return true;
|
@@ -140,28 +132,28 @@ class PDFSidebar {
|
|
140
132
|
|
141
133
|
return false;
|
142
134
|
|
143
|
-
case SidebarView.THUMBS:
|
135
|
+
case _ui_utils.SidebarView.THUMBS:
|
144
136
|
if (this.isOpen && isViewChanged) {
|
145
137
|
shouldForceRendering = true;
|
146
138
|
}
|
147
139
|
|
148
140
|
break;
|
149
141
|
|
150
|
-
case SidebarView.OUTLINE:
|
142
|
+
case _ui_utils.SidebarView.OUTLINE:
|
151
143
|
if (this.outlineButton.disabled) {
|
152
144
|
return false;
|
153
145
|
}
|
154
146
|
|
155
147
|
break;
|
156
148
|
|
157
|
-
case SidebarView.ATTACHMENTS:
|
149
|
+
case _ui_utils.SidebarView.ATTACHMENTS:
|
158
150
|
if (this.attachmentsButton.disabled) {
|
159
151
|
return false;
|
160
152
|
}
|
161
153
|
|
162
154
|
break;
|
163
155
|
|
164
|
-
case SidebarView.LAYERS:
|
156
|
+
case _ui_utils.SidebarView.LAYERS:
|
165
157
|
if (this.layersButton.disabled) {
|
166
158
|
return false;
|
167
159
|
}
|
@@ -174,14 +166,16 @@ class PDFSidebar {
|
|
174
166
|
}
|
175
167
|
|
176
168
|
this.active = view;
|
177
|
-
this.thumbnailButton.classList.toggle("toggled", view === SidebarView.THUMBS);
|
178
|
-
this.outlineButton.classList.toggle("toggled", view === SidebarView.OUTLINE);
|
179
|
-
this.attachmentsButton.classList.toggle("toggled", view === SidebarView.ATTACHMENTS);
|
180
|
-
this.layersButton.classList.toggle("toggled", view === SidebarView.LAYERS);
|
181
|
-
this.thumbnailView.classList.toggle("hidden", view !== SidebarView.THUMBS);
|
182
|
-
this.outlineView.classList.toggle("hidden", view !== SidebarView.OUTLINE);
|
183
|
-
this.attachmentsView.classList.toggle("hidden", view !== SidebarView.ATTACHMENTS);
|
184
|
-
this.layersView.classList.toggle("hidden", view !== SidebarView.LAYERS);
|
169
|
+
this.thumbnailButton.classList.toggle("toggled", view === _ui_utils.SidebarView.THUMBS);
|
170
|
+
this.outlineButton.classList.toggle("toggled", view === _ui_utils.SidebarView.OUTLINE);
|
171
|
+
this.attachmentsButton.classList.toggle("toggled", view === _ui_utils.SidebarView.ATTACHMENTS);
|
172
|
+
this.layersButton.classList.toggle("toggled", view === _ui_utils.SidebarView.LAYERS);
|
173
|
+
this.thumbnailView.classList.toggle("hidden", view !== _ui_utils.SidebarView.THUMBS);
|
174
|
+
this.outlineView.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
|
175
|
+
this.attachmentsView.classList.toggle("hidden", view !== _ui_utils.SidebarView.ATTACHMENTS);
|
176
|
+
this.layersView.classList.toggle("hidden", view !== _ui_utils.SidebarView.LAYERS);
|
177
|
+
|
178
|
+
this._outlineOptionsContainer.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
|
185
179
|
|
186
180
|
if (forceOpen && !this.isOpen) {
|
187
181
|
this.open();
|
@@ -198,8 +192,6 @@ class PDFSidebar {
|
|
198
192
|
this._dispatchEvent();
|
199
193
|
}
|
200
194
|
|
201
|
-
this._hideUINotification(this.active);
|
202
|
-
|
203
195
|
return isViewChanged;
|
204
196
|
}
|
205
197
|
|
@@ -212,7 +204,7 @@ class PDFSidebar {
|
|
212
204
|
this.toggleButton.classList.add("toggled");
|
213
205
|
this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
|
214
206
|
|
215
|
-
if (this.active === SidebarView.THUMBS) {
|
207
|
+
if (this.active === _ui_utils.SidebarView.THUMBS) {
|
216
208
|
this._updateThumbnailViewer();
|
217
209
|
}
|
218
210
|
|
@@ -220,7 +212,7 @@ class PDFSidebar {
|
|
220
212
|
|
221
213
|
this._dispatchEvent();
|
222
214
|
|
223
|
-
this._hideUINotification(
|
215
|
+
this._hideUINotification();
|
224
216
|
}
|
225
217
|
|
226
218
|
close() {
|
@@ -281,75 +273,26 @@ class PDFSidebar {
|
|
281
273
|
pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
|
282
274
|
}
|
283
275
|
|
284
|
-
_showUINotification(
|
285
|
-
if (this._disableNotification) {
|
286
|
-
return;
|
287
|
-
}
|
288
|
-
|
276
|
+
_showUINotification() {
|
289
277
|
this.l10n.get("toggle_sidebar_notification2.title", null, "Toggle Sidebar (document contains outline/attachments/layers)").then(msg => {
|
290
278
|
this.toggleButton.title = msg;
|
291
279
|
});
|
292
280
|
|
293
281
|
if (!this.isOpen) {
|
294
282
|
this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
|
295
|
-
} else if (view === this.active) {
|
296
|
-
return;
|
297
|
-
}
|
298
|
-
|
299
|
-
switch (view) {
|
300
|
-
case SidebarView.OUTLINE:
|
301
|
-
this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
|
302
|
-
break;
|
303
|
-
|
304
|
-
case SidebarView.ATTACHMENTS:
|
305
|
-
this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
|
306
|
-
break;
|
307
|
-
|
308
|
-
case SidebarView.LAYERS:
|
309
|
-
this.layersButton.classList.add(UI_NOTIFICATION_CLASS);
|
310
|
-
break;
|
311
283
|
}
|
312
284
|
}
|
313
285
|
|
314
|
-
_hideUINotification(
|
315
|
-
if (this.
|
316
|
-
|
286
|
+
_hideUINotification(reset = false) {
|
287
|
+
if (this.isOpen || reset) {
|
288
|
+
this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
|
317
289
|
}
|
318
290
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
break;
|
324
|
-
|
325
|
-
case SidebarView.ATTACHMENTS:
|
326
|
-
this.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
|
327
|
-
break;
|
328
|
-
|
329
|
-
case SidebarView.LAYERS:
|
330
|
-
this.layersButton.classList.remove(UI_NOTIFICATION_CLASS);
|
331
|
-
break;
|
332
|
-
}
|
333
|
-
};
|
334
|
-
|
335
|
-
if (!this.isOpen && view !== null) {
|
336
|
-
return;
|
337
|
-
}
|
338
|
-
|
339
|
-
this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
|
340
|
-
|
341
|
-
if (view !== null) {
|
342
|
-
removeNotification(view);
|
343
|
-
return;
|
344
|
-
}
|
345
|
-
|
346
|
-
for (view in SidebarView) {
|
347
|
-
removeNotification(SidebarView[view]);
|
291
|
+
if (reset) {
|
292
|
+
this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(msg => {
|
293
|
+
this.toggleButton.title = msg;
|
294
|
+
});
|
348
295
|
}
|
349
|
-
|
350
|
-
this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(msg => {
|
351
|
-
this.toggleButton.title = msg;
|
352
|
-
});
|
353
296
|
}
|
354
297
|
|
355
298
|
_addEventListeners() {
|
@@ -362,10 +305,10 @@ class PDFSidebar {
|
|
362
305
|
this.toggle();
|
363
306
|
});
|
364
307
|
this.thumbnailButton.addEventListener("click", () => {
|
365
|
-
this.switchView(SidebarView.THUMBS);
|
308
|
+
this.switchView(_ui_utils.SidebarView.THUMBS);
|
366
309
|
});
|
367
310
|
this.outlineButton.addEventListener("click", () => {
|
368
|
-
this.switchView(SidebarView.OUTLINE);
|
311
|
+
this.switchView(_ui_utils.SidebarView.OUTLINE);
|
369
312
|
});
|
370
313
|
this.outlineButton.addEventListener("dblclick", () => {
|
371
314
|
this.eventBus.dispatch("toggleoutlinetree", {
|
@@ -373,10 +316,10 @@ class PDFSidebar {
|
|
373
316
|
});
|
374
317
|
});
|
375
318
|
this.attachmentsButton.addEventListener("click", () => {
|
376
|
-
this.switchView(SidebarView.ATTACHMENTS);
|
319
|
+
this.switchView(_ui_utils.SidebarView.ATTACHMENTS);
|
377
320
|
});
|
378
321
|
this.layersButton.addEventListener("click", () => {
|
379
|
-
this.switchView(SidebarView.LAYERS);
|
322
|
+
this.switchView(_ui_utils.SidebarView.LAYERS);
|
380
323
|
});
|
381
324
|
this.layersButton.addEventListener("dblclick", () => {
|
382
325
|
this.eventBus.dispatch("resetlayers", {
|
@@ -384,30 +327,42 @@ class PDFSidebar {
|
|
384
327
|
});
|
385
328
|
});
|
386
329
|
|
330
|
+
this._currentOutlineItemButton.addEventListener("click", () => {
|
331
|
+
this.eventBus.dispatch("currentoutlineitem", {
|
332
|
+
source: this
|
333
|
+
});
|
334
|
+
});
|
335
|
+
|
387
336
|
const onTreeLoaded = (count, button, view) => {
|
388
337
|
button.disabled = !count;
|
389
338
|
|
390
339
|
if (count) {
|
391
|
-
this._showUINotification(
|
340
|
+
this._showUINotification();
|
392
341
|
} else if (this.active === view) {
|
393
|
-
this.switchView(SidebarView.THUMBS);
|
342
|
+
this.switchView(_ui_utils.SidebarView.THUMBS);
|
394
343
|
}
|
395
344
|
};
|
396
345
|
|
397
346
|
this.eventBus._on("outlineloaded", evt => {
|
398
|
-
onTreeLoaded(evt.outlineCount, this.outlineButton, SidebarView.OUTLINE);
|
347
|
+
onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils.SidebarView.OUTLINE);
|
348
|
+
|
349
|
+
if (evt.enableCurrentOutlineItemButton) {
|
350
|
+
this.pdfViewer.pagesPromise.then(() => {
|
351
|
+
this._currentOutlineItemButton.disabled = !this.isInitialViewSet;
|
352
|
+
});
|
353
|
+
}
|
399
354
|
});
|
400
355
|
|
401
356
|
this.eventBus._on("attachmentsloaded", evt => {
|
402
|
-
onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, SidebarView.ATTACHMENTS);
|
357
|
+
onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
|
403
358
|
});
|
404
359
|
|
405
360
|
this.eventBus._on("layersloaded", evt => {
|
406
|
-
onTreeLoaded(evt.layersCount, this.layersButton, SidebarView.LAYERS);
|
361
|
+
onTreeLoaded(evt.layersCount, this.layersButton, _ui_utils.SidebarView.LAYERS);
|
407
362
|
});
|
408
363
|
|
409
364
|
this.eventBus._on("presentationmodechanged", evt => {
|
410
|
-
if (
|
365
|
+
if (evt.state === _ui_utils.PresentationModeState.NORMAL && this.isThumbnailViewVisible) {
|
411
366
|
this._updateThumbnailViewer();
|
412
367
|
}
|
413
368
|
});
|
@@ -34,7 +34,6 @@ const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
|
|
34
34
|
|
35
35
|
class PDFSidebarResizer {
|
36
36
|
constructor(options, eventBus, l10n = _ui_utils.NullL10n) {
|
37
|
-
this.enabled = false;
|
38
37
|
this.isRTL = false;
|
39
38
|
this.sidebarOpen = false;
|
40
39
|
this.doc = document.documentElement;
|
@@ -44,16 +43,7 @@ class PDFSidebarResizer {
|
|
44
43
|
this.outerContainer = options.outerContainer;
|
45
44
|
this.resizer = options.resizer;
|
46
45
|
this.eventBus = eventBus;
|
47
|
-
|
48
|
-
|
49
|
-
if (typeof CSS === "undefined" || typeof CSS.supports !== "function" || !CSS.supports(SIDEBAR_WIDTH_VAR, `calc(-1 * ${SIDEBAR_MIN_WIDTH}px)`)) {
|
50
|
-
console.warn("PDFSidebarResizer: " + "The browser does not support resizing of the sidebar.");
|
51
|
-
return;
|
52
|
-
}
|
53
|
-
|
54
|
-
this.enabled = true;
|
55
|
-
this.resizer.classList.remove("hidden");
|
56
|
-
this.l10n.getDirection().then(dir => {
|
46
|
+
l10n.getDirection().then(dir => {
|
57
47
|
this.isRTL = dir === "rtl";
|
58
48
|
});
|
59
49
|
|
@@ -69,18 +59,22 @@ class PDFSidebarResizer {
|
|
69
59
|
}
|
70
60
|
|
71
61
|
_updateWidth(width = 0) {
|
72
|
-
|
73
|
-
|
62
|
+
const maxWidth = Math.floor(this.outerContainerWidth / 2);
|
63
|
+
|
64
|
+
if (width > maxWidth) {
|
65
|
+
width = maxWidth;
|
74
66
|
}
|
75
67
|
|
76
|
-
|
68
|
+
if (width < SIDEBAR_MIN_WIDTH) {
|
69
|
+
width = SIDEBAR_MIN_WIDTH;
|
70
|
+
}
|
77
71
|
|
78
|
-
if (
|
72
|
+
if (width === this._width) {
|
79
73
|
return false;
|
80
74
|
}
|
81
75
|
|
82
|
-
this._width =
|
83
|
-
this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, `${
|
76
|
+
this._width = width;
|
77
|
+
this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);
|
84
78
|
return true;
|
85
79
|
}
|
86
80
|
|
@@ -105,10 +99,6 @@ class PDFSidebarResizer {
|
|
105
99
|
}
|
106
100
|
|
107
101
|
_addEventListeners() {
|
108
|
-
if (!this.enabled) {
|
109
|
-
return;
|
110
|
-
}
|
111
|
-
|
112
102
|
const _boundEvents = this._boundEvents;
|
113
103
|
_boundEvents.mouseMove = this._mouseMove.bind(this);
|
114
104
|
_boundEvents.mouseUp = this._mouseUp.bind(this);
|
@@ -43,6 +43,10 @@ class PDFSinglePageViewer extends _base_viewer.BaseViewer {
|
|
43
43
|
return (0, _pdf.shadow)(this, "_viewerElement", this._shadowViewer);
|
44
44
|
}
|
45
45
|
|
46
|
+
get _pageWidthScaleFactor() {
|
47
|
+
return 1;
|
48
|
+
}
|
49
|
+
|
46
50
|
_resetView() {
|
47
51
|
super._resetView();
|
48
52
|
|
@@ -132,6 +136,10 @@ class PDFSinglePageViewer extends _base_viewer.BaseViewer {
|
|
132
136
|
|
133
137
|
_updateSpreadMode() {}
|
134
138
|
|
139
|
+
_getPageAdvance() {
|
140
|
+
return 1;
|
141
|
+
}
|
142
|
+
|
135
143
|
}
|
136
144
|
|
137
145
|
exports.PDFSinglePageViewer = PDFSinglePageViewer;
|
@@ -24,12 +24,12 @@
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.PDFThumbnailView = void 0;
|
28
|
-
|
29
|
-
var _pdf = require("../pdf");
|
27
|
+
exports.TempImageFactory = exports.PDFThumbnailView = void 0;
|
30
28
|
|
31
29
|
var _ui_utils = require("./ui_utils.js");
|
32
30
|
|
31
|
+
var _pdf = require("../pdf");
|
32
|
+
|
33
33
|
var _pdf_rendering_queue = require("./pdf_rendering_queue.js");
|
34
34
|
|
35
35
|
const MAX_NUM_SCALING_STEPS = 3;
|
@@ -74,6 +74,8 @@ const TempImageFactory = function TempImageFactoryClosure() {
|
|
74
74
|
};
|
75
75
|
}();
|
76
76
|
|
77
|
+
exports.TempImageFactory = TempImageFactory;
|
78
|
+
|
77
79
|
class PDFThumbnailView {
|
78
80
|
constructor({
|
79
81
|
container,
|
@@ -120,7 +122,7 @@ class PDFThumbnailView {
|
|
120
122
|
});
|
121
123
|
|
122
124
|
anchor.onclick = function () {
|
123
|
-
linkService.
|
125
|
+
linkService.goToPage(id);
|
124
126
|
return false;
|
125
127
|
};
|
126
128
|
|
@@ -205,7 +207,7 @@ class PDFThumbnailView {
|
|
205
207
|
this.resume = null;
|
206
208
|
}
|
207
209
|
|
208
|
-
_getPageDrawContext(
|
210
|
+
_getPageDrawContext() {
|
209
211
|
const canvas = document.createElement("canvas");
|
210
212
|
this.canvas = canvas;
|
211
213
|
canvas.mozOpaque = true;
|
@@ -217,12 +219,8 @@ class PDFThumbnailView {
|
|
217
219
|
canvas.height = this.canvasHeight * outputScale.sy | 0;
|
218
220
|
canvas.style.width = this.canvasWidth + "px";
|
219
221
|
canvas.style.height = this.canvasHeight + "px";
|
220
|
-
|
221
|
-
|
222
|
-
ctx.scale(outputScale.sx, outputScale.sy);
|
223
|
-
}
|
224
|
-
|
225
|
-
return ctx;
|
222
|
+
const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
|
223
|
+
return [ctx, transform];
|
226
224
|
}
|
227
225
|
|
228
226
|
_convertCanvasToImage() {
|
@@ -282,15 +280,13 @@ class PDFThumbnailView {
|
|
282
280
|
}
|
283
281
|
|
284
282
|
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
|
285
|
-
const renderCapability = (0, _pdf.createPromiseCapability)();
|
286
283
|
|
287
|
-
const finishRenderTask = error => {
|
284
|
+
const finishRenderTask = async (error = null) => {
|
288
285
|
if (renderTask === this.renderTask) {
|
289
286
|
this.renderTask = null;
|
290
287
|
}
|
291
288
|
|
292
289
|
if (error instanceof _pdf.RenderingCancelledException) {
|
293
|
-
renderCapability.resolve(undefined);
|
294
290
|
return;
|
295
291
|
}
|
296
292
|
|
@@ -298,14 +294,12 @@ class PDFThumbnailView {
|
|
298
294
|
|
299
295
|
this._convertCanvasToImage();
|
300
296
|
|
301
|
-
if (
|
302
|
-
|
303
|
-
} else {
|
304
|
-
renderCapability.reject(error);
|
297
|
+
if (error) {
|
298
|
+
throw error;
|
305
299
|
}
|
306
300
|
};
|
307
301
|
|
308
|
-
const ctx = this._getPageDrawContext();
|
302
|
+
const [ctx, transform] = this._getPageDrawContext();
|
309
303
|
|
310
304
|
const drawViewport = this.viewport.clone({
|
311
305
|
scale: this.scale
|
@@ -328,17 +322,27 @@ class PDFThumbnailView {
|
|
328
322
|
|
329
323
|
const renderContext = {
|
330
324
|
canvasContext: ctx,
|
325
|
+
transform,
|
331
326
|
viewport: drawViewport,
|
332
327
|
optionalContentConfigPromise: this._optionalContentConfigPromise
|
333
328
|
};
|
334
329
|
const renderTask = this.renderTask = pdfPage.render(renderContext);
|
335
330
|
renderTask.onContinue = renderContinueCallback;
|
336
|
-
renderTask.promise.then(function () {
|
331
|
+
const resultPromise = renderTask.promise.then(function () {
|
337
332
|
finishRenderTask(null);
|
338
333
|
}, function (error) {
|
339
334
|
finishRenderTask(error);
|
340
335
|
});
|
341
|
-
|
336
|
+
resultPromise.finally(() => {
|
337
|
+
const pageCached = this.linkService.isPageCached(this.id);
|
338
|
+
|
339
|
+
if (pageCached) {
|
340
|
+
return;
|
341
|
+
}
|
342
|
+
|
343
|
+
this.pdfPage?.cleanup();
|
344
|
+
});
|
345
|
+
return resultPromise;
|
342
346
|
}
|
343
347
|
|
344
348
|
setImage(pageView) {
|
@@ -362,7 +366,7 @@ class PDFThumbnailView {
|
|
362
366
|
|
363
367
|
this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
|
364
368
|
|
365
|
-
const ctx = this._getPageDrawContext(
|
369
|
+
const [ctx] = this._getPageDrawContext();
|
366
370
|
|
367
371
|
const canvas = ctx.canvas;
|
368
372
|
|
@@ -429,10 +433,6 @@ class PDFThumbnailView {
|
|
429
433
|
});
|
430
434
|
}
|
431
435
|
|
432
|
-
static cleanup() {
|
433
|
-
TempImageFactory.destroyCanvas();
|
434
|
-
}
|
435
|
-
|
436
436
|
}
|
437
437
|
|
438
438
|
exports.PDFThumbnailView = PDFThumbnailView;
|
@@ -30,6 +30,8 @@ var _ui_utils = require("./ui_utils.js");
|
|
30
30
|
|
31
31
|
var _pdf_thumbnail_view = require("./pdf_thumbnail_view.js");
|
32
32
|
|
33
|
+
var _pdf_rendering_queue = require("./pdf_rendering_queue.js");
|
34
|
+
|
33
35
|
const THUMBNAIL_SCROLL_MARGIN = -19;
|
34
36
|
const THUMBNAIL_SELECTED_CLASS = "selected";
|
35
37
|
|
@@ -63,7 +65,10 @@ class PDFThumbnailViewer {
|
|
63
65
|
}
|
64
66
|
|
65
67
|
_getVisibleThumbs() {
|
66
|
-
return (0, _ui_utils.getVisibleElements)(
|
68
|
+
return (0, _ui_utils.getVisibleElements)({
|
69
|
+
scrollEl: this.container,
|
70
|
+
views: this._thumbnails
|
71
|
+
});
|
67
72
|
}
|
68
73
|
|
69
74
|
scrollThumbnailIntoView(pageNumber) {
|
@@ -141,7 +146,13 @@ class PDFThumbnailViewer {
|
|
141
146
|
}
|
142
147
|
|
143
148
|
cleanup() {
|
144
|
-
|
149
|
+
for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
|
150
|
+
if (this._thumbnails[i] && this._thumbnails[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
|
151
|
+
this._thumbnails[i].reset();
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
_pdf_thumbnail_view.TempImageFactory.destroyCanvas();
|
145
156
|
}
|
146
157
|
|
147
158
|
_resetView() {
|
@@ -143,5 +143,5 @@ var _pdf_single_page_viewer = require("./pdf_single_page_viewer.js");
|
|
143
143
|
|
144
144
|
var _pdf_viewer = require("./pdf_viewer.js");
|
145
145
|
|
146
|
-
const pdfjsVersion = '2.
|
147
|
-
const pdfjsBuild = '
|
146
|
+
const pdfjsVersion = '2.7.570';
|
147
|
+
const pdfjsBuild = 'f2c7338b0';
|
package/lib/web/pdf_viewer.js
CHANGED
@@ -26,6 +26,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.PDFViewer = void 0;
|
28
28
|
|
29
|
+
var _ui_utils = require("./ui_utils.js");
|
30
|
+
|
29
31
|
var _base_viewer = require("./base_viewer.js");
|
30
32
|
|
31
33
|
var _pdf = require("../pdf");
|
@@ -84,7 +86,7 @@ class PDFViewer extends _base_viewer.BaseViewer {
|
|
84
86
|
break;
|
85
87
|
}
|
86
88
|
|
87
|
-
if (page.id === currentId) {
|
89
|
+
if (page.id === currentId && this._scrollMode === _ui_utils.ScrollMode.VERTICAL && this._spreadMode === _ui_utils.SpreadMode.NONE) {
|
88
90
|
stillFullyVisible = true;
|
89
91
|
break;
|
90
92
|
}
|