pdfjs-dist 2.0.943 → 2.4.456
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/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +25500 -26628
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +2887 -4094
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/web/dom_events.js +0 -140
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,29 +19,19 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.PasswordPrompt =
|
27
|
+
exports.PasswordPrompt = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _ui_utils = require("./ui_utils.js");
|
30
30
|
|
31
|
-
var
|
32
|
-
|
33
|
-
var _pdf = require('../pdf');
|
34
|
-
|
35
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
36
|
-
|
37
|
-
var PasswordPrompt = function () {
|
38
|
-
function PasswordPrompt(options, overlayManager) {
|
39
|
-
var _this = this;
|
40
|
-
|
41
|
-
var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
|
42
|
-
|
43
|
-
_classCallCheck(this, PasswordPrompt);
|
31
|
+
var _pdf = require("../pdf");
|
44
32
|
|
33
|
+
class PasswordPrompt {
|
34
|
+
constructor(options, overlayManager, l10n = _ui_utils.NullL10n) {
|
45
35
|
this.overlayName = options.overlayName;
|
46
36
|
this.container = options.container;
|
47
37
|
this.label = options.label;
|
@@ -52,61 +42,53 @@ var PasswordPrompt = function () {
|
|
52
42
|
this.l10n = l10n;
|
53
43
|
this.updateCallback = null;
|
54
44
|
this.reason = null;
|
55
|
-
this.submitButton.addEventListener(
|
56
|
-
this.cancelButton.addEventListener(
|
57
|
-
this.input.addEventListener(
|
45
|
+
this.submitButton.addEventListener("click", this.verify.bind(this));
|
46
|
+
this.cancelButton.addEventListener("click", this.close.bind(this));
|
47
|
+
this.input.addEventListener("keydown", e => {
|
58
48
|
if (e.keyCode === 13) {
|
59
|
-
|
49
|
+
this.verify();
|
60
50
|
}
|
61
51
|
});
|
62
52
|
this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
|
63
53
|
}
|
64
54
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
55
|
+
open() {
|
56
|
+
this.overlayManager.open(this.overlayName).then(() => {
|
57
|
+
this.input.focus();
|
58
|
+
let promptString;
|
69
59
|
|
70
|
-
this.
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
} else {
|
76
|
-
promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
|
77
|
-
}
|
78
|
-
promptString.then(function (msg) {
|
79
|
-
_this2.label.textContent = msg;
|
80
|
-
});
|
81
|
-
});
|
82
|
-
}
|
83
|
-
}, {
|
84
|
-
key: 'close',
|
85
|
-
value: function close() {
|
86
|
-
var _this3 = this;
|
60
|
+
if (this.reason === _pdf.PasswordResponses.INCORRECT_PASSWORD) {
|
61
|
+
promptString = this.l10n.get("password_invalid", null, "Invalid password. Please try again.");
|
62
|
+
} else {
|
63
|
+
promptString = this.l10n.get("password_label", null, "Enter the password to open this PDF file.");
|
64
|
+
}
|
87
65
|
|
88
|
-
|
89
|
-
|
66
|
+
promptString.then(msg => {
|
67
|
+
this.label.textContent = msg;
|
90
68
|
});
|
69
|
+
});
|
70
|
+
}
|
71
|
+
|
72
|
+
close() {
|
73
|
+
this.overlayManager.close(this.overlayName).then(() => {
|
74
|
+
this.input.value = "";
|
75
|
+
});
|
76
|
+
}
|
77
|
+
|
78
|
+
verify() {
|
79
|
+
const password = this.input.value;
|
80
|
+
|
81
|
+
if (password && password.length > 0) {
|
82
|
+
this.close();
|
83
|
+
this.updateCallback(password);
|
91
84
|
}
|
92
|
-
}
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
return this.updateCallback(password);
|
99
|
-
}
|
100
|
-
}
|
101
|
-
}, {
|
102
|
-
key: 'setUpdateCallback',
|
103
|
-
value: function setUpdateCallback(updateCallback, reason) {
|
104
|
-
this.updateCallback = updateCallback;
|
105
|
-
this.reason = reason;
|
106
|
-
}
|
107
|
-
}]);
|
85
|
+
}
|
86
|
+
|
87
|
+
setUpdateCallback(updateCallback, reason) {
|
88
|
+
this.updateCallback = updateCallback;
|
89
|
+
this.reason = reason;
|
90
|
+
}
|
108
91
|
|
109
|
-
|
110
|
-
}();
|
92
|
+
}
|
111
93
|
|
112
94
|
exports.PasswordPrompt = PasswordPrompt;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,151 +19,146 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.PDFAttachmentViewer =
|
27
|
+
exports.PDFAttachmentViewer = void 0;
|
28
28
|
|
29
|
-
var
|
30
|
-
|
31
|
-
var _pdf = require('../pdf');
|
32
|
-
|
33
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
34
|
-
|
35
|
-
var PDFAttachmentViewer = function () {
|
36
|
-
function PDFAttachmentViewer(_ref) {
|
37
|
-
var container = _ref.container,
|
38
|
-
eventBus = _ref.eventBus,
|
39
|
-
downloadManager = _ref.downloadManager;
|
40
|
-
|
41
|
-
_classCallCheck(this, PDFAttachmentViewer);
|
29
|
+
var _pdf = require("../pdf");
|
42
30
|
|
31
|
+
class PDFAttachmentViewer {
|
32
|
+
constructor({
|
33
|
+
container,
|
34
|
+
eventBus,
|
35
|
+
downloadManager
|
36
|
+
}) {
|
43
37
|
this.container = container;
|
44
38
|
this.eventBus = eventBus;
|
45
39
|
this.downloadManager = downloadManager;
|
46
40
|
this.reset();
|
47
|
-
|
41
|
+
|
42
|
+
this.eventBus._on("fileattachmentannotation", this._appendAttachment.bind(this));
|
48
43
|
}
|
49
44
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
45
|
+
reset(keepRenderedCapability = false) {
|
46
|
+
this.attachments = null;
|
47
|
+
this.container.textContent = "";
|
54
48
|
|
55
|
-
|
56
|
-
this.
|
57
|
-
if (!keepRenderedCapability) {
|
58
|
-
this._renderedCapability = (0, _pdf.createPromiseCapability)();
|
59
|
-
}
|
49
|
+
if (!keepRenderedCapability) {
|
50
|
+
this._renderedCapability = (0, _pdf.createPromiseCapability)();
|
60
51
|
}
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
52
|
+
}
|
53
|
+
|
54
|
+
_dispatchEvent(attachmentsCount) {
|
55
|
+
this._renderedCapability.resolve();
|
56
|
+
|
57
|
+
this.eventBus.dispatch("attachmentsloaded", {
|
58
|
+
source: this,
|
59
|
+
attachmentsCount
|
60
|
+
});
|
61
|
+
}
|
62
|
+
|
63
|
+
_bindPdfLink(button, content, filename) {
|
64
|
+
if (this.downloadManager.disableCreateObjectURL) {
|
65
|
+
throw new Error('bindPdfLink: Unsupported "disableCreateObjectURL" value.');
|
69
66
|
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
67
|
+
|
68
|
+
let blobUrl;
|
69
|
+
|
70
|
+
button.onclick = function () {
|
71
|
+
if (!blobUrl) {
|
72
|
+
blobUrl = (0, _pdf.createObjectURL)(content, "application/pdf");
|
75
73
|
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
74
|
+
|
75
|
+
let viewerUrl;
|
76
|
+
viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
|
77
|
+
window.open(viewerUrl);
|
78
|
+
return false;
|
79
|
+
};
|
80
|
+
}
|
81
|
+
|
82
|
+
_bindLink(button, content, filename) {
|
83
|
+
button.onclick = () => {
|
84
|
+
this.downloadManager.downloadData(content, filename, "");
|
85
|
+
return false;
|
86
|
+
};
|
87
|
+
}
|
88
|
+
|
89
|
+
render({
|
90
|
+
attachments,
|
91
|
+
keepRenderedCapability = false
|
92
|
+
}) {
|
93
|
+
let attachmentsCount = 0;
|
94
|
+
|
95
|
+
if (this.attachments) {
|
96
|
+
this.reset(keepRenderedCapability === true);
|
86
97
|
}
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
return false;
|
95
|
-
};
|
98
|
+
|
99
|
+
this.attachments = attachments || null;
|
100
|
+
|
101
|
+
if (!attachments) {
|
102
|
+
this._dispatchEvent(attachmentsCount);
|
103
|
+
|
104
|
+
return;
|
96
105
|
}
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
});
|
116
|
-
attachmentsCount = names.length;
|
117
|
-
for (var i = 0; i < attachmentsCount; i++) {
|
118
|
-
var item = attachments[names[i]];
|
119
|
-
var filename = (0, _pdf.removeNullCharacters)((0, _pdf.getFilenameFromUrl)(item.filename));
|
120
|
-
var div = document.createElement('div');
|
121
|
-
div.className = 'attachmentsItem';
|
122
|
-
var button = document.createElement('button');
|
123
|
-
button.textContent = filename;
|
124
|
-
if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
|
125
|
-
this._bindPdfLink(button, item.content, filename);
|
126
|
-
} else {
|
127
|
-
this._bindLink(button, item.content, filename);
|
128
|
-
}
|
129
|
-
div.appendChild(button);
|
130
|
-
this.container.appendChild(div);
|
106
|
+
|
107
|
+
const names = Object.keys(attachments).sort(function (a, b) {
|
108
|
+
return a.toLowerCase().localeCompare(b.toLowerCase());
|
109
|
+
});
|
110
|
+
attachmentsCount = names.length;
|
111
|
+
|
112
|
+
for (let i = 0; i < attachmentsCount; i++) {
|
113
|
+
const item = attachments[names[i]];
|
114
|
+
const filename = (0, _pdf.removeNullCharacters)((0, _pdf.getFilenameFromUrl)(item.filename));
|
115
|
+
const div = document.createElement("div");
|
116
|
+
div.className = "attachmentsItem";
|
117
|
+
const button = document.createElement("button");
|
118
|
+
button.textContent = filename;
|
119
|
+
|
120
|
+
if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
|
121
|
+
this._bindPdfLink(button, item.content, filename);
|
122
|
+
} else {
|
123
|
+
this._bindLink(button, item.content, filename);
|
131
124
|
}
|
132
|
-
|
125
|
+
|
126
|
+
div.appendChild(button);
|
127
|
+
this.container.appendChild(div);
|
133
128
|
}
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
129
|
+
|
130
|
+
this._dispatchEvent(attachmentsCount);
|
131
|
+
}
|
132
|
+
|
133
|
+
_appendAttachment({
|
134
|
+
id,
|
135
|
+
filename,
|
136
|
+
content
|
137
|
+
}) {
|
138
|
+
this._renderedCapability.promise.then(() => {
|
139
|
+
let attachments = this.attachments;
|
140
|
+
|
141
|
+
if (!attachments) {
|
142
|
+
attachments = Object.create(null);
|
143
|
+
} else {
|
144
|
+
for (const name in attachments) {
|
145
|
+
if (id === name) {
|
146
|
+
return;
|
152
147
|
}
|
153
148
|
}
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
149
|
+
}
|
150
|
+
|
151
|
+
attachments[id] = {
|
152
|
+
filename,
|
153
|
+
content
|
154
|
+
};
|
155
|
+
this.render({
|
156
|
+
attachments,
|
157
|
+
keepRenderedCapability: true
|
162
158
|
});
|
163
|
-
}
|
164
|
-
}
|
159
|
+
});
|
160
|
+
}
|
165
161
|
|
166
|
-
|
167
|
-
}();
|
162
|
+
}
|
168
163
|
|
169
164
|
exports.PDFAttachmentViewer = PDFAttachmentViewer;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,125 +19,121 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.PDFCursorTools = exports.CursorTool =
|
27
|
+
exports.PDFCursorTools = exports.CursorTool = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _grab_to_pan = require("./grab_to_pan.js");
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
34
|
-
|
35
|
-
var CursorTool = {
|
31
|
+
const CursorTool = {
|
36
32
|
SELECT: 0,
|
37
33
|
HAND: 1,
|
38
34
|
ZOOM: 2
|
39
35
|
};
|
36
|
+
exports.CursorTool = CursorTool;
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
_ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
|
48
|
-
cursorToolOnLoad = _ref$cursorToolOnLoad === undefined ? CursorTool.SELECT : _ref$cursorToolOnLoad;
|
49
|
-
|
50
|
-
_classCallCheck(this, PDFCursorTools);
|
51
|
-
|
38
|
+
class PDFCursorTools {
|
39
|
+
constructor({
|
40
|
+
container,
|
41
|
+
eventBus,
|
42
|
+
cursorToolOnLoad = CursorTool.SELECT
|
43
|
+
}) {
|
52
44
|
this.container = container;
|
53
45
|
this.eventBus = eventBus;
|
54
46
|
this.active = CursorTool.SELECT;
|
55
47
|
this.activeBeforePresentationMode = null;
|
56
|
-
this.handTool = new _grab_to_pan.GrabToPan({
|
48
|
+
this.handTool = new _grab_to_pan.GrabToPan({
|
49
|
+
element: this.container
|
50
|
+
});
|
51
|
+
|
57
52
|
this._addEventListeners();
|
58
|
-
|
59
|
-
|
53
|
+
|
54
|
+
Promise.resolve().then(() => {
|
55
|
+
this.switchTool(cursorToolOnLoad);
|
60
56
|
});
|
61
57
|
}
|
62
58
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
var _this2 = this;
|
59
|
+
get activeTool() {
|
60
|
+
return this.active;
|
61
|
+
}
|
67
62
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
_this2.handTool.deactivate();
|
80
|
-
break;
|
81
|
-
case CursorTool.ZOOM:
|
82
|
-
}
|
83
|
-
};
|
84
|
-
switch (tool) {
|
63
|
+
switchTool(tool) {
|
64
|
+
if (this.activeBeforePresentationMode !== null) {
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
|
68
|
+
if (tool === this.active) {
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
|
72
|
+
const disableActiveTool = () => {
|
73
|
+
switch (this.active) {
|
85
74
|
case CursorTool.SELECT:
|
86
|
-
disableActiveTool();
|
87
75
|
break;
|
76
|
+
|
88
77
|
case CursorTool.HAND:
|
89
|
-
|
90
|
-
this.handTool.activate();
|
78
|
+
this.handTool.deactivate();
|
91
79
|
break;
|
80
|
+
|
92
81
|
case CursorTool.ZOOM:
|
93
|
-
default:
|
94
|
-
console.error('switchTool: "' + tool + '" is an unsupported value.');
|
95
|
-
return;
|
96
82
|
}
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
this.eventBus.on('switchcursortool', function (evt) {
|
114
|
-
_this3.switchTool(evt.tool);
|
115
|
-
});
|
116
|
-
this.eventBus.on('presentationmodechanged', function (evt) {
|
117
|
-
if (evt.switchInProgress) {
|
118
|
-
return;
|
119
|
-
}
|
120
|
-
var previouslyActive = void 0;
|
121
|
-
if (evt.active) {
|
122
|
-
previouslyActive = _this3.active;
|
123
|
-
_this3.switchTool(CursorTool.SELECT);
|
124
|
-
_this3.activeBeforePresentationMode = previouslyActive;
|
125
|
-
} else {
|
126
|
-
previouslyActive = _this3.activeBeforePresentationMode;
|
127
|
-
_this3.activeBeforePresentationMode = null;
|
128
|
-
_this3.switchTool(previouslyActive);
|
129
|
-
}
|
130
|
-
});
|
131
|
-
}
|
132
|
-
}, {
|
133
|
-
key: 'activeTool',
|
134
|
-
get: function get() {
|
135
|
-
return this.active;
|
83
|
+
};
|
84
|
+
|
85
|
+
switch (tool) {
|
86
|
+
case CursorTool.SELECT:
|
87
|
+
disableActiveTool();
|
88
|
+
break;
|
89
|
+
|
90
|
+
case CursorTool.HAND:
|
91
|
+
disableActiveTool();
|
92
|
+
this.handTool.activate();
|
93
|
+
break;
|
94
|
+
|
95
|
+
case CursorTool.ZOOM:
|
96
|
+
default:
|
97
|
+
console.error(`switchTool: "${tool}" is an unsupported value.`);
|
98
|
+
return;
|
136
99
|
}
|
137
|
-
}]);
|
138
100
|
|
139
|
-
|
140
|
-
|
101
|
+
this.active = tool;
|
102
|
+
|
103
|
+
this._dispatchEvent();
|
104
|
+
}
|
105
|
+
|
106
|
+
_dispatchEvent() {
|
107
|
+
this.eventBus.dispatch("cursortoolchanged", {
|
108
|
+
source: this,
|
109
|
+
tool: this.active
|
110
|
+
});
|
111
|
+
}
|
112
|
+
|
113
|
+
_addEventListeners() {
|
114
|
+
this.eventBus._on("switchcursortool", evt => {
|
115
|
+
this.switchTool(evt.tool);
|
116
|
+
});
|
117
|
+
|
118
|
+
this.eventBus._on("presentationmodechanged", evt => {
|
119
|
+
if (evt.switchInProgress) {
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
|
123
|
+
let previouslyActive;
|
124
|
+
|
125
|
+
if (evt.active) {
|
126
|
+
previouslyActive = this.active;
|
127
|
+
this.switchTool(CursorTool.SELECT);
|
128
|
+
this.activeBeforePresentationMode = previouslyActive;
|
129
|
+
} else {
|
130
|
+
previouslyActive = this.activeBeforePresentationMode;
|
131
|
+
this.activeBeforePresentationMode = null;
|
132
|
+
this.switchTool(previouslyActive);
|
133
|
+
}
|
134
|
+
});
|
135
|
+
}
|
136
|
+
|
137
|
+
}
|
141
138
|
|
142
|
-
exports.CursorTool = CursorTool;
|
143
139
|
exports.PDFCursorTools = PDFCursorTools;
|