1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | "use strict";
|
23 |
|
24 | Object.defineProperty(exports, "__esModule", {
|
25 | value: true
|
26 | });
|
27 | exports.AnnotationEditorLayerBuilder = void 0;
|
28 |
|
29 | var _pdf = require("../pdf");
|
30 |
|
31 | var _l10n_utils = require("./l10n_utils.js");
|
32 |
|
33 | class AnnotationEditorLayerBuilder {
|
34 | #uiManager;
|
35 |
|
36 | constructor(options) {
|
37 | this.pageDiv = options.pageDiv;
|
38 | this.pdfPage = options.pdfPage;
|
39 | this.annotationStorage = options.annotationStorage || null;
|
40 | this.l10n = options.l10n || _l10n_utils.NullL10n;
|
41 | this.annotationEditorLayer = null;
|
42 | this.div = null;
|
43 | this._cancelled = false;
|
44 | this.#uiManager = options.uiManager;
|
45 | }
|
46 |
|
47 | async render(viewport, intent = "display") {
|
48 | if (intent !== "display") {
|
49 | return;
|
50 | }
|
51 |
|
52 | if (this._cancelled) {
|
53 | return;
|
54 | }
|
55 |
|
56 | const clonedViewport = viewport.clone({
|
57 | dontFlip: true
|
58 | });
|
59 |
|
60 | if (this.div) {
|
61 | this.annotationEditorLayer.update({
|
62 | viewport: clonedViewport
|
63 | });
|
64 | this.show();
|
65 | return;
|
66 | }
|
67 |
|
68 | this.div = document.createElement("div");
|
69 | this.div.className = "annotationEditorLayer";
|
70 | this.div.tabIndex = 0;
|
71 | this.pageDiv.append(this.div);
|
72 | this.annotationEditorLayer = new _pdf.AnnotationEditorLayer({
|
73 | uiManager: this.#uiManager,
|
74 | div: this.div,
|
75 | annotationStorage: this.annotationStorage,
|
76 | pageIndex: this.pdfPage._pageIndex,
|
77 | l10n: this.l10n,
|
78 | viewport: clonedViewport
|
79 | });
|
80 | const parameters = {
|
81 | viewport: clonedViewport,
|
82 | div: this.div,
|
83 | annotations: null,
|
84 | intent
|
85 | };
|
86 | this.annotationEditorLayer.render(parameters);
|
87 | }
|
88 |
|
89 | cancel() {
|
90 | this._cancelled = true;
|
91 | this.destroy();
|
92 | }
|
93 |
|
94 | hide() {
|
95 | if (!this.div) {
|
96 | return;
|
97 | }
|
98 |
|
99 | this.div.hidden = true;
|
100 | }
|
101 |
|
102 | show() {
|
103 | if (!this.div) {
|
104 | return;
|
105 | }
|
106 |
|
107 | this.div.hidden = false;
|
108 | }
|
109 |
|
110 | destroy() {
|
111 | if (!this.div) {
|
112 | return;
|
113 | }
|
114 |
|
115 | this.pageDiv = null;
|
116 | this.annotationEditorLayer.destroy();
|
117 | this.div.remove();
|
118 | }
|
119 |
|
120 | }
|
121 |
|
122 | exports.AnnotationEditorLayerBuilder = AnnotationEditorLayerBuilder; |
\ | No newline at end of file |