@d-i-t-a/reader 2.3.16 → 2.3.17

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/dist/esm/index.js CHANGED
@@ -55193,10 +55193,8 @@ var TextHighlighter = class _TextHighlighter {
55193
55193
  }
55194
55194
  el.addEventListener("mousedown", this.mousedown.bind(this));
55195
55195
  el.addEventListener("mouseup", this.mouseup.bind(this));
55196
- el.addEventListener("mousemove", this.mousemove.bind(this));
55197
55196
  el.addEventListener("touchstart", this.mousedown.bind(this));
55198
55197
  el.addEventListener("touchend", this.mouseup.bind(this));
55199
- el.addEventListener("touchmove", this.mousemove.bind(this));
55200
55198
  this.hasEventListener = true;
55201
55199
  }
55202
55200
  async mousedown(ev) {
@@ -56529,56 +56527,21 @@ var TextHighlighter = class _TextHighlighter {
56529
56527
  return navigator.userAgent.match(/Android/i) != null;
56530
56528
  }
56531
56529
  async processMouseEvent(ev) {
56532
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
56530
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
56533
56531
  const doc = (_a = this.navigator.iframes[0].contentWindow) == null ? void 0 : _a.document;
56534
- const x = ev.clientX;
56535
- const y = ev.clientY;
56536
- if (!doc) {
56532
+ if (!doc || !(ev.type === "mouseup" || ev.type === "click" || ev.type === "touchup")) {
56537
56533
  return;
56538
56534
  }
56539
56535
  if (!doc.getElementById("R2_ID_HIGHLIGHTS_CONTAINER" /* R2_ID_HIGHLIGHTS_CONTAINER */) && !doc.getElementById("R2_ID_SEARCH_CONTAINER" /* R2_ID_SEARCH_CONTAINER */) && !doc.getElementById("R2_ID_PAGEBREAK_CONTAINER" /* R2_ID_PAGEBREAK_CONTAINER */) && !doc.getElementById("R2_ID_READALOUD_CONTAINER" /* R2_ID_READALOUD_CONTAINER */) && !doc.getElementById("R2_ID_DEFINITIONS_CONTAINER" /* R2_ID_DEFINITIONS_CONTAINER */)) {
56540
56536
  return;
56541
56537
  }
56542
- const paginated = (_b = this.navigator.view) == null ? void 0 : _b.isPaginated();
56543
- const bodyRect = doc.body.getBoundingClientRect();
56544
- const scrollElement = this.getScrollingElement(doc);
56545
- const xOffset = paginated ? -scrollElement.scrollLeft : bodyRect.left;
56546
- const yOffset = paginated ? -scrollElement.scrollTop : bodyRect.top;
56547
- let foundHighlight;
56548
- let foundElement;
56549
- for (let i = _highlights.length - 1; i >= 0; i--) {
56550
- const highlight = _highlights[i];
56551
- let highlightParent = doc.getElementById(`${highlight.id}`);
56552
- if (!highlightParent) {
56553
- let container = doc.getElementById(
56554
- "R2_ID_HIGHLIGHTS_CONTAINER" /* R2_ID_HIGHLIGHTS_CONTAINER */
56555
- );
56556
- if (container) {
56557
- highlightParent = container.querySelector(`#${highlight.id}`);
56558
- }
56559
- }
56560
- if (!highlightParent) {
56561
- continue;
56562
- }
56563
- let hit = false;
56564
- const highlightFragments = highlightParent.querySelectorAll(
56565
- `.${CLASS_HIGHLIGHT_AREA}`
56566
- );
56567
- for (const highlightFragment of highlightFragments) {
56568
- const withRect = highlightFragment;
56569
- const left = withRect.rect.left + xOffset;
56570
- const top = withRect.rect.top + yOffset;
56571
- if (x >= left && x < left + withRect.rect.width && y >= top && y < top + withRect.rect.height) {
56572
- hit = true;
56573
- break;
56574
- }
56575
- }
56576
- if (hit) {
56577
- foundHighlight = highlight;
56578
- foundElement = highlightParent;
56579
- break;
56538
+ const foundElement = ev.target;
56539
+ const foundHighlight = _highlights.find(
56540
+ (el) => {
56541
+ var _a2;
56542
+ return el.id === ((_a2 = ev.target.parentElement) == null ? void 0 : _a2.id);
56580
56543
  }
56581
- }
56544
+ );
56582
56545
  if (!foundHighlight || !foundElement) {
56583
56546
  for (let id2 in HighlightContainer) {
56584
56547
  let container = doc.getElementById(id2);
@@ -56600,47 +56563,7 @@ var TextHighlighter = class _TextHighlighter {
56600
56563
  return;
56601
56564
  }
56602
56565
  if (foundElement.getAttribute("data-click")) {
56603
- if ((ev.type === "mousemove" || ev.type === "touchmove") && ((_c = foundElement.parentElement) == null ? void 0 : _c.style.display) !== "none") {
56604
- const foundElementHighlightAreas = Array.from(
56605
- foundElement.querySelectorAll(`.${CLASS_HIGHLIGHT_AREA}`)
56606
- );
56607
- for (let id2 in HighlightContainer) {
56608
- let container = doc.getElementById(id2);
56609
- if (container) {
56610
- const allHighlightAreas = container.querySelectorAll(
56611
- `.${CLASS_HIGHLIGHT_AREA}`
56612
- );
56613
- for (const highlightArea of allHighlightAreas) {
56614
- if (foundElementHighlightAreas.indexOf(highlightArea) < 0) {
56615
- this.resetHighlightAreaStyle(highlightArea, id2);
56616
- }
56617
- }
56618
- }
56619
- }
56620
- this.setHighlightAreaStyle(
56621
- doc,
56622
- foundElementHighlightAreas,
56623
- foundHighlight
56624
- );
56625
- const foundElementHighlightBounding = foundElement.querySelector(
56626
- `.${CLASS_HIGHLIGHT_BOUNDING_AREA}`
56627
- );
56628
- for (let id2 in HighlightContainer) {
56629
- let container = doc.getElementById(id2);
56630
- if (container) {
56631
- const allHighlightBoundings = container.querySelectorAll(
56632
- `.${CLASS_HIGHLIGHT_BOUNDING_AREA}`
56633
- );
56634
- for (const highlightBounding of allHighlightBoundings) {
56635
- if (!foundElementHighlightBounding || highlightBounding !== foundElementHighlightBounding) {
56636
- this.resetHighlightBoundingStyle(
56637
- highlightBounding
56638
- );
56639
- }
56640
- }
56641
- }
56642
- }
56643
- } else if ((ev.type === "mouseup" || ev.type === "click" || ev.type === "touchup") && ((_d = foundElement.parentElement) == null ? void 0 : _d.style.display) !== "none") {
56566
+ if ((ev.type === "mouseup" || ev.type === "click" || ev.type === "touchup") && ((_b = foundElement.parentElement) == null ? void 0 : _b.style.display) !== "none") {
56644
56567
  const payload = {
56645
56568
  highlight: foundHighlight
56646
56569
  };
@@ -56648,16 +56571,16 @@ var TextHighlighter = class _TextHighlighter {
56648
56571
  let self2 = this;
56649
56572
  let anno;
56650
56573
  if (self2.navigator.rights.enableAnnotations) {
56651
- anno = await ((_e = this.navigator.annotationModule) == null ? void 0 : _e.getAnnotation(
56574
+ anno = await ((_c = this.navigator.annotationModule) == null ? void 0 : _c.getAnnotation(
56652
56575
  payload.highlight
56653
56576
  ));
56654
56577
  } else if (self2.navigator.rights.enableBookmarks) {
56655
- anno = await ((_f = this.navigator.bookmarkModule) == null ? void 0 : _f.getAnnotation(
56578
+ anno = await ((_d = this.navigator.bookmarkModule) == null ? void 0 : _d.getAnnotation(
56656
56579
  payload.highlight
56657
56580
  ));
56658
56581
  }
56659
56582
  if (payload.highlight.type === 0 /* Annotation */) {
56660
- (_h = (_g = this.navigator.annotationModule) == null ? void 0 : _g.api) == null ? void 0 : _h.selectedAnnotation(anno).then(async () => {
56583
+ (_f = (_e = this.navigator.annotationModule) == null ? void 0 : _e.api) == null ? void 0 : _f.selectedAnnotation(anno).then(async () => {
56661
56584
  });
56662
56585
  }
56663
56586
  if (anno == null ? void 0 : anno.id) {
@@ -56665,7 +56588,7 @@ var TextHighlighter = class _TextHighlighter {
56665
56588
  self2.lastSelectedHighlight = anno.id;
56666
56589
  let toolbox = document.getElementById("highlight-toolbox");
56667
56590
  if (toolbox) {
56668
- toolbox.style.top = ev.clientY + (((_i = this.navigator.attributes) == null ? void 0 : _i.navHeight) ?? 0) + "px";
56591
+ toolbox.style.top = ev.clientY + (((_g = this.navigator.attributes) == null ? void 0 : _g.navHeight) ?? 0) + "px";
56669
56592
  toolbox.style.left = ev.clientX + "px";
56670
56593
  if (getComputedStyle(toolbox).display === "none") {
56671
56594
  let noteH = function() {
@@ -56765,12 +56688,12 @@ var TextHighlighter = class _TextHighlighter {
56765
56688
  const popup = new Popup(this.navigator);
56766
56689
  popup.showPopup(foundElement.dataset.definition, ev);
56767
56690
  }
56768
- let result = (_l = (_k = (_j = this.navigator.definitionsModule) == null ? void 0 : _j.properties) == null ? void 0 : _k.definitions) == null ? void 0 : _l.filter(
56691
+ let result = (_j = (_i = (_h = this.navigator.definitionsModule) == null ? void 0 : _h.properties) == null ? void 0 : _i.definitions) == null ? void 0 : _j.filter(
56769
56692
  (el) => el.order === Number(foundElement == null ? void 0 : foundElement.dataset.order)
56770
56693
  )[0];
56771
56694
  import_loglevel5.default.log(result);
56772
- if ((_n = (_m = this.navigator.definitionsModule) == null ? void 0 : _m.api) == null ? void 0 : _n.click) {
56773
- (_o = this.navigator.definitionsModule.api) == null ? void 0 : _o.click(
56695
+ if ((_l = (_k = this.navigator.definitionsModule) == null ? void 0 : _k.api) == null ? void 0 : _l.click) {
56696
+ (_m = this.navigator.definitionsModule.api) == null ? void 0 : _m.click(
56774
56697
  lodash.omit(result, "callbacks"),
56775
56698
  lodash.omit(foundHighlight, "definition")
56776
56699
  );
@@ -56963,6 +56886,50 @@ var TextHighlighter = class _TextHighlighter {
56963
56886
  highlightParent.style.setProperty("pointer-events", "none");
56964
56887
  if (highlight.pointerInteraction) {
56965
56888
  highlightParent.setAttribute("data-click", "1");
56889
+ highlightParent.addEventListener("mouseover", (ev) => {
56890
+ var _a2;
56891
+ if (ev.target.classList.contains(
56892
+ "R2_CLASS_HIGHLIGHT_AREA"
56893
+ )) {
56894
+ const foundElement = ev.currentTarget;
56895
+ const foundHighlight = _highlights.find(
56896
+ (el) => el.id === ev.currentTarget.id
56897
+ );
56898
+ if (ev.type === "mouseover" && ((_a2 = foundElement.parentElement) == null ? void 0 : _a2.style.display) !== "none" && foundHighlight) {
56899
+ const foundElementHighlightAreas = Array.from(
56900
+ foundElement.querySelectorAll(`.${CLASS_HIGHLIGHT_AREA}`)
56901
+ );
56902
+ this.setHighlightAreaStyle(
56903
+ doc,
56904
+ foundElementHighlightAreas,
56905
+ foundHighlight
56906
+ );
56907
+ }
56908
+ }
56909
+ });
56910
+ highlightParent.addEventListener("mouseleave", (ev) => {
56911
+ const foundElement = ev.currentTarget;
56912
+ const foundElementHighlightAreas = Array.from(
56913
+ foundElement.querySelectorAll(`.${CLASS_HIGHLIGHT_AREA}`)
56914
+ );
56915
+ for (const highlightArea of foundElementHighlightAreas) {
56916
+ this.resetHighlightAreaStyle(
56917
+ highlightArea,
56918
+ foundElement.id
56919
+ );
56920
+ }
56921
+ const foundElementHighlightBounding = foundElement.querySelector(
56922
+ `.${CLASS_HIGHLIGHT_BOUNDING_AREA}`
56923
+ );
56924
+ const allHighlightBoundings = foundElement.querySelectorAll(
56925
+ `.${CLASS_HIGHLIGHT_BOUNDING_AREA}`
56926
+ );
56927
+ for (const highlightBounding2 of allHighlightBoundings) {
56928
+ if (!foundElementHighlightBounding || highlightBounding2 !== foundElementHighlightBounding) {
56929
+ this.resetHighlightBoundingStyle(highlightBounding2);
56930
+ }
56931
+ }
56932
+ });
56966
56933
  }
56967
56934
  const paginated = (_a = this.navigator.view) == null ? void 0 : _a.isPaginated();
56968
56935
  if (paginated) {
@@ -57069,7 +57036,12 @@ var TextHighlighter = class _TextHighlighter {
57069
57036
  );
57070
57037
  }
57071
57038
  }
57072
- highlightArea.style.setProperty("pointer-events", "none");
57039
+ if (highlight.type === 1 /* Search */ || highlight.type === 2 /* ReadAloud */ || highlight.type === 5 /* LineFocus */ || highlight.type === 3 /* PageBreak */) {
57040
+ highlightArea.style.setProperty("pointer-events", "none");
57041
+ } else {
57042
+ highlightArea.style.setProperty("pointer-events", "all");
57043
+ highlightArea.style.setProperty("cursor", "hand");
57044
+ }
57073
57045
  highlightArea.style.position = "absolute";
57074
57046
  highlightArea.scale = scale;
57075
57047
  highlightArea.rect = {
@@ -57105,7 +57077,12 @@ var TextHighlighter = class _TextHighlighter {
57105
57077
  "style",
57106
57078
  `background-color: rgba(${color.red}, ${color.green}, ${color.blue}, ${DEFAULT_BACKGROUND_COLOR_OPACITY}) !important;`
57107
57079
  );
57108
- highlightAreaLine.style.setProperty("pointer-events", "none");
57080
+ if (highlight.type === 1 /* Search */ || highlight.type === 2 /* ReadAloud */ || highlight.type === 5 /* LineFocus */ || highlight.type === 3 /* PageBreak */) {
57081
+ highlightAreaLine.style.setProperty("pointer-events", "none");
57082
+ } else {
57083
+ highlightAreaLine.style.setProperty("pointer-events", "all");
57084
+ highlightAreaLine.style.setProperty("cursor", "hand");
57085
+ }
57109
57086
  highlightAreaLine.style.position = "absolute";
57110
57087
  highlightAreaLine.scale = scale;
57111
57088
  highlightAreaLine.rect = {
@@ -57275,7 +57252,12 @@ var TextHighlighter = class _TextHighlighter {
57275
57252
  }
57276
57253
  }
57277
57254
  }
57278
- highlightAreaIcon.style.setProperty("pointer-events", "all");
57255
+ if (highlight.type === 1 /* Search */ || highlight.type === 2 /* ReadAloud */ || highlight.type === 5 /* LineFocus */ || highlight.type === 3 /* PageBreak */) {
57256
+ highlightAreaIcon.style.setProperty("pointer-events", "none");
57257
+ } else {
57258
+ highlightAreaIcon.style.setProperty("pointer-events", "all");
57259
+ highlightAreaIcon.style.setProperty("cursor", "hand");
57260
+ }
57279
57261
  let self2 = this;
57280
57262
  if (highlight.type !== 3 /* PageBreak */ && highlight.type !== 4 /* Definition */) {
57281
57263
  highlightAreaIcon.addEventListener("click", async function(ev) {