@d-i-t-a/reader 2.4.8 → 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,6 +46466,7 @@ var EventHandler = class {
46466
46466
  );
46467
46467
  return isEpubInternal;
46468
46468
  };
46469
+ this.clickTimeout = null;
46469
46470
  this.handleLinks = async (event) => {
46470
46471
  var _a;
46471
46472
  import_loglevel.default.log("R2 Click Handler");
@@ -46477,28 +46478,28 @@ var EventHandler = class {
46477
46478
  if (!isResourceInternal) {
46478
46479
  await this.popup.hidePopover();
46479
46480
  }
46480
- const isInternal = link.href.indexOf("#");
46481
+ const isInternal = link.href.indexOf("#") !== -1;
46481
46482
  if (!isEpubInternal && !isResourceInternal) {
46482
46483
  window.open(link.href, link.target ?? "_blank");
46483
46484
  event.preventDefault();
46484
46485
  event.stopPropagation();
46485
46486
  } else {
46486
46487
  event.target.href = link.href;
46487
- if ((isSameOrigin || isEpubInternal) && isInternal !== -1) {
46488
- const link2 = event.target;
46489
- if (link2) {
46490
- const attribute = link2.getAttribute("epub:type") === "noteref";
46488
+ if ((isSameOrigin || isEpubInternal) && isInternal) {
46489
+ const linkElement = event.target;
46490
+ if (linkElement) {
46491
+ const attribute = linkElement.getAttribute("epub:type") === "noteref";
46491
46492
  if (attribute) {
46492
- await this.popup.handleFootnote(link2, event);
46493
+ await this.popup.handleFootnote(linkElement, event);
46493
46494
  } else if (isResourceInternal && !isEpubInternal) {
46494
- await this.popup.showPopover(link2, event);
46495
+ await this.popup.showPopover(linkElement, event);
46495
46496
  } else {
46496
46497
  this.onInternalLink(event);
46497
46498
  }
46498
46499
  } else {
46499
46500
  this.onInternalLink(event);
46500
46501
  }
46501
- } else if ((isSameOrigin || isEpubInternal) && isInternal === -1) {
46502
+ } else if ((isSameOrigin || isEpubInternal) && !isInternal) {
46502
46503
  this.onInternalLink(event);
46503
46504
  }
46504
46505
  }
@@ -46513,17 +46514,29 @@ var EventHandler = class {
46513
46514
  }
46514
46515
  setupEvents(element) {
46515
46516
  if (element !== null) {
46516
- element.addEventListener(
46517
- "dblclick",
46518
- 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");
46519
46528
  let htmlElement = event.target;
46520
46529
  if (event.target && htmlElement.tagName.toLowerCase() === "img") {
46521
46530
  await this.popup.showPopover(htmlElement, event);
46522
46531
  }
46523
- },
46524
- true
46525
- );
46526
- 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
+ });
46527
46540
  } else {
46528
46541
  throw "cannot setup events for null";
46529
46542
  }
@@ -50318,6 +50331,7 @@ var TextHighlighter = class _TextHighlighter {
50318
50331
  );
50319
50332
  switch (mode) {
50320
50333
  case "colors":
50334
+ this.selectionMenuOpened();
50321
50335
  if (toolboxColorsOptions)
50322
50336
  toolboxColorsOptions.style.display = "unset";
50323
50337
  if (toolboxAddOptions)
@@ -50328,6 +50342,7 @@ var TextHighlighter = class _TextHighlighter {
50328
50342
  toolboxMarkOptions.style.display = "none";
50329
50343
  break;
50330
50344
  case "edit":
50345
+ this.selectionMenuOpened();
50331
50346
  if (toolboxColorsOptions)
50332
50347
  toolboxColorsOptions.style.display = "none";
50333
50348
  if (toolboxAddOptions)
@@ -50338,6 +50353,7 @@ var TextHighlighter = class _TextHighlighter {
50338
50353
  toolboxMarkOptions.style.display = "none";
50339
50354
  break;
50340
50355
  case "action":
50356
+ this.selectionMenuOpened();
50341
50357
  if (toolboxColorsOptions)
50342
50358
  toolboxColorsOptions.style.display = "none";
50343
50359
  if (toolboxAddOptions)
@@ -50348,6 +50364,7 @@ var TextHighlighter = class _TextHighlighter {
50348
50364
  toolboxMarkOptions.style.display = "unset";
50349
50365
  break;
50350
50366
  default:
50367
+ this.selectionMenuOpened();
50351
50368
  if (toolboxColorsOptions)
50352
50369
  toolboxColorsOptions.style.display = "none";
50353
50370
  if (toolboxAddOptions)
@@ -65259,6 +65276,17 @@ var D2Reader = class _D2Reader {
65259
65276
  var _a;
65260
65277
  return await ((_a = this.annotationModule) == null ? void 0 : _a.addAnnotation(highlight)) ?? false;
65261
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
+ };
65262
65290
  /** Hide Annotation Layer */
65263
65291
  this.hideAnnotationLayer = () => {
65264
65292
  var _a;