pdfjs-dist 2.1.266 → 2.5.207
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 +8382 -18492
- 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 +20417 -29816
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25688 -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 +58239 -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 +403 -0
- package/es5/web/pdf_viewer.js +7742 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1475 -4897
- 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 +750 -899
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +235 -183
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +447 -542
- package/lib/core/cmap.js +222 -264
- package/lib/core/colorspace.js +699 -863
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +379 -437
- package/lib/core/document.js +573 -660
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +1103 -868
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +570 -491
- package/lib/core/function.js +291 -288
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +145 -149
- package/lib/core/image_utils.js +170 -0
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +284 -232
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2929 -2929
- package/lib/core/murmurhash3.js +90 -101
- package/lib/core/obj.js +1183 -1157
- package/lib/core/operator_list.js +99 -67
- package/lib/core/parser.js +972 -911
- package/lib/core/pattern.js +87 -70
- package/lib/core/pdf_manager.js +150 -315
- package/lib/core/primitives.js +83 -56
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +87 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +193 -390
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +741 -972
- package/lib/display/api.js +1500 -1791
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +165 -165
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +515 -0
- package/lib/display/fetch_stream.js +183 -298
- package/lib/display/font_loader.js +273 -413
- package/lib/display/metadata.js +86 -98
- package/lib/display/network.js +266 -359
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +285 -458
- package/lib/display/pattern_helper.js +113 -65
- package/lib/display/svg.js +1166 -901
- package/lib/display/text_layer.js +156 -132
- package/lib/display/transport_stream.js +262 -278
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +40 -37
- package/lib/pdf.js +226 -59
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +266 -416
- package/lib/test/unit/annotation_spec.js +1555 -701
- package/lib/test/unit/api_spec.js +802 -604
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +84 -69
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +74 -76
- package/lib/test/unit/colorspace_spec.js +166 -161
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +181 -181
- package/lib/test/unit/custom_spec.js +20 -22
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +16 -21
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +83 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +46 -30
- package/lib/test/unit/message_handler_spec.js +173 -159
- package/lib/test/unit/metadata_spec.js +69 -69
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -61
- package/lib/test/unit/network_utils_spec.js +183 -119
- package/lib/test/unit/node_stream_spec.js +78 -92
- package/lib/test/unit/parser_spec.js +172 -114
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +140 -125
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +131 -143
- package/lib/test/unit/testreporter.js +19 -19
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +297 -459
- package/lib/test/unit/unicode_spec.js +38 -38
- package/lib/test/unit/util_spec.js +121 -305
- package/lib/web/annotation_layer_builder.js +66 -103
- package/lib/web/app.js +1328 -1214
- package/lib/web/app_options.js +105 -107
- package/lib/web/base_viewer.js +824 -838
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +39 -55
- package/lib/web/firefox_print_service.js +37 -27
- package/lib/web/firefoxcom.js +212 -363
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +32 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +113 -131
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +221 -306
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +491 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +140 -175
- package/lib/web/pdf_page_view.js +452 -523
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +90 -104
- package/lib/web/pdf_rendering_queue.js +84 -108
- package/lib/web/pdf_sidebar.js +276 -306
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +276 -297
- package/lib/web/pdf_thumbnail_viewer.js +186 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +82 -286
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +282 -339
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +267 -420
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +35 -25
- package/web/pdf_viewer.js +3489 -4855
- 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 -494
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/lib/test/unit/dom_utils_spec.js +0 -89
@@ -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.
|
@@ -26,130 +26,97 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.AnnotationLayer = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _display_utils = require("./display_utils.js");
|
30
30
|
|
31
|
-
var _util = require("../shared/util");
|
31
|
+
var _util = require("../shared/util.js");
|
32
32
|
|
33
|
-
|
33
|
+
class AnnotationElementFactory {
|
34
|
+
static create(parameters) {
|
35
|
+
const subtype = parameters.data.annotationType;
|
34
36
|
|
35
|
-
|
37
|
+
switch (subtype) {
|
38
|
+
case _util.AnnotationType.LINK:
|
39
|
+
return new LinkAnnotationElement(parameters);
|
36
40
|
|
37
|
-
|
41
|
+
case _util.AnnotationType.TEXT:
|
42
|
+
return new TextAnnotationElement(parameters);
|
38
43
|
|
39
|
-
|
44
|
+
case _util.AnnotationType.WIDGET:
|
45
|
+
const fieldType = parameters.data.fieldType;
|
40
46
|
|
41
|
-
|
47
|
+
switch (fieldType) {
|
48
|
+
case "Tx":
|
49
|
+
return new TextWidgetAnnotationElement(parameters);
|
42
50
|
|
43
|
-
|
51
|
+
case "Btn":
|
52
|
+
if (parameters.data.radioButton) {
|
53
|
+
return new RadioButtonWidgetAnnotationElement(parameters);
|
54
|
+
} else if (parameters.data.checkBox) {
|
55
|
+
return new CheckboxWidgetAnnotationElement(parameters);
|
56
|
+
}
|
44
57
|
|
45
|
-
|
58
|
+
return new PushButtonWidgetAnnotationElement(parameters);
|
46
59
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
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); } }
|
52
|
-
|
53
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
54
|
-
|
55
|
-
var AnnotationElementFactory =
|
56
|
-
/*#__PURE__*/
|
57
|
-
function () {
|
58
|
-
function AnnotationElementFactory() {
|
59
|
-
_classCallCheck(this, AnnotationElementFactory);
|
60
|
-
}
|
61
|
-
|
62
|
-
_createClass(AnnotationElementFactory, null, [{
|
63
|
-
key: "create",
|
64
|
-
value: function create(parameters) {
|
65
|
-
var subtype = parameters.data.annotationType;
|
66
|
-
|
67
|
-
switch (subtype) {
|
68
|
-
case _util.AnnotationType.LINK:
|
69
|
-
return new LinkAnnotationElement(parameters);
|
70
|
-
|
71
|
-
case _util.AnnotationType.TEXT:
|
72
|
-
return new TextAnnotationElement(parameters);
|
73
|
-
|
74
|
-
case _util.AnnotationType.WIDGET:
|
75
|
-
var fieldType = parameters.data.fieldType;
|
76
|
-
|
77
|
-
switch (fieldType) {
|
78
|
-
case 'Tx':
|
79
|
-
return new TextWidgetAnnotationElement(parameters);
|
80
|
-
|
81
|
-
case 'Btn':
|
82
|
-
if (parameters.data.radioButton) {
|
83
|
-
return new RadioButtonWidgetAnnotationElement(parameters);
|
84
|
-
} else if (parameters.data.checkBox) {
|
85
|
-
return new CheckboxWidgetAnnotationElement(parameters);
|
86
|
-
}
|
60
|
+
case "Ch":
|
61
|
+
return new ChoiceWidgetAnnotationElement(parameters);
|
62
|
+
}
|
87
63
|
|
88
|
-
|
64
|
+
return new WidgetAnnotationElement(parameters);
|
89
65
|
|
90
|
-
|
91
|
-
|
92
|
-
}
|
66
|
+
case _util.AnnotationType.POPUP:
|
67
|
+
return new PopupAnnotationElement(parameters);
|
93
68
|
|
94
|
-
|
69
|
+
case _util.AnnotationType.FREETEXT:
|
70
|
+
return new FreeTextAnnotationElement(parameters);
|
95
71
|
|
96
|
-
|
97
|
-
|
72
|
+
case _util.AnnotationType.LINE:
|
73
|
+
return new LineAnnotationElement(parameters);
|
98
74
|
|
99
|
-
|
100
|
-
|
75
|
+
case _util.AnnotationType.SQUARE:
|
76
|
+
return new SquareAnnotationElement(parameters);
|
101
77
|
|
102
|
-
|
103
|
-
|
78
|
+
case _util.AnnotationType.CIRCLE:
|
79
|
+
return new CircleAnnotationElement(parameters);
|
104
80
|
|
105
|
-
|
106
|
-
|
81
|
+
case _util.AnnotationType.POLYLINE:
|
82
|
+
return new PolylineAnnotationElement(parameters);
|
107
83
|
|
108
|
-
|
109
|
-
|
84
|
+
case _util.AnnotationType.CARET:
|
85
|
+
return new CaretAnnotationElement(parameters);
|
110
86
|
|
111
|
-
|
112
|
-
|
87
|
+
case _util.AnnotationType.INK:
|
88
|
+
return new InkAnnotationElement(parameters);
|
113
89
|
|
114
|
-
|
115
|
-
|
90
|
+
case _util.AnnotationType.POLYGON:
|
91
|
+
return new PolygonAnnotationElement(parameters);
|
116
92
|
|
117
|
-
|
118
|
-
|
93
|
+
case _util.AnnotationType.HIGHLIGHT:
|
94
|
+
return new HighlightAnnotationElement(parameters);
|
119
95
|
|
120
|
-
|
121
|
-
|
96
|
+
case _util.AnnotationType.UNDERLINE:
|
97
|
+
return new UnderlineAnnotationElement(parameters);
|
122
98
|
|
123
|
-
|
124
|
-
|
99
|
+
case _util.AnnotationType.SQUIGGLY:
|
100
|
+
return new SquigglyAnnotationElement(parameters);
|
125
101
|
|
126
|
-
|
127
|
-
|
102
|
+
case _util.AnnotationType.STRIKEOUT:
|
103
|
+
return new StrikeOutAnnotationElement(parameters);
|
128
104
|
|
129
|
-
|
130
|
-
|
105
|
+
case _util.AnnotationType.STAMP:
|
106
|
+
return new StampAnnotationElement(parameters);
|
131
107
|
|
132
|
-
|
133
|
-
|
108
|
+
case _util.AnnotationType.FILEATTACHMENT:
|
109
|
+
return new FileAttachmentAnnotationElement(parameters);
|
134
110
|
|
135
|
-
|
136
|
-
|
137
|
-
}
|
111
|
+
default:
|
112
|
+
return new AnnotationElement(parameters);
|
138
113
|
}
|
139
|
-
}
|
140
|
-
|
141
|
-
return AnnotationElementFactory;
|
142
|
-
}();
|
143
|
-
|
144
|
-
var AnnotationElement =
|
145
|
-
/*#__PURE__*/
|
146
|
-
function () {
|
147
|
-
function AnnotationElement(parameters) {
|
148
|
-
var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
149
|
-
var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
114
|
+
}
|
150
115
|
|
151
|
-
|
116
|
+
}
|
152
117
|
|
118
|
+
class AnnotationElement {
|
119
|
+
constructor(parameters, isRenderable = false, ignoreBorder = false) {
|
153
120
|
this.isRenderable = isRenderable;
|
154
121
|
this.data = parameters.data;
|
155
122
|
this.layer = parameters.layer;
|
@@ -166,1117 +133,919 @@ function () {
|
|
166
133
|
}
|
167
134
|
}
|
168
135
|
|
169
|
-
|
170
|
-
|
171
|
-
value: function _createContainer() {
|
172
|
-
var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
173
|
-
var data = this.data,
|
136
|
+
_createContainer(ignoreBorder = false) {
|
137
|
+
const data = this.data,
|
174
138
|
page = this.page,
|
175
139
|
viewport = this.viewport;
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
140
|
+
const container = document.createElement("section");
|
141
|
+
let width = data.rect[2] - data.rect[0];
|
142
|
+
let height = data.rect[3] - data.rect[1];
|
143
|
+
container.setAttribute("data-annotation-id", data.id);
|
180
144
|
|
181
|
-
|
145
|
+
const rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
|
182
146
|
|
183
|
-
|
184
|
-
|
147
|
+
container.style.transform = `matrix(${viewport.transform.join(",")})`;
|
148
|
+
container.style.transformOrigin = `-${rect[0]}px -${rect[1]}px`;
|
185
149
|
|
186
|
-
|
187
|
-
|
150
|
+
if (!ignoreBorder && data.borderStyle.width > 0) {
|
151
|
+
container.style.borderWidth = `${data.borderStyle.width}px`;
|
188
152
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
var horizontalRadius = data.borderStyle.horizontalCornerRadius;
|
195
|
-
var verticalRadius = data.borderStyle.verticalCornerRadius;
|
153
|
+
if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
|
154
|
+
width = width - 2 * data.borderStyle.width;
|
155
|
+
height = height - 2 * data.borderStyle.width;
|
156
|
+
}
|
196
157
|
|
197
|
-
|
198
|
-
|
199
|
-
container.style.borderRadius = radius;
|
200
|
-
}
|
158
|
+
const horizontalRadius = data.borderStyle.horizontalCornerRadius;
|
159
|
+
const verticalRadius = data.borderStyle.verticalCornerRadius;
|
201
160
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
161
|
+
if (horizontalRadius > 0 || verticalRadius > 0) {
|
162
|
+
const radius = `${horizontalRadius}px / ${verticalRadius}px`;
|
163
|
+
container.style.borderRadius = radius;
|
164
|
+
}
|
206
165
|
|
207
|
-
|
208
|
-
|
209
|
-
|
166
|
+
switch (data.borderStyle.style) {
|
167
|
+
case _util.AnnotationBorderStyleType.SOLID:
|
168
|
+
container.style.borderStyle = "solid";
|
169
|
+
break;
|
210
170
|
|
211
|
-
|
212
|
-
|
213
|
-
|
171
|
+
case _util.AnnotationBorderStyleType.DASHED:
|
172
|
+
container.style.borderStyle = "dashed";
|
173
|
+
break;
|
214
174
|
|
215
|
-
|
216
|
-
|
217
|
-
|
175
|
+
case _util.AnnotationBorderStyleType.BEVELED:
|
176
|
+
(0, _util.warn)("Unimplemented border style: beveled");
|
177
|
+
break;
|
218
178
|
|
219
|
-
|
220
|
-
|
221
|
-
|
179
|
+
case _util.AnnotationBorderStyleType.INSET:
|
180
|
+
(0, _util.warn)("Unimplemented border style: inset");
|
181
|
+
break;
|
222
182
|
|
223
|
-
|
224
|
-
|
225
|
-
|
183
|
+
case _util.AnnotationBorderStyleType.UNDERLINE:
|
184
|
+
container.style.borderBottomStyle = "solid";
|
185
|
+
break;
|
226
186
|
|
227
|
-
|
228
|
-
|
229
|
-
} else {
|
230
|
-
container.style.borderWidth = 0;
|
231
|
-
}
|
187
|
+
default:
|
188
|
+
break;
|
232
189
|
}
|
233
190
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
return container;
|
239
|
-
}
|
240
|
-
}, {
|
241
|
-
key: "_createPopup",
|
242
|
-
value: function _createPopup(container, trigger, data) {
|
243
|
-
if (!trigger) {
|
244
|
-
trigger = document.createElement('div');
|
245
|
-
trigger.style.height = container.style.height;
|
246
|
-
trigger.style.width = container.style.width;
|
247
|
-
container.appendChild(trigger);
|
191
|
+
if (data.color) {
|
192
|
+
container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
|
193
|
+
} else {
|
194
|
+
container.style.borderWidth = 0;
|
248
195
|
}
|
249
|
-
|
250
|
-
var popupElement = new PopupElement({
|
251
|
-
container: container,
|
252
|
-
trigger: trigger,
|
253
|
-
color: data.color,
|
254
|
-
title: data.title,
|
255
|
-
contents: data.contents,
|
256
|
-
hideWrapper: true
|
257
|
-
});
|
258
|
-
var popup = popupElement.render();
|
259
|
-
popup.style.left = container.style.width;
|
260
|
-
container.appendChild(popup);
|
261
196
|
}
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
197
|
+
|
198
|
+
container.style.left = `${rect[0]}px`;
|
199
|
+
container.style.top = `${rect[1]}px`;
|
200
|
+
container.style.width = `${width}px`;
|
201
|
+
container.style.height = `${height}px`;
|
202
|
+
return container;
|
203
|
+
}
|
204
|
+
|
205
|
+
_createPopup(container, trigger, data) {
|
206
|
+
if (!trigger) {
|
207
|
+
trigger = document.createElement("div");
|
208
|
+
trigger.style.height = container.style.height;
|
209
|
+
trigger.style.width = container.style.width;
|
210
|
+
container.appendChild(trigger);
|
266
211
|
}
|
267
|
-
}]);
|
268
212
|
|
269
|
-
|
270
|
-
|
213
|
+
const popupElement = new PopupElement({
|
214
|
+
container,
|
215
|
+
trigger,
|
216
|
+
color: data.color,
|
217
|
+
title: data.title,
|
218
|
+
modificationDate: data.modificationDate,
|
219
|
+
contents: data.contents,
|
220
|
+
hideWrapper: true
|
221
|
+
});
|
222
|
+
const popup = popupElement.render();
|
223
|
+
popup.style.left = container.style.width;
|
224
|
+
container.appendChild(popup);
|
225
|
+
}
|
271
226
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
_inherits(LinkAnnotationElement, _AnnotationElement);
|
227
|
+
render() {
|
228
|
+
(0, _util.unreachable)("Abstract method `AnnotationElement.render` called");
|
229
|
+
}
|
276
230
|
|
277
|
-
|
278
|
-
_classCallCheck(this, LinkAnnotationElement);
|
231
|
+
}
|
279
232
|
|
280
|
-
|
281
|
-
|
233
|
+
class LinkAnnotationElement extends AnnotationElement {
|
234
|
+
constructor(parameters) {
|
235
|
+
const isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
|
236
|
+
super(parameters, isRenderable);
|
282
237
|
}
|
283
238
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
239
|
+
render() {
|
240
|
+
this.container.className = "linkAnnotation";
|
241
|
+
const {
|
242
|
+
data,
|
243
|
+
linkService
|
244
|
+
} = this;
|
245
|
+
const link = document.createElement("a");
|
246
|
+
|
247
|
+
if (data.url) {
|
248
|
+
(0, _display_utils.addLinkAttributes)(link, {
|
292
249
|
url: data.url,
|
293
|
-
target: data.newWindow ?
|
294
|
-
rel: linkService.externalLinkRel
|
250
|
+
target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
|
251
|
+
rel: linkService.externalLinkRel,
|
252
|
+
enabled: linkService.externalLinkEnabled
|
295
253
|
});
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
} else {
|
301
|
-
this._bindLink(link, data.dest);
|
302
|
-
}
|
303
|
-
}
|
304
|
-
|
305
|
-
this.container.appendChild(link);
|
306
|
-
return this.container;
|
254
|
+
} else if (data.action) {
|
255
|
+
this._bindNamedAction(link, data.action);
|
256
|
+
} else {
|
257
|
+
this._bindLink(link, data.dest);
|
307
258
|
}
|
308
|
-
}, {
|
309
|
-
key: "_bindLink",
|
310
|
-
value: function _bindLink(link, destination) {
|
311
|
-
var _this = this;
|
312
259
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
if (destination) {
|
317
|
-
_this.linkService.navigateTo(destination);
|
318
|
-
}
|
260
|
+
this.container.appendChild(link);
|
261
|
+
return this.container;
|
262
|
+
}
|
319
263
|
|
320
|
-
|
321
|
-
|
264
|
+
_bindLink(link, destination) {
|
265
|
+
link.href = this.linkService.getDestinationHash(destination);
|
322
266
|
|
267
|
+
link.onclick = () => {
|
323
268
|
if (destination) {
|
324
|
-
|
269
|
+
this.linkService.navigateTo(destination);
|
325
270
|
}
|
326
|
-
}
|
327
|
-
}, {
|
328
|
-
key: "_bindNamedAction",
|
329
|
-
value: function _bindNamedAction(link, action) {
|
330
|
-
var _this2 = this;
|
331
271
|
|
332
|
-
|
272
|
+
return false;
|
273
|
+
};
|
333
274
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
return false;
|
338
|
-
};
|
339
|
-
|
340
|
-
link.className = 'internalLink';
|
275
|
+
if (destination) {
|
276
|
+
link.className = "internalLink";
|
341
277
|
}
|
342
|
-
}]);
|
343
|
-
|
344
|
-
return LinkAnnotationElement;
|
345
|
-
}(AnnotationElement);
|
346
|
-
|
347
|
-
var TextAnnotationElement =
|
348
|
-
/*#__PURE__*/
|
349
|
-
function (_AnnotationElement2) {
|
350
|
-
_inherits(TextAnnotationElement, _AnnotationElement2);
|
351
|
-
|
352
|
-
function TextAnnotationElement(parameters) {
|
353
|
-
_classCallCheck(this, TextAnnotationElement);
|
354
|
-
|
355
|
-
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
356
|
-
return _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotationElement).call(this, parameters, isRenderable));
|
357
278
|
}
|
358
279
|
|
359
|
-
|
360
|
-
|
361
|
-
value: function render() {
|
362
|
-
this.container.className = 'textAnnotation';
|
363
|
-
var image = document.createElement('img');
|
364
|
-
image.style.height = this.container.style.height;
|
365
|
-
image.style.width = this.container.style.width;
|
366
|
-
image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
|
367
|
-
image.alt = '[{{type}} Annotation]';
|
368
|
-
image.dataset.l10nId = 'text_annotation_type';
|
369
|
-
image.dataset.l10nArgs = JSON.stringify({
|
370
|
-
type: this.data.name
|
371
|
-
});
|
280
|
+
_bindNamedAction(link, action) {
|
281
|
+
link.href = this.linkService.getAnchorUrl("");
|
372
282
|
|
373
|
-
|
374
|
-
|
375
|
-
|
283
|
+
link.onclick = () => {
|
284
|
+
this.linkService.executeNamedAction(action);
|
285
|
+
return false;
|
286
|
+
};
|
376
287
|
|
377
|
-
|
378
|
-
|
379
|
-
}
|
380
|
-
}]);
|
381
|
-
|
382
|
-
return TextAnnotationElement;
|
383
|
-
}(AnnotationElement);
|
384
|
-
|
385
|
-
var WidgetAnnotationElement =
|
386
|
-
/*#__PURE__*/
|
387
|
-
function (_AnnotationElement3) {
|
388
|
-
_inherits(WidgetAnnotationElement, _AnnotationElement3);
|
288
|
+
link.className = "internalLink";
|
289
|
+
}
|
389
290
|
|
390
|
-
|
391
|
-
_classCallCheck(this, WidgetAnnotationElement);
|
291
|
+
}
|
392
292
|
|
393
|
-
|
293
|
+
class TextAnnotationElement extends AnnotationElement {
|
294
|
+
constructor(parameters) {
|
295
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
296
|
+
super(parameters, isRenderable);
|
394
297
|
}
|
395
298
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
299
|
+
render() {
|
300
|
+
this.container.className = "textAnnotation";
|
301
|
+
const image = document.createElement("img");
|
302
|
+
image.style.height = this.container.style.height;
|
303
|
+
image.style.width = this.container.style.width;
|
304
|
+
image.src = this.imageResourcesPath + "annotation-" + this.data.name.toLowerCase() + ".svg";
|
305
|
+
image.alt = "[{{type}} Annotation]";
|
306
|
+
image.dataset.l10nId = "text_annotation_type";
|
307
|
+
image.dataset.l10nArgs = JSON.stringify({
|
308
|
+
type: this.data.name
|
309
|
+
});
|
310
|
+
|
311
|
+
if (!this.data.hasPopup) {
|
312
|
+
this._createPopup(this.container, image, this.data);
|
400
313
|
}
|
401
|
-
}]);
|
402
|
-
|
403
|
-
return WidgetAnnotationElement;
|
404
|
-
}(AnnotationElement);
|
405
314
|
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
_inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
|
315
|
+
this.container.appendChild(image);
|
316
|
+
return this.container;
|
317
|
+
}
|
410
318
|
|
411
|
-
|
412
|
-
_classCallCheck(this, TextWidgetAnnotationElement);
|
319
|
+
}
|
413
320
|
|
414
|
-
|
415
|
-
|
321
|
+
class WidgetAnnotationElement extends AnnotationElement {
|
322
|
+
render() {
|
323
|
+
return this.container;
|
416
324
|
}
|
417
325
|
|
418
|
-
|
419
|
-
key: "render",
|
420
|
-
value: function render() {
|
421
|
-
var TEXT_ALIGNMENT = ['left', 'center', 'right'];
|
422
|
-
this.container.className = 'textWidgetAnnotation';
|
423
|
-
var element = null;
|
424
|
-
|
425
|
-
if (this.renderInteractiveForms) {
|
426
|
-
if (this.data.multiLine) {
|
427
|
-
element = document.createElement('textarea');
|
428
|
-
element.textContent = this.data.fieldValue;
|
429
|
-
} else {
|
430
|
-
element = document.createElement('input');
|
431
|
-
element.type = 'text';
|
432
|
-
element.setAttribute('value', this.data.fieldValue);
|
433
|
-
}
|
326
|
+
}
|
434
327
|
|
435
|
-
|
328
|
+
class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
329
|
+
constructor(parameters) {
|
330
|
+
const isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
|
331
|
+
super(parameters, isRenderable);
|
332
|
+
}
|
436
333
|
|
437
|
-
|
438
|
-
|
439
|
-
|
334
|
+
render() {
|
335
|
+
const TEXT_ALIGNMENT = ["left", "center", "right"];
|
336
|
+
this.container.className = "textWidgetAnnotation";
|
337
|
+
let element = null;
|
440
338
|
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
element.classList.add('comb');
|
445
|
-
element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
|
446
|
-
}
|
447
|
-
} else {
|
448
|
-
element = document.createElement('div');
|
339
|
+
if (this.renderInteractiveForms) {
|
340
|
+
if (this.data.multiLine) {
|
341
|
+
element = document.createElement("textarea");
|
449
342
|
element.textContent = this.data.fieldValue;
|
450
|
-
|
451
|
-
element
|
452
|
-
|
343
|
+
} else {
|
344
|
+
element = document.createElement("input");
|
345
|
+
element.type = "text";
|
346
|
+
element.setAttribute("value", this.data.fieldValue);
|
347
|
+
}
|
453
348
|
|
454
|
-
|
455
|
-
|
456
|
-
}
|
349
|
+
element.disabled = this.data.readOnly;
|
350
|
+
element.name = this.data.fieldName;
|
457
351
|
|
458
|
-
|
352
|
+
if (this.data.maxLen !== null) {
|
353
|
+
element.maxLength = this.data.maxLen;
|
459
354
|
}
|
460
355
|
|
461
|
-
if (this.data.
|
462
|
-
|
356
|
+
if (this.data.comb) {
|
357
|
+
const fieldWidth = this.data.rect[2] - this.data.rect[0];
|
358
|
+
const combWidth = fieldWidth / this.data.maxLen;
|
359
|
+
element.classList.add("comb");
|
360
|
+
element.style.letterSpacing = `calc(${combWidth}px - 1ch)`;
|
463
361
|
}
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
|
474
|
-
|
475
|
-
if (!font) {
|
476
|
-
return;
|
362
|
+
} else {
|
363
|
+
element = document.createElement("div");
|
364
|
+
element.textContent = this.data.fieldValue;
|
365
|
+
element.style.verticalAlign = "middle";
|
366
|
+
element.style.display = "table-cell";
|
367
|
+
let font = null;
|
368
|
+
|
369
|
+
if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
|
370
|
+
font = this.page.commonObjs.get(this.data.fontRefName);
|
477
371
|
}
|
478
372
|
|
479
|
-
|
480
|
-
style.fontStyle = font.italic ? 'italic' : 'normal';
|
481
|
-
var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
|
482
|
-
var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
|
483
|
-
style.fontFamily = fontFamily + fallbackName;
|
373
|
+
this._setTextStyle(element, font);
|
484
374
|
}
|
485
|
-
}]);
|
486
375
|
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
var CheckboxWidgetAnnotationElement =
|
491
|
-
/*#__PURE__*/
|
492
|
-
function (_WidgetAnnotationElem2) {
|
493
|
-
_inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
|
494
|
-
|
495
|
-
function CheckboxWidgetAnnotationElement(parameters) {
|
496
|
-
_classCallCheck(this, CheckboxWidgetAnnotationElement);
|
376
|
+
if (this.data.textAlignment !== null) {
|
377
|
+
element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
|
378
|
+
}
|
497
379
|
|
498
|
-
|
380
|
+
this.container.appendChild(element);
|
381
|
+
return this.container;
|
499
382
|
}
|
500
383
|
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
var element = document.createElement('input');
|
506
|
-
element.disabled = this.data.readOnly;
|
507
|
-
element.type = 'checkbox';
|
508
|
-
|
509
|
-
if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
|
510
|
-
element.setAttribute('checked', true);
|
511
|
-
}
|
384
|
+
_setTextStyle(element, font) {
|
385
|
+
const style = element.style;
|
386
|
+
style.fontSize = `${this.data.fontSize}px`;
|
387
|
+
style.direction = this.data.fontDirection < 0 ? "rtl" : "ltr";
|
512
388
|
|
513
|
-
|
514
|
-
return
|
389
|
+
if (!font) {
|
390
|
+
return;
|
515
391
|
}
|
516
|
-
}]);
|
517
|
-
|
518
|
-
return CheckboxWidgetAnnotationElement;
|
519
|
-
}(WidgetAnnotationElement);
|
520
392
|
|
521
|
-
|
522
|
-
/*#__PURE__*/
|
523
|
-
function (_WidgetAnnotationElem3) {
|
524
|
-
_inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
|
393
|
+
let bold = "normal";
|
525
394
|
|
526
|
-
|
527
|
-
|
395
|
+
if (font.black) {
|
396
|
+
bold = "900";
|
397
|
+
} else if (font.bold) {
|
398
|
+
bold = "bold";
|
399
|
+
}
|
528
400
|
|
529
|
-
|
401
|
+
style.fontWeight = bold;
|
402
|
+
style.fontStyle = font.italic ? "italic" : "normal";
|
403
|
+
const fontFamily = font.loadedName ? `"${font.loadedName}", ` : "";
|
404
|
+
const fallbackName = font.fallbackName || "Helvetica, sans-serif";
|
405
|
+
style.fontFamily = fontFamily + fallbackName;
|
530
406
|
}
|
531
407
|
|
532
|
-
|
533
|
-
key: "render",
|
534
|
-
value: function render() {
|
535
|
-
this.container.className = 'buttonWidgetAnnotation radioButton';
|
536
|
-
var element = document.createElement('input');
|
537
|
-
element.disabled = this.data.readOnly;
|
538
|
-
element.type = 'radio';
|
539
|
-
element.name = this.data.fieldName;
|
408
|
+
}
|
540
409
|
|
541
|
-
|
542
|
-
|
543
|
-
|
410
|
+
class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
|
411
|
+
constructor(parameters) {
|
412
|
+
super(parameters, parameters.renderInteractiveForms);
|
413
|
+
}
|
544
414
|
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
415
|
+
render() {
|
416
|
+
this.container.className = "buttonWidgetAnnotation checkBox";
|
417
|
+
const element = document.createElement("input");
|
418
|
+
element.disabled = this.data.readOnly;
|
419
|
+
element.type = "checkbox";
|
420
|
+
element.name = this.data.fieldName;
|
549
421
|
|
550
|
-
|
551
|
-
|
422
|
+
if (this.data.fieldValue && this.data.fieldValue !== "Off") {
|
423
|
+
element.setAttribute("checked", true);
|
424
|
+
}
|
552
425
|
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
_inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
|
426
|
+
this.container.appendChild(element);
|
427
|
+
return this.container;
|
428
|
+
}
|
557
429
|
|
558
|
-
|
559
|
-
_classCallCheck(this, PushButtonWidgetAnnotationElement);
|
430
|
+
}
|
560
431
|
|
561
|
-
|
432
|
+
class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
|
433
|
+
constructor(parameters) {
|
434
|
+
super(parameters, parameters.renderInteractiveForms);
|
562
435
|
}
|
563
436
|
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
437
|
+
render() {
|
438
|
+
this.container.className = "buttonWidgetAnnotation radioButton";
|
439
|
+
const element = document.createElement("input");
|
440
|
+
element.disabled = this.data.readOnly;
|
441
|
+
element.type = "radio";
|
442
|
+
element.name = this.data.fieldName;
|
568
443
|
|
569
|
-
|
570
|
-
|
444
|
+
if (this.data.fieldValue === this.data.buttonValue) {
|
445
|
+
element.setAttribute("checked", true);
|
571
446
|
}
|
572
|
-
}]);
|
573
447
|
|
574
|
-
|
575
|
-
|
448
|
+
this.container.appendChild(element);
|
449
|
+
return this.container;
|
450
|
+
}
|
451
|
+
|
452
|
+
}
|
576
453
|
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
454
|
+
class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
|
455
|
+
render() {
|
456
|
+
const container = super.render();
|
457
|
+
container.className = "buttonWidgetAnnotation pushButton";
|
458
|
+
return container;
|
459
|
+
}
|
581
460
|
|
582
|
-
|
583
|
-
_classCallCheck(this, ChoiceWidgetAnnotationElement);
|
461
|
+
}
|
584
462
|
|
585
|
-
|
463
|
+
class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
464
|
+
constructor(parameters) {
|
465
|
+
super(parameters, parameters.renderInteractiveForms);
|
586
466
|
}
|
587
467
|
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
selectElement.disabled = this.data.readOnly;
|
468
|
+
render() {
|
469
|
+
this.container.className = "choiceWidgetAnnotation";
|
470
|
+
const selectElement = document.createElement("select");
|
471
|
+
selectElement.disabled = this.data.readOnly;
|
472
|
+
selectElement.name = this.data.fieldName;
|
594
473
|
|
595
|
-
|
596
|
-
|
474
|
+
if (!this.data.combo) {
|
475
|
+
selectElement.size = this.data.options.length;
|
597
476
|
|
598
|
-
|
599
|
-
|
600
|
-
}
|
477
|
+
if (this.data.multiSelect) {
|
478
|
+
selectElement.multiple = true;
|
601
479
|
}
|
480
|
+
}
|
602
481
|
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
optionElement.value = option.exportValue;
|
482
|
+
for (const option of this.data.options) {
|
483
|
+
const optionElement = document.createElement("option");
|
484
|
+
optionElement.textContent = option.displayValue;
|
485
|
+
optionElement.value = option.exportValue;
|
608
486
|
|
609
|
-
|
610
|
-
|
611
|
-
}
|
612
|
-
|
613
|
-
selectElement.appendChild(optionElement);
|
487
|
+
if (this.data.fieldValue.includes(option.displayValue)) {
|
488
|
+
optionElement.setAttribute("selected", true);
|
614
489
|
}
|
615
490
|
|
616
|
-
|
617
|
-
return this.container;
|
491
|
+
selectElement.appendChild(optionElement);
|
618
492
|
}
|
619
|
-
}]);
|
620
|
-
|
621
|
-
return ChoiceWidgetAnnotationElement;
|
622
|
-
}(WidgetAnnotationElement);
|
623
493
|
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
_inherits(PopupAnnotationElement, _AnnotationElement4);
|
494
|
+
this.container.appendChild(selectElement);
|
495
|
+
return this.container;
|
496
|
+
}
|
628
497
|
|
629
|
-
|
630
|
-
_classCallCheck(this, PopupAnnotationElement);
|
498
|
+
}
|
631
499
|
|
632
|
-
|
633
|
-
|
500
|
+
class PopupAnnotationElement extends AnnotationElement {
|
501
|
+
constructor(parameters) {
|
502
|
+
const isRenderable = !!(parameters.data.title || parameters.data.contents);
|
503
|
+
super(parameters, isRenderable);
|
634
504
|
}
|
635
505
|
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];
|
640
|
-
this.container.className = 'popupAnnotation';
|
641
|
-
|
642
|
-
if (IGNORE_TYPES.includes(this.data.parentType)) {
|
643
|
-
return this.container;
|
644
|
-
}
|
506
|
+
render() {
|
507
|
+
const IGNORE_TYPES = ["Line", "Square", "Circle", "PolyLine", "Polygon", "Ink"];
|
508
|
+
this.container.className = "popupAnnotation";
|
645
509
|
|
646
|
-
|
647
|
-
|
510
|
+
if (IGNORE_TYPES.includes(this.data.parentType)) {
|
511
|
+
return this.container;
|
512
|
+
}
|
648
513
|
|
649
|
-
|
650
|
-
|
651
|
-
}
|
514
|
+
const selector = `[data-annotation-id="${this.data.parentId}"]`;
|
515
|
+
const parentElement = this.layer.querySelector(selector);
|
652
516
|
|
653
|
-
|
654
|
-
container: this.container,
|
655
|
-
trigger: parentElement,
|
656
|
-
color: this.data.color,
|
657
|
-
title: this.data.title,
|
658
|
-
contents: this.data.contents
|
659
|
-
});
|
660
|
-
var parentLeft = parseFloat(parentElement.style.left);
|
661
|
-
var parentWidth = parseFloat(parentElement.style.width);
|
662
|
-
this.container.style.transformOrigin = -(parentLeft + parentWidth) + 'px -' + parentElement.style.top;
|
663
|
-
this.container.style.left = parentLeft + parentWidth + 'px';
|
664
|
-
this.container.appendChild(popup.render());
|
517
|
+
if (!parentElement) {
|
665
518
|
return this.container;
|
666
519
|
}
|
667
|
-
}]);
|
668
520
|
|
669
|
-
|
670
|
-
|
521
|
+
const popup = new PopupElement({
|
522
|
+
container: this.container,
|
523
|
+
trigger: parentElement,
|
524
|
+
color: this.data.color,
|
525
|
+
title: this.data.title,
|
526
|
+
modificationDate: this.data.modificationDate,
|
527
|
+
contents: this.data.contents
|
528
|
+
});
|
529
|
+
const parentLeft = parseFloat(parentElement.style.left);
|
530
|
+
const parentWidth = parseFloat(parentElement.style.width);
|
531
|
+
this.container.style.transformOrigin = `-${parentLeft + parentWidth}px -${parentElement.style.top}`;
|
532
|
+
this.container.style.left = `${parentLeft + parentWidth}px`;
|
533
|
+
this.container.appendChild(popup.render());
|
534
|
+
return this.container;
|
535
|
+
}
|
671
536
|
|
672
|
-
|
673
|
-
/*#__PURE__*/
|
674
|
-
function () {
|
675
|
-
function PopupElement(parameters) {
|
676
|
-
_classCallCheck(this, PopupElement);
|
537
|
+
}
|
677
538
|
|
539
|
+
class PopupElement {
|
540
|
+
constructor(parameters) {
|
678
541
|
this.container = parameters.container;
|
679
542
|
this.trigger = parameters.trigger;
|
680
543
|
this.color = parameters.color;
|
681
544
|
this.title = parameters.title;
|
545
|
+
this.modificationDate = parameters.modificationDate;
|
682
546
|
this.contents = parameters.contents;
|
683
547
|
this.hideWrapper = parameters.hideWrapper || false;
|
684
548
|
this.pinned = false;
|
685
549
|
}
|
686
550
|
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
|
703
|
-
popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
|
704
|
-
}
|
705
|
-
|
706
|
-
var contents = this._formatContents(this.contents);
|
707
|
-
|
708
|
-
var title = document.createElement('h1');
|
709
|
-
title.textContent = this.title;
|
710
|
-
this.trigger.addEventListener('click', this._toggle.bind(this));
|
711
|
-
this.trigger.addEventListener('mouseover', this._show.bind(this, false));
|
712
|
-
this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
|
713
|
-
popup.addEventListener('click', this._hide.bind(this, true));
|
714
|
-
popup.appendChild(title);
|
715
|
-
popup.appendChild(contents);
|
716
|
-
wrapper.appendChild(popup);
|
717
|
-
return wrapper;
|
551
|
+
render() {
|
552
|
+
const BACKGROUND_ENLIGHT = 0.7;
|
553
|
+
const wrapper = document.createElement("div");
|
554
|
+
wrapper.className = "popupWrapper";
|
555
|
+
this.hideElement = this.hideWrapper ? wrapper : this.container;
|
556
|
+
this.hideElement.setAttribute("hidden", true);
|
557
|
+
const popup = document.createElement("div");
|
558
|
+
popup.className = "popup";
|
559
|
+
const color = this.color;
|
560
|
+
|
561
|
+
if (color) {
|
562
|
+
const r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
|
563
|
+
const g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
|
564
|
+
const b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
|
565
|
+
popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
|
718
566
|
}
|
719
|
-
}, {
|
720
|
-
key: "_formatContents",
|
721
|
-
value: function _formatContents(contents) {
|
722
|
-
var p = document.createElement('p');
|
723
|
-
var lines = contents.split(/(?:\r\n?|\n)/);
|
724
|
-
|
725
|
-
for (var i = 0, ii = lines.length; i < ii; ++i) {
|
726
|
-
var line = lines[i];
|
727
|
-
p.appendChild(document.createTextNode(line));
|
728
|
-
|
729
|
-
if (i < ii - 1) {
|
730
|
-
p.appendChild(document.createElement('br'));
|
731
|
-
}
|
732
|
-
}
|
733
567
|
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
key: "_toggle",
|
738
|
-
value: function _toggle() {
|
739
|
-
if (this.pinned) {
|
740
|
-
this._hide(true);
|
741
|
-
} else {
|
742
|
-
this._show(true);
|
743
|
-
}
|
744
|
-
}
|
745
|
-
}, {
|
746
|
-
key: "_show",
|
747
|
-
value: function _show() {
|
748
|
-
var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
568
|
+
const title = document.createElement("h1");
|
569
|
+
title.textContent = this.title;
|
570
|
+
popup.appendChild(title);
|
749
571
|
|
750
|
-
|
751
|
-
this.pinned = true;
|
752
|
-
}
|
572
|
+
const dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);
|
753
573
|
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
574
|
+
if (dateObject) {
|
575
|
+
const modificationDate = document.createElement("span");
|
576
|
+
modificationDate.textContent = "{{date}}, {{time}}";
|
577
|
+
modificationDate.dataset.l10nId = "annotation_date_string";
|
578
|
+
modificationDate.dataset.l10nArgs = JSON.stringify({
|
579
|
+
date: dateObject.toLocaleDateString(),
|
580
|
+
time: dateObject.toLocaleTimeString()
|
581
|
+
});
|
582
|
+
popup.appendChild(modificationDate);
|
758
583
|
}
|
759
|
-
}, {
|
760
|
-
key: "_hide",
|
761
|
-
value: function _hide() {
|
762
|
-
var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
763
584
|
|
764
|
-
|
765
|
-
this.pinned = false;
|
766
|
-
}
|
585
|
+
const contents = this._formatContents(this.contents);
|
767
586
|
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
587
|
+
popup.appendChild(contents);
|
588
|
+
this.trigger.addEventListener("click", this._toggle.bind(this));
|
589
|
+
this.trigger.addEventListener("mouseover", this._show.bind(this, false));
|
590
|
+
this.trigger.addEventListener("mouseout", this._hide.bind(this, false));
|
591
|
+
popup.addEventListener("click", this._hide.bind(this, true));
|
592
|
+
wrapper.appendChild(popup);
|
593
|
+
return wrapper;
|
594
|
+
}
|
774
595
|
|
775
|
-
|
776
|
-
|
596
|
+
_formatContents(contents) {
|
597
|
+
const p = document.createElement("p");
|
598
|
+
const lines = contents.split(/(?:\r\n?|\n)/);
|
777
599
|
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
_inherits(LineAnnotationElement, _AnnotationElement5);
|
600
|
+
for (let i = 0, ii = lines.length; i < ii; ++i) {
|
601
|
+
const line = lines[i];
|
602
|
+
p.appendChild(document.createTextNode(line));
|
782
603
|
|
783
|
-
|
784
|
-
|
604
|
+
if (i < ii - 1) {
|
605
|
+
p.appendChild(document.createElement("br"));
|
606
|
+
}
|
607
|
+
}
|
785
608
|
|
786
|
-
|
787
|
-
return _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotationElement).call(this, parameters, isRenderable, true));
|
609
|
+
return p;
|
788
610
|
}
|
789
611
|
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
var svg = this.svgFactory.create(width, height);
|
798
|
-
var line = this.svgFactory.createElement('svg:line');
|
799
|
-
line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
|
800
|
-
line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
|
801
|
-
line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
|
802
|
-
line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
|
803
|
-
line.setAttribute('stroke-width', data.borderStyle.width);
|
804
|
-
line.setAttribute('stroke', 'transparent');
|
805
|
-
svg.appendChild(line);
|
806
|
-
this.container.append(svg);
|
807
|
-
|
808
|
-
this._createPopup(this.container, line, data);
|
612
|
+
_toggle() {
|
613
|
+
if (this.pinned) {
|
614
|
+
this._hide(true);
|
615
|
+
} else {
|
616
|
+
this._show(true);
|
617
|
+
}
|
618
|
+
}
|
809
619
|
|
810
|
-
|
620
|
+
_show(pin = false) {
|
621
|
+
if (pin) {
|
622
|
+
this.pinned = true;
|
623
|
+
}
|
624
|
+
|
625
|
+
if (this.hideElement.hasAttribute("hidden")) {
|
626
|
+
this.hideElement.removeAttribute("hidden");
|
627
|
+
this.container.style.zIndex += 1;
|
811
628
|
}
|
812
|
-
}
|
629
|
+
}
|
813
630
|
|
814
|
-
|
815
|
-
|
631
|
+
_hide(unpin = true) {
|
632
|
+
if (unpin) {
|
633
|
+
this.pinned = false;
|
634
|
+
}
|
816
635
|
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
636
|
+
if (!this.hideElement.hasAttribute("hidden") && !this.pinned) {
|
637
|
+
this.hideElement.setAttribute("hidden", true);
|
638
|
+
this.container.style.zIndex -= 1;
|
639
|
+
}
|
640
|
+
}
|
821
641
|
|
822
|
-
|
823
|
-
_classCallCheck(this, SquareAnnotationElement);
|
642
|
+
}
|
824
643
|
|
825
|
-
|
826
|
-
|
644
|
+
class FreeTextAnnotationElement extends AnnotationElement {
|
645
|
+
constructor(parameters) {
|
646
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
647
|
+
super(parameters, isRenderable, true);
|
827
648
|
}
|
828
649
|
|
829
|
-
|
830
|
-
|
831
|
-
value: function render() {
|
832
|
-
this.container.className = 'squareAnnotation';
|
833
|
-
var data = this.data;
|
834
|
-
var width = data.rect[2] - data.rect[0];
|
835
|
-
var height = data.rect[3] - data.rect[1];
|
836
|
-
var svg = this.svgFactory.create(width, height);
|
837
|
-
var borderWidth = data.borderStyle.width;
|
838
|
-
var square = this.svgFactory.createElement('svg:rect');
|
839
|
-
square.setAttribute('x', borderWidth / 2);
|
840
|
-
square.setAttribute('y', borderWidth / 2);
|
841
|
-
square.setAttribute('width', width - borderWidth);
|
842
|
-
square.setAttribute('height', height - borderWidth);
|
843
|
-
square.setAttribute('stroke-width', borderWidth);
|
844
|
-
square.setAttribute('stroke', 'transparent');
|
845
|
-
square.setAttribute('fill', 'none');
|
846
|
-
svg.appendChild(square);
|
847
|
-
this.container.append(svg);
|
848
|
-
|
849
|
-
this._createPopup(this.container, square, data);
|
650
|
+
render() {
|
651
|
+
this.container.className = "freeTextAnnotation";
|
850
652
|
|
851
|
-
|
653
|
+
if (!this.data.hasPopup) {
|
654
|
+
this._createPopup(this.container, null, this.data);
|
852
655
|
}
|
853
|
-
}]);
|
854
|
-
|
855
|
-
return SquareAnnotationElement;
|
856
|
-
}(AnnotationElement);
|
857
656
|
|
858
|
-
|
859
|
-
|
860
|
-
function (_AnnotationElement7) {
|
861
|
-
_inherits(CircleAnnotationElement, _AnnotationElement7);
|
657
|
+
return this.container;
|
658
|
+
}
|
862
659
|
|
863
|
-
|
864
|
-
_classCallCheck(this, CircleAnnotationElement);
|
660
|
+
}
|
865
661
|
|
866
|
-
|
867
|
-
|
662
|
+
class LineAnnotationElement extends AnnotationElement {
|
663
|
+
constructor(parameters) {
|
664
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
665
|
+
super(parameters, isRenderable, true);
|
868
666
|
}
|
869
667
|
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
this._createPopup(this.container, circle, data);
|
891
|
-
|
892
|
-
return this.container;
|
893
|
-
}
|
894
|
-
}]);
|
668
|
+
render() {
|
669
|
+
this.container.className = "lineAnnotation";
|
670
|
+
const data = this.data;
|
671
|
+
const width = data.rect[2] - data.rect[0];
|
672
|
+
const height = data.rect[3] - data.rect[1];
|
673
|
+
const svg = this.svgFactory.create(width, height);
|
674
|
+
const line = this.svgFactory.createElement("svg:line");
|
675
|
+
line.setAttribute("x1", data.rect[2] - data.lineCoordinates[0]);
|
676
|
+
line.setAttribute("y1", data.rect[3] - data.lineCoordinates[1]);
|
677
|
+
line.setAttribute("x2", data.rect[2] - data.lineCoordinates[2]);
|
678
|
+
line.setAttribute("y2", data.rect[3] - data.lineCoordinates[3]);
|
679
|
+
line.setAttribute("stroke-width", data.borderStyle.width || 1);
|
680
|
+
line.setAttribute("stroke", "transparent");
|
681
|
+
svg.appendChild(line);
|
682
|
+
this.container.append(svg);
|
683
|
+
|
684
|
+
this._createPopup(this.container, line, data);
|
685
|
+
|
686
|
+
return this.container;
|
687
|
+
}
|
895
688
|
|
896
|
-
|
897
|
-
}(AnnotationElement);
|
689
|
+
}
|
898
690
|
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
691
|
+
class SquareAnnotationElement extends AnnotationElement {
|
692
|
+
constructor(parameters) {
|
693
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
694
|
+
super(parameters, isRenderable, true);
|
695
|
+
}
|
903
696
|
|
904
|
-
|
905
|
-
|
697
|
+
render() {
|
698
|
+
this.container.className = "squareAnnotation";
|
699
|
+
const data = this.data;
|
700
|
+
const width = data.rect[2] - data.rect[0];
|
701
|
+
const height = data.rect[3] - data.rect[1];
|
702
|
+
const svg = this.svgFactory.create(width, height);
|
703
|
+
const borderWidth = data.borderStyle.width;
|
704
|
+
const square = this.svgFactory.createElement("svg:rect");
|
705
|
+
square.setAttribute("x", borderWidth / 2);
|
706
|
+
square.setAttribute("y", borderWidth / 2);
|
707
|
+
square.setAttribute("width", width - borderWidth);
|
708
|
+
square.setAttribute("height", height - borderWidth);
|
709
|
+
square.setAttribute("stroke-width", borderWidth || 1);
|
710
|
+
square.setAttribute("stroke", "transparent");
|
711
|
+
square.setAttribute("fill", "none");
|
712
|
+
svg.appendChild(square);
|
713
|
+
this.container.append(svg);
|
714
|
+
|
715
|
+
this._createPopup(this.container, square, data);
|
716
|
+
|
717
|
+
return this.container;
|
718
|
+
}
|
906
719
|
|
907
|
-
|
720
|
+
}
|
908
721
|
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
return _this3;
|
722
|
+
class CircleAnnotationElement extends AnnotationElement {
|
723
|
+
constructor(parameters) {
|
724
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
725
|
+
super(parameters, isRenderable, true);
|
914
726
|
}
|
915
727
|
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
728
|
+
render() {
|
729
|
+
this.container.className = "circleAnnotation";
|
730
|
+
const data = this.data;
|
731
|
+
const width = data.rect[2] - data.rect[0];
|
732
|
+
const height = data.rect[3] - data.rect[1];
|
733
|
+
const svg = this.svgFactory.create(width, height);
|
734
|
+
const borderWidth = data.borderStyle.width;
|
735
|
+
const circle = this.svgFactory.createElement("svg:ellipse");
|
736
|
+
circle.setAttribute("cx", width / 2);
|
737
|
+
circle.setAttribute("cy", height / 2);
|
738
|
+
circle.setAttribute("rx", width / 2 - borderWidth / 2);
|
739
|
+
circle.setAttribute("ry", height / 2 - borderWidth / 2);
|
740
|
+
circle.setAttribute("stroke-width", borderWidth || 1);
|
741
|
+
circle.setAttribute("stroke", "transparent");
|
742
|
+
circle.setAttribute("fill", "none");
|
743
|
+
svg.appendChild(circle);
|
744
|
+
this.container.append(svg);
|
745
|
+
|
746
|
+
this._createPopup(this.container, circle, data);
|
747
|
+
|
748
|
+
return this.container;
|
749
|
+
}
|
932
750
|
|
933
|
-
|
934
|
-
var borderWidth = data.borderStyle.width;
|
935
|
-
var polyline = this.svgFactory.createElement(this.svgElementName);
|
936
|
-
polyline.setAttribute('points', points);
|
937
|
-
polyline.setAttribute('stroke-width', borderWidth);
|
938
|
-
polyline.setAttribute('stroke', 'transparent');
|
939
|
-
polyline.setAttribute('fill', 'none');
|
940
|
-
svg.appendChild(polyline);
|
941
|
-
this.container.append(svg);
|
751
|
+
}
|
942
752
|
|
943
|
-
|
753
|
+
class PolylineAnnotationElement extends AnnotationElement {
|
754
|
+
constructor(parameters) {
|
755
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
756
|
+
super(parameters, isRenderable, true);
|
757
|
+
this.containerClassName = "polylineAnnotation";
|
758
|
+
this.svgElementName = "svg:polyline";
|
759
|
+
}
|
944
760
|
|
945
|
-
|
761
|
+
render() {
|
762
|
+
this.container.className = this.containerClassName;
|
763
|
+
const data = this.data;
|
764
|
+
const width = data.rect[2] - data.rect[0];
|
765
|
+
const height = data.rect[3] - data.rect[1];
|
766
|
+
const svg = this.svgFactory.create(width, height);
|
767
|
+
let points = [];
|
768
|
+
|
769
|
+
for (const coordinate of data.vertices) {
|
770
|
+
const x = coordinate.x - data.rect[0];
|
771
|
+
const y = data.rect[3] - coordinate.y;
|
772
|
+
points.push(x + "," + y);
|
946
773
|
}
|
947
|
-
}]);
|
948
774
|
|
949
|
-
|
950
|
-
|
775
|
+
points = points.join(" ");
|
776
|
+
const polyline = this.svgFactory.createElement(this.svgElementName);
|
777
|
+
polyline.setAttribute("points", points);
|
778
|
+
polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
|
779
|
+
polyline.setAttribute("stroke", "transparent");
|
780
|
+
polyline.setAttribute("fill", "none");
|
781
|
+
svg.appendChild(polyline);
|
782
|
+
this.container.append(svg);
|
951
783
|
|
952
|
-
|
953
|
-
/*#__PURE__*/
|
954
|
-
function (_PolylineAnnotationEl) {
|
955
|
-
_inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
|
784
|
+
this._createPopup(this.container, polyline, data);
|
956
785
|
|
957
|
-
|
958
|
-
|
786
|
+
return this.container;
|
787
|
+
}
|
959
788
|
|
960
|
-
|
789
|
+
}
|
961
790
|
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
791
|
+
class PolygonAnnotationElement extends PolylineAnnotationElement {
|
792
|
+
constructor(parameters) {
|
793
|
+
super(parameters);
|
794
|
+
this.containerClassName = "polygonAnnotation";
|
795
|
+
this.svgElementName = "svg:polygon";
|
966
796
|
}
|
967
797
|
|
968
|
-
|
969
|
-
}(PolylineAnnotationElement);
|
798
|
+
}
|
970
799
|
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
800
|
+
class CaretAnnotationElement extends AnnotationElement {
|
801
|
+
constructor(parameters) {
|
802
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
803
|
+
super(parameters, isRenderable, true);
|
804
|
+
}
|
975
805
|
|
976
|
-
|
977
|
-
|
806
|
+
render() {
|
807
|
+
this.container.className = "caretAnnotation";
|
978
808
|
|
979
|
-
|
809
|
+
if (!this.data.hasPopup) {
|
810
|
+
this._createPopup(this.container, null, this.data);
|
811
|
+
}
|
980
812
|
|
981
|
-
|
982
|
-
_this5 = _possibleConstructorReturn(this, _getPrototypeOf(InkAnnotationElement).call(this, parameters, isRenderable, true));
|
983
|
-
_this5.containerClassName = 'inkAnnotation';
|
984
|
-
_this5.svgElementName = 'svg:polyline';
|
985
|
-
return _this5;
|
813
|
+
return this.container;
|
986
814
|
}
|
987
815
|
|
988
|
-
|
989
|
-
key: "render",
|
990
|
-
value: function render() {
|
991
|
-
this.container.className = this.containerClassName;
|
992
|
-
var data = this.data;
|
993
|
-
var width = data.rect[2] - data.rect[0];
|
994
|
-
var height = data.rect[3] - data.rect[1];
|
995
|
-
var svg = this.svgFactory.create(width, height);
|
996
|
-
var inkLists = data.inkLists;
|
997
|
-
|
998
|
-
for (var i = 0, ii = inkLists.length; i < ii; i++) {
|
999
|
-
var inkList = inkLists[i];
|
1000
|
-
var points = [];
|
1001
|
-
|
1002
|
-
for (var j = 0, jj = inkList.length; j < jj; j++) {
|
1003
|
-
var x = inkList[j].x - data.rect[0];
|
1004
|
-
var y = data.rect[3] - inkList[j].y;
|
1005
|
-
points.push(x + ',' + y);
|
1006
|
-
}
|
816
|
+
}
|
1007
817
|
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
818
|
+
class InkAnnotationElement extends AnnotationElement {
|
819
|
+
constructor(parameters) {
|
820
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
821
|
+
super(parameters, isRenderable, true);
|
822
|
+
this.containerClassName = "inkAnnotation";
|
823
|
+
this.svgElementName = "svg:polyline";
|
824
|
+
}
|
1015
825
|
|
1016
|
-
|
826
|
+
render() {
|
827
|
+
this.container.className = this.containerClassName;
|
828
|
+
const data = this.data;
|
829
|
+
const width = data.rect[2] - data.rect[0];
|
830
|
+
const height = data.rect[3] - data.rect[1];
|
831
|
+
const svg = this.svgFactory.create(width, height);
|
1017
832
|
|
1018
|
-
|
1019
|
-
|
833
|
+
for (const inkList of data.inkLists) {
|
834
|
+
let points = [];
|
1020
835
|
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
836
|
+
for (const coordinate of inkList) {
|
837
|
+
const x = coordinate.x - data.rect[0];
|
838
|
+
const y = data.rect[3] - coordinate.y;
|
839
|
+
points.push(`${x},${y}`);
|
840
|
+
}
|
1025
841
|
|
1026
|
-
|
1027
|
-
|
842
|
+
points = points.join(" ");
|
843
|
+
const polyline = this.svgFactory.createElement(this.svgElementName);
|
844
|
+
polyline.setAttribute("points", points);
|
845
|
+
polyline.setAttribute("stroke-width", data.borderStyle.width || 1);
|
846
|
+
polyline.setAttribute("stroke", "transparent");
|
847
|
+
polyline.setAttribute("fill", "none");
|
1028
848
|
|
1029
|
-
|
1030
|
-
/*#__PURE__*/
|
1031
|
-
function (_AnnotationElement10) {
|
1032
|
-
_inherits(HighlightAnnotationElement, _AnnotationElement10);
|
849
|
+
this._createPopup(this.container, polyline, data);
|
1033
850
|
|
1034
|
-
|
1035
|
-
|
851
|
+
svg.appendChild(polyline);
|
852
|
+
}
|
1036
853
|
|
1037
|
-
|
1038
|
-
return
|
854
|
+
this.container.append(svg);
|
855
|
+
return this.container;
|
1039
856
|
}
|
1040
857
|
|
1041
|
-
|
1042
|
-
key: "render",
|
1043
|
-
value: function render() {
|
1044
|
-
this.container.className = 'highlightAnnotation';
|
858
|
+
}
|
1045
859
|
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
860
|
+
class HighlightAnnotationElement extends AnnotationElement {
|
861
|
+
constructor(parameters) {
|
862
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
863
|
+
super(parameters, isRenderable, true);
|
864
|
+
}
|
1049
865
|
|
1050
|
-
|
1051
|
-
|
1052
|
-
}]);
|
866
|
+
render() {
|
867
|
+
this.container.className = "highlightAnnotation";
|
1053
868
|
|
1054
|
-
|
1055
|
-
|
869
|
+
if (!this.data.hasPopup) {
|
870
|
+
this._createPopup(this.container, null, this.data);
|
871
|
+
}
|
1056
872
|
|
1057
|
-
|
1058
|
-
|
1059
|
-
function (_AnnotationElement11) {
|
1060
|
-
_inherits(UnderlineAnnotationElement, _AnnotationElement11);
|
873
|
+
return this.container;
|
874
|
+
}
|
1061
875
|
|
1062
|
-
|
1063
|
-
_classCallCheck(this, UnderlineAnnotationElement);
|
876
|
+
}
|
1064
877
|
|
1065
|
-
|
1066
|
-
|
878
|
+
class UnderlineAnnotationElement extends AnnotationElement {
|
879
|
+
constructor(parameters) {
|
880
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
881
|
+
super(parameters, isRenderable, true);
|
1067
882
|
}
|
1068
883
|
|
1069
|
-
|
1070
|
-
|
1071
|
-
value: function render() {
|
1072
|
-
this.container.className = 'underlineAnnotation';
|
1073
|
-
|
1074
|
-
if (!this.data.hasPopup) {
|
1075
|
-
this._createPopup(this.container, null, this.data);
|
1076
|
-
}
|
884
|
+
render() {
|
885
|
+
this.container.className = "underlineAnnotation";
|
1077
886
|
|
1078
|
-
|
887
|
+
if (!this.data.hasPopup) {
|
888
|
+
this._createPopup(this.container, null, this.data);
|
1079
889
|
}
|
1080
|
-
}]);
|
1081
|
-
|
1082
|
-
return UnderlineAnnotationElement;
|
1083
|
-
}(AnnotationElement);
|
1084
890
|
|
1085
|
-
|
1086
|
-
|
1087
|
-
function (_AnnotationElement12) {
|
1088
|
-
_inherits(SquigglyAnnotationElement, _AnnotationElement12);
|
891
|
+
return this.container;
|
892
|
+
}
|
1089
893
|
|
1090
|
-
|
1091
|
-
_classCallCheck(this, SquigglyAnnotationElement);
|
894
|
+
}
|
1092
895
|
|
1093
|
-
|
1094
|
-
|
896
|
+
class SquigglyAnnotationElement extends AnnotationElement {
|
897
|
+
constructor(parameters) {
|
898
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
899
|
+
super(parameters, isRenderable, true);
|
1095
900
|
}
|
1096
901
|
|
1097
|
-
|
1098
|
-
|
1099
|
-
value: function render() {
|
1100
|
-
this.container.className = 'squigglyAnnotation';
|
1101
|
-
|
1102
|
-
if (!this.data.hasPopup) {
|
1103
|
-
this._createPopup(this.container, null, this.data);
|
1104
|
-
}
|
902
|
+
render() {
|
903
|
+
this.container.className = "squigglyAnnotation";
|
1105
904
|
|
1106
|
-
|
905
|
+
if (!this.data.hasPopup) {
|
906
|
+
this._createPopup(this.container, null, this.data);
|
1107
907
|
}
|
1108
|
-
}]);
|
1109
908
|
|
1110
|
-
|
1111
|
-
}
|
1112
|
-
|
1113
|
-
var StrikeOutAnnotationElement =
|
1114
|
-
/*#__PURE__*/
|
1115
|
-
function (_AnnotationElement13) {
|
1116
|
-
_inherits(StrikeOutAnnotationElement, _AnnotationElement13);
|
909
|
+
return this.container;
|
910
|
+
}
|
1117
911
|
|
1118
|
-
|
1119
|
-
_classCallCheck(this, StrikeOutAnnotationElement);
|
912
|
+
}
|
1120
913
|
|
1121
|
-
|
1122
|
-
|
914
|
+
class StrikeOutAnnotationElement extends AnnotationElement {
|
915
|
+
constructor(parameters) {
|
916
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
917
|
+
super(parameters, isRenderable, true);
|
1123
918
|
}
|
1124
919
|
|
1125
|
-
|
1126
|
-
|
1127
|
-
value: function render() {
|
1128
|
-
this.container.className = 'strikeoutAnnotation';
|
920
|
+
render() {
|
921
|
+
this.container.className = "strikeoutAnnotation";
|
1129
922
|
|
1130
|
-
|
1131
|
-
|
1132
|
-
}
|
1133
|
-
|
1134
|
-
return this.container;
|
923
|
+
if (!this.data.hasPopup) {
|
924
|
+
this._createPopup(this.container, null, this.data);
|
1135
925
|
}
|
1136
|
-
}]);
|
1137
|
-
|
1138
|
-
return StrikeOutAnnotationElement;
|
1139
|
-
}(AnnotationElement);
|
1140
926
|
|
1141
|
-
|
1142
|
-
|
1143
|
-
function (_AnnotationElement14) {
|
1144
|
-
_inherits(StampAnnotationElement, _AnnotationElement14);
|
927
|
+
return this.container;
|
928
|
+
}
|
1145
929
|
|
1146
|
-
|
1147
|
-
_classCallCheck(this, StampAnnotationElement);
|
930
|
+
}
|
1148
931
|
|
1149
|
-
|
1150
|
-
|
932
|
+
class StampAnnotationElement extends AnnotationElement {
|
933
|
+
constructor(parameters) {
|
934
|
+
const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
|
935
|
+
super(parameters, isRenderable, true);
|
1151
936
|
}
|
1152
937
|
|
1153
|
-
|
1154
|
-
|
1155
|
-
value: function render() {
|
1156
|
-
this.container.className = 'stampAnnotation';
|
1157
|
-
|
1158
|
-
if (!this.data.hasPopup) {
|
1159
|
-
this._createPopup(this.container, null, this.data);
|
1160
|
-
}
|
938
|
+
render() {
|
939
|
+
this.container.className = "stampAnnotation";
|
1161
940
|
|
1162
|
-
|
941
|
+
if (!this.data.hasPopup) {
|
942
|
+
this._createPopup(this.container, null, this.data);
|
1163
943
|
}
|
1164
|
-
}]);
|
1165
944
|
|
1166
|
-
|
1167
|
-
}
|
945
|
+
return this.container;
|
946
|
+
}
|
1168
947
|
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
948
|
+
}
|
949
|
+
|
950
|
+
class FileAttachmentAnnotationElement extends AnnotationElement {
|
951
|
+
constructor(parameters) {
|
952
|
+
super(parameters, true);
|
953
|
+
const {
|
954
|
+
filename,
|
955
|
+
content
|
956
|
+
} = this.data.file;
|
957
|
+
this.filename = (0, _display_utils.getFilenameFromUrl)(filename);
|
958
|
+
this.content = content;
|
959
|
+
|
960
|
+
if (this.linkService.eventBus) {
|
961
|
+
this.linkService.eventBus.dispatch("fileattachmentannotation", {
|
962
|
+
source: this,
|
963
|
+
id: (0, _util.stringToPDFString)(filename),
|
964
|
+
filename,
|
965
|
+
content
|
966
|
+
});
|
967
|
+
}
|
968
|
+
}
|
1173
969
|
|
1174
|
-
|
1175
|
-
|
970
|
+
render() {
|
971
|
+
this.container.className = "fileAttachmentAnnotation";
|
972
|
+
const trigger = document.createElement("div");
|
973
|
+
trigger.style.height = this.container.style.height;
|
974
|
+
trigger.style.width = this.container.style.width;
|
975
|
+
trigger.addEventListener("dblclick", this._download.bind(this));
|
1176
976
|
|
1177
|
-
|
977
|
+
if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
|
978
|
+
this._createPopup(this.container, trigger, this.data);
|
979
|
+
}
|
1178
980
|
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
content = _this6$data$file.content;
|
1183
|
-
_this6.filename = (0, _dom_utils.getFilenameFromUrl)(filename);
|
1184
|
-
_this6.content = content;
|
981
|
+
this.container.appendChild(trigger);
|
982
|
+
return this.container;
|
983
|
+
}
|
1185
984
|
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
filename: filename,
|
1191
|
-
content: content
|
1192
|
-
});
|
985
|
+
_download() {
|
986
|
+
if (!this.downloadManager) {
|
987
|
+
(0, _util.warn)("Download cannot be started due to unavailable download manager");
|
988
|
+
return;
|
1193
989
|
}
|
1194
990
|
|
1195
|
-
|
991
|
+
this.downloadManager.downloadData(this.content, this.filename, "");
|
1196
992
|
}
|
1197
993
|
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
this._createPopup(this.container, trigger, this.data);
|
994
|
+
}
|
995
|
+
|
996
|
+
class AnnotationLayer {
|
997
|
+
static render(parameters) {
|
998
|
+
const sortedAnnotations = [],
|
999
|
+
popupAnnotations = [];
|
1000
|
+
|
1001
|
+
for (const data of parameters.annotations) {
|
1002
|
+
if (!data) {
|
1003
|
+
continue;
|
1209
1004
|
}
|
1210
1005
|
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
}, {
|
1215
|
-
key: "_download",
|
1216
|
-
value: function _download() {
|
1217
|
-
if (!this.downloadManager) {
|
1218
|
-
(0, _util.warn)('Download cannot be started due to unavailable download manager');
|
1219
|
-
return;
|
1006
|
+
if (data.annotationType === _util.AnnotationType.POPUP) {
|
1007
|
+
popupAnnotations.push(data);
|
1008
|
+
continue;
|
1220
1009
|
}
|
1221
1010
|
|
1222
|
-
|
1011
|
+
sortedAnnotations.push(data);
|
1012
|
+
}
|
1013
|
+
|
1014
|
+
if (popupAnnotations.length) {
|
1015
|
+
sortedAnnotations.push(...popupAnnotations);
|
1223
1016
|
}
|
1224
|
-
}]);
|
1225
1017
|
|
1226
|
-
|
1227
|
-
|
1018
|
+
for (const data of sortedAnnotations) {
|
1019
|
+
const element = AnnotationElementFactory.create({
|
1020
|
+
data,
|
1021
|
+
layer: parameters.div,
|
1022
|
+
page: parameters.page,
|
1023
|
+
viewport: parameters.viewport,
|
1024
|
+
linkService: parameters.linkService,
|
1025
|
+
downloadManager: parameters.downloadManager,
|
1026
|
+
imageResourcesPath: parameters.imageResourcesPath || "",
|
1027
|
+
renderInteractiveForms: parameters.renderInteractiveForms || false,
|
1028
|
+
svgFactory: new _display_utils.DOMSVGFactory()
|
1029
|
+
});
|
1228
1030
|
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
_classCallCheck(this, AnnotationLayer);
|
1031
|
+
if (element.isRenderable) {
|
1032
|
+
parameters.div.appendChild(element.render());
|
1033
|
+
}
|
1034
|
+
}
|
1234
1035
|
}
|
1235
1036
|
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
|
1240
|
-
var data = parameters.annotations[i];
|
1037
|
+
static update(parameters) {
|
1038
|
+
for (const data of parameters.annotations) {
|
1039
|
+
const element = parameters.div.querySelector(`[data-annotation-id="${data.id}"]`);
|
1241
1040
|
|
1242
|
-
|
1243
|
-
|
1244
|
-
}
|
1245
|
-
|
1246
|
-
var element = AnnotationElementFactory.create({
|
1247
|
-
data: data,
|
1248
|
-
layer: parameters.div,
|
1249
|
-
page: parameters.page,
|
1250
|
-
viewport: parameters.viewport,
|
1251
|
-
linkService: parameters.linkService,
|
1252
|
-
downloadManager: parameters.downloadManager,
|
1253
|
-
imageResourcesPath: parameters.imageResourcesPath || '',
|
1254
|
-
renderInteractiveForms: parameters.renderInteractiveForms || false,
|
1255
|
-
svgFactory: new _dom_utils.DOMSVGFactory()
|
1256
|
-
});
|
1257
|
-
|
1258
|
-
if (element.isRenderable) {
|
1259
|
-
parameters.div.appendChild(element.render());
|
1260
|
-
}
|
1041
|
+
if (element) {
|
1042
|
+
element.style.transform = `matrix(${parameters.viewport.transform.join(",")})`;
|
1261
1043
|
}
|
1262
1044
|
}
|
1263
|
-
}, {
|
1264
|
-
key: "update",
|
1265
|
-
value: function update(parameters) {
|
1266
|
-
for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
|
1267
|
-
var data = parameters.annotations[i];
|
1268
|
-
var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
|
1269
|
-
|
1270
|
-
if (element) {
|
1271
|
-
element.style.transform = 'matrix(' + parameters.viewport.transform.join(',') + ')';
|
1272
|
-
}
|
1273
|
-
}
|
1274
1045
|
|
1275
|
-
|
1276
|
-
|
1277
|
-
}]);
|
1046
|
+
parameters.div.removeAttribute("hidden");
|
1047
|
+
}
|
1278
1048
|
|
1279
|
-
|
1280
|
-
}();
|
1049
|
+
}
|
1281
1050
|
|
1282
1051
|
exports.AnnotationLayer = AnnotationLayer;
|