@d-i-t-a/reader 2.1.0-beta.6 → 2.1.0-beta.9
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 +126 -47
- package/dist/esm/index.js.map +2 -2
- package/dist/injectables/style/popup.css +2 -2
- package/dist/reader.js +28 -28
- package/dist/reader.js.map +2 -2
- package/dist/types/model/Locator.d.ts +0 -4
- package/dist/types/modules/TTS/TTSModule2.d.ts +1 -1
- package/dist/types/modules/search/SearchModule.d.ts +1 -3
- package/dist/types/store/Annotator.d.ts +3 -0
- package/dist/types/store/LocalAnnotator.d.ts +4 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -35079,8 +35079,8 @@ var EventHandler = class {
|
|
|
35079
35079
|
await this.popup.hidePopover();
|
|
35080
35080
|
}
|
|
35081
35081
|
const isInternal = link.href.indexOf("#");
|
|
35082
|
-
if (!
|
|
35083
|
-
window.open(link.href, "_blank");
|
|
35082
|
+
if (!isEpubInternal && !isResourceInternal) {
|
|
35083
|
+
window.open(link.href, link.target ?? "_blank");
|
|
35084
35084
|
event.preventDefault();
|
|
35085
35085
|
event.stopPropagation();
|
|
35086
35086
|
} else {
|
|
@@ -38052,7 +38052,7 @@ var TextHighlighter = class {
|
|
|
38052
38052
|
let self2 = this;
|
|
38053
38053
|
let doc = this.delegate.iframes[0].contentDocument;
|
|
38054
38054
|
if (doc) {
|
|
38055
|
-
let selection = self2.dom(doc.body)?.
|
|
38055
|
+
let selection = self2.dom(doc.body)?.getSelection();
|
|
38056
38056
|
if (self2.dom(doc.body)) {
|
|
38057
38057
|
if (selection && !selection?.isCollapsed) {
|
|
38058
38058
|
let removeTrailingPunctuation = function(text2) {
|
|
@@ -38121,7 +38121,6 @@ var TextHighlighter = class {
|
|
|
38121
38121
|
return;
|
|
38122
38122
|
}
|
|
38123
38123
|
if (this.isIOS()) {
|
|
38124
|
-
this.delegate.iframes[0].contentDocument?.body.removeEventListener("selectionchange", this.toolboxPlacement.bind(this));
|
|
38125
38124
|
setTimeout(function() {
|
|
38126
38125
|
let doc = self2.delegate.iframes[0].contentDocument;
|
|
38127
38126
|
if (doc) {
|
|
@@ -38129,6 +38128,25 @@ var TextHighlighter = class {
|
|
|
38129
38128
|
selection.removeAllRanges();
|
|
38130
38129
|
setTimeout(function() {
|
|
38131
38130
|
selection.addRange(range);
|
|
38131
|
+
function getCssSelector(element) {
|
|
38132
|
+
const options = {
|
|
38133
|
+
className: (str) => {
|
|
38134
|
+
return _blacklistIdClassForCssSelectors.indexOf(str) < 0;
|
|
38135
|
+
},
|
|
38136
|
+
idName: (str) => {
|
|
38137
|
+
return _blacklistIdClassForCssSelectors.indexOf(str) < 0;
|
|
38138
|
+
}
|
|
38139
|
+
};
|
|
38140
|
+
let doc2 = self2.delegate.iframes[0].contentDocument;
|
|
38141
|
+
if (doc2) {
|
|
38142
|
+
return uniqueCssSelector(element, doc2, options);
|
|
38143
|
+
} else {
|
|
38144
|
+
return void 0;
|
|
38145
|
+
}
|
|
38146
|
+
}
|
|
38147
|
+
let win = self2.delegate.iframes[0].contentWindow;
|
|
38148
|
+
const selectionInfo = getCurrentSelectionInfo(win, getCssSelector);
|
|
38149
|
+
self2.delegate.annotationModule?.annotator?.saveTemporarySelectionInfo(selectionInfo);
|
|
38132
38150
|
}, 5);
|
|
38133
38151
|
}
|
|
38134
38152
|
}, 100);
|
|
@@ -38201,7 +38219,10 @@ var TextHighlighter = class {
|
|
|
38201
38219
|
self2.toolboxHide();
|
|
38202
38220
|
highlightIcon?.removeEventListener("click", highlightEvent);
|
|
38203
38221
|
};
|
|
38204
|
-
highlightIcon.
|
|
38222
|
+
const clone = highlightIcon.cloneNode(true);
|
|
38223
|
+
highlightIcon?.parentNode?.replaceChild(clone, highlightIcon);
|
|
38224
|
+
highlightIcon = document.getElementById("highlightIcon");
|
|
38225
|
+
highlightIcon?.addEventListener("click", highlightEvent);
|
|
38205
38226
|
}
|
|
38206
38227
|
if (underlineIcon) {
|
|
38207
38228
|
let commentEvent = function() {
|
|
@@ -38209,7 +38230,10 @@ var TextHighlighter = class {
|
|
|
38209
38230
|
self2.toolboxHide();
|
|
38210
38231
|
underlineIcon?.removeEventListener("click", commentEvent);
|
|
38211
38232
|
};
|
|
38212
|
-
underlineIcon.
|
|
38233
|
+
const clone = underlineIcon.cloneNode(true);
|
|
38234
|
+
underlineIcon?.parentNode?.replaceChild(clone, underlineIcon);
|
|
38235
|
+
underlineIcon = document.getElementById("underlineIcon");
|
|
38236
|
+
underlineIcon?.addEventListener("click", commentEvent);
|
|
38213
38237
|
}
|
|
38214
38238
|
} else {
|
|
38215
38239
|
if (highlightIcon) {
|
|
@@ -38231,7 +38255,10 @@ var TextHighlighter = class {
|
|
|
38231
38255
|
speakIcon?.removeEventListener("click", speakEvent);
|
|
38232
38256
|
self2.speak();
|
|
38233
38257
|
};
|
|
38234
|
-
speakIcon.
|
|
38258
|
+
const clone = speakIcon.cloneNode(true);
|
|
38259
|
+
speakIcon?.parentNode?.replaceChild(clone, speakIcon);
|
|
38260
|
+
speakIcon = document.getElementById("speakIcon");
|
|
38261
|
+
speakIcon?.addEventListener("click", speakEvent);
|
|
38235
38262
|
}
|
|
38236
38263
|
} else {
|
|
38237
38264
|
if (speakIcon) {
|
|
@@ -38265,7 +38292,11 @@ var TextHighlighter = class {
|
|
|
38265
38292
|
}
|
|
38266
38293
|
let win = self3.delegate.iframes[0].contentWindow;
|
|
38267
38294
|
if (win) {
|
|
38268
|
-
|
|
38295
|
+
let selectionInfo = getCurrentSelectionInfo(win, getCssSelector);
|
|
38296
|
+
if (selectionInfo === void 0) {
|
|
38297
|
+
let doc = self3.delegate.iframes[0].contentDocument;
|
|
38298
|
+
selectionInfo = self3.delegate.annotationModule?.annotator?.getTemporarySelectionInfo(doc);
|
|
38299
|
+
}
|
|
38269
38300
|
if (selectionInfo !== void 0) {
|
|
38270
38301
|
if (menuItem.callback) {
|
|
38271
38302
|
menuItem.callback(selectionInfo.cleanText, selectionInfo.range?.startContainer.parentElement);
|
|
@@ -38326,7 +38357,11 @@ var TextHighlighter = class {
|
|
|
38326
38357
|
}
|
|
38327
38358
|
let win = self2.delegate.iframes[0].contentWindow;
|
|
38328
38359
|
if (win) {
|
|
38329
|
-
|
|
38360
|
+
let selectionInfo = getCurrentSelectionInfo(win, getCssSelector);
|
|
38361
|
+
if (selectionInfo === void 0) {
|
|
38362
|
+
let doc = self2.delegate.iframes[0].contentDocument;
|
|
38363
|
+
selectionInfo = this.delegate.annotationModule?.annotator?.getTemporarySelectionInfo(doc);
|
|
38364
|
+
}
|
|
38330
38365
|
if (selectionInfo) {
|
|
38331
38366
|
if (this.options.onBeforeHighlight(selectionInfo) === true) {
|
|
38332
38367
|
let createColor;
|
|
@@ -38376,7 +38411,11 @@ var TextHighlighter = class {
|
|
|
38376
38411
|
let self2 = this;
|
|
38377
38412
|
let win = self2.delegate.iframes[0].contentWindow;
|
|
38378
38413
|
if (win) {
|
|
38379
|
-
|
|
38414
|
+
let selectionInfo = getCurrentSelectionInfo(win, getCssSelector);
|
|
38415
|
+
if (selectionInfo === void 0) {
|
|
38416
|
+
let doc2 = self2.delegate.iframes[0].contentDocument;
|
|
38417
|
+
selectionInfo = self2.delegate.annotationModule?.annotator?.getTemporarySelectionInfo(doc2);
|
|
38418
|
+
}
|
|
38380
38419
|
if (selectionInfo !== void 0) {
|
|
38381
38420
|
this.delegate.ttsModule.speak(selectionInfo, true, () => {
|
|
38382
38421
|
});
|
|
@@ -40343,7 +40382,11 @@ var BookmarkModule = class {
|
|
|
40343
40382
|
}
|
|
40344
40383
|
};
|
|
40345
40384
|
if (win !== null) {
|
|
40346
|
-
|
|
40385
|
+
let selectionInfo = getCurrentSelectionInfo(win, getCssSelector);
|
|
40386
|
+
if (selectionInfo === void 0) {
|
|
40387
|
+
let doc3 = self2.delegate.iframes[0].contentDocument;
|
|
40388
|
+
selectionInfo = this.delegate.annotationModule?.annotator?.getTemporarySelectionInfo(doc3);
|
|
40389
|
+
}
|
|
40347
40390
|
let doc2 = self2.delegate.iframes[0].contentDocument;
|
|
40348
40391
|
if (selectionInfo && doc2) {
|
|
40349
40392
|
let book = this.delegate.highlighter?.createHighlight(this.delegate.highlighter?.dom(doc2.body).getWindow(), selectionInfo, menuItem.highlight?.color, true, AnnotationMarker.Bookmark, menuItem.icon, menuItem.popup, menuItem.highlight?.style);
|
|
@@ -41690,7 +41733,7 @@ var ContentProtectionModule = class {
|
|
|
41690
41733
|
window.sessionStorage.clear();
|
|
41691
41734
|
window.location.replace(window.location.origin);
|
|
41692
41735
|
}
|
|
41693
|
-
if (typeof config2.api?.inspectDetected === "function") {
|
|
41736
|
+
if (config2.detectInspect && typeof config2.api?.inspectDetected === "function") {
|
|
41694
41737
|
config2.api.inspectDetected();
|
|
41695
41738
|
}
|
|
41696
41739
|
}
|
|
@@ -42301,7 +42344,7 @@ async function searchDocDomSeek(searchInput, doc, href, title, fullWordSearch =
|
|
|
42301
42344
|
// src/modules/search/SearchModule.ts
|
|
42302
42345
|
var import_loglevel14 = __toModule(require_loglevel());
|
|
42303
42346
|
var SearchModule = class {
|
|
42304
|
-
constructor(delegate, publication, properties, highlighter,
|
|
42347
|
+
constructor(delegate, publication, properties, highlighter, api, headerMenu) {
|
|
42305
42348
|
this.currentChapterSearchResult = [];
|
|
42306
42349
|
this.bookSearchResult = [];
|
|
42307
42350
|
this.currentSearchHighlights = [];
|
|
@@ -42311,10 +42354,9 @@ var SearchModule = class {
|
|
|
42311
42354
|
this.properties = properties;
|
|
42312
42355
|
this.api = api;
|
|
42313
42356
|
this.highlighter = highlighter;
|
|
42314
|
-
this.requestConfig = requestConfig;
|
|
42315
42357
|
}
|
|
42316
42358
|
static async create(config2) {
|
|
42317
|
-
const search = new this(config2.delegate, config2.publication, config2, config2.highlighter, config2.
|
|
42359
|
+
const search = new this(config2.delegate, config2.publication, config2, config2.highlighter, config2.api, config2.headerMenu);
|
|
42318
42360
|
await search.start();
|
|
42319
42361
|
return search;
|
|
42320
42362
|
}
|
|
@@ -42738,9 +42780,9 @@ var SearchModule = class {
|
|
|
42738
42780
|
}
|
|
42739
42781
|
if (tocItem) {
|
|
42740
42782
|
let href = this.publication.getAbsoluteHref(tocItem.Href);
|
|
42741
|
-
await fetch(href, this.requestConfig).then((r) => r.text()).then(async (data) => {
|
|
42783
|
+
await fetch(href, this.delegate.requestConfig).then((r) => r.text()).then(async (data) => {
|
|
42742
42784
|
let parser = new DOMParser();
|
|
42743
|
-
let doc = parser.parseFromString(this.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
|
|
42785
|
+
let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
|
|
42744
42786
|
if (tocItem) {
|
|
42745
42787
|
searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
|
|
42746
42788
|
result.forEach((searchItem) => {
|
|
@@ -42775,9 +42817,9 @@ var SearchModule = class {
|
|
|
42775
42817
|
}
|
|
42776
42818
|
if (tocItem) {
|
|
42777
42819
|
let href = this.publication.getAbsoluteHref(tocItem.Href);
|
|
42778
|
-
await fetch(href, this.requestConfig).then((r) => r.text()).then(async (data) => {
|
|
42820
|
+
await fetch(href, this.delegate.requestConfig).then((r) => r.text()).then(async (data) => {
|
|
42779
42821
|
let parser = new DOMParser();
|
|
42780
|
-
let doc = parser.parseFromString(this.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
|
|
42822
|
+
let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
|
|
42781
42823
|
if (tocItem) {
|
|
42782
42824
|
searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
|
|
42783
42825
|
result.forEach((searchItem) => {
|
|
@@ -43522,7 +43564,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
43522
43564
|
this.sampleReadEventHandler = new SampleReadEventHandler(this);
|
|
43523
43565
|
}
|
|
43524
43566
|
static async create(config2) {
|
|
43525
|
-
const navigator2 = new this(config2.settings, config2.annotator || void 0, config2.initialLastReadingPosition || void 0, config2.publication, config2.api, config2.rights, config2.tts, config2.injectables, config2.attributes || { margin: 0 }, config2.services, config2.sample);
|
|
43567
|
+
const navigator2 = new this(config2.settings, config2.annotator || void 0, config2.initialLastReadingPosition || void 0, config2.publication, config2.api, config2.rights, config2.tts, config2.injectables, config2.attributes || { margin: 0 }, config2.services, config2.sample, config2.requestConfig);
|
|
43526
43568
|
await navigator2.start(config2.mainElement, config2.headerMenu, config2.footerMenu);
|
|
43527
43569
|
return new Promise((resolve) => resolve(navigator2));
|
|
43528
43570
|
}
|
|
@@ -45752,8 +45794,12 @@ var _LocalAnnotator = class {
|
|
|
45752
45794
|
const uniqueStr = `${rangeRepresentation.highlight.selectionInfo.rangeInfo.startContainerElementCssSelector}${rangeRepresentation.highlight.selectionInfo.rangeInfo.startContainerChildTextNodeIndex}${rangeRepresentation.highlight.selectionInfo.rangeInfo.startOffset}${rangeRepresentation.highlight.selectionInfo.rangeInfo.endContainerElementCssSelector}${rangeRepresentation.highlight.selectionInfo.rangeInfo.endContainerChildTextNodeIndex}${rangeRepresentation.highlight.selectionInfo.rangeInfo.endOffset}`;
|
|
45753
45795
|
const sha256Hex = SHA256.hash(uniqueStr);
|
|
45754
45796
|
rangeRepresentation.highlight.id = "R2_HIGHLIGHT_" + sha256Hex;
|
|
45755
|
-
|
|
45756
|
-
|
|
45797
|
+
let rangeColor;
|
|
45798
|
+
if (rangeRepresentation.highlight.color) {
|
|
45799
|
+
rangeColor = rangeRepresentation.highlight.color;
|
|
45800
|
+
} else if (rangeRepresentation.color) {
|
|
45801
|
+
rangeColor = rangeRepresentation.color;
|
|
45802
|
+
}
|
|
45757
45803
|
if (TextHighlighter.isHexColor(rangeColor)) {
|
|
45758
45804
|
rangeColor = TextHighlighter.hexToRgbString(rangeColor);
|
|
45759
45805
|
}
|
|
@@ -45765,6 +45811,21 @@ var _LocalAnnotator = class {
|
|
|
45765
45811
|
this.store.set(_LocalAnnotator.ANNOTATIONS, JSON.stringify(annotationsToStore));
|
|
45766
45812
|
return annotationsToStore;
|
|
45767
45813
|
}
|
|
45814
|
+
saveTemporarySelectionInfo(selectionInfo) {
|
|
45815
|
+
this.store.set(_LocalAnnotator.SELECTIONINFO, JSON.stringify(selectionInfo));
|
|
45816
|
+
}
|
|
45817
|
+
getTemporarySelectionInfo(doc) {
|
|
45818
|
+
const selectionInfos = this.store.get(_LocalAnnotator.SELECTIONINFO);
|
|
45819
|
+
if (selectionInfos) {
|
|
45820
|
+
let selectionInfo = JSON.parse(selectionInfos);
|
|
45821
|
+
selectionInfo.range = convertRangeInfo(doc, selectionInfo.rangeInfo);
|
|
45822
|
+
return selectionInfo;
|
|
45823
|
+
}
|
|
45824
|
+
return [];
|
|
45825
|
+
}
|
|
45826
|
+
deleteTemporarySelectionInfo() {
|
|
45827
|
+
this.store.remove(_LocalAnnotator.SELECTIONINFO);
|
|
45828
|
+
}
|
|
45768
45829
|
saveAnnotation(annotation) {
|
|
45769
45830
|
let savedAnnotations = this.store.get(_LocalAnnotator.ANNOTATIONS);
|
|
45770
45831
|
if (savedAnnotations) {
|
|
@@ -45815,7 +45876,7 @@ var _LocalAnnotator = class {
|
|
|
45815
45876
|
const savedAnnotations = this.store.get(_LocalAnnotator.ANNOTATIONS);
|
|
45816
45877
|
if (savedAnnotations) {
|
|
45817
45878
|
const annotations = JSON.parse(savedAnnotations);
|
|
45818
|
-
const filtered = annotations.filter((el) => el.id === id2);
|
|
45879
|
+
const filtered = annotations.filter((el) => el.highlight?.id === id2 || el.id === id2);
|
|
45819
45880
|
if (filtered.length > 0) {
|
|
45820
45881
|
let foundElement = iframeWin.document.getElementById(`${filtered[0].highlight.id}`);
|
|
45821
45882
|
if (foundElement) {
|
|
@@ -45864,6 +45925,7 @@ var LocalAnnotator = _LocalAnnotator;
|
|
|
45864
45925
|
LocalAnnotator.LAST_READING_POSITION = "last-reading-position";
|
|
45865
45926
|
LocalAnnotator.BOOKMARKS = "bookmarks";
|
|
45866
45927
|
LocalAnnotator.ANNOTATIONS = "annotations";
|
|
45928
|
+
LocalAnnotator.SELECTIONINFO = "selectionInfo";
|
|
45867
45929
|
|
|
45868
45930
|
// src/store/LocalStorageStore.ts
|
|
45869
45931
|
init_polyfills();
|
|
@@ -46278,7 +46340,12 @@ var TTSModule2 = class {
|
|
|
46278
46340
|
if (window.speechSynthesis.speaking && this.speaking && startX === this.startX && startY === this.startY) {
|
|
46279
46341
|
let doc = this.delegate.iframes[0].contentDocument;
|
|
46280
46342
|
if (doc) {
|
|
46281
|
-
|
|
46343
|
+
let selection = this.highlighter.dom(doc.body).getSelection();
|
|
46344
|
+
if (selection.isCollapsed) {
|
|
46345
|
+
let doc2 = this.delegate.iframes[0].contentDocument;
|
|
46346
|
+
const selectionInfo = this.delegate.annotationModule?.annotator?.getTemporarySelectionInfo(doc2);
|
|
46347
|
+
selection.addRange(selectionInfo.range);
|
|
46348
|
+
}
|
|
46282
46349
|
let range = selection.getRangeAt(0);
|
|
46283
46350
|
let node = selection.anchorNode;
|
|
46284
46351
|
while (range.toString().indexOf(" ") !== 0) {
|
|
@@ -46373,15 +46440,20 @@ var TTSModule2 = class {
|
|
|
46373
46440
|
let rootEl = iframe.contentWindow?.document.body;
|
|
46374
46441
|
let doc = this.delegate.iframes[0].contentDocument;
|
|
46375
46442
|
if (doc) {
|
|
46376
|
-
|
|
46443
|
+
let selection = this.highlighter.dom(doc.body).getSelection();
|
|
46444
|
+
if (selection.isCollapsed) {
|
|
46445
|
+
let doc2 = self2.delegate.iframes[0].contentDocument;
|
|
46446
|
+
const selectionInfo2 = self2.delegate.annotationModule?.annotator?.getTemporarySelectionInfo(doc2);
|
|
46447
|
+
selection.addRange(selectionInfo2.range);
|
|
46448
|
+
}
|
|
46377
46449
|
if (rootEl) {
|
|
46378
46450
|
var ttsQueue = this.generateTtsQueue(rootEl);
|
|
46379
46451
|
if (!ttsQueue.length) {
|
|
46380
46452
|
return;
|
|
46381
46453
|
}
|
|
46382
46454
|
var idx = this.findTtsQueueItemIndex(ttsQueue, selection.anchorNode, selection.anchorNode, selection.anchorOffset, rootEl);
|
|
46383
|
-
const ttsQueueItem = getTtsQueueItemRef(ttsQueue, idx);
|
|
46384
46455
|
var idxEnd = this.findTtsQueueItemIndex(ttsQueue, selection.focusNode, selection.focusNode, selection.focusOffset, rootEl);
|
|
46456
|
+
const ttsQueueItem = getTtsQueueItemRef(ttsQueue, idx);
|
|
46385
46457
|
const ttsQueueItemEnd = getTtsQueueItemRef(ttsQueue, idxEnd);
|
|
46386
46458
|
var restOfTheText;
|
|
46387
46459
|
if (ttsQueueItem && selectionInfo && selectionInfo.cleanText) {
|
|
@@ -46412,8 +46484,18 @@ var TTSModule2 = class {
|
|
|
46412
46484
|
restOfTheText = restOfTheText.replace(textToBeSpoken, "").trim();
|
|
46413
46485
|
}
|
|
46414
46486
|
utterance = new SpeechSynthesisUtterance(textToBeSpoken);
|
|
46487
|
+
import_loglevel19.default.log(selectionInfo);
|
|
46488
|
+
import_loglevel19.default.log(textToBeSpoken, selectionInfo.range?.commonAncestorContainer.textContent);
|
|
46489
|
+
import_loglevel19.default.log(ttsQueueItem);
|
|
46490
|
+
import_loglevel19.default.log(ttsQueueItem.item.textNodes);
|
|
46491
|
+
import_loglevel19.default.log(startIndex);
|
|
46492
|
+
import_loglevel19.default.log(ttsQueueItem.item.combinedText);
|
|
46493
|
+
let node = ttsQueueItem.item.textNodes.filter((node2) => {
|
|
46494
|
+
return node2 === selectionInfo.range?.commonAncestorContainer;
|
|
46495
|
+
})[0];
|
|
46496
|
+
import_loglevel19.default.log(node);
|
|
46415
46497
|
utterance.onboundary = (ev) => {
|
|
46416
|
-
this.updateTTSInfo(ttsQueueItem, ev.charIndex
|
|
46498
|
+
this.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, startIndex, utterance.text);
|
|
46417
46499
|
};
|
|
46418
46500
|
}
|
|
46419
46501
|
}
|
|
@@ -46518,7 +46600,7 @@ var TTSModule2 = class {
|
|
|
46518
46600
|
const sentence = getTtsQueueItemRefText(ttsQueueItem);
|
|
46519
46601
|
utterance = new SpeechSynthesisUtterance(sentence);
|
|
46520
46602
|
utterance.onboundary = (ev) => {
|
|
46521
|
-
self2.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, utterance.text);
|
|
46603
|
+
self2.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, 0, utterance.text);
|
|
46522
46604
|
};
|
|
46523
46605
|
setTimeout(() => {
|
|
46524
46606
|
window.speechSynthesis.speak(utterance);
|
|
@@ -46530,7 +46612,7 @@ var TTSModule2 = class {
|
|
|
46530
46612
|
if (ttsQueueItem) {
|
|
46531
46613
|
utterance = new SpeechSynthesisUtterance(restOfTheText);
|
|
46532
46614
|
utterance.onboundary = (ev) => {
|
|
46533
|
-
self2.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, utterance.text);
|
|
46615
|
+
self2.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, 0, utterance.text);
|
|
46534
46616
|
};
|
|
46535
46617
|
setTimeout(() => {
|
|
46536
46618
|
window.speechSynthesis.speak(utterance);
|
|
@@ -46903,7 +46985,7 @@ var TTSModule2 = class {
|
|
|
46903
46985
|
import_loglevel19.default.log("navigator.language", navigator.language);
|
|
46904
46986
|
utterance.onboundary = (ev) => {
|
|
46905
46987
|
import_loglevel19.default.log(ev.name);
|
|
46906
|
-
this.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, utterance.text);
|
|
46988
|
+
this.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, 0, utterance.text);
|
|
46907
46989
|
};
|
|
46908
46990
|
setTimeout(() => {
|
|
46909
46991
|
window.speechSynthesis.speak(utterance);
|
|
@@ -46917,42 +46999,40 @@ var TTSModule2 = class {
|
|
|
46917
46999
|
}
|
|
46918
47000
|
};
|
|
46919
47001
|
}
|
|
46920
|
-
updateTTSInfo(ttsQueueItem, charIndex, charLength, utteranceText) {
|
|
47002
|
+
updateTTSInfo(ttsQueueItem, charIndex, charLength, startIndex, utteranceText) {
|
|
46921
47003
|
if (!ttsQueueItem) {
|
|
46922
47004
|
return void 0;
|
|
46923
47005
|
}
|
|
47006
|
+
import_loglevel19.default.log(ttsQueueItem, charIndex, charLength, utteranceText);
|
|
46924
47007
|
const ttsQueueItemText = utteranceText ? utteranceText : getTtsQueueItemRefText(ttsQueueItem);
|
|
46925
47008
|
if (charIndex >= 0 && utteranceText) {
|
|
46926
47009
|
const start = utteranceText.slice(0, charIndex + 1).search(/\S+$/);
|
|
46927
47010
|
const right = utteranceText.slice(charIndex).search(/\s/);
|
|
46928
47011
|
const word = right < 0 ? utteranceText.slice(start) : utteranceText.slice(start, right + charIndex);
|
|
46929
47012
|
const end = start + word.length;
|
|
46930
|
-
|
|
46931
|
-
|
|
47013
|
+
if (charLength === void 0) {
|
|
47014
|
+
const match = utteranceText.substring(charIndex).match(/^[a-z\d']*/i);
|
|
47015
|
+
if (match) {
|
|
47016
|
+
charLength = match[0].length;
|
|
47017
|
+
}
|
|
47018
|
+
}
|
|
47019
|
+
if (charLength === void 0) {
|
|
46932
47020
|
charLength = word.length;
|
|
46933
|
-
useStart = true;
|
|
46934
|
-
} else {
|
|
46935
|
-
useStart = false;
|
|
46936
47021
|
}
|
|
46937
|
-
this.wrapHighlightWord(ttsQueueItem, utteranceText,
|
|
47022
|
+
this.wrapHighlightWord(ttsQueueItem, utteranceText, charIndex + startIndex, charLength, word, start, end);
|
|
46938
47023
|
}
|
|
46939
47024
|
return ttsQueueItemText;
|
|
46940
47025
|
}
|
|
46941
47026
|
wrapHighlightWord(ttsQueueItemRef, utteranceText, charIndex, charLength, word, start, end) {
|
|
47027
|
+
import_loglevel19.default.log(ttsQueueItemRef);
|
|
47028
|
+
import_loglevel19.default.log(utteranceText);
|
|
47029
|
+
import_loglevel19.default.log(charIndex, charLength, word, start, end);
|
|
46942
47030
|
if (this._ttsQueueItemHighlightsWord) {
|
|
46943
47031
|
this.delegate.highlighter?.destroyHighlights(HighlightType.ReadAloud);
|
|
46944
47032
|
this._ttsQueueItemHighlightsWord = void 0;
|
|
46945
47033
|
}
|
|
46946
47034
|
const ttsQueueItem = ttsQueueItemRef.item;
|
|
46947
|
-
let txtToCheck = ttsQueueItemRef.item.combinedText;
|
|
46948
47035
|
let charIndexAdjusted = charIndex;
|
|
46949
|
-
if (utteranceText !== txtToCheck) {
|
|
46950
|
-
import_loglevel19.default.log("TTS utteranceText DIFF?? ", `[[${utteranceText}]]`, `[[${txtToCheck}]]`);
|
|
46951
|
-
}
|
|
46952
|
-
const ttsWord = utteranceText.substr(charIndex, charLength);
|
|
46953
|
-
if (ttsWord !== word) {
|
|
46954
|
-
import_loglevel19.default.log("TTS word DIFF?? ", `[[${ttsWord}]]`, `[[${word}]]`, `${charIndex}--${charLength}`, `${start}--${end - start}`);
|
|
46955
|
-
}
|
|
46956
47036
|
let acc = 0;
|
|
46957
47037
|
let rangeStartNode;
|
|
46958
47038
|
let rangeStartOffset = -1;
|
|
@@ -48333,8 +48413,7 @@ var D2Reader = class {
|
|
|
48333
48413
|
headerMenu,
|
|
48334
48414
|
delegate: navigator2,
|
|
48335
48415
|
publication,
|
|
48336
|
-
highlighter
|
|
48337
|
-
requestConfig: initialConfig.requestConfig
|
|
48416
|
+
highlighter
|
|
48338
48417
|
}, initialConfig.search)) : void 0;
|
|
48339
48418
|
const definitionsModule = rights.enableDefinitions ? await DefinitionsModule.create(__spreadValues({
|
|
48340
48419
|
delegate: navigator2,
|