@d-i-t-a/reader 2.0.0-beta.21 → 2.0.0-beta.22
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 +47 -43
- package/dist/esm/index.js.map +2 -2
- package/dist/reader.js +34 -34
- package/dist/reader.js.map +2 -2
- package/dist/types/modules/highlight/TextHighlighter.d.ts +7 -4
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -49267,7 +49267,6 @@ var _blacklistIdClassForCssSelectors = [
|
|
|
49267
49267
|
];
|
|
49268
49268
|
var lastMouseDownX = -1;
|
|
49269
49269
|
var lastMouseDownY = -1;
|
|
49270
|
-
var bodyEventListeners = [];
|
|
49271
49270
|
var TextHighlighter = class {
|
|
49272
49271
|
constructor(delegate, layerSettings, properties, hasEventListener, options, api) {
|
|
49273
49272
|
this.lastSelectedHighlight = void 0;
|
|
@@ -49332,7 +49331,6 @@ var TextHighlighter = class {
|
|
|
49332
49331
|
this.initializeToolbox();
|
|
49333
49332
|
lastMouseDownX = -1;
|
|
49334
49333
|
lastMouseDownY = -1;
|
|
49335
|
-
bodyEventListeners = [];
|
|
49336
49334
|
let self2 = this;
|
|
49337
49335
|
async function unselect() {
|
|
49338
49336
|
if (self2.lastSelectedHighlight === void 0) {
|
|
@@ -49559,8 +49557,26 @@ var TextHighlighter = class {
|
|
|
49559
49557
|
if (this.isAndroid()) {
|
|
49560
49558
|
el.addEventListener("contextmenu", this.disableContext);
|
|
49561
49559
|
}
|
|
49560
|
+
el.addEventListener("mousedown", this.mousedown.bind(this));
|
|
49561
|
+
el.addEventListener("mouseup", this.mouseup.bind(this));
|
|
49562
|
+
el.addEventListener("mousemove", this.mousemove.bind(this));
|
|
49563
|
+
el.addEventListener("touchstart", this.mousedown.bind(this));
|
|
49564
|
+
el.addEventListener("touchend", this.mouseup.bind(this));
|
|
49565
|
+
el.addEventListener("touchmove", this.mousemove.bind(this));
|
|
49562
49566
|
this.hasEventListener = true;
|
|
49563
49567
|
}
|
|
49568
|
+
async mousedown(ev) {
|
|
49569
|
+
lastMouseDownX = ev.clientX;
|
|
49570
|
+
lastMouseDownY = ev.clientY;
|
|
49571
|
+
}
|
|
49572
|
+
async mouseup(ev) {
|
|
49573
|
+
if (Math.abs(lastMouseDownX - ev.clientX) < 3 && Math.abs(lastMouseDownY - ev.clientY) < 3) {
|
|
49574
|
+
await this.processMouseEvent(ev);
|
|
49575
|
+
}
|
|
49576
|
+
}
|
|
49577
|
+
async mousemove(ev) {
|
|
49578
|
+
await this.processMouseEvent(ev);
|
|
49579
|
+
}
|
|
49564
49580
|
unbindEvents(el, _scope) {
|
|
49565
49581
|
let doc = el.ownerDocument;
|
|
49566
49582
|
doc.removeEventListener("keyup", this.toolboxShowDelayed.bind(this));
|
|
@@ -49574,6 +49590,12 @@ var TextHighlighter = class {
|
|
|
49574
49590
|
if (this.isAndroid()) {
|
|
49575
49591
|
el.removeEventListener("contextmenu", this.disableContext);
|
|
49576
49592
|
}
|
|
49593
|
+
el.removeEventListener("mousedown", this.mousedown.bind(this));
|
|
49594
|
+
el.removeEventListener("mouseup", this.mouseup.bind(this));
|
|
49595
|
+
el.removeEventListener("mousemove", this.mousemove.bind(this));
|
|
49596
|
+
el.removeEventListener("touchstart", this.mousedown.bind(this));
|
|
49597
|
+
el.removeEventListener("touchend", this.mouseup.bind(this));
|
|
49598
|
+
el.removeEventListener("touchmove", this.mousemove.bind(this));
|
|
49577
49599
|
this.hasEventListener = false;
|
|
49578
49600
|
}
|
|
49579
49601
|
destroy() {
|
|
@@ -50350,12 +50372,12 @@ var TextHighlighter = class {
|
|
|
50350
50372
|
}
|
|
50351
50373
|
throw new Error("Bad Hex");
|
|
50352
50374
|
}
|
|
50353
|
-
resetHighlightBoundingStyle(
|
|
50375
|
+
resetHighlightBoundingStyle(highlightBounding) {
|
|
50354
50376
|
highlightBounding.style.outline = "none";
|
|
50355
50377
|
highlightBounding.style.setProperty("background-color", "transparent", "important");
|
|
50356
50378
|
}
|
|
50357
|
-
resetHighlightAreaStyle(
|
|
50358
|
-
let doc =
|
|
50379
|
+
resetHighlightAreaStyle(highlightArea, id_container) {
|
|
50380
|
+
let doc = this.delegate.iframes[0].contentWindow?.document;
|
|
50359
50381
|
const id2 = highlightArea.parentNode && highlightArea.parentNode.nodeType === Node.ELEMENT_NODE && highlightArea.parentNode.getAttribute ? highlightArea.parentNode.getAttribute("id") : void 0;
|
|
50360
50382
|
if (id2) {
|
|
50361
50383
|
const highlight = _highlights.find((h) => {
|
|
@@ -50420,9 +50442,11 @@ var TextHighlighter = class {
|
|
|
50420
50442
|
}
|
|
50421
50443
|
}
|
|
50422
50444
|
let highlightParent;
|
|
50423
|
-
|
|
50424
|
-
|
|
50425
|
-
|
|
50445
|
+
if (doc) {
|
|
50446
|
+
let container = doc.getElementById(id_container);
|
|
50447
|
+
if (container) {
|
|
50448
|
+
highlightParent = container.querySelector(`#${highlight.id}`);
|
|
50449
|
+
}
|
|
50426
50450
|
}
|
|
50427
50451
|
if (highlightParent) {
|
|
50428
50452
|
let nodeList = highlightParent.getElementsByClassName(CLASS_HIGHLIGHT_ICON);
|
|
@@ -50436,8 +50460,7 @@ var TextHighlighter = class {
|
|
|
50436
50460
|
}
|
|
50437
50461
|
}
|
|
50438
50462
|
}
|
|
50439
|
-
setHighlightAreaStyle(
|
|
50440
|
-
let doc = win.document;
|
|
50463
|
+
setHighlightAreaStyle(doc, highlightAreas, highlight) {
|
|
50441
50464
|
for (const highlightArea of highlightAreas) {
|
|
50442
50465
|
if (highlight.marker === AnnotationMarker.Custom || highlight.marker === AnnotationMarker.Bookmark) {
|
|
50443
50466
|
if (highlight.style?.hover) {
|
|
@@ -50562,10 +50585,13 @@ var TextHighlighter = class {
|
|
|
50562
50585
|
isAndroid() {
|
|
50563
50586
|
return navigator.userAgent.match(/Android/i) != null;
|
|
50564
50587
|
}
|
|
50565
|
-
async processMouseEvent(
|
|
50566
|
-
const doc =
|
|
50588
|
+
async processMouseEvent(ev) {
|
|
50589
|
+
const doc = this.delegate.iframes[0].contentWindow?.document;
|
|
50567
50590
|
const x = ev.clientX;
|
|
50568
50591
|
const y = ev.clientY;
|
|
50592
|
+
if (!doc) {
|
|
50593
|
+
return;
|
|
50594
|
+
}
|
|
50569
50595
|
if (!doc.getElementById(HighlightContainer.R2_ID_HIGHLIGHTS_CONTAINER) && !doc.getElementById(HighlightContainer.R2_ID_SEARCH_CONTAINER) && !doc.getElementById(HighlightContainer.R2_ID_PAGEBREAK_CONTAINER) && !doc.getElementById(HighlightContainer.R2_ID_READALOUD_CONTAINER) && !doc.getElementById(HighlightContainer.R2_ID_DEFINITIONS_CONTAINER)) {
|
|
50570
50596
|
return;
|
|
50571
50597
|
}
|
|
@@ -50581,7 +50607,9 @@ var TextHighlighter = class {
|
|
|
50581
50607
|
let highlightParent = doc.getElementById(`${highlight.id}`);
|
|
50582
50608
|
if (!highlightParent) {
|
|
50583
50609
|
let container = doc.getElementById(HighlightContainer.R2_ID_HIGHLIGHTS_CONTAINER);
|
|
50584
|
-
|
|
50610
|
+
if (container) {
|
|
50611
|
+
highlightParent = container.querySelector(`#${highlight.id}`);
|
|
50612
|
+
}
|
|
50585
50613
|
}
|
|
50586
50614
|
if (!highlightParent) {
|
|
50587
50615
|
continue;
|
|
@@ -50609,11 +50637,11 @@ var TextHighlighter = class {
|
|
|
50609
50637
|
if (container) {
|
|
50610
50638
|
const highlightBoundings = container.querySelectorAll(`.${CLASS_HIGHLIGHT_BOUNDING_AREA}`);
|
|
50611
50639
|
for (const highlightBounding of highlightBoundings) {
|
|
50612
|
-
this.resetHighlightBoundingStyle(
|
|
50640
|
+
this.resetHighlightBoundingStyle(highlightBounding);
|
|
50613
50641
|
}
|
|
50614
50642
|
const allHighlightAreas = Array.from(container.querySelectorAll(`.${CLASS_HIGHLIGHT_AREA}`));
|
|
50615
50643
|
for (const highlightArea of allHighlightAreas) {
|
|
50616
|
-
this.resetHighlightAreaStyle(
|
|
50644
|
+
this.resetHighlightAreaStyle(highlightArea, id2);
|
|
50617
50645
|
}
|
|
50618
50646
|
}
|
|
50619
50647
|
}
|
|
@@ -50628,12 +50656,12 @@ var TextHighlighter = class {
|
|
|
50628
50656
|
const allHighlightAreas = container.querySelectorAll(`.${CLASS_HIGHLIGHT_AREA}`);
|
|
50629
50657
|
for (const highlightArea of allHighlightAreas) {
|
|
50630
50658
|
if (foundElementHighlightAreas.indexOf(highlightArea) < 0) {
|
|
50631
|
-
this.resetHighlightAreaStyle(
|
|
50659
|
+
this.resetHighlightAreaStyle(highlightArea, id2);
|
|
50632
50660
|
}
|
|
50633
50661
|
}
|
|
50634
50662
|
}
|
|
50635
50663
|
}
|
|
50636
|
-
this.setHighlightAreaStyle(
|
|
50664
|
+
this.setHighlightAreaStyle(doc, foundElementHighlightAreas, foundHighlight);
|
|
50637
50665
|
const foundElementHighlightBounding = foundElement.querySelector(`.${CLASS_HIGHLIGHT_BOUNDING_AREA}`);
|
|
50638
50666
|
for (let id2 in HighlightContainer) {
|
|
50639
50667
|
let container = doc.getElementById(id2);
|
|
@@ -50641,7 +50669,7 @@ var TextHighlighter = class {
|
|
|
50641
50669
|
const allHighlightBoundings = container.querySelectorAll(`.${CLASS_HIGHLIGHT_BOUNDING_AREA}`);
|
|
50642
50670
|
for (const highlightBounding of allHighlightBoundings) {
|
|
50643
50671
|
if (!foundElementHighlightBounding || highlightBounding !== foundElementHighlightBounding) {
|
|
50644
|
-
this.resetHighlightBoundingStyle(
|
|
50672
|
+
this.resetHighlightBoundingStyle(highlightBounding);
|
|
50645
50673
|
}
|
|
50646
50674
|
}
|
|
50647
50675
|
}
|
|
@@ -50790,31 +50818,7 @@ var TextHighlighter = class {
|
|
|
50790
50818
|
}
|
|
50791
50819
|
async ensureHighlightsContainer(win, id2) {
|
|
50792
50820
|
const doc = win.document;
|
|
50793
|
-
let self2 = this;
|
|
50794
50821
|
if (!doc.getElementById(id2)) {
|
|
50795
|
-
if (!bodyEventListeners[id2]) {
|
|
50796
|
-
bodyEventListeners[id2] = true;
|
|
50797
|
-
async function mousedown(ev) {
|
|
50798
|
-
lastMouseDownX = ev.clientX;
|
|
50799
|
-
lastMouseDownY = ev.clientY;
|
|
50800
|
-
}
|
|
50801
|
-
async function mouseup(ev) {
|
|
50802
|
-
if (Math.abs(lastMouseDownX - ev.clientX) < 3 && Math.abs(lastMouseDownY - ev.clientY) < 3) {
|
|
50803
|
-
self2.processMouseEvent(win, ev);
|
|
50804
|
-
}
|
|
50805
|
-
}
|
|
50806
|
-
async function mousemove(ev) {
|
|
50807
|
-
self2.processMouseEvent(win, ev);
|
|
50808
|
-
}
|
|
50809
|
-
if (doc.body) {
|
|
50810
|
-
doc.body.addEventListener("mousedown", mousedown, false);
|
|
50811
|
-
doc.body.addEventListener("mouseup", mouseup, false);
|
|
50812
|
-
doc.body.addEventListener("mousemove", mousemove, false);
|
|
50813
|
-
doc.body.addEventListener("touchstart", mousedown, false);
|
|
50814
|
-
doc.body.addEventListener("touchend", mouseup, false);
|
|
50815
|
-
doc.body.addEventListener("touchmove", mousemove, false);
|
|
50816
|
-
}
|
|
50817
|
-
}
|
|
50818
50822
|
let container = doc.createElement("div");
|
|
50819
50823
|
container.setAttribute("id", id2);
|
|
50820
50824
|
container.style.setProperty("pointer-events", "none");
|
|
@@ -51263,7 +51267,7 @@ var TextHighlighter = class {
|
|
|
51263
51267
|
}
|
|
51264
51268
|
}
|
|
51265
51269
|
const foundElementHighlightAreas = Array.from(highlightParent.querySelectorAll(`.${CLASS_HIGHLIGHT_AREA}`));
|
|
51266
|
-
self2.setHighlightAreaStyle(
|
|
51270
|
+
self2.setHighlightAreaStyle(doc, foundElementHighlightAreas, highlight);
|
|
51267
51271
|
});
|
|
51268
51272
|
}
|
|
51269
51273
|
if (highlight.note) {
|