@d-i-t-a/reader 2.2.0-beta.2 → 2.2.0-beta.3
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 +321 -95
- package/dist/esm/index.js.map +3 -3
- package/dist/reader.css +1 -1
- package/dist/reader.css.map +1 -1
- package/dist/reader.js +35 -35
- package/dist/reader.js.map +3 -3
- package/dist/types/modules/citation/CitationModule.d.ts +4 -0
- package/dist/types/modules/protection/ContentProtectionModule.d.ts +3 -2
- package/dist/types/modules/search/SearchModule.d.ts +1 -1
- package/dist/types/navigator/PDFNavigator.d.ts +11 -4
- package/dist/types/reader.d.ts +3 -1
- package/dist/types/utils/GrabToPan.d.ts +42 -0
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -55563,17 +55563,7 @@ var TextHighlighter = class {
|
|
|
55563
55563
|
toolbox.style.top = ev.clientY + (self2.delegate.attributes?.navHeight ?? 0) + "px";
|
|
55564
55564
|
toolbox.style.left = ev.clientX + "px";
|
|
55565
55565
|
if (getComputedStyle(toolbox).display === "none") {
|
|
55566
|
-
let
|
|
55567
|
-
self2.delegate.annotationModule?.api?.addCommentToAnnotation(anno).then((result) => {
|
|
55568
|
-
self2.delegate.annotationModule?.updateAnnotation(result).then(async () => {
|
|
55569
|
-
import_loglevel5.default.log("update highlight " + result.id);
|
|
55570
|
-
toolbox.style.display = "none";
|
|
55571
|
-
self2.selectionMenuClosed();
|
|
55572
|
-
});
|
|
55573
|
-
toolbox.style.display = "none";
|
|
55574
|
-
self2.selectionMenuClosed();
|
|
55575
|
-
});
|
|
55576
|
-
}, deleteH = function() {
|
|
55566
|
+
let deleteH = function() {
|
|
55577
55567
|
if (self2.delegate.rights.enableAnnotations) {
|
|
55578
55568
|
self2.delegate.annotationModule?.deleteSelectedHighlight(anno).then(async () => {
|
|
55579
55569
|
import_loglevel5.default.log("delete highlight " + anno.id);
|
|
@@ -55608,14 +55598,6 @@ var TextHighlighter = class {
|
|
|
55608
55598
|
}
|
|
55609
55599
|
if (commentIcon) {
|
|
55610
55600
|
commentIcon.style.display = "none";
|
|
55611
|
-
let clone = commentIcon.cloneNode(true);
|
|
55612
|
-
let parent = commentIcon.parentElement;
|
|
55613
|
-
clone.style.display = "unset";
|
|
55614
|
-
clone.id = "cloneCommentIcon";
|
|
55615
|
-
clone.addEventListener("click", noteH, false);
|
|
55616
|
-
if (parent) {
|
|
55617
|
-
parent.append(clone);
|
|
55618
|
-
}
|
|
55619
55601
|
}
|
|
55620
55602
|
let deleteIcon = document.getElementById("deleteIcon");
|
|
55621
55603
|
let cloneDeleteIcon = document.getElementById("cloneDeleteIcon");
|
|
@@ -58323,6 +58305,9 @@ var ContentProtectionModule = class {
|
|
|
58323
58305
|
return true;
|
|
58324
58306
|
}
|
|
58325
58307
|
restrictCopy(event) {
|
|
58308
|
+
if (this.citation) {
|
|
58309
|
+
return;
|
|
58310
|
+
}
|
|
58326
58311
|
import_loglevel13.default.log("copy action initiated");
|
|
58327
58312
|
let win = this.delegate.iframes[0].contentWindow;
|
|
58328
58313
|
if (win) {
|
|
@@ -58982,14 +58967,14 @@ var SearchModule = class {
|
|
|
58982
58967
|
this.currentSearchHighlights = [];
|
|
58983
58968
|
this.bookSearchResult = [];
|
|
58984
58969
|
reset();
|
|
58985
|
-
this.searchAndPaintChapter(term, 0, async () => {
|
|
58970
|
+
await this.searchAndPaintChapter(term, 0, async () => {
|
|
58986
58971
|
});
|
|
58987
|
-
var chapter = this.searchChapter(term);
|
|
58988
|
-
var book = this.searchBook(term);
|
|
58989
58972
|
if (current) {
|
|
58990
|
-
|
|
58973
|
+
await this.searchBook(term);
|
|
58974
|
+
return await this.searchChapter(term);
|
|
58991
58975
|
} else {
|
|
58992
|
-
|
|
58976
|
+
await this.searchChapter(term);
|
|
58977
|
+
return await this.searchBook(term);
|
|
58993
58978
|
}
|
|
58994
58979
|
}
|
|
58995
58980
|
async goToSearchID(href, index2, current) {
|
|
@@ -59197,18 +59182,33 @@ var SearchModule = class {
|
|
|
59197
59182
|
}
|
|
59198
59183
|
if (tocItem) {
|
|
59199
59184
|
let href = this.publication.getAbsoluteHref(tocItem.Href);
|
|
59200
|
-
|
|
59201
|
-
|
|
59202
|
-
|
|
59203
|
-
|
|
59204
|
-
|
|
59205
|
-
|
|
59206
|
-
|
|
59207
|
-
|
|
59185
|
+
if (this.delegate.api?.getContent) {
|
|
59186
|
+
await this.delegate.api?.getContent(href).then((content) => {
|
|
59187
|
+
let parser = new DOMParser();
|
|
59188
|
+
let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(content) : content, "application/xhtml+xml");
|
|
59189
|
+
if (tocItem) {
|
|
59190
|
+
searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
|
|
59191
|
+
result.forEach((searchItem) => {
|
|
59192
|
+
localSearchResultBook.push(searchItem);
|
|
59193
|
+
this.bookSearchResult.push(searchItem);
|
|
59194
|
+
});
|
|
59208
59195
|
});
|
|
59209
|
-
}
|
|
59210
|
-
}
|
|
59211
|
-
}
|
|
59196
|
+
}
|
|
59197
|
+
});
|
|
59198
|
+
} else {
|
|
59199
|
+
await fetch(href, this.delegate.requestConfig).then((r) => r.text()).then(async (data) => {
|
|
59200
|
+
let parser = new DOMParser();
|
|
59201
|
+
let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
|
|
59202
|
+
if (tocItem) {
|
|
59203
|
+
searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
|
|
59204
|
+
result.forEach((searchItem) => {
|
|
59205
|
+
localSearchResultBook.push(searchItem);
|
|
59206
|
+
this.bookSearchResult.push(searchItem);
|
|
59207
|
+
});
|
|
59208
|
+
});
|
|
59209
|
+
}
|
|
59210
|
+
});
|
|
59211
|
+
}
|
|
59212
59212
|
}
|
|
59213
59213
|
if (index2 === this.publication.readingOrder.length - 1) {
|
|
59214
59214
|
return localSearchResultBook;
|
|
@@ -59234,17 +59234,31 @@ var SearchModule = class {
|
|
|
59234
59234
|
}
|
|
59235
59235
|
if (tocItem) {
|
|
59236
59236
|
let href = this.publication.getAbsoluteHref(tocItem.Href);
|
|
59237
|
-
|
|
59238
|
-
|
|
59239
|
-
|
|
59240
|
-
|
|
59241
|
-
|
|
59242
|
-
|
|
59243
|
-
|
|
59237
|
+
if (this.delegate.api?.getContent) {
|
|
59238
|
+
await this.delegate.api?.getContent(href).then((content) => {
|
|
59239
|
+
let parser = new DOMParser();
|
|
59240
|
+
let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(content) : content, "application/xhtml+xml");
|
|
59241
|
+
if (tocItem) {
|
|
59242
|
+
searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
|
|
59243
|
+
result.forEach((searchItem) => {
|
|
59244
|
+
localSearchResultBook.push(searchItem);
|
|
59245
|
+
});
|
|
59244
59246
|
});
|
|
59245
|
-
}
|
|
59246
|
-
}
|
|
59247
|
-
}
|
|
59247
|
+
}
|
|
59248
|
+
});
|
|
59249
|
+
} else {
|
|
59250
|
+
await fetch(href, this.delegate.requestConfig).then((r) => r.text()).then(async (data) => {
|
|
59251
|
+
let parser = new DOMParser();
|
|
59252
|
+
let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
|
|
59253
|
+
if (tocItem) {
|
|
59254
|
+
searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
|
|
59255
|
+
result.forEach((searchItem) => {
|
|
59256
|
+
localSearchResultBook.push(searchItem);
|
|
59257
|
+
});
|
|
59258
|
+
});
|
|
59259
|
+
}
|
|
59260
|
+
});
|
|
59261
|
+
}
|
|
59248
59262
|
}
|
|
59249
59263
|
return localSearchResultBook;
|
|
59250
59264
|
}
|
|
@@ -64360,9 +64374,12 @@ var CitationModule = class {
|
|
|
64360
64374
|
return module2;
|
|
64361
64375
|
}
|
|
64362
64376
|
async stop() {
|
|
64363
|
-
import_loglevel23.default.log("
|
|
64377
|
+
import_loglevel23.default.log("Citation module stop");
|
|
64364
64378
|
}
|
|
64365
64379
|
copyToClipboard(textToClipboard) {
|
|
64380
|
+
if (this.delegate?.contentProtectionModule) {
|
|
64381
|
+
this.delegate.contentProtectionModule.citation = true;
|
|
64382
|
+
}
|
|
64366
64383
|
let success = true;
|
|
64367
64384
|
if (window.clipboardData) {
|
|
64368
64385
|
window.clipboardData.setData("text/plain", textToClipboard);
|
|
@@ -64412,7 +64429,11 @@ var CitationModule = class {
|
|
|
64412
64429
|
let chicagoString = "";
|
|
64413
64430
|
let mlaString = "";
|
|
64414
64431
|
let apaString = "";
|
|
64415
|
-
if (self2.
|
|
64432
|
+
if (self2.properties.author) {
|
|
64433
|
+
apaString = apaString + self2.properties.author;
|
|
64434
|
+
mlaString = mlaString + self2.properties.author;
|
|
64435
|
+
chicagoString = chicagoString + self2.properties.author;
|
|
64436
|
+
} else if (self2.publication.Metadata.Author?.length > 0) {
|
|
64416
64437
|
let authorIndex = 0;
|
|
64417
64438
|
if (authorIndex === 0) {
|
|
64418
64439
|
if (self2.publication.Metadata.Author[0].Name) {
|
|
@@ -64433,11 +64454,18 @@ var CitationModule = class {
|
|
|
64433
64454
|
let chicagoString = "";
|
|
64434
64455
|
let mlaString = "";
|
|
64435
64456
|
let apaString = "";
|
|
64436
|
-
if (self2.
|
|
64457
|
+
if (self2.properties.publisher) {
|
|
64458
|
+
mlaString = mlaString + self2.properties.publisher + ", ";
|
|
64459
|
+
chicagoString = chicagoString + self2.properties.publisher + ", ";
|
|
64460
|
+
} else if (self2.publication.Metadata.Publisher && self2.publication.Metadata.Publisher[0].Name) {
|
|
64437
64461
|
mlaString = mlaString + self2.publication.Metadata.Publisher[0].Name + ", ";
|
|
64438
64462
|
chicagoString = chicagoString + self2.publication.Metadata.Publisher[0].Name + ", ";
|
|
64439
64463
|
}
|
|
64440
|
-
if (self2.
|
|
64464
|
+
if (self2.properties.published) {
|
|
64465
|
+
apaString = apaString + "(" + self2.properties.published + ")";
|
|
64466
|
+
mlaString = mlaString + self2.properties.published;
|
|
64467
|
+
chicagoString = chicagoString + self2.properties.published;
|
|
64468
|
+
} else if (self2.publication.Metadata.PublicationDate) {
|
|
64441
64469
|
if (self2.publication.Metadata.PublicationDate.getFullYear() > 0) {
|
|
64442
64470
|
apaString = apaString + "(" + self2.publication.Metadata.PublicationDate.getFullYear() + ")";
|
|
64443
64471
|
mlaString = mlaString + self2.publication.Metadata.PublicationDate.getFullYear();
|
|
@@ -64450,7 +64478,13 @@ var CitationModule = class {
|
|
|
64450
64478
|
return ["", "", ""];
|
|
64451
64479
|
};
|
|
64452
64480
|
let bookTitleFormatted = function() {
|
|
64453
|
-
if (self2.
|
|
64481
|
+
if (self2.properties.title) {
|
|
64482
|
+
return [
|
|
64483
|
+
self2.properties.title + ". ",
|
|
64484
|
+
self2.properties.title + ". ",
|
|
64485
|
+
self2.properties.title + ". "
|
|
64486
|
+
];
|
|
64487
|
+
} else if (self2.publication.Metadata.Title) {
|
|
64454
64488
|
return [
|
|
64455
64489
|
self2.publication.Metadata.Title + ". ",
|
|
64456
64490
|
self2.publication.Metadata.Title + ". ",
|
|
@@ -64467,7 +64501,11 @@ var CitationModule = class {
|
|
|
64467
64501
|
let chicagoString = "";
|
|
64468
64502
|
let mlaString = "";
|
|
64469
64503
|
let apaString = "";
|
|
64470
|
-
if (self2.
|
|
64504
|
+
if (self2.properties.publisher) {
|
|
64505
|
+
mlaString = mlaString + self2.properties.publisher + ", ";
|
|
64506
|
+
chicagoString = chicagoString + self2.properties.publisher + ", ";
|
|
64507
|
+
apaString = apaString + self2.properties.publisher + ", ";
|
|
64508
|
+
} else if (self2.publication.Metadata.Publisher && self2.publication.Metadata.Publisher[0].Name) {
|
|
64471
64509
|
mlaString = mlaString + self2.publication.Metadata.Publisher[0].Name + ", ";
|
|
64472
64510
|
chicagoString = chicagoString + self2.publication.Metadata.Publisher[0].Name + ", ";
|
|
64473
64511
|
apaString = apaString + self2.publication.Metadata.Publisher[0].Name + ", ";
|
|
@@ -64549,13 +64587,126 @@ var CitationModule = class {
|
|
|
64549
64587
|
init_polyfills();
|
|
64550
64588
|
var import_eventemitter32 = __toModule(require_eventemitter3());
|
|
64551
64589
|
var import_pdfjs_dist = __toModule(require_pdf());
|
|
64590
|
+
|
|
64591
|
+
// src/utils/GrabToPan.ts
|
|
64592
|
+
init_polyfills();
|
|
64593
|
+
var CSS_CLASS_GRAB = "grab-to-pan-grab";
|
|
64594
|
+
var _onMouseDown, onMouseDown_fn, _onMouseMove, onMouseMove_fn, _endPan, endPan_fn;
|
|
64595
|
+
var GrabToPan = class {
|
|
64596
|
+
constructor(options) {
|
|
64597
|
+
__privateAdd(this, _onMouseDown);
|
|
64598
|
+
__privateAdd(this, _onMouseMove);
|
|
64599
|
+
__privateAdd(this, _endPan);
|
|
64600
|
+
this.element = options.element;
|
|
64601
|
+
this.document = options.element.ownerDocument;
|
|
64602
|
+
if (typeof options.ignoreTarget === "function") {
|
|
64603
|
+
this.ignoreTarget = options.ignoreTarget;
|
|
64604
|
+
}
|
|
64605
|
+
this.onActiveChanged = options.onActiveChanged;
|
|
64606
|
+
this.activate = this.activate.bind(this);
|
|
64607
|
+
this.deactivate = this.deactivate.bind(this);
|
|
64608
|
+
this.toggle = this.toggle.bind(this);
|
|
64609
|
+
this._onMouseDown = __privateMethod(this, _onMouseDown, onMouseDown_fn).bind(this);
|
|
64610
|
+
this._onMouseMove = __privateMethod(this, _onMouseMove, onMouseMove_fn).bind(this);
|
|
64611
|
+
this._endPan = __privateMethod(this, _endPan, endPan_fn).bind(this);
|
|
64612
|
+
const overlay = this.overlay = document.createElement("div");
|
|
64613
|
+
overlay.className = "grab-to-pan-grabbing";
|
|
64614
|
+
}
|
|
64615
|
+
activate() {
|
|
64616
|
+
if (!this.active) {
|
|
64617
|
+
this.active = true;
|
|
64618
|
+
this.element.addEventListener("mousedown", this._onMouseDown, true);
|
|
64619
|
+
this.element.classList.add(CSS_CLASS_GRAB);
|
|
64620
|
+
this.onActiveChanged?.(true);
|
|
64621
|
+
}
|
|
64622
|
+
}
|
|
64623
|
+
deactivate() {
|
|
64624
|
+
if (this.active) {
|
|
64625
|
+
this.active = false;
|
|
64626
|
+
this.element.removeEventListener("mousedown", this._onMouseDown, true);
|
|
64627
|
+
this._endPan();
|
|
64628
|
+
this.element.classList.remove(CSS_CLASS_GRAB);
|
|
64629
|
+
this.onActiveChanged?.(false);
|
|
64630
|
+
}
|
|
64631
|
+
}
|
|
64632
|
+
toggle() {
|
|
64633
|
+
if (this.active) {
|
|
64634
|
+
this.deactivate();
|
|
64635
|
+
} else {
|
|
64636
|
+
this.activate();
|
|
64637
|
+
}
|
|
64638
|
+
}
|
|
64639
|
+
ignoreTarget(node) {
|
|
64640
|
+
return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
|
|
64641
|
+
}
|
|
64642
|
+
};
|
|
64643
|
+
_onMouseDown = new WeakSet();
|
|
64644
|
+
onMouseDown_fn = function(event) {
|
|
64645
|
+
if (event.button !== 0 || this.ignoreTarget(event.target)) {
|
|
64646
|
+
return;
|
|
64647
|
+
}
|
|
64648
|
+
if (event.originalTarget) {
|
|
64649
|
+
try {
|
|
64650
|
+
event.originalTarget.tagName;
|
|
64651
|
+
} catch (e) {
|
|
64652
|
+
return;
|
|
64653
|
+
}
|
|
64654
|
+
}
|
|
64655
|
+
this.scrollLeftStart = this.element.scrollLeft;
|
|
64656
|
+
this.scrollTopStart = this.element.scrollTop;
|
|
64657
|
+
this.clientXStart = event.clientX;
|
|
64658
|
+
this.clientYStart = event.clientY;
|
|
64659
|
+
this.document.addEventListener("mousemove", this._onMouseMove, true);
|
|
64660
|
+
this.document.addEventListener("mouseup", this._endPan, true);
|
|
64661
|
+
this.element.addEventListener("scroll", this._endPan, true);
|
|
64662
|
+
event.preventDefault();
|
|
64663
|
+
event.stopPropagation();
|
|
64664
|
+
const focusedElement = document.activeElement;
|
|
64665
|
+
if (focusedElement && !focusedElement.contains(event.target)) {
|
|
64666
|
+
focusedElement.blur();
|
|
64667
|
+
}
|
|
64668
|
+
};
|
|
64669
|
+
_onMouseMove = new WeakSet();
|
|
64670
|
+
onMouseMove_fn = function(event) {
|
|
64671
|
+
this.element.removeEventListener("scroll", this._endPan, true);
|
|
64672
|
+
if (!(event.buttons & 1)) {
|
|
64673
|
+
this._endPan();
|
|
64674
|
+
return;
|
|
64675
|
+
}
|
|
64676
|
+
const xDiff = event.clientX - this.clientXStart;
|
|
64677
|
+
const yDiff = event.clientY - this.clientYStart;
|
|
64678
|
+
const scrollTop = this.scrollTopStart - yDiff;
|
|
64679
|
+
const scrollLeft = this.scrollLeftStart - xDiff;
|
|
64680
|
+
if (this.element.scrollTo) {
|
|
64681
|
+
this.element.scrollTo({
|
|
64682
|
+
top: scrollTop,
|
|
64683
|
+
left: scrollLeft,
|
|
64684
|
+
behavior: "instant"
|
|
64685
|
+
});
|
|
64686
|
+
} else {
|
|
64687
|
+
this.element.scrollTop = scrollTop;
|
|
64688
|
+
this.element.scrollLeft = scrollLeft;
|
|
64689
|
+
}
|
|
64690
|
+
if (!this.overlay.parentNode) {
|
|
64691
|
+
document.body.append(this.overlay);
|
|
64692
|
+
}
|
|
64693
|
+
};
|
|
64694
|
+
_endPan = new WeakSet();
|
|
64695
|
+
endPan_fn = function() {
|
|
64696
|
+
this.element.removeEventListener("scroll", this._endPan, true);
|
|
64697
|
+
this.document.removeEventListener("mousemove", this._onMouseMove, true);
|
|
64698
|
+
this.document.removeEventListener("mouseup", this._endPan, true);
|
|
64699
|
+
this.overlay.remove();
|
|
64700
|
+
};
|
|
64701
|
+
|
|
64702
|
+
// src/navigator/PDFNavigator.ts
|
|
64552
64703
|
var ScaleType;
|
|
64553
64704
|
(function(ScaleType2) {
|
|
64554
64705
|
ScaleType2[ScaleType2["Page"] = 0] = "Page";
|
|
64555
64706
|
ScaleType2[ScaleType2["Width"] = 1] = "Width";
|
|
64556
64707
|
})(ScaleType || (ScaleType = {}));
|
|
64557
64708
|
var PDFNavigator = class extends import_eventemitter32.default {
|
|
64558
|
-
constructor(settings, publication) {
|
|
64709
|
+
constructor(settings, publication, api) {
|
|
64559
64710
|
super();
|
|
64560
64711
|
this.pdfDoc = null;
|
|
64561
64712
|
this.pageNum = 1;
|
|
@@ -64570,9 +64721,10 @@ var PDFNavigator = class extends import_eventemitter32.default {
|
|
|
64570
64721
|
};
|
|
64571
64722
|
this.settings = settings;
|
|
64572
64723
|
this.publication = publication;
|
|
64724
|
+
this.api = api;
|
|
64573
64725
|
}
|
|
64574
64726
|
static async create(config2) {
|
|
64575
|
-
const navigator2 = new this(config2.settings, config2.publication);
|
|
64727
|
+
const navigator2 = new this(config2.settings, config2.publication, config2.api);
|
|
64576
64728
|
await navigator2.start(config2.mainElement, config2.headerMenu, config2.footerMenu);
|
|
64577
64729
|
return new Promise((resolve) => resolve(navigator2));
|
|
64578
64730
|
}
|
|
@@ -64585,40 +64737,58 @@ var PDFNavigator = class extends import_eventemitter32.default {
|
|
|
64585
64737
|
console.log(this.resource);
|
|
64586
64738
|
console.log(this.resource.Href1);
|
|
64587
64739
|
import_pdfjs_dist.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.16.105/pdf.worker.js`;
|
|
64588
|
-
|
|
64589
|
-
this.
|
|
64590
|
-
|
|
64591
|
-
|
|
64592
|
-
|
|
64593
|
-
wrapper.appendChild(newCanvas);
|
|
64594
|
-
this.canvas = document.getElementById("canvas");
|
|
64595
|
-
}
|
|
64596
|
-
this.ctx = this.canvas.getContext("2d");
|
|
64740
|
+
this.wrapper = findRequiredElement(this.mainElement, "main#iframe-wrapper");
|
|
64741
|
+
this.pdfContainer = findRequiredElement(this.mainElement, "#pdf-container");
|
|
64742
|
+
this.handTool = new GrabToPan({
|
|
64743
|
+
element: this.pdfContainer
|
|
64744
|
+
});
|
|
64597
64745
|
const self2 = this;
|
|
64746
|
+
let loadingMessage = document.createElement("div");
|
|
64747
|
+
loadingMessage.id = "loadingpdf";
|
|
64748
|
+
loadingMessage.innerHTML = readerLoading;
|
|
64749
|
+
loadingMessage.style.width = getComputedStyle(this.wrapper).width;
|
|
64750
|
+
loadingMessage.style.height = getComputedStyle(this.wrapper).height;
|
|
64751
|
+
loadingMessage.style.display = "flex";
|
|
64752
|
+
loadingMessage.style.zIndex = "100";
|
|
64753
|
+
loadingMessage.style.position = "absolute";
|
|
64754
|
+
loadingMessage.style.alignItems = "center";
|
|
64755
|
+
loadingMessage.style.justifyContent = "center";
|
|
64756
|
+
loadingMessage.style.background = "white";
|
|
64757
|
+
loadingMessage.className = "loading is-loading";
|
|
64758
|
+
this.pdfContainer.appendChild(loadingMessage);
|
|
64598
64759
|
(0, import_pdfjs_dist.getDocument)(this.publication.getAbsoluteHref(this.resource.Href)).promise.then(function(pdfDoc_) {
|
|
64599
64760
|
self2.pdfDoc = pdfDoc_;
|
|
64600
|
-
self2.
|
|
64761
|
+
self2.loadPDFJS(self2.pageNum);
|
|
64601
64762
|
});
|
|
64602
64763
|
this.setupEvents();
|
|
64603
64764
|
}
|
|
64604
64765
|
async handleResize() {
|
|
64605
|
-
this.
|
|
64766
|
+
this.loadPDFJS(this.pageNum);
|
|
64606
64767
|
}
|
|
64607
64768
|
setupEvents() {
|
|
64608
64769
|
addEventListenerOptional(window, "resize", this.onResize);
|
|
64609
64770
|
}
|
|
64610
|
-
|
|
64771
|
+
loadPDFJS(num) {
|
|
64611
64772
|
const self2 = this;
|
|
64612
|
-
|
|
64613
|
-
|
|
64614
|
-
|
|
64615
|
-
|
|
64773
|
+
let currentPage = 1;
|
|
64774
|
+
this.wrapper.style.height = "calc(100vh - 10px)";
|
|
64775
|
+
this.pdfContainer.style.height = "calc(100vh - 10px)";
|
|
64776
|
+
this.pdfContainer.style.flexDirection = "column";
|
|
64777
|
+
let collection = document.getElementsByTagName("canvas");
|
|
64778
|
+
Array.from(collection).forEach(function(element) {
|
|
64779
|
+
element?.parentNode?.removeChild(element);
|
|
64780
|
+
});
|
|
64781
|
+
function renderPage(page) {
|
|
64782
|
+
const canvas = document.createElement("canvas");
|
|
64783
|
+
canvas.id = String(currentPage);
|
|
64784
|
+
canvas.style.border = "1px solid gray";
|
|
64785
|
+
canvas.style.margin = "1px";
|
|
64616
64786
|
let viewport = page.getViewport({ scale: self2.scale });
|
|
64617
64787
|
if (self2.scale === 1) {
|
|
64618
|
-
const fitPage = wrapper.clientHeight / viewport.height;
|
|
64619
|
-
const fitWidth = wrapper.clientWidth / viewport.width;
|
|
64788
|
+
const fitPage = self2.wrapper.clientHeight / viewport.height;
|
|
64789
|
+
const fitWidth = self2.wrapper.clientWidth / viewport.width;
|
|
64620
64790
|
console.log(fitPage, fitWidth);
|
|
64621
|
-
if (
|
|
64791
|
+
if (self2.scaleType === 0) {
|
|
64622
64792
|
viewport = page.getViewport({
|
|
64623
64793
|
scale: fitPage < fitWidth ? fitPage : fitWidth
|
|
64624
64794
|
});
|
|
@@ -64626,41 +64796,55 @@ var PDFNavigator = class extends import_eventemitter32.default {
|
|
|
64626
64796
|
viewport = page.getViewport({ scale: fitWidth });
|
|
64627
64797
|
}
|
|
64628
64798
|
}
|
|
64629
|
-
self2.canvas
|
|
64630
|
-
|
|
64799
|
+
self2.pdfContainer.appendChild(canvas);
|
|
64800
|
+
const context = canvas.getContext("2d");
|
|
64801
|
+
canvas.height = viewport.height;
|
|
64802
|
+
canvas.width = viewport.width;
|
|
64631
64803
|
const renderContext = {
|
|
64632
|
-
canvasContext:
|
|
64804
|
+
canvasContext: context,
|
|
64633
64805
|
viewport
|
|
64634
64806
|
};
|
|
64807
|
+
let pdfload = document.getElementById("loadingpdf");
|
|
64808
|
+
pdfload.style.display = "flex";
|
|
64809
|
+
pdfload.style.width = getComputedStyle(self2.wrapper).width;
|
|
64810
|
+
pdfload.style.height = getComputedStyle(self2.wrapper).height;
|
|
64635
64811
|
const renderTask = page.render(renderContext);
|
|
64636
64812
|
renderTask.promise.then(function() {
|
|
64637
|
-
self2.
|
|
64638
|
-
|
|
64639
|
-
self2.
|
|
64640
|
-
|
|
64813
|
+
if (currentPage < self2.pdfDoc.numPages) {
|
|
64814
|
+
currentPage++;
|
|
64815
|
+
self2.pdfDoc.getPage(currentPage).then(renderPage);
|
|
64816
|
+
} else {
|
|
64817
|
+
document.getElementById(String(num))?.scrollIntoView();
|
|
64818
|
+
pdfload.style.display = "none";
|
|
64641
64819
|
}
|
|
64642
64820
|
});
|
|
64643
|
-
}
|
|
64821
|
+
}
|
|
64822
|
+
this.pdfDoc.getPage(currentPage).then(renderPage);
|
|
64644
64823
|
}
|
|
64645
64824
|
queueRenderPage(num) {
|
|
64646
64825
|
const self2 = this;
|
|
64647
64826
|
if (self2.pageRendering) {
|
|
64648
64827
|
self2.pageNumPending = num;
|
|
64649
64828
|
} else {
|
|
64650
|
-
|
|
64829
|
+
this.pageNum = num;
|
|
64830
|
+
document.getElementById(String(num))?.scrollIntoView();
|
|
64651
64831
|
}
|
|
64652
64832
|
}
|
|
64653
64833
|
readingOrder() {
|
|
64834
|
+
return this.publication.readingOrder;
|
|
64654
64835
|
}
|
|
64655
64836
|
tableOfContents() {
|
|
64837
|
+
return this.publication.tableOfContents;
|
|
64656
64838
|
}
|
|
64657
64839
|
currentResource() {
|
|
64658
64840
|
}
|
|
64659
64841
|
totalResources() {
|
|
64842
|
+
return this.publication.readingOrder.length;
|
|
64660
64843
|
}
|
|
64661
64844
|
currentLocator() {
|
|
64662
64845
|
}
|
|
64663
64846
|
positions() {
|
|
64847
|
+
return this.publication.positions ? this.publication.positions : [];
|
|
64664
64848
|
}
|
|
64665
64849
|
nextPage() {
|
|
64666
64850
|
const self2 = this;
|
|
@@ -64692,7 +64876,7 @@ var PDFNavigator = class extends import_eventemitter32.default {
|
|
|
64692
64876
|
(0, import_pdfjs_dist.getDocument)(this.publication.getAbsoluteHref(this.resource.Href)).promise.then(function(pdfDoc_) {
|
|
64693
64877
|
self2.pdfDoc = pdfDoc_;
|
|
64694
64878
|
self2.pageNum = 1;
|
|
64695
|
-
self2.
|
|
64879
|
+
self2.loadPDFJS(self2.pageNum);
|
|
64696
64880
|
});
|
|
64697
64881
|
}
|
|
64698
64882
|
previousResource() {
|
|
@@ -64707,38 +64891,67 @@ var PDFNavigator = class extends import_eventemitter32.default {
|
|
|
64707
64891
|
(0, import_pdfjs_dist.getDocument)(this.publication.getAbsoluteHref(this.resource.Href)).promise.then(function(pdfDoc_) {
|
|
64708
64892
|
self2.pdfDoc = pdfDoc_;
|
|
64709
64893
|
self2.pageNum = self2.pdfDoc.numPages;
|
|
64710
|
-
self2.
|
|
64894
|
+
self2.loadPDFJS(self2.pageNum);
|
|
64711
64895
|
});
|
|
64712
64896
|
}
|
|
64713
64897
|
goTo(locator) {
|
|
64714
64898
|
console.log(locator);
|
|
64899
|
+
const url = new URL(locator.href);
|
|
64900
|
+
if (url.searchParams.has("start")) {
|
|
64901
|
+
const page = url.searchParams.get("start");
|
|
64902
|
+
if (page) {
|
|
64903
|
+
this.queueRenderPage(parseInt(page));
|
|
64904
|
+
}
|
|
64905
|
+
} else {
|
|
64906
|
+
this.queueRenderPage(1);
|
|
64907
|
+
}
|
|
64715
64908
|
}
|
|
64716
64909
|
goToPosition(value) {
|
|
64717
64910
|
console.log(value);
|
|
64911
|
+
this.queueRenderPage(value);
|
|
64718
64912
|
}
|
|
64719
64913
|
async goToPage(page) {
|
|
64720
64914
|
console.log(page);
|
|
64721
64915
|
this.queueRenderPage(page);
|
|
64722
64916
|
}
|
|
64723
64917
|
fitToWidth() {
|
|
64724
|
-
console.log("fit to width");
|
|
64918
|
+
console.log("fit to width", this.pageNum);
|
|
64725
64919
|
this.scale = 1;
|
|
64726
64920
|
this.scaleType = 1;
|
|
64727
|
-
this.
|
|
64921
|
+
this.loadPDFJS(this.pageNum);
|
|
64728
64922
|
}
|
|
64729
64923
|
fitToPage() {
|
|
64730
|
-
console.log("fit to page");
|
|
64924
|
+
console.log("fit to page", this.pageNum);
|
|
64731
64925
|
this.scale = 1;
|
|
64732
64926
|
this.scaleType = 0;
|
|
64733
|
-
this.
|
|
64927
|
+
this.loadPDFJS(this.pageNum);
|
|
64734
64928
|
}
|
|
64735
64929
|
zoomIn() {
|
|
64736
64930
|
this.scale = this.scale + 0.2;
|
|
64737
|
-
this.
|
|
64931
|
+
this.loadPDFJS(this.pageNum);
|
|
64738
64932
|
}
|
|
64739
64933
|
zoomOut() {
|
|
64740
64934
|
this.scale = this.scale - 0.2;
|
|
64741
|
-
this.
|
|
64935
|
+
this.loadPDFJS(this.pageNum);
|
|
64936
|
+
}
|
|
64937
|
+
activateHand() {
|
|
64938
|
+
this.handTool.activate();
|
|
64939
|
+
}
|
|
64940
|
+
deactivateHand() {
|
|
64941
|
+
this.handTool.deactivate();
|
|
64942
|
+
}
|
|
64943
|
+
async scroll(scroll, direction) {
|
|
64944
|
+
if (scroll) {
|
|
64945
|
+
if (direction === "horizontal") {
|
|
64946
|
+
this.pdfContainer.style.flexDirection = "row";
|
|
64947
|
+
} else {
|
|
64948
|
+
this.pdfContainer.style.flexDirection = "column";
|
|
64949
|
+
}
|
|
64950
|
+
this.pdfContainer.style.overflow = "auto";
|
|
64951
|
+
} else {
|
|
64952
|
+
this.pdfContainer.style.flexDirection = "column";
|
|
64953
|
+
this.pdfContainer.style.overflow = "hidden";
|
|
64954
|
+
}
|
|
64742
64955
|
}
|
|
64743
64956
|
stop() {
|
|
64744
64957
|
removeEventListenerOptional(window, "resize", this.onResize);
|
|
@@ -64868,7 +65081,10 @@ var D2Reader = class {
|
|
|
64868
65081
|
this.applyUserSettings = async (userSettings) => {
|
|
64869
65082
|
return await this.settings.applyUserSettings(userSettings);
|
|
64870
65083
|
};
|
|
64871
|
-
this.scroll = async (value) => {
|
|
65084
|
+
this.scroll = async (value, direction) => {
|
|
65085
|
+
if (this.navigator instanceof PDFNavigator) {
|
|
65086
|
+
return this.navigator.scroll(value, direction);
|
|
65087
|
+
}
|
|
64872
65088
|
return await this.settings.scroll(value);
|
|
64873
65089
|
};
|
|
64874
65090
|
this.increase = async (incremental) => {
|
|
@@ -64951,6 +65167,16 @@ var D2Reader = class {
|
|
|
64951
65167
|
this.navigator.zoomOut();
|
|
64952
65168
|
}
|
|
64953
65169
|
};
|
|
65170
|
+
this.activateHand = () => {
|
|
65171
|
+
if (this.navigator instanceof PDFNavigator) {
|
|
65172
|
+
this.navigator.activateHand();
|
|
65173
|
+
}
|
|
65174
|
+
};
|
|
65175
|
+
this.deactivateHand = () => {
|
|
65176
|
+
if (this.navigator instanceof PDFNavigator) {
|
|
65177
|
+
this.navigator.deactivateHand();
|
|
65178
|
+
}
|
|
65179
|
+
};
|
|
64954
65180
|
this.copyToClipboard = (text) => {
|
|
64955
65181
|
this.contentProtectionModule?.copyToClipboard(text);
|
|
64956
65182
|
};
|
|
@@ -65150,6 +65376,11 @@ var D2Reader = class {
|
|
|
65150
65376
|
const contentProtectionModule = rights.enableContentProtection ? await ContentProtectionModule.create(__spreadValues({
|
|
65151
65377
|
delegate: navigator2
|
|
65152
65378
|
}, initialConfig.protection)) : void 0;
|
|
65379
|
+
const citationModule = rights.enableCitations ? await CitationModule.create(__spreadValues({
|
|
65380
|
+
publication,
|
|
65381
|
+
delegate: navigator2,
|
|
65382
|
+
highlighter
|
|
65383
|
+
}, initialConfig.citations)) : void 0;
|
|
65153
65384
|
const enableMediaOverlays = rights.enableMediaOverlays;
|
|
65154
65385
|
const mediaOverlaySettings = enableMediaOverlays ? await MediaOverlaySettings.create(__spreadValues({
|
|
65155
65386
|
store: settingsStore,
|
|
@@ -65178,11 +65409,6 @@ var D2Reader = class {
|
|
|
65178
65409
|
delegate: navigator2,
|
|
65179
65410
|
headerMenu
|
|
65180
65411
|
}) : void 0;
|
|
65181
|
-
const citationModule = rights.enableCitations ? await CitationModule.create(__spreadValues({
|
|
65182
|
-
publication,
|
|
65183
|
-
delegate: navigator2,
|
|
65184
|
-
highlighter
|
|
65185
|
-
}, initialConfig.citations)) : void 0;
|
|
65186
65412
|
return new D2Reader(settings, navigator2, highlighter, bookmarkModule, annotationModule, ttsSettings, ttsModule, searchModule, definitionsModule, contentProtectionModule, timelineModule, mediaOverlaySettings, mediaOverlayModule, pageBreakModule, lineFocusModule, historyModule, citationModule);
|
|
65187
65413
|
}
|
|
65188
65414
|
}
|