@d-i-t-a/reader 2.3.16 → 2.3.18
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 +116 -108
- package/dist/esm/index.js.map +3 -3
- package/dist/injectables/click/click.js +38 -12
- package/dist/injectables/click/click.js.map +3 -3
- package/dist/reader.js +40 -40
- package/dist/reader.js.map +3 -3
- package/package.json +14 -14
package/dist/esm/index.js
CHANGED
|
@@ -345,39 +345,65 @@ var require_implementation = __commonJS({
|
|
|
345
345
|
"use strict";
|
|
346
346
|
init_polyfills();
|
|
347
347
|
var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
|
|
348
|
-
var slice = Array.prototype.slice;
|
|
349
348
|
var toStr = Object.prototype.toString;
|
|
349
|
+
var max = Math.max;
|
|
350
350
|
var funcType = "[object Function]";
|
|
351
|
+
var concatty = function concatty2(a, b) {
|
|
352
|
+
var arr = [];
|
|
353
|
+
for (var i = 0; i < a.length; i += 1) {
|
|
354
|
+
arr[i] = a[i];
|
|
355
|
+
}
|
|
356
|
+
for (var j = 0; j < b.length; j += 1) {
|
|
357
|
+
arr[j + a.length] = b[j];
|
|
358
|
+
}
|
|
359
|
+
return arr;
|
|
360
|
+
};
|
|
361
|
+
var slicy = function slicy2(arrLike, offset) {
|
|
362
|
+
var arr = [];
|
|
363
|
+
for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {
|
|
364
|
+
arr[j] = arrLike[i];
|
|
365
|
+
}
|
|
366
|
+
return arr;
|
|
367
|
+
};
|
|
368
|
+
var joiny = function(arr, joiner) {
|
|
369
|
+
var str = "";
|
|
370
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
371
|
+
str += arr[i];
|
|
372
|
+
if (i + 1 < arr.length) {
|
|
373
|
+
str += joiner;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return str;
|
|
377
|
+
};
|
|
351
378
|
module2.exports = function bind(that) {
|
|
352
379
|
var target = this;
|
|
353
|
-
if (typeof target !== "function" || toStr.
|
|
380
|
+
if (typeof target !== "function" || toStr.apply(target) !== funcType) {
|
|
354
381
|
throw new TypeError(ERROR_MESSAGE + target);
|
|
355
382
|
}
|
|
356
|
-
var args =
|
|
383
|
+
var args = slicy(arguments, 1);
|
|
357
384
|
var bound;
|
|
358
385
|
var binder = function() {
|
|
359
386
|
if (this instanceof bound) {
|
|
360
387
|
var result = target.apply(
|
|
361
388
|
this,
|
|
362
|
-
args
|
|
389
|
+
concatty(args, arguments)
|
|
363
390
|
);
|
|
364
391
|
if (Object(result) === result) {
|
|
365
392
|
return result;
|
|
366
393
|
}
|
|
367
394
|
return this;
|
|
368
|
-
} else {
|
|
369
|
-
return target.apply(
|
|
370
|
-
that,
|
|
371
|
-
args.concat(slice.call(arguments))
|
|
372
|
-
);
|
|
373
395
|
}
|
|
396
|
+
return target.apply(
|
|
397
|
+
that,
|
|
398
|
+
concatty(args, arguments)
|
|
399
|
+
);
|
|
374
400
|
};
|
|
375
|
-
var boundLength =
|
|
401
|
+
var boundLength = max(0, target.length - args.length);
|
|
376
402
|
var boundArgs = [];
|
|
377
403
|
for (var i = 0; i < boundLength; i++) {
|
|
378
|
-
boundArgs
|
|
404
|
+
boundArgs[i] = "$" + i;
|
|
379
405
|
}
|
|
380
|
-
bound = Function("binder", "return function (" + boundArgs
|
|
406
|
+
bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
|
|
381
407
|
if (target.prototype) {
|
|
382
408
|
var Empty = function Empty2() {
|
|
383
409
|
};
|
|
@@ -55193,10 +55219,8 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
55193
55219
|
}
|
|
55194
55220
|
el.addEventListener("mousedown", this.mousedown.bind(this));
|
|
55195
55221
|
el.addEventListener("mouseup", this.mouseup.bind(this));
|
|
55196
|
-
el.addEventListener("mousemove", this.mousemove.bind(this));
|
|
55197
55222
|
el.addEventListener("touchstart", this.mousedown.bind(this));
|
|
55198
55223
|
el.addEventListener("touchend", this.mouseup.bind(this));
|
|
55199
|
-
el.addEventListener("touchmove", this.mousemove.bind(this));
|
|
55200
55224
|
this.hasEventListener = true;
|
|
55201
55225
|
}
|
|
55202
55226
|
async mousedown(ev) {
|
|
@@ -56529,56 +56553,21 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
56529
56553
|
return navigator.userAgent.match(/Android/i) != null;
|
|
56530
56554
|
}
|
|
56531
56555
|
async processMouseEvent(ev) {
|
|
56532
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
56556
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
56533
56557
|
const doc = (_a = this.navigator.iframes[0].contentWindow) == null ? void 0 : _a.document;
|
|
56534
|
-
|
|
56535
|
-
const y = ev.clientY;
|
|
56536
|
-
if (!doc) {
|
|
56558
|
+
if (!doc || !(ev.type === "mouseup" || ev.type === "click" || ev.type === "touchup")) {
|
|
56537
56559
|
return;
|
|
56538
56560
|
}
|
|
56539
56561
|
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
56562
|
return;
|
|
56541
56563
|
}
|
|
56542
|
-
const
|
|
56543
|
-
const
|
|
56544
|
-
|
|
56545
|
-
|
|
56546
|
-
|
|
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;
|
|
56564
|
+
const foundElement = ev.target;
|
|
56565
|
+
const foundHighlight = _highlights.find(
|
|
56566
|
+
(el) => {
|
|
56567
|
+
var _a2;
|
|
56568
|
+
return el.id === ((_a2 = ev.target.parentElement) == null ? void 0 : _a2.id);
|
|
56580
56569
|
}
|
|
56581
|
-
|
|
56570
|
+
);
|
|
56582
56571
|
if (!foundHighlight || !foundElement) {
|
|
56583
56572
|
for (let id2 in HighlightContainer) {
|
|
56584
56573
|
let container = doc.getElementById(id2);
|
|
@@ -56600,47 +56589,7 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
56600
56589
|
return;
|
|
56601
56590
|
}
|
|
56602
56591
|
if (foundElement.getAttribute("data-click")) {
|
|
56603
|
-
if ((ev.type === "
|
|
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") {
|
|
56592
|
+
if ((ev.type === "mouseup" || ev.type === "click" || ev.type === "touchup") && ((_b = foundElement.parentElement) == null ? void 0 : _b.style.display) !== "none") {
|
|
56644
56593
|
const payload = {
|
|
56645
56594
|
highlight: foundHighlight
|
|
56646
56595
|
};
|
|
@@ -56648,16 +56597,16 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
56648
56597
|
let self2 = this;
|
|
56649
56598
|
let anno;
|
|
56650
56599
|
if (self2.navigator.rights.enableAnnotations) {
|
|
56651
|
-
anno = await ((
|
|
56600
|
+
anno = await ((_c = this.navigator.annotationModule) == null ? void 0 : _c.getAnnotation(
|
|
56652
56601
|
payload.highlight
|
|
56653
56602
|
));
|
|
56654
56603
|
} else if (self2.navigator.rights.enableBookmarks) {
|
|
56655
|
-
anno = await ((
|
|
56604
|
+
anno = await ((_d = this.navigator.bookmarkModule) == null ? void 0 : _d.getAnnotation(
|
|
56656
56605
|
payload.highlight
|
|
56657
56606
|
));
|
|
56658
56607
|
}
|
|
56659
56608
|
if (payload.highlight.type === 0 /* Annotation */) {
|
|
56660
|
-
(
|
|
56609
|
+
(_f = (_e = this.navigator.annotationModule) == null ? void 0 : _e.api) == null ? void 0 : _f.selectedAnnotation(anno).then(async () => {
|
|
56661
56610
|
});
|
|
56662
56611
|
}
|
|
56663
56612
|
if (anno == null ? void 0 : anno.id) {
|
|
@@ -56665,7 +56614,7 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
56665
56614
|
self2.lastSelectedHighlight = anno.id;
|
|
56666
56615
|
let toolbox = document.getElementById("highlight-toolbox");
|
|
56667
56616
|
if (toolbox) {
|
|
56668
|
-
toolbox.style.top = ev.clientY + (((
|
|
56617
|
+
toolbox.style.top = ev.clientY + (((_g = this.navigator.attributes) == null ? void 0 : _g.navHeight) ?? 0) + "px";
|
|
56669
56618
|
toolbox.style.left = ev.clientX + "px";
|
|
56670
56619
|
if (getComputedStyle(toolbox).display === "none") {
|
|
56671
56620
|
let noteH = function() {
|
|
@@ -56765,12 +56714,12 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
56765
56714
|
const popup = new Popup(this.navigator);
|
|
56766
56715
|
popup.showPopup(foundElement.dataset.definition, ev);
|
|
56767
56716
|
}
|
|
56768
|
-
let result = (
|
|
56717
|
+
let result = (_j = (_i = (_h = this.navigator.definitionsModule) == null ? void 0 : _h.properties) == null ? void 0 : _i.definitions) == null ? void 0 : _j.filter(
|
|
56769
56718
|
(el) => el.order === Number(foundElement == null ? void 0 : foundElement.dataset.order)
|
|
56770
56719
|
)[0];
|
|
56771
56720
|
import_loglevel5.default.log(result);
|
|
56772
|
-
if ((
|
|
56773
|
-
(
|
|
56721
|
+
if ((_l = (_k = this.navigator.definitionsModule) == null ? void 0 : _k.api) == null ? void 0 : _l.click) {
|
|
56722
|
+
(_m = this.navigator.definitionsModule.api) == null ? void 0 : _m.click(
|
|
56774
56723
|
lodash.omit(result, "callbacks"),
|
|
56775
56724
|
lodash.omit(foundHighlight, "definition")
|
|
56776
56725
|
);
|
|
@@ -56963,6 +56912,50 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
56963
56912
|
highlightParent.style.setProperty("pointer-events", "none");
|
|
56964
56913
|
if (highlight.pointerInteraction) {
|
|
56965
56914
|
highlightParent.setAttribute("data-click", "1");
|
|
56915
|
+
highlightParent.addEventListener("mouseover", (ev) => {
|
|
56916
|
+
var _a2;
|
|
56917
|
+
if (ev.target.classList.contains(
|
|
56918
|
+
"R2_CLASS_HIGHLIGHT_AREA"
|
|
56919
|
+
)) {
|
|
56920
|
+
const foundElement = ev.currentTarget;
|
|
56921
|
+
const foundHighlight = _highlights.find(
|
|
56922
|
+
(el) => el.id === ev.currentTarget.id
|
|
56923
|
+
);
|
|
56924
|
+
if (ev.type === "mouseover" && ((_a2 = foundElement.parentElement) == null ? void 0 : _a2.style.display) !== "none" && foundHighlight) {
|
|
56925
|
+
const foundElementHighlightAreas = Array.from(
|
|
56926
|
+
foundElement.querySelectorAll(`.${CLASS_HIGHLIGHT_AREA}`)
|
|
56927
|
+
);
|
|
56928
|
+
this.setHighlightAreaStyle(
|
|
56929
|
+
doc,
|
|
56930
|
+
foundElementHighlightAreas,
|
|
56931
|
+
foundHighlight
|
|
56932
|
+
);
|
|
56933
|
+
}
|
|
56934
|
+
}
|
|
56935
|
+
});
|
|
56936
|
+
highlightParent.addEventListener("mouseleave", (ev) => {
|
|
56937
|
+
const foundElement = ev.currentTarget;
|
|
56938
|
+
const foundElementHighlightAreas = Array.from(
|
|
56939
|
+
foundElement.querySelectorAll(`.${CLASS_HIGHLIGHT_AREA}`)
|
|
56940
|
+
);
|
|
56941
|
+
for (const highlightArea of foundElementHighlightAreas) {
|
|
56942
|
+
this.resetHighlightAreaStyle(
|
|
56943
|
+
highlightArea,
|
|
56944
|
+
foundElement.id
|
|
56945
|
+
);
|
|
56946
|
+
}
|
|
56947
|
+
const foundElementHighlightBounding = foundElement.querySelector(
|
|
56948
|
+
`.${CLASS_HIGHLIGHT_BOUNDING_AREA}`
|
|
56949
|
+
);
|
|
56950
|
+
const allHighlightBoundings = foundElement.querySelectorAll(
|
|
56951
|
+
`.${CLASS_HIGHLIGHT_BOUNDING_AREA}`
|
|
56952
|
+
);
|
|
56953
|
+
for (const highlightBounding2 of allHighlightBoundings) {
|
|
56954
|
+
if (!foundElementHighlightBounding || highlightBounding2 !== foundElementHighlightBounding) {
|
|
56955
|
+
this.resetHighlightBoundingStyle(highlightBounding2);
|
|
56956
|
+
}
|
|
56957
|
+
}
|
|
56958
|
+
});
|
|
56966
56959
|
}
|
|
56967
56960
|
const paginated = (_a = this.navigator.view) == null ? void 0 : _a.isPaginated();
|
|
56968
56961
|
if (paginated) {
|
|
@@ -57069,7 +57062,12 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
57069
57062
|
);
|
|
57070
57063
|
}
|
|
57071
57064
|
}
|
|
57072
|
-
|
|
57065
|
+
if (highlight.type === 1 /* Search */ || highlight.type === 2 /* ReadAloud */ || highlight.type === 5 /* LineFocus */ || highlight.type === 3 /* PageBreak */) {
|
|
57066
|
+
highlightArea.style.setProperty("pointer-events", "none");
|
|
57067
|
+
} else {
|
|
57068
|
+
highlightArea.style.setProperty("pointer-events", "all");
|
|
57069
|
+
highlightArea.style.setProperty("cursor", "hand");
|
|
57070
|
+
}
|
|
57073
57071
|
highlightArea.style.position = "absolute";
|
|
57074
57072
|
highlightArea.scale = scale;
|
|
57075
57073
|
highlightArea.rect = {
|
|
@@ -57105,7 +57103,12 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
57105
57103
|
"style",
|
|
57106
57104
|
`background-color: rgba(${color.red}, ${color.green}, ${color.blue}, ${DEFAULT_BACKGROUND_COLOR_OPACITY}) !important;`
|
|
57107
57105
|
);
|
|
57108
|
-
|
|
57106
|
+
if (highlight.type === 1 /* Search */ || highlight.type === 2 /* ReadAloud */ || highlight.type === 5 /* LineFocus */ || highlight.type === 3 /* PageBreak */) {
|
|
57107
|
+
highlightAreaLine.style.setProperty("pointer-events", "none");
|
|
57108
|
+
} else {
|
|
57109
|
+
highlightAreaLine.style.setProperty("pointer-events", "all");
|
|
57110
|
+
highlightAreaLine.style.setProperty("cursor", "hand");
|
|
57111
|
+
}
|
|
57109
57112
|
highlightAreaLine.style.position = "absolute";
|
|
57110
57113
|
highlightAreaLine.scale = scale;
|
|
57111
57114
|
highlightAreaLine.rect = {
|
|
@@ -57275,7 +57278,12 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
57275
57278
|
}
|
|
57276
57279
|
}
|
|
57277
57280
|
}
|
|
57278
|
-
|
|
57281
|
+
if (highlight.type === 1 /* Search */ || highlight.type === 2 /* ReadAloud */ || highlight.type === 5 /* LineFocus */ || highlight.type === 3 /* PageBreak */) {
|
|
57282
|
+
highlightAreaIcon.style.setProperty("pointer-events", "none");
|
|
57283
|
+
} else {
|
|
57284
|
+
highlightAreaIcon.style.setProperty("pointer-events", "all");
|
|
57285
|
+
highlightAreaIcon.style.setProperty("cursor", "hand");
|
|
57286
|
+
}
|
|
57279
57287
|
let self2 = this;
|
|
57280
57288
|
if (highlight.type !== 3 /* PageBreak */ && highlight.type !== 4 /* Definition */) {
|
|
57281
57289
|
highlightAreaIcon.addEventListener("click", async function(ev) {
|