Skip to content

Commit

Permalink
Merge pull request #417 from d-i-t-a/develop
Browse files Browse the repository at this point in the history
2.1.6
  • Loading branch information
aferditamuriqi authored Dec 14, 2022
2 parents 79fc4d0 + 326b9b8 commit 72e08f9
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@d-i-t-a/reader",
"version": "2.1.5",
"version": "2.1.6",
"description": "A viewer application for EPUB files.",
"repository": "https://github.com/d-i-t-a/R2D2BC",
"license": "Apache-2.0",
Expand Down
67 changes: 55 additions & 12 deletions src/modules/search/SearchModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,15 +717,13 @@ export class SearchModule implements ReaderModule {
}
if (tocItem) {
let href = this.publication.getAbsoluteHref(tocItem.Href);
await fetch(href, this.delegate.requestConfig)
.then((r) => r.text())
.then(async (data) => {
// ({ data, tocItem });
if (this.delegate.api?.getContent) {
this.delegate.api?.getContent(href).then((content) => {
let parser = new DOMParser();
let doc = parser.parseFromString(
this.delegate.requestConfig?.encoded
? this.decodeBase64(data)
: data,
? this.decodeBase64(content)
: content,
"application/xhtml+xml"
);
if (tocItem) {
Expand All @@ -739,6 +737,29 @@ export class SearchModule implements ReaderModule {
);
}
});
} else {
await fetch(href, this.delegate.requestConfig)
.then((r) => r.text())
.then(async (data) => {
let parser = new DOMParser();
let doc = parser.parseFromString(
this.delegate.requestConfig?.encoded
? this.decodeBase64(data)
: data,
"application/xhtml+xml"
);
if (tocItem) {
searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then(
(result) => {
result.forEach((searchItem) => {
localSearchResultBook.push(searchItem);
this.bookSearchResult.push(searchItem);
});
}
);
}
});
}
}
if (index === this.publication.readingOrder.length - 1) {
return localSearchResultBook;
Expand Down Expand Up @@ -768,17 +789,16 @@ export class SearchModule implements ReaderModule {
this.delegate.currentResource() ?? 0
];
}

if (tocItem) {
let href = this.publication.getAbsoluteHref(tocItem.Href);
await fetch(href, this.delegate.requestConfig)
.then((r) => r.text())
.then(async (data) => {
// ({ data, tocItem });
if (this.delegate.api?.getContent) {
this.delegate.api?.getContent(href).then((content) => {
let parser = new DOMParser();
let doc = parser.parseFromString(
this.delegate.requestConfig?.encoded
? this.decodeBase64(data)
: data,
? this.decodeBase64(content)
: content,
"application/xhtml+xml"
);
if (tocItem) {
Expand All @@ -791,6 +811,29 @@ export class SearchModule implements ReaderModule {
);
}
});
} else {
await fetch(href, this.delegate.requestConfig)
.then((r) => r.text())
.then(async (data) => {
// ({ data, tocItem });
let parser = new DOMParser();
let doc = parser.parseFromString(
this.delegate.requestConfig?.encoded
? this.decodeBase64(data)
: data,
"application/xhtml+xml"
);
if (tocItem) {
searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then(
(result) => {
result.forEach((searchItem) => {
localSearchResultBook.push(searchItem);
});
}
);
}
});
}
}

return localSearchResultBook;
Expand Down

0 comments on commit 72e08f9

Please sign in to comment.