@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 +65 -57
- package/dist/esm/index.js.map +3 -3
- package/dist/reader.js +24 -24
- package/dist/reader.js.map +3 -3
- package/dist/types/reader.d.ts +8 -0
- package/dist/types/utils/EventHandler.d.ts +1 -3
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -46466,62 +46466,47 @@ var EventHandler = class {
|
|
|
46466
46466
|
);
|
|
46467
46467
|
return isEpubInternal;
|
|
46468
46468
|
};
|
|
46469
|
-
this.
|
|
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.
|
|
46475
|
-
if (
|
|
46476
|
-
|
|
46477
|
-
|
|
46478
|
-
|
|
46479
|
-
|
|
46480
|
-
|
|
46481
|
-
|
|
46482
|
-
|
|
46483
|
-
|
|
46484
|
-
|
|
46485
|
-
|
|
46486
|
-
|
|
46487
|
-
|
|
46488
|
-
|
|
46489
|
-
|
|
46490
|
-
|
|
46491
|
-
|
|
46492
|
-
|
|
46493
|
-
if (
|
|
46494
|
-
|
|
46495
|
-
|
|
46496
|
-
|
|
46497
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
46521
|
-
}
|
|
46522
|
-
|
|
46523
|
-
|
|
46524
|
-
|
|
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
|
-
|
|
46534
|
-
|
|
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
|
-
|
|
46541
|
-
|
|
46542
|
-
|
|
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;
|