UNPKG

3.42 kBJavaScriptView Raw
1/**
2 * @licstart The following is the entire license notice for the
3 * JavaScript code in this page
4 *
5 * Copyright 2022 Mozilla Foundation
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * @licend The above is the entire license notice for the
20 * JavaScript code in this page
21 */
22"use strict";
23
24Object.defineProperty(exports, "__esModule", {
25 value: true
26});
27exports.AnnotationEditorParams = void 0;
28
29var _pdf = require("../pdf");
30
31class AnnotationEditorParams {
32 constructor(options, eventBus) {
33 this.eventBus = eventBus;
34 this.#bindListeners(options);
35 }
36
37 #bindListeners({
38 editorFreeTextFontSize,
39 editorFreeTextColor,
40 editorInkColor,
41 editorInkThickness,
42 editorInkOpacity
43 }) {
44 editorFreeTextFontSize.addEventListener("input", evt => {
45 this.eventBus.dispatch("switchannotationeditorparams", {
46 source: this,
47 type: _pdf.AnnotationEditorParamsType.FREETEXT_SIZE,
48 value: editorFreeTextFontSize.valueAsNumber
49 });
50 });
51 editorFreeTextColor.addEventListener("input", evt => {
52 this.eventBus.dispatch("switchannotationeditorparams", {
53 source: this,
54 type: _pdf.AnnotationEditorParamsType.FREETEXT_COLOR,
55 value: editorFreeTextColor.value
56 });
57 });
58 editorInkColor.addEventListener("input", evt => {
59 this.eventBus.dispatch("switchannotationeditorparams", {
60 source: this,
61 type: _pdf.AnnotationEditorParamsType.INK_COLOR,
62 value: editorInkColor.value
63 });
64 });
65 editorInkThickness.addEventListener("input", evt => {
66 this.eventBus.dispatch("switchannotationeditorparams", {
67 source: this,
68 type: _pdf.AnnotationEditorParamsType.INK_THICKNESS,
69 value: editorInkThickness.valueAsNumber
70 });
71 });
72 editorInkOpacity.addEventListener("input", evt => {
73 this.eventBus.dispatch("switchannotationeditorparams", {
74 source: this,
75 type: _pdf.AnnotationEditorParamsType.INK_OPACITY,
76 value: editorInkOpacity.valueAsNumber
77 });
78 });
79
80 this.eventBus._on("annotationeditorparamschanged", evt => {
81 for (const [type, value] of evt.details) {
82 switch (type) {
83 case _pdf.AnnotationEditorParamsType.FREETEXT_SIZE:
84 editorFreeTextFontSize.value = value;
85 break;
86
87 case _pdf.AnnotationEditorParamsType.FREETEXT_COLOR:
88 editorFreeTextColor.value = value;
89 break;
90
91 case _pdf.AnnotationEditorParamsType.INK_COLOR:
92 editorInkColor.value = value;
93 break;
94
95 case _pdf.AnnotationEditorParamsType.INK_THICKNESS:
96 editorInkThickness.value = value;
97 break;
98
99 case _pdf.AnnotationEditorParamsType.INK_OPACITY:
100 editorInkOpacity.value = value;
101 break;
102 }
103 }
104 });
105 }
106
107}
108
109exports.AnnotationEditorParams = AnnotationEditorParams;
\No newline at end of file