@d-i-t-a/reader 2.4.9 → 2.4.10

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
@@ -46466,62 +46466,47 @@ var EventHandler = class {
46466
46466
  );
46467
46467
  return isEpubInternal;
46468
46468
  };
46469
- this.clicks = 0;
46470
- this.clickTimer = 0;
46471
- this.dblClickTimeSpan = 300;
46469
+ this.clickTimeout = null;
46472
46470
  this.handleLinks = async (event) => {
46471
+ var _a;
46473
46472
  import_loglevel.default.log("R2 Click Handler");
46474
- this.clicks++;
46475
- if (this.clicks === 1) {
46476
- this.clickTimer = setTimeout(async () => {
46477
- this.clicks = 0;
46478
- const link = this.checkForLink(event);
46479
- if (link) {
46480
- const isSameOrigin = window.location.protocol === link.protocol && window.location.port === link.port && window.location.hostname === link.hostname;
46481
- const isEpubInternal = this.isReadingOrderInternal(link);
46482
- const isResourceInternal = this.isResourceInternal(link);
46483
- if (!isResourceInternal) {
46484
- await this.popup.hidePopover();
46485
- }
46486
- const isInternal = link.href.indexOf("#");
46487
- if (!isEpubInternal && !isResourceInternal) {
46488
- window.open(link.href, link.target ?? "_blank");
46489
- event.preventDefault();
46490
- event.stopPropagation();
46491
- } else {
46492
- event.target.href = link.href;
46493
- if ((isSameOrigin || isEpubInternal) && isInternal !== -1) {
46494
- const link2 = event.target;
46495
- if (link2) {
46496
- const attribute = link2.getAttribute("epub:type") === "noteref";
46497
- if (attribute) {
46498
- await this.popup.handleFootnote(link2, event);
46499
- } else if (isResourceInternal && !isEpubInternal) {
46500
- await this.popup.showPopover(link2, event);
46501
- } else {
46502
- this.onInternalLink(event);
46503
- }
46504
- } else {
46505
- this.onInternalLink(event);
46506
- }
46507
- } else if ((isSameOrigin || isEpubInternal) && isInternal === -1) {
46473
+ const link = this.checkForLink(event);
46474
+ if (link) {
46475
+ const isSameOrigin = window.location.protocol === link.protocol && window.location.port === link.port && window.location.hostname === link.hostname;
46476
+ const isEpubInternal = this.isReadingOrderInternal(link);
46477
+ const isResourceInternal = this.isResourceInternal(link);
46478
+ if (!isResourceInternal) {
46479
+ await this.popup.hidePopover();
46480
+ }
46481
+ const isInternal = link.href.indexOf("#") !== -1;
46482
+ if (!isEpubInternal && !isResourceInternal) {
46483
+ window.open(link.href, link.target ?? "_blank");
46484
+ event.preventDefault();
46485
+ event.stopPropagation();
46486
+ } else {
46487
+ event.target.href = link.href;
46488
+ if ((isSameOrigin || isEpubInternal) && isInternal) {
46489
+ const linkElement = event.target;
46490
+ if (linkElement) {
46491
+ const attribute = linkElement.getAttribute("epub:type") === "noteref";
46492
+ if (attribute) {
46493
+ await this.popup.handleFootnote(linkElement, event);
46494
+ } else if (isResourceInternal && !isEpubInternal) {
46495
+ await this.popup.showPopover(linkElement, event);
46496
+ } else {
46508
46497
  this.onInternalLink(event);
46509
46498
  }
46499
+ } else {
46500
+ this.onInternalLink(event);
46510
46501
  }
46511
- } else {
46512
- setTimeout(() => {
46513
- var _a;
46514
- console.log("event.detail", event.detail);
46515
- if (!((_a = this.navigator.highlighter) == null ? void 0 : _a.isSelectionMenuOpen) && event.detail === 1) {
46516
- this.onClickThrough(event);
46517
- }
46518
- }, 100);
46502
+ } else if ((isSameOrigin || isEpubInternal) && !isInternal) {
46503
+ this.onInternalLink(event);
46519
46504
  }
46520
- }, this.dblClickTimeSpan);
46521
- }
46522
- if (this.clicks === 2) {
46523
- clearTimeout(this.clickTimer);
46524
- this.clicks = 0;
46505
+ }
46506
+ } else {
46507
+ if (!((_a = this.navigator.highlighter) == null ? void 0 : _a.isSelectionMenuOpen)) {
46508
+ this.onClickThrough(event);
46509
+ }
46525
46510
  }
46526
46511
  };
46527
46512
  this.navigator = navigator2;
@@ -46529,17 +46514,29 @@ var EventHandler = class {
46529
46514
  }
46530
46515
  setupEvents(element) {
46531
46516
  if (element !== null) {
46532
- element.addEventListener(
46533
- "dblclick",
46534
- async (event) => {
46517
+ element.addEventListener("click", async (event) => {
46518
+ const link = this.checkForLink(event);
46519
+ if (link) {
46520
+ await this.handleLinks(event);
46521
+ event.preventDefault();
46522
+ event.stopPropagation();
46523
+ }
46524
+ if (this.clickTimeout !== null) {
46525
+ clearTimeout(this.clickTimeout);
46526
+ this.clickTimeout = null;
46527
+ import_loglevel.default.log("Double Click Detected");
46535
46528
  let htmlElement = event.target;
46536
46529
  if (event.target && htmlElement.tagName.toLowerCase() === "img") {
46537
46530
  await this.popup.showPopover(htmlElement, event);
46538
46531
  }
46539
- },
46540
- true
46541
- );
46542
- element.addEventListener("click", this.handleLinks.bind(this), true);
46532
+ } else {
46533
+ this.clickTimeout = window.setTimeout(async () => {
46534
+ import_loglevel.default.log("Single Click Detected");
46535
+ await this.handleLinks(event);
46536
+ this.clickTimeout = null;
46537
+ }, 200);
46538
+ }
46539
+ });
46543
46540
  } else {
46544
46541
  throw "cannot setup events for null";
46545
46542
  }
@@ -65279,6 +65276,17 @@ var D2Reader = class _D2Reader {
65279
65276
  var _a;
65280
65277
  return await ((_a = this.annotationModule) == null ? void 0 : _a.addAnnotation(highlight)) ?? false;
65281
65278
  };
65279
+ /**
65280
+ * Update annotation
65281
+ *
65282
+ * This should be used only when the add/delete of the annotation note
65283
+ * is not directly handled in the `addAnnotation`/`addCommentToAnnotation`
65284
+ * callback defined in the configuration of the D2Reader.load() method
65285
+ * */
65286
+ this.updateAnnotation = async (highlight) => {
65287
+ var _a;
65288
+ return await ((_a = this.annotationModule) == null ? void 0 : _a.updateAnnotation(highlight)) ?? false;
65289
+ };
65282
65290
  /** Hide Annotation Layer */
65283
65291
  this.hideAnnotationLayer = () => {
65284
65292
  var _a;