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