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.

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