@d-i-t-a/reader 2.1.5 → 2.1.7

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 CHANGED
@@ -42925,14 +42925,14 @@ var SearchModule = class {
42925
42925
  this.currentSearchHighlights = [];
42926
42926
  this.bookSearchResult = [];
42927
42927
  reset();
42928
- this.searchAndPaintChapter(term, 0, async () => {
42928
+ await this.searchAndPaintChapter(term, 0, async () => {
42929
42929
  });
42930
- var chapter = this.searchChapter(term);
42931
- var book = this.searchBook(term);
42932
42930
  if (current) {
42933
- return chapter;
42931
+ await this.searchBook(term);
42932
+ return await this.searchChapter(term);
42934
42933
  } else {
42935
- return book;
42934
+ await this.searchChapter(term);
42935
+ return await this.searchBook(term);
42936
42936
  }
42937
42937
  }
42938
42938
  async goToSearchID(href, index2, current) {
@@ -43140,18 +43140,33 @@ var SearchModule = class {
43140
43140
  }
43141
43141
  if (tocItem) {
43142
43142
  let href = this.publication.getAbsoluteHref(tocItem.Href);
43143
- await fetch(href, this.delegate.requestConfig).then((r) => r.text()).then(async (data) => {
43144
- let parser = new DOMParser();
43145
- let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
43146
- if (tocItem) {
43147
- searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
43148
- result.forEach((searchItem) => {
43149
- localSearchResultBook.push(searchItem);
43150
- this.bookSearchResult.push(searchItem);
43143
+ if (this.delegate.api?.getContent) {
43144
+ await this.delegate.api?.getContent(href).then((content) => {
43145
+ let parser = new DOMParser();
43146
+ let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(content) : content, "application/xhtml+xml");
43147
+ if (tocItem) {
43148
+ searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
43149
+ result.forEach((searchItem) => {
43150
+ localSearchResultBook.push(searchItem);
43151
+ this.bookSearchResult.push(searchItem);
43152
+ });
43151
43153
  });
43152
- });
43153
- }
43154
- });
43154
+ }
43155
+ });
43156
+ } else {
43157
+ await fetch(href, this.delegate.requestConfig).then((r) => r.text()).then(async (data) => {
43158
+ let parser = new DOMParser();
43159
+ let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
43160
+ if (tocItem) {
43161
+ searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
43162
+ result.forEach((searchItem) => {
43163
+ localSearchResultBook.push(searchItem);
43164
+ this.bookSearchResult.push(searchItem);
43165
+ });
43166
+ });
43167
+ }
43168
+ });
43169
+ }
43155
43170
  }
43156
43171
  if (index2 === this.publication.readingOrder.length - 1) {
43157
43172
  return localSearchResultBook;
@@ -43177,17 +43192,31 @@ var SearchModule = class {
43177
43192
  }
43178
43193
  if (tocItem) {
43179
43194
  let href = this.publication.getAbsoluteHref(tocItem.Href);
43180
- await fetch(href, this.delegate.requestConfig).then((r) => r.text()).then(async (data) => {
43181
- let parser = new DOMParser();
43182
- let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
43183
- if (tocItem) {
43184
- searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
43185
- result.forEach((searchItem) => {
43186
- localSearchResultBook.push(searchItem);
43195
+ if (this.delegate.api?.getContent) {
43196
+ await this.delegate.api?.getContent(href).then((content) => {
43197
+ let parser = new DOMParser();
43198
+ let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(content) : content, "application/xhtml+xml");
43199
+ if (tocItem) {
43200
+ searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
43201
+ result.forEach((searchItem) => {
43202
+ localSearchResultBook.push(searchItem);
43203
+ });
43187
43204
  });
43188
- });
43189
- }
43190
- });
43205
+ }
43206
+ });
43207
+ } else {
43208
+ await fetch(href, this.delegate.requestConfig).then((r) => r.text()).then(async (data) => {
43209
+ let parser = new DOMParser();
43210
+ let doc = parser.parseFromString(this.delegate.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
43211
+ if (tocItem) {
43212
+ searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
43213
+ result.forEach((searchItem) => {
43214
+ localSearchResultBook.push(searchItem);
43215
+ });
43216
+ });
43217
+ }
43218
+ });
43219
+ }
43191
43220
  }
43192
43221
  return localSearchResultBook;
43193
43222
  }