PageSourceSearch

https://paie.ca/viewer/web/annotation_editor_params.js

js paie.ca collected 2026-09-29 23:18:36 UTC 2,834 bytes, 84 lines download raw bytes

1/* Copyright 2022 Mozilla Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AnnotationEditorParamsType } from "pdfjs-lib";
17
18class AnnotationEditorParams {
19  /**
20   * @param {AnnotationEditorParamsOptions} options
21   * @param {EventBus} eventBus
22   */
23  constructor(options, eventBus) {
24    this.eventBus = eventBus;
25    this.#bindListeners(options);
26  }
27
28  #bindListeners({
29    editorFreeTextFontSize,
30    editorFreeTextColor,
31    editorInkColor,
32    editorInkThickness,
33  }) {
34    editorFreeTextFontSize.addEventListener("input", evt => {
35      this.eventBus.dispatch("switchannotationeditorparams", {
36        source: this,
37        type: AnnotationEditorParamsType.FREETEXT_SIZE,
38        value: editorFreeTextFontSize.valueAsNumber,
39      });
40    });
41    editorFreeTextColor.addEventListener("input", evt => {
42      this.eventBus.dispatch("switchannotationeditorparams", {
43        source: this,
44        type: AnnotationEditorParamsType.FREETEXT_COLOR,
45        value: editorFreeTextColor.value,
46      });
47    });
48    editorInkColor.addEventListener("input", evt => {
49      this.eventBus.dispatch("switchannotationeditorparams", {
50        source: this,
51        type: AnnotationEditorParamsType.INK_COLOR,
52        value: editorInkColor.value,
53      });
54    });
55    editorInkThickness.addEventListener("input", evt => {
56      this.eventBus.dispatch("switchannotationeditorparams", {
57        source: this,
58        type: AnnotationEditorParamsType.INK_THICKNESS,
59        value: editorInkThickness.valueAsNumber,
60      });
61    });
62
63    this.eventBus._on("annotationeditorparamschanged", evt => {
64      for (const [type, value] of evt.details) {
65        switch (type) {
66          case AnnotationEditorParamsType.FREETEXT_SIZE:
67            editorFreeTextFontSize.value = value;
68            break;
69          case AnnotationEditorParamsType.FREETEXT_COLOR:
70            editorFreeTextColor.value = value;
71            break;
72          case AnnotationEditorParamsType.INK_COLOR:
73            editorInkColor.value = value;
74            break;
75          case AnnotationEditorParamsType.INK_THICKNESS:
76            editorInkThickness.value = value;
77            break;
78        }
79      }
80    });
81  }
82}
83
84export { AnnotationEditorParams };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.