pdfjs-viewer-highlight-echo 5.4.457 → 5.4.462

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.
package/build/pdf.mjs CHANGED
@@ -21,8 +21,8 @@
21
21
  */
22
22
 
23
23
  /**
24
- * pdfjsVersion = 5.4.457
25
- * pdfjsBuild = d53d4404b
24
+ * pdfjsVersion = 5.4.462
25
+ * pdfjsBuild = 34e1cb08c
26
26
  */
27
27
  /******/ // The require scope
28
28
  /******/ var __webpack_require__ = {};
@@ -1988,6 +1988,18 @@ class EditorToolbar {
1988
1988
  }
1989
1989
  this.#buttons.append(button);
1990
1990
  }
1991
+ addSaveButton(saveButton) {
1992
+ if (!saveButton) {
1993
+ return;
1994
+ }
1995
+ saveButton.classList.add("basic", "saveButton");
1996
+ this.#addListenersToElement(saveButton);
1997
+ this.#buttons.append(saveButton);
1998
+ }
1999
+ removeSaveButton() {
2000
+ const saveButton = this.#buttons.querySelector(".saveButton");
2001
+ saveButton?.remove();
2002
+ }
1991
2003
  get #divider() {
1992
2004
  const divider = document.createElement("div");
1993
2005
  divider.className = "divider";
@@ -2067,6 +2079,11 @@ class EditorToolbar {
2067
2079
  this.addComment(tool);
2068
2080
  }
2069
2081
  break;
2082
+ case "save":
2083
+ if (tool) {
2084
+ this.addSaveButton(tool);
2085
+ }
2086
+ break;
2070
2087
  }
2071
2088
  }
2072
2089
  async addButtonBefore(name, tool, beforeSelector) {
@@ -3116,9 +3133,11 @@ class AnnotationEditorUIManager {
3116
3133
  navigator.clipboard.writeText(selectedText).catch(() => {});
3117
3134
  this.#floatingToolbar?.hide();
3118
3135
  }
3119
- saveSelectionAsJson(methodOfCreation = "") {
3136
+ saveSelectionAsJson(methodOfCreation = "", editorInfo = null) {
3120
3137
  this._eventBus.dispatch("saveselectionasjson", {
3121
- source: this
3138
+ source: this,
3139
+ methodOfCreation,
3140
+ editorInfo
3122
3141
  });
3123
3142
  }
3124
3143
  #displayFloatingToolbar() {
@@ -4972,6 +4991,7 @@ class AnnotationEditor {
4972
4991
  #altText = null;
4973
4992
  #comment = null;
4974
4993
  #commentStandaloneButton = null;
4994
+ #saveSelectionButton = null;
4975
4995
  #disabled = false;
4976
4996
  #dragPointerId = null;
4977
4997
  #dragPointerType = "";
@@ -5652,15 +5672,7 @@ class AnnotationEditor {
5652
5672
  const {
5653
5673
  toolbarButtons
5654
5674
  } = this;
5655
- if (toolbarButtons) {
5656
- for (const [name, tool] of toolbarButtons) {
5657
- await this._editToolbar.addButton(name, tool);
5658
- }
5659
- }
5660
- if (!this.hasComment) {
5661
- this._editToolbar.addButton("comment", this.addCommentButton());
5662
- }
5663
- this._editToolbar.addButton("delete");
5675
+ this._editToolbar.addButton("save", this.addSaveSelectionButton());
5664
5676
  return this._editToolbar;
5665
5677
  }
5666
5678
  addCommentButtonInToolbar() {
@@ -5749,6 +5761,62 @@ class AnnotationEditor {
5749
5761
  hideStandaloneCommentButton() {
5750
5762
  this.#commentStandaloneButton?.classList.add("hidden");
5751
5763
  }
5764
+ addSaveSelectionButton() {
5765
+ const button = document.createElement("button");
5766
+ button.className = "saveSelectionButton";
5767
+ button.textContent = "Save";
5768
+ button.title = "Save selection as JSON";
5769
+ button.tabIndex = 0;
5770
+ button.addEventListener("click", event => {
5771
+ event.stopPropagation();
5772
+ const editorRect = this.div.getBoundingClientRect();
5773
+ let selectedText = "";
5774
+ if (this.contentText) {
5775
+ selectedText = this.contentText;
5776
+ } else if (this.contentDiv) {
5777
+ selectedText = this.contentDiv.textContent || "";
5778
+ } else {
5779
+ selectedText = this.div.textContent || "";
5780
+ }
5781
+ const editorInfo = {
5782
+ editorId: this.id,
5783
+ editorType: this.editorType,
5784
+ pageIndex: this.pageIndex,
5785
+ pageNumber: this.pageIndex + 1,
5786
+ parent: this.parent,
5787
+ x: this.x,
5788
+ y: this.y,
5789
+ width: this.width,
5790
+ height: this.height,
5791
+ screenRect: {
5792
+ left: editorRect.left,
5793
+ top: editorRect.top,
5794
+ right: editorRect.right,
5795
+ bottom: editorRect.bottom,
5796
+ width: editorRect.width,
5797
+ height: editorRect.height
5798
+ },
5799
+ textContent: selectedText
5800
+ };
5801
+ this._uiManager.saveSelectionAsJson("editor_save_button", editorInfo);
5802
+ });
5803
+ return button;
5804
+ }
5805
+ addSaveButtonInToolbar() {
5806
+ if (this.#saveSelectionButton) {
5807
+ return;
5808
+ }
5809
+ const button = this.addSaveSelectionButton();
5810
+ this._editToolbar?.addSaveButton(button);
5811
+ this.#saveSelectionButton = button;
5812
+ }
5813
+ removeSaveButtonFromToolbar() {
5814
+ if (!this.#saveSelectionButton) {
5815
+ return;
5816
+ }
5817
+ this._editToolbar?.removeSaveButton();
5818
+ this.#saveSelectionButton = null;
5819
+ }
5752
5820
  get comment() {
5753
5821
  const {
5754
5822
  data: {
@@ -14437,7 +14505,7 @@ function getDocument(src = {}) {
14437
14505
  }
14438
14506
  const docParams = {
14439
14507
  docId,
14440
- apiVersion: "5.4.457",
14508
+ apiVersion: "5.4.462",
14441
14509
  data,
14442
14510
  password,
14443
14511
  disableAutoFetch,
@@ -16102,8 +16170,8 @@ class InternalRenderTask {
16102
16170
  }
16103
16171
  }
16104
16172
  }
16105
- const version = "5.4.457";
16106
- const build = "d53d4404b";
16173
+ const version = "5.4.462";
16174
+ const build = "34e1cb08c";
16107
16175
 
16108
16176
  ;// ./src/display/editor/color_picker.js
16109
16177
 
@@ -21313,6 +21381,9 @@ class HighlightEditor extends AnnotationEditor {
21313
21381
  numberOfColors: data.get("color").size
21314
21382
  };
21315
21383
  }
21384
+ get contentText() {
21385
+ return this.#text;
21386
+ }
21316
21387
  #createOutlines() {
21317
21388
  const outliner = new HighlightOutliner(this.#boxes, 0.001);
21318
21389
  this.#highlightOutlines = outliner.getOutlines();