annotation_editor_params.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.AnnotationEditorParams = void 0;
  27. var _pdf = require("../pdf");
  28. class AnnotationEditorParams {
  29. constructor(options, eventBus) {
  30. this.eventBus = eventBus;
  31. this.#bindListeners(options);
  32. }
  33. #bindListeners({
  34. editorFreeTextFontSize,
  35. editorFreeTextColor,
  36. editorInkColor,
  37. editorInkThickness,
  38. editorInkOpacity
  39. }) {
  40. editorFreeTextFontSize.addEventListener("input", evt => {
  41. this.eventBus.dispatch("switchannotationeditorparams", {
  42. source: this,
  43. type: _pdf.AnnotationEditorParamsType.FREETEXT_SIZE,
  44. value: editorFreeTextFontSize.valueAsNumber
  45. });
  46. });
  47. editorFreeTextColor.addEventListener("input", evt => {
  48. this.eventBus.dispatch("switchannotationeditorparams", {
  49. source: this,
  50. type: _pdf.AnnotationEditorParamsType.FREETEXT_COLOR,
  51. value: editorFreeTextColor.value
  52. });
  53. });
  54. editorInkColor.addEventListener("input", evt => {
  55. this.eventBus.dispatch("switchannotationeditorparams", {
  56. source: this,
  57. type: _pdf.AnnotationEditorParamsType.INK_COLOR,
  58. value: editorInkColor.value
  59. });
  60. });
  61. editorInkThickness.addEventListener("input", evt => {
  62. this.eventBus.dispatch("switchannotationeditorparams", {
  63. source: this,
  64. type: _pdf.AnnotationEditorParamsType.INK_THICKNESS,
  65. value: editorInkThickness.valueAsNumber
  66. });
  67. });
  68. editorInkOpacity.addEventListener("input", evt => {
  69. this.eventBus.dispatch("switchannotationeditorparams", {
  70. source: this,
  71. type: _pdf.AnnotationEditorParamsType.INK_OPACITY,
  72. value: editorInkOpacity.valueAsNumber
  73. });
  74. });
  75. this.eventBus._on("annotationeditorparamschanged", evt => {
  76. for (const [type, value] of evt.details) {
  77. switch (type) {
  78. case _pdf.AnnotationEditorParamsType.FREETEXT_SIZE:
  79. editorFreeTextFontSize.value = value;
  80. break;
  81. case _pdf.AnnotationEditorParamsType.FREETEXT_COLOR:
  82. editorFreeTextColor.value = value;
  83. break;
  84. case _pdf.AnnotationEditorParamsType.INK_COLOR:
  85. editorInkColor.value = value;
  86. break;
  87. case _pdf.AnnotationEditorParamsType.INK_THICKNESS:
  88. editorInkThickness.value = value;
  89. break;
  90. case _pdf.AnnotationEditorParamsType.INK_OPACITY:
  91. editorInkOpacity.value = value;
  92. break;
  93. }
  94. }
  95. });
  96. }
  97. }
  98. exports.AnnotationEditorParams = AnnotationEditorParams;