@d-i-t-a/reader 2.0.3 → 2.0.4
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 +38 -164
- package/dist/esm/index.js.map +2 -2
- package/dist/reader.js +13 -13
- package/dist/reader.js.map +2 -2
- package/dist/types/navigator/IFrameNavigator.d.ts +1 -8
- package/dist/types/utils/KeyboardEventHandler.d.ts +2 -1
- package/dist/types/utils/TouchEventHandler.d.ts +3 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -47367,7 +47367,6 @@ var TextHighlighter = class {
|
|
|
47367
47367
|
}
|
|
47368
47368
|
bindEvents(el, _scope, hasEventListener) {
|
|
47369
47369
|
let doc = el.ownerDocument;
|
|
47370
|
-
doc.addEventListener("keyup", this.toolboxShowDelayed.bind(this));
|
|
47371
47370
|
el.addEventListener("mouseup", this.toolboxShowDelayed.bind(this));
|
|
47372
47371
|
el.addEventListener("touchend", this.toolboxShowDelayed.bind(this));
|
|
47373
47372
|
doc.addEventListener("selectstart", this.toolboxShowDelayed.bind(this));
|
|
@@ -47402,7 +47401,6 @@ var TextHighlighter = class {
|
|
|
47402
47401
|
}
|
|
47403
47402
|
unbindEvents(el, _scope) {
|
|
47404
47403
|
let doc = el.ownerDocument;
|
|
47405
|
-
doc.removeEventListener("keyup", this.toolboxShowDelayed.bind(this));
|
|
47406
47404
|
el.removeEventListener("mouseup", this.toolboxShowDelayed.bind(this));
|
|
47407
47405
|
el.removeEventListener("touchend", this.toolboxShowDelayed.bind(this));
|
|
47408
47406
|
doc.removeEventListener("selectstart", this.toolboxShowDelayed.bind(this));
|
|
@@ -52943,7 +52941,7 @@ var import_debounce5 = __toModule(require_debounce());
|
|
|
52943
52941
|
// src/utils/TouchEventHandler.ts
|
|
52944
52942
|
init_polyfills();
|
|
52945
52943
|
var _TouchEventHandler = class {
|
|
52946
|
-
constructor() {
|
|
52944
|
+
constructor(navigator2) {
|
|
52947
52945
|
this.onBackwardSwipe = () => {
|
|
52948
52946
|
};
|
|
52949
52947
|
this.onForwardSwipe = () => {
|
|
@@ -53008,6 +53006,7 @@ var _TouchEventHandler = class {
|
|
|
53008
53006
|
}, false);
|
|
53009
53007
|
}
|
|
53010
53008
|
};
|
|
53009
|
+
this.navigator = navigator2;
|
|
53011
53010
|
}
|
|
53012
53011
|
};
|
|
53013
53012
|
var TouchEventHandler = _TouchEventHandler;
|
|
@@ -53018,7 +53017,7 @@ TouchEventHandler.SLOW_SWIPE_MS = 500;
|
|
|
53018
53017
|
// src/utils/KeyboardEventHandler.ts
|
|
53019
53018
|
init_polyfills();
|
|
53020
53019
|
var KeyboardEventHandler = class {
|
|
53021
|
-
constructor() {
|
|
53020
|
+
constructor(navigator2) {
|
|
53022
53021
|
this.onBackwardSwipe = () => {
|
|
53023
53022
|
};
|
|
53024
53023
|
this.onForwardSwipe = () => {
|
|
@@ -53032,33 +53031,36 @@ var KeyboardEventHandler = class {
|
|
|
53032
53031
|
this.focusin = (element) => {
|
|
53033
53032
|
const self2 = this;
|
|
53034
53033
|
element.addEventListener("focusin", function(event) {
|
|
53035
|
-
self2.
|
|
53034
|
+
self2.navigator.view?.snap(event.target);
|
|
53036
53035
|
}, true);
|
|
53037
53036
|
};
|
|
53038
53037
|
this.keydown = (element) => {
|
|
53039
53038
|
const self2 = this;
|
|
53040
|
-
|
|
53041
|
-
|
|
53042
|
-
|
|
53043
|
-
|
|
53044
|
-
|
|
53045
|
-
|
|
53046
|
-
|
|
53047
|
-
|
|
53048
|
-
|
|
53049
|
-
|
|
53050
|
-
|
|
53051
|
-
|
|
53052
|
-
|
|
53053
|
-
|
|
53054
|
-
|
|
53055
|
-
|
|
53056
|
-
|
|
53057
|
-
|
|
53058
|
-
|
|
53059
|
-
|
|
53060
|
-
|
|
53039
|
+
if (!this.navigator.rights.customKeyboardEvents) {
|
|
53040
|
+
element.addEventListener("keydown", function(event) {
|
|
53041
|
+
const eventTarget = event.target;
|
|
53042
|
+
if (/input|select|option|textarea/i.test(eventTarget.tagName)) {
|
|
53043
|
+
return;
|
|
53044
|
+
}
|
|
53045
|
+
const ownerDocument = eventTarget.ownerDocument || eventTarget;
|
|
53046
|
+
const ownerWindow = ownerDocument.defaultView;
|
|
53047
|
+
const selection = ownerWindow.getSelection();
|
|
53048
|
+
if (!selection.isCollapsed) {
|
|
53049
|
+
return;
|
|
53050
|
+
}
|
|
53051
|
+
const key = event.key;
|
|
53052
|
+
switch (key) {
|
|
53053
|
+
case "ArrowRight":
|
|
53054
|
+
self2.onForwardSwipe(event);
|
|
53055
|
+
break;
|
|
53056
|
+
case "ArrowLeft":
|
|
53057
|
+
self2.onBackwardSwipe(event);
|
|
53058
|
+
break;
|
|
53059
|
+
}
|
|
53060
|
+
}, false);
|
|
53061
|
+
}
|
|
53061
53062
|
};
|
|
53063
|
+
this.navigator = navigator2;
|
|
53062
53064
|
}
|
|
53063
53065
|
};
|
|
53064
53066
|
|
|
@@ -53191,7 +53193,8 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
53191
53193
|
enablePageBreaks: false,
|
|
53192
53194
|
enableSearch: false,
|
|
53193
53195
|
enableTTS: false,
|
|
53194
|
-
enableTimeline: false
|
|
53196
|
+
enableTimeline: false,
|
|
53197
|
+
customKeyboardEvents: false
|
|
53195
53198
|
};
|
|
53196
53199
|
this.didInitKeyboardEventHandler = false;
|
|
53197
53200
|
this.onResize = () => {
|
|
@@ -53239,8 +53242,8 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
53239
53242
|
this.view.attributes = attributes;
|
|
53240
53243
|
this.view.delegate = this;
|
|
53241
53244
|
this.eventHandler = new EventHandler(this);
|
|
53242
|
-
this.touchEventHandler = new TouchEventHandler();
|
|
53243
|
-
this.keyboardEventHandler = new KeyboardEventHandler();
|
|
53245
|
+
this.touchEventHandler = new TouchEventHandler(this);
|
|
53246
|
+
this.keyboardEventHandler = new KeyboardEventHandler(this);
|
|
53244
53247
|
this.upLinkConfig = upLinkConfig;
|
|
53245
53248
|
this.initialLastReadingPosition = initialLastReadingPosition;
|
|
53246
53249
|
this.publication = publication;
|
|
@@ -53258,7 +53261,8 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
53258
53261
|
enablePageBreaks: false,
|
|
53259
53262
|
enableSearch: false,
|
|
53260
53263
|
enableTTS: false,
|
|
53261
|
-
enableTimeline: false
|
|
53264
|
+
enableTimeline: false,
|
|
53265
|
+
customKeyboardEvents: false
|
|
53262
53266
|
};
|
|
53263
53267
|
this.tts = tts;
|
|
53264
53268
|
this.injectables = injectables;
|
|
@@ -53284,7 +53288,6 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
53284
53288
|
removeEventListenerOptional(this.nextPageAnchorElement, "click", this.handleNextPageClick.bind(this));
|
|
53285
53289
|
removeEventListenerOptional(this.tryAgainButton, "click", this.tryAgain.bind(this));
|
|
53286
53290
|
removeEventListenerOptional(this.goBackButton, "click", IFrameNavigator.goBack.bind(this));
|
|
53287
|
-
removeEventListenerOptional(this.bookmarksControl, "keydown", this.hideBookmarksOnEscape.bind(this));
|
|
53288
53291
|
removeEventListenerOptional(this.espandMenuIcon, "click", this.handleEditClick.bind(this));
|
|
53289
53292
|
removeEventListenerOptional(window, "resize", this.onResize);
|
|
53290
53293
|
this.iframes.forEach((iframe) => {
|
|
@@ -53557,38 +53560,12 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
53557
53560
|
addEventListenerOptional(this.nextPageAnchorElement, "click", this.handleNextPageClick.bind(this));
|
|
53558
53561
|
addEventListenerOptional(this.tryAgainButton, "click", this.tryAgain.bind(this));
|
|
53559
53562
|
addEventListenerOptional(this.goBackButton, "click", IFrameNavigator.goBack.bind(this));
|
|
53560
|
-
addEventListenerOptional(this.bookmarksControl, "keydown", this.hideBookmarksOnEscape.bind(this));
|
|
53561
53563
|
addEventListenerOptional(this.espandMenuIcon, "click", this.handleEditClick.bind(this));
|
|
53562
53564
|
addEventListenerOptional(window, "resize", this.onResize);
|
|
53563
53565
|
for (const iframe of this.iframes) {
|
|
53564
53566
|
addEventListenerOptional(iframe, "resize", this.onResize);
|
|
53565
53567
|
}
|
|
53566
53568
|
}
|
|
53567
|
-
setupModalFocusTrap(modal, closeButton, lastFocusableElement) {
|
|
53568
|
-
const TAB_KEY = 9;
|
|
53569
|
-
closeButton.addEventListener("keydown", (event) => {
|
|
53570
|
-
if (IFrameNavigator.isDisplayed(modal)) {
|
|
53571
|
-
const tab = event.keyCode === TAB_KEY;
|
|
53572
|
-
const shift = event.shiftKey;
|
|
53573
|
-
if (tab && shift) {
|
|
53574
|
-
lastFocusableElement.focus();
|
|
53575
|
-
event.preventDefault();
|
|
53576
|
-
event.stopPropagation();
|
|
53577
|
-
}
|
|
53578
|
-
}
|
|
53579
|
-
});
|
|
53580
|
-
lastFocusableElement.addEventListener("keydown", (event) => {
|
|
53581
|
-
if (IFrameNavigator.isDisplayed(modal)) {
|
|
53582
|
-
const tab = event.keyCode === TAB_KEY;
|
|
53583
|
-
const shift = event.shiftKey;
|
|
53584
|
-
if (tab && !shift) {
|
|
53585
|
-
closeButton.focus();
|
|
53586
|
-
event.preventDefault();
|
|
53587
|
-
event.stopPropagation();
|
|
53588
|
-
}
|
|
53589
|
-
}
|
|
53590
|
-
});
|
|
53591
|
-
}
|
|
53592
53569
|
updateBookView() {
|
|
53593
53570
|
if (this.view?.layout === "fixed") {
|
|
53594
53571
|
if (this.nextPageAnchorElement)
|
|
@@ -53765,21 +53742,12 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
53765
53742
|
}
|
|
53766
53743
|
async loadManifest() {
|
|
53767
53744
|
try {
|
|
53768
|
-
const createSubmenu = (parentElement, links,
|
|
53769
|
-
let menuControl;
|
|
53770
|
-
let mainElement;
|
|
53771
|
-
if (control) {
|
|
53772
|
-
menuControl = control;
|
|
53773
|
-
if (parentElement instanceof HTMLDivElement) {
|
|
53774
|
-
mainElement = parentElement;
|
|
53775
|
-
}
|
|
53776
|
-
}
|
|
53745
|
+
const createSubmenu = (parentElement, links, ol = false) => {
|
|
53777
53746
|
var listElement = document.createElement("ul");
|
|
53778
53747
|
if (ol) {
|
|
53779
53748
|
listElement = document.createElement("ol");
|
|
53780
53749
|
}
|
|
53781
53750
|
listElement.className = "sidenav-toc";
|
|
53782
|
-
let lastLink = void 0;
|
|
53783
53751
|
for (const link of links) {
|
|
53784
53752
|
const listItemElement = document.createElement("li");
|
|
53785
53753
|
const linkElement = document.createElement("a");
|
|
@@ -53798,13 +53766,9 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
53798
53766
|
listItemElement.appendChild(spanElement);
|
|
53799
53767
|
}
|
|
53800
53768
|
if (link.Children && link.Children.length > 0) {
|
|
53801
|
-
createSubmenu(listItemElement, link.Children,
|
|
53769
|
+
createSubmenu(listItemElement, link.Children, true);
|
|
53802
53770
|
}
|
|
53803
53771
|
listElement.appendChild(listItemElement);
|
|
53804
|
-
lastLink = linkElement;
|
|
53805
|
-
}
|
|
53806
|
-
if (lastLink && menuControl && mainElement) {
|
|
53807
|
-
this.setupModalFocusTrap(mainElement, menuControl, lastLink);
|
|
53808
53772
|
}
|
|
53809
53773
|
addEventListenerOptional(listElement, "click", (event) => {
|
|
53810
53774
|
event.preventDefault();
|
|
@@ -53814,7 +53778,6 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
53814
53778
|
if (linkElement.className.indexOf("active") !== -1) {
|
|
53815
53779
|
this.hideView();
|
|
53816
53780
|
} else {
|
|
53817
|
-
menuControl?.focus();
|
|
53818
53781
|
let locations = {
|
|
53819
53782
|
progression: 0
|
|
53820
53783
|
};
|
|
@@ -54028,7 +53991,6 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
54028
53991
|
}
|
|
54029
53992
|
this.touchEventHandler.setupEvents(this.errorMessage);
|
|
54030
53993
|
if (!this.didInitKeyboardEventHandler) {
|
|
54031
|
-
this.keyboardEventHandler.delegate = this;
|
|
54032
53994
|
this.keyboardEventHandler.keydown(document);
|
|
54033
53995
|
this.didInitKeyboardEventHandler = true;
|
|
54034
53996
|
}
|
|
@@ -54505,89 +54467,6 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
54505
54467
|
static goBack() {
|
|
54506
54468
|
window.history.back();
|
|
54507
54469
|
}
|
|
54508
|
-
static isDisplayed(element) {
|
|
54509
|
-
return element ? element.className.indexOf(" active") !== -1 : false;
|
|
54510
|
-
}
|
|
54511
|
-
static showElement(element, control) {
|
|
54512
|
-
if (element) {
|
|
54513
|
-
element.className = element.className.replace(" inactive", "");
|
|
54514
|
-
if (element.className.indexOf(" active") === -1) {
|
|
54515
|
-
element.className += " active";
|
|
54516
|
-
}
|
|
54517
|
-
element.setAttribute("aria-hidden", "false");
|
|
54518
|
-
if (control) {
|
|
54519
|
-
control.setAttribute("aria-expanded", "true");
|
|
54520
|
-
const openIcon = control.querySelector(".icon.open");
|
|
54521
|
-
if (openIcon && (openIcon.getAttribute("class") || "").indexOf(" inactive-icon") === -1) {
|
|
54522
|
-
const newIconClass = (openIcon.getAttribute("class") || "") + " inactive-icon";
|
|
54523
|
-
openIcon.setAttribute("class", newIconClass);
|
|
54524
|
-
}
|
|
54525
|
-
const closeIcon = control.querySelector(".icon.close");
|
|
54526
|
-
if (closeIcon) {
|
|
54527
|
-
const newIconClass = (closeIcon.getAttribute("class") || "").replace(" inactive-icon", "");
|
|
54528
|
-
closeIcon.setAttribute("class", newIconClass);
|
|
54529
|
-
}
|
|
54530
|
-
}
|
|
54531
|
-
const buttons = Array.prototype.slice.call(element.querySelectorAll("button"));
|
|
54532
|
-
const links = Array.prototype.slice.call(element.querySelectorAll("a"));
|
|
54533
|
-
for (const button of buttons) {
|
|
54534
|
-
button.tabIndex = 0;
|
|
54535
|
-
}
|
|
54536
|
-
for (const link of links) {
|
|
54537
|
-
link.tabIndex = 0;
|
|
54538
|
-
}
|
|
54539
|
-
}
|
|
54540
|
-
}
|
|
54541
|
-
static hideElement(element, control) {
|
|
54542
|
-
if (element) {
|
|
54543
|
-
element.className = element.className.replace(" active", "");
|
|
54544
|
-
if (element.className.indexOf(" inactive") === -1) {
|
|
54545
|
-
element.className += " inactive";
|
|
54546
|
-
}
|
|
54547
|
-
element.setAttribute("aria-hidden", "true");
|
|
54548
|
-
if (control) {
|
|
54549
|
-
control.setAttribute("aria-expanded", "false");
|
|
54550
|
-
const openIcon = control.querySelector(".icon.open");
|
|
54551
|
-
if (openIcon) {
|
|
54552
|
-
const newIconClass = (openIcon.getAttribute("class") || "").replace(" inactive-icon", "");
|
|
54553
|
-
openIcon.setAttribute("class", newIconClass);
|
|
54554
|
-
}
|
|
54555
|
-
const closeIcon = control.querySelector(".icon.close");
|
|
54556
|
-
if (closeIcon && (closeIcon.getAttribute("class") || "").indexOf(" inactive-icon") === -1) {
|
|
54557
|
-
const newIconClass = (closeIcon.getAttribute("class") || "") + " inactive-icon";
|
|
54558
|
-
closeIcon.setAttribute("class", newIconClass);
|
|
54559
|
-
}
|
|
54560
|
-
}
|
|
54561
|
-
const buttons = Array.prototype.slice.call(element.querySelectorAll("button"));
|
|
54562
|
-
const links = Array.prototype.slice.call(element.querySelectorAll("a"));
|
|
54563
|
-
for (const button of buttons) {
|
|
54564
|
-
button.tabIndex = -1;
|
|
54565
|
-
}
|
|
54566
|
-
for (const link of links) {
|
|
54567
|
-
link.tabIndex = -1;
|
|
54568
|
-
}
|
|
54569
|
-
}
|
|
54570
|
-
}
|
|
54571
|
-
hideModal(modal, control) {
|
|
54572
|
-
for (const iframe of this.iframes) {
|
|
54573
|
-
iframe.setAttribute("aria-hidden", "false");
|
|
54574
|
-
}
|
|
54575
|
-
if (this.upLink)
|
|
54576
|
-
this.upLink.setAttribute("aria-hidden", "false");
|
|
54577
|
-
if (this.linksBottom)
|
|
54578
|
-
this.linksBottom.setAttribute("aria-hidden", "false");
|
|
54579
|
-
if (this.linksMiddle)
|
|
54580
|
-
this.linksMiddle.setAttribute("aria-hidden", "false");
|
|
54581
|
-
if (this.loadingMessage)
|
|
54582
|
-
this.loadingMessage.setAttribute("aria-hidden", "false");
|
|
54583
|
-
if (this.errorMessage)
|
|
54584
|
-
this.errorMessage.setAttribute("aria-hidden", "false");
|
|
54585
|
-
if (this.infoTop)
|
|
54586
|
-
this.infoTop.setAttribute("aria-hidden", "false");
|
|
54587
|
-
if (this.infoBottom)
|
|
54588
|
-
this.infoBottom.setAttribute("aria-hidden", "false");
|
|
54589
|
-
IFrameNavigator.hideElement(modal, control);
|
|
54590
|
-
}
|
|
54591
54470
|
handleEditClick(event) {
|
|
54592
54471
|
var element = event.target;
|
|
54593
54472
|
if (this.headerMenu) {
|
|
@@ -55127,12 +55006,6 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
55127
55006
|
event.stopPropagation();
|
|
55128
55007
|
}
|
|
55129
55008
|
}
|
|
55130
|
-
hideBookmarksOnEscape(event) {
|
|
55131
|
-
const ESCAPE_KEY = 27;
|
|
55132
|
-
if (IFrameNavigator.isDisplayed(this.bookmarksView) && event.keyCode === ESCAPE_KEY) {
|
|
55133
|
-
this.hideModal(this.bookmarksView, this.bookmarksControl);
|
|
55134
|
-
}
|
|
55135
|
-
}
|
|
55136
55009
|
hideView() {
|
|
55137
55010
|
if (this.view?.layout !== "fixed") {
|
|
55138
55011
|
if (this.view?.isScrollMode()) {
|
|
@@ -58335,7 +58208,8 @@ var D2Reader = class {
|
|
|
58335
58208
|
enablePageBreaks: false,
|
|
58336
58209
|
enableSearch: false,
|
|
58337
58210
|
enableTTS: false,
|
|
58338
|
-
enableTimeline: false
|
|
58211
|
+
enableTimeline: false,
|
|
58212
|
+
customKeyboardEvents: false
|
|
58339
58213
|
};
|
|
58340
58214
|
if (rights.enableContentProtection && initialConfig.protection) {
|
|
58341
58215
|
await ContentProtectionModule.setupPreloadProtection(initialConfig.protection);
|